summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xine-engine/audio_decoder.c11
-rw-r--r--src/xine-engine/video_decoder.c20
-rw-r--r--src/xine-engine/xine.c33
-rw-r--r--src/xine-engine/xine_internal.h6
4 files changed, 53 insertions, 17 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index b6d674370..d504d9511 100644
--- a/src/xine-engine/audio_decoder.c
+++ b/src/xine-engine/audio_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_decoder.c,v 1.137 2006/02/05 16:41:16 miguelfreitas Exp $
+ * $Id: audio_decoder.c,v 1.138 2006/09/08 21:11:29 miguelfreitas Exp $
*
*
* functions that implement audio decoding
@@ -459,7 +459,7 @@ static void *audio_decoder_loop (void *stream_gen) {
return NULL;
}
-void _x_audio_decoder_init (xine_stream_t *stream) {
+int _x_audio_decoder_init (xine_stream_t *stream) {
pthread_attr_t pth_attrs;
struct sched_param pth_params;
@@ -467,7 +467,7 @@ void _x_audio_decoder_init (xine_stream_t *stream) {
if (stream->audio_out == NULL) {
stream->audio_fifo = _x_dummy_fifo_buffer_new (5, 8192);
- return;
+ return 1;
} else {
int num_buffers;
@@ -510,11 +510,14 @@ void _x_audio_decoder_init (xine_stream_t *stream) {
&pth_attrs, audio_decoder_loop, stream)) != 0) {
xprintf (stream->xine, XINE_VERBOSITY_DEBUG,
"audio_decoder: can't create new thread (%s)\n", strerror(err));
- _x_abort();
+ stream->audio_thread_created = 0;
+ pthread_attr_destroy(&pth_attrs);
+ return 0;
}
pthread_attr_destroy(&pth_attrs);
}
+ return 1;
}
void _x_audio_decoder_shutdown (xine_stream_t *stream) {
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index 061962d4a..16ebb61b2 100644
--- a/src/xine-engine/video_decoder.c
+++ b/src/xine-engine/video_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_decoder.c,v 1.160 2005/10/30 02:18:35 miguelfreitas Exp $
+ * $Id: video_decoder.c,v 1.161 2006/09/08 21:11:29 miguelfreitas Exp $
*
*/
@@ -464,12 +464,12 @@ static void *video_decoder_loop (void *stream_gen) {
return NULL;
}
-void _x_video_decoder_init (xine_stream_t *stream) {
+int _x_video_decoder_init (xine_stream_t *stream) {
if (stream->video_out == NULL) {
stream->video_fifo = _x_dummy_fifo_buffer_new (5, 8192);
stream->spu_track_map_entries = 0;
- return;
+ return 1;
} else {
pthread_attr_t pth_attrs;
@@ -494,6 +494,11 @@ void _x_video_decoder_init (xine_stream_t *stream) {
20, NULL, NULL);
stream->video_fifo = _x_fifo_buffer_new (num_buffers, 8192);
+ if (stream->video_fifo == NULL) {
+ xine_log(stream->xine, XINE_LOG_MSG, "video_decoder: can't allocated video fifo\n");
+ return 0;
+ }
+
stream->spu_track_map_entries = 0;
pthread_attr_init(&pth_attrs);
@@ -505,13 +510,16 @@ void _x_video_decoder_init (xine_stream_t *stream) {
stream->video_thread_created = 1;
if ((err = pthread_create (&stream->video_thread,
&pth_attrs, video_decoder_loop, stream)) != 0) {
- fprintf (stderr, "video_decoder: can't create new thread (%s)\n",
- strerror(err));
- _x_abort();
+ xine_log (stream->xine, XINE_LOG_MSG, "video_decoder: can't create new thread (%s)\n",
+ strerror(err));
+ stream->video_thread_created = 0;
+ pthread_attr_destroy(&pth_attrs);
+ return 0;
}
pthread_attr_destroy(&pth_attrs);
}
+ return 1;
}
void _x_video_decoder_shutdown (xine_stream_t *stream) {
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index d8cdb2b83..a4e31aba6 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine.c,v 1.326 2006/08/13 23:51:34 miguelfreitas Exp $
+ * $Id: xine.c,v 1.327 2006/09/08 21:11:29 miguelfreitas Exp $
*/
/*
@@ -576,9 +576,24 @@ xine_stream_t *xine_stream_new (xine_t *this,
* alloc fifos, init and start decoder threads
*/
- _x_video_decoder_init (stream);
+ if (!_x_video_decoder_init (stream))
+ {
+ free(stream->audio_decoder_extra_info);
+ free(stream->current_extra_info);
+ free(stream);
+ pthread_mutex_unlock(&this->streams_lock);
+ return NULL;
+ }
- _x_audio_decoder_init (stream);
+ if (!_x_audio_decoder_init (stream))
+ {
+ _x_video_decoder_shutdown(stream);
+ free(stream->audio_decoder_extra_info);
+ free(stream->current_extra_info);
+ free(stream);
+ pthread_mutex_unlock(&this->streams_lock);
+ return NULL;
+ }
/*
* osd
@@ -592,7 +607,17 @@ xine_stream_t *xine_stream_new (xine_t *this,
* create a reference counter
*/
stream->refcounter = _x_new_refcounter(stream, (refcounter_destructor)xine_dispose_internal);
-
+ if (!stream->refcounter)
+ {
+ _x_video_decoder_shutdown(stream);
+ _x_audio_decoder_shutdown(stream);
+ free(stream->audio_decoder_extra_info);
+ free(stream->current_extra_info);
+ free(stream);
+ pthread_mutex_unlock(&this->streams_lock);
+ return NULL;
+ }
+
/*
* register stream
*/
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 99bcb1478..fc76527f0 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_internal.h,v 1.175 2006/08/13 23:51:33 miguelfreitas Exp $
+ * $Id: xine_internal.h,v 1.176 2006/09/08 21:11:29 miguelfreitas Exp $
*
*/
@@ -384,10 +384,10 @@ void _x_free_demux_plugin (xine_stream_t *stream, demux_plugin_t *demux);
/* create decoder fifos and threads */
-void _x_video_decoder_init (xine_stream_t *stream);
+int _x_video_decoder_init (xine_stream_t *stream);
void _x_video_decoder_shutdown (xine_stream_t *stream);
-void _x_audio_decoder_init (xine_stream_t *stream);
+int _x_audio_decoder_init (xine_stream_t *stream);
void _x_audio_decoder_shutdown (xine_stream_t *stream);
/* extra_info operations */