diff options
author | Juergen Keil <jkeil@users.sourceforge.net> | 2001-10-03 17:15:43 +0000 |
---|---|---|
committer | Juergen Keil <jkeil@users.sourceforge.net> | 2001-10-03 17:15:43 +0000 |
commit | 70564011218ab5eef38842412af9313b2a133f69 (patch) | |
tree | dda4a4296e74ddb4c07c14aa7eea471eef9bbe15 | |
parent | 2341ac8aa13c8ad994eab1fbbefe98238ed4f117 (diff) | |
download | xine-lib-70564011218ab5eef38842412af9313b2a133f69.tar.gz xine-lib-70564011218ab5eef38842412af9313b2a133f69.tar.bz2 |
Add error checks to all "pthread_create" calls, print error message and exit
xine, whenever a pthread_create fails
CVS patchset: 729
CVS date: 2001/10/03 17:15:43
-rw-r--r-- | src/demuxers/demux_avi.c | 9 | ||||
-rw-r--r-- | src/demuxers/demux_elem.c | 10 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg.c | 11 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 10 | ||||
-rw-r--r-- | src/demuxers/demux_mpgaudio.c | 10 | ||||
-rw-r--r-- | src/demuxers/demux_pes.c | 11 | ||||
-rw-r--r-- | src/demuxers/demux_qt.c | 10 | ||||
-rw-r--r-- | src/demuxers/demux_ts.c | 9 | ||||
-rw-r--r-- | src/input/input_rtp.c | 9 | ||||
-rw-r--r-- | src/xine-engine/audio_decoder.c | 13 | ||||
-rw-r--r-- | src/xine-engine/metronom.c | 9 | ||||
-rw-r--r-- | src/xine-engine/video_decoder.c | 14 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 10 |
13 files changed, 104 insertions, 31 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index b48a0653f..91ca2d758 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.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: demux_avi.c,v 1.42 2001/09/18 17:41:47 jkeil Exp $ + * $Id: demux_avi.c,v 1.43 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for avi streams * @@ -870,6 +870,7 @@ static void demux_avi_start (demux_plugin_t *this_gen, buf_element_t *buf; demux_avi_t *this = (demux_avi_t *) this_gen; uint32_t video_pts = 0; + int err; this->audio_fifo = audio_fifo; this->video_fifo = video_fifo; @@ -1091,7 +1092,11 @@ static void demux_avi_start (demux_plugin_t *this_gen, this->audio_fifo->put (this->audio_fifo, buf); } - pthread_create (&this->thread, NULL, demux_avi_loop, this) ; + if ((err = pthread_create (&this->thread, NULL, demux_avi_loop, this)) != 0) { + fprintf (stderr, "demux_avi: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } static int demux_avi_open(demux_plugin_t *this_gen, diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c index 719bdc098..c15ca3d39 100644 --- a/src/demuxers/demux_elem.c +++ b/src/demuxers/demux_elem.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: demux_elem.c,v 1.20 2001/10/03 15:08:06 jkeil Exp $ + * $Id: demux_elem.c,v 1.21 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for elementary mpeg streams * @@ -186,6 +186,7 @@ static void demux_mpeg_elem_start (demux_plugin_t *this_gen, demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen; buf_element_t *buf; + int err; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; @@ -227,7 +228,12 @@ static void demux_mpeg_elem_start (demux_plugin_t *this_gen, * now start demuxing */ - pthread_create (&this->thread, NULL, demux_mpeg_elem_loop, this) ; + if ((err = pthread_create (&this->thread, + NULL, demux_mpeg_elem_loop, this)) != 0) { + fprintf (stderr, "demux_elem: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } /* diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index 8974680cd..2a2652c23 100644 --- a/src/demuxers/demux_mpeg.c +++ b/src/demuxers/demux_mpeg.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: demux_mpeg.c,v 1.34 2001/09/04 16:19:27 guenter Exp $ + * $Id: demux_mpeg.c,v 1.35 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for mpeg 1/2 program streams * reads streams of variable blocksizes @@ -31,6 +31,7 @@ #endif #include <stdio.h> +#include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <pthread.h> @@ -662,6 +663,7 @@ static void demux_mpeg_start (demux_plugin_t *this_gen, { demux_mpeg_t *this = (demux_mpeg_t *) this_gen; buf_element_t *buf; + int err; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; @@ -712,7 +714,12 @@ static void demux_mpeg_start (demux_plugin_t *this_gen, this->send_end_buffers = 1; this->status = DEMUX_OK ; - pthread_create (&this->thread, NULL, demux_mpeg_loop, this) ; + if ((err = pthread_create (&this->thread, + NULL, demux_mpeg_loop, this)) != 0) { + fprintf (stderr, "demux_mpeg: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } static int demux_mpeg_open(demux_plugin_t *this_gen, diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 3f53c42f2..7de991ee5 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.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: demux_mpeg_block.c,v 1.47 2001/09/25 23:44:46 guenter Exp $ + * $Id: demux_mpeg_block.c,v 1.48 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -658,6 +658,7 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; buf_element_t *buf; + int err; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; @@ -732,7 +733,12 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, this->status = DEMUX_OK ; - pthread_create (&this->thread, NULL, demux_mpeg_block_loop, this) ; + if ((err = pthread_create (&this->thread, + NULL, demux_mpeg_block_loop, this)) != 0) { + fprintf (stderr, "demux_mpeg_block: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } static void demux_mpeg_block_accept_input (demux_mpeg_block_t *this, diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 3b2e66517..606cc8f82 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.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: demux_mpgaudio.c,v 1.21 2001/10/03 15:08:06 jkeil Exp $ + * $Id: demux_mpgaudio.c,v 1.22 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for mpeg audio (i.e. mp3) streams * @@ -304,6 +304,7 @@ static void demux_mpgaudio_start (demux_plugin_t *this_gen, gui_branched_cb_t branched_cb) { demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen; buf_element_t *buf; + int err; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; @@ -341,7 +342,12 @@ static void demux_mpgaudio_start (demux_plugin_t *this_gen, * now start demuxing */ - pthread_create (&this->thread, NULL, demux_mpgaudio_loop, this) ; + if ((err = pthread_create (&this->thread, + NULL, demux_mpgaudio_loop, this)) != 0) { + fprintf (stderr, "demux_mpgaudio: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } static int demux_mpgaudio_open(demux_plugin_t *this_gen, diff --git a/src/demuxers/demux_pes.c b/src/demuxers/demux_pes.c index 0c5b33fa9..f493fc21c 100644 --- a/src/demuxers/demux_pes.c +++ b/src/demuxers/demux_pes.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: demux_pes.c,v 1.7 2001/09/04 16:19:27 guenter Exp $ + * $Id: demux_pes.c,v 1.8 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for mpeg 2 PES (Packetized Elementary Streams) * reads streams of variable blocksizes @@ -30,6 +30,7 @@ #endif #include <stdio.h> +#include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <pthread.h> @@ -405,6 +406,7 @@ static void demux_pes_start (demux_plugin_t *this_gen, { demux_pes_t *this = (demux_pes_t *) this_gen; buf_element_t *buf; + int err; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; @@ -452,7 +454,12 @@ static void demux_pes_start (demux_plugin_t *this_gen, this->send_end_buffers = 1; this->status = DEMUX_OK ; - pthread_create (&this->thread, NULL, demux_pes_loop, this) ; + if ((err = pthread_create (&this->thread, + NULL, demux_pes_loop, this)) != 0) { + fprintf (stderr, "demux_pes: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } static int demux_pes_open(demux_plugin_t *this_gen, diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index feb8ac777..e9bfb573d 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.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: demux_qt.c,v 1.5 2001/09/20 13:25:40 heikos Exp $ + * $Id: demux_qt.c,v 1.6 2001/10/03 17:15:43 jkeil Exp $ * * demultiplexer for quicktime streams, based on: * @@ -1070,7 +1070,7 @@ static int quicktime_atom_read_type(char *data, char *type) //printf("%c%c%c%c ", type[0], type[1], type[2], type[3]); /* need this for quicktime_check_sig */ - if(isalpha(type[0]) && isalpha(type[1]) && isalpha(type[2]) && isalpha(type[3])) + if(isalpha(type[0] & 0xff) && isalpha(type[1] & 0xff) && isalpha(type[2] & 0xff) && isalpha(type[3] & 0xff)) return 0; else return 1; @@ -4213,6 +4213,7 @@ static void demux_qt_start (demux_plugin_t *this_gen, demux_qt_t *this = (demux_qt_t *) this_gen; buf_element_t *buf; + int err; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; @@ -4307,7 +4308,10 @@ static void demux_qt_start (demux_plugin_t *this_gen, this->status = DEMUX_OK ; - pthread_create (&this->thread, NULL, demux_qt_loop, this) ; + if ((err = pthread_create (&this->thread, NULL, demux_qt_loop, this)) != 0) { + fprintf (stderr, "demux_qt: can't create new thread (%s)\n", strerror(err)); + exit (1); + } } static int demux_qt_open(demux_plugin_t *this_gen, diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 815c0c499..ed782ec10 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.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: demux_ts.c,v 1.16 2001/09/17 14:35:19 jcdutton Exp $ + * $Id: demux_ts.c,v 1.17 2001/10/03 17:15:43 jkeil Exp $ * * Demultiplexer for MPEG2 Transport Streams. * @@ -58,6 +58,7 @@ #endif #include <stdio.h> +#include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <pthread.h> @@ -882,6 +883,7 @@ static void demux_ts_start(demux_plugin_t *this_gen, demux_ts *this = (demux_ts *)this_gen; buf_element_t *buf; + int err; this->fifoVideo = fifoVideo; this->fifoAudio = fifoAudio; @@ -913,7 +915,10 @@ static void demux_ts_start(demux_plugin_t *this_gen, /* * Now start demuxing. */ - pthread_create(&this->thread, NULL, demux_ts_loop, this); + if ((err = pthread_create(&this->thread, NULL, demux_ts_loop, this)) != 0) { + fprintf(stderr, "demux_ts: can't create new thread (%s)\n", strerror(err)); + exit (1); + } } static void demux_ts_stop(demux_plugin_t *this_gen) diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index 31dcf403d..eaebb5a8f 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -270,6 +270,7 @@ static int rtp_plugin_open (input_plugin_t *this_gen, char *mrl ) { char *pptr; int port = 7658; pthread_attr_t thread_attrs; + int err; this->mrl = mrl; @@ -309,8 +310,12 @@ static int rtp_plugin_open (input_plugin_t *this_gen, char *mrl ) { pthread_cond_init(&this->buffer_notempty, NULL); pthread_attr_init(&thread_attrs); pthread_attr_setdetachstate(&thread_attrs, PTHREAD_CREATE_DETACHED); - pthread_create(&this->reader_thread, &thread_attrs, - input_plugin_read_loop, (void *)&this); + if ((err = pthread_create(&this->reader_thread, &thread_attrs, + input_plugin_read_loop, (void *)&this)) != 0) { + fprintf (stderr, "input_rtp: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } pthread_attr_destroy(&thread_attrs); return 1; diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index f6995c439..0235ba7fc 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.42 2001/10/01 23:04:57 f1rmb Exp $ + * $Id: audio_decoder.c,v 1.43 2001/10/03 17:15:43 jkeil Exp $ * * * functions that implement audio decoding @@ -27,6 +27,9 @@ #include "config.h" #endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sched.h> #include <unistd.h> @@ -268,6 +271,7 @@ void audio_decoder_init (xine_t *this) { pthread_attr_t pth_attrs; struct sched_param pth_params; + int err; if (this->audio_out == NULL) { this->audio_finished = 1; @@ -283,7 +287,12 @@ void audio_decoder_init (xine_t *this) { pthread_attr_setschedparam(&pth_attrs, &pth_params); pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); - pthread_create (&this->audio_thread, &pth_attrs, audio_decoder_loop, this) ; + if ((err = pthread_create (&this->audio_thread, + &pth_attrs, audio_decoder_loop, this)) != 0) { + fprintf (stderr, "audio_decoder: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } void audio_decoder_shutdown (xine_t *this) { diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index ad52e2012..4f93a736f 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.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: metronom.c,v 1.28 2001/09/25 23:30:38 guenter Exp $ + * $Id: metronom.c,v 1.29 2001/10/03 17:15:44 jkeil Exp $ */ #ifdef HAVE_CONFIG_H @@ -742,6 +742,7 @@ static int metronom_sync_loop (metronom_t *this) { metronom_t * metronom_init (int have_audio) { metronom_t *this = xmalloc (sizeof (metronom_t)); + int err; this->audio_stream_start = metronom_audio_stream_start; this->audio_stream_end = metronom_audio_stream_end ; @@ -769,10 +770,10 @@ metronom_t * metronom_init (int have_audio) { this->scr_list = calloc(MAX_SCR_PROVIDERS, sizeof(void*)); this->register_scr(this, unixscr_init()); - if (pthread_create(&this->sync_thread, NULL, - (void*(*)(void*)) metronom_sync_loop, this)) + if ((err = pthread_create(&this->sync_thread, NULL, + (void*(*)(void*)) metronom_sync_loop, this)) != 0) fprintf(stderr, "metronom: cannot create sync thread (%s)\n", - strerror(errno)); + strerror(err)); pthread_mutex_init (&this->lock, NULL); pthread_cond_init (&this->video_started, NULL); diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index 971b38d0b..5611964ed 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.52 2001/09/26 01:18:19 guenter Exp $ + * $Id: video_decoder.c,v 1.53 2001/10/03 17:15:44 jkeil Exp $ * */ @@ -25,6 +25,10 @@ #include "config.h" #endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "xine_internal.h" #include "monitor.h" #include <sched.h> @@ -252,6 +256,7 @@ void video_decoder_init (xine_t *this) { pthread_attr_t pth_attrs; struct sched_param pth_params; + int err; this->video_fifo = fifo_buffer_new (500, 4096); @@ -265,7 +270,12 @@ void video_decoder_init (xine_t *this) { pthread_attr_setschedparam(&pth_attrs, &pth_params); pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); - pthread_create (&this->video_thread, &pth_attrs, video_decoder_loop, this) ; + if ((err = pthread_create (&this->video_thread, + &pth_attrs, video_decoder_loop, this)) != 0) { + fprintf (stderr, "video_decoder: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } void video_decoder_shutdown (xine_t *this) { diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 97b228327..142488a48 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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_out.c,v 1.49 2001/10/03 14:11:54 miguelfreitas Exp $ + * $Id: video_out.c,v 1.50 2001/10/03 17:15:44 jkeil Exp $ * */ @@ -337,6 +337,7 @@ static uint32_t vo_get_capabilities (vo_instance_t *this) { static void vo_open (vo_instance_t *this) { pthread_attr_t pth_attrs; + int err; if (!this->video_loop_running) { this->video_loop_running = 1; @@ -344,11 +345,12 @@ static void vo_open (vo_instance_t *this) { pthread_attr_init(&pth_attrs); pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); - if( pthread_create (&this->video_thread, &pth_attrs, video_out_loop, this) ) + if((err = pthread_create (&this->video_thread, + &pth_attrs, video_out_loop, this)) != 0) { - printf ("video_out: error creating thread\n"); + fprintf (stderr, "video_out: can't create thread (%s)\n", strerror(err)); /* FIXME: why pthread_create fails? */ - printf ("Sorry, this should not happen. Please restart Xine.\n"); + fprintf (stderr, "Sorry, this should not happen. Please restart Xine.\n"); exit(1); } else |