From 18b58faa961cb45344c0d00a753c2d65e2ce8a98 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Thu, 14 Jun 2001 09:54:13 +0000 Subject: more small fixes and workarounds CVS patchset: 176 CVS date: 2001/06/14 09:54:13 --- src/video_out/video_out_xshm.c | 5 +- src/video_out/video_out_xv.c | 6 +- src/xine-engine/audio_decoder.c | 246 +++++++++++++++++++--------------------- src/xine-engine/audio_out.c | 103 ----------------- 4 files changed, 126 insertions(+), 234 deletions(-) delete mode 100644 src/xine-engine/audio_out.c diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index 7df4bcca8..165e907a2 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.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_xshm.c,v 1.7 2001/06/14 09:19:44 guenter Exp $ + * $Id: video_out_xshm.c,v 1.8 2001/06/14 09:54:13 guenter Exp $ * * video_out_xshm.c, X11 shared memory extension interface for xine * @@ -538,6 +538,7 @@ static void xshm_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { if (this->expecting_event) { + this->expecting_event--; frame->vo_frame.displayed (&frame->vo_frame); } else { @@ -566,7 +567,7 @@ static void xshm_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { 0, 0, this->output_xoffset, this->output_yoffset, frame->rgb_width, frame->rgb_height, True); - this->expecting_event = 1; + this->expecting_event = 10; } else { XPutImage(this->display, diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 524cfae44..5d2bb8b98 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.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_xv.c,v 1.40 2001/06/14 09:19:44 guenter Exp $ + * $Id: video_out_xv.c,v 1.41 2001/06/14 09:54:13 guenter Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -445,6 +445,8 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { xv_frame_t *frame = (xv_frame_t *) frame_gen; if (this->expecting_event) { + + this->expecting_event--; frame->vo_frame.displayed (&frame->vo_frame); } else { @@ -465,7 +467,7 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { this->output_xoffset, this->output_yoffset, this->output_width, this->output_height, True); - this->expecting_event = 1; + this->expecting_event = 10; XFlush(this->display); diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 0d7af2614..547589604 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.16 2001/06/11 03:14:29 heikos Exp $ + * $Id: audio_decoder.c,v 1.17 2001/06/14 09:54:13 guenter Exp $ * * * functions that implement audio decoding @@ -41,140 +41,123 @@ void *audio_decoder_loop (void *this_gen) { buf = this->audio_fifo->get (this->audio_fifo); - if (this->audio_out) { - - this->cur_input_pos = buf->input_pos; - - /* - * Call update status callback function if - * there is no video decoder initialized, like - * in .mp3 playback. - */ - if(this->cur_video_decoder_plugin == NULL) { - if(this->status == XINE_PLAY) - this->status_callback (this->status); + this->cur_input_pos = buf->input_pos; + + /* + * Call update status callback function if + * there is no video decoder initialized, like + * in .mp3 playback. + */ + if(this->cur_video_decoder_plugin == NULL) { + if(this->status == XINE_PLAY) + this->status_callback (this->status); + } + + switch (buf->type) { + + case BUF_CONTROL_START: + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; } - - switch (buf->type) { - - case BUF_CONTROL_START: - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - - pthread_mutex_lock (&this->xine_lock); - this->audio_finished = 0; + + pthread_mutex_lock (&this->xine_lock); + this->audio_finished = 0; + pthread_mutex_unlock (&this->xine_lock); + + for (i=0 ; i<50; i++) + this->audio_track_map[0] = 0; + + this->audio_track_map_entries = 0; + + break; + + case BUF_CONTROL_END: + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; + } + + pthread_mutex_lock (&this->xine_lock); + + this->audio_finished = 1; + + if (this->video_finished) { pthread_mutex_unlock (&this->xine_lock); - - for (i=0 ; i<50; i++) - this->audio_track_map[0] = 0; - - this->audio_track_map_entries = 0; - + xine_notify_stream_finished (this); + } else + pthread_mutex_unlock (&this->xine_lock); + break; - - case BUF_CONTROL_END: - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - - pthread_mutex_lock (&this->xine_lock); - - this->audio_finished = 1; - if (this->video_finished) { - pthread_mutex_unlock (&this->xine_lock); - xine_notify_stream_finished (this); - } else - pthread_mutex_unlock (&this->xine_lock); - - break; - - case BUF_CONTROL_QUIT: - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - running = 0; - break; - - default: - if ( (buf->type & 0xFF000000) == BUF_AUDIO_BASE ) { + case BUF_CONTROL_QUIT: + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; + } + running = 0; + break; - /* printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); */ - - /* update track map */ - - i = 0; - while ( (iaudio_track_map_entries) && (this->audio_track_map[i]type) ) - i++; - - /* + default: + if ( (buf->type & 0xFF000000) == BUF_AUDIO_BASE ) { + + /* printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); */ + + /* update track map */ + + i = 0; + while ( (iaudio_track_map_entries) && (this->audio_track_map[i]type) ) + i++; + + /* printf ("audio_decoder: got an audio buffer, type %08x, %d map entries, i=%d\n", - buf->type, this->audio_track_map_entries, i); - */ + buf->type, this->audio_track_map_entries, i); + */ + + if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) { - if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) { + j = this->audio_track_map_entries; + while (j>i) { + this->audio_track_map[j] = this->audio_track_map[j-1]; + j--; + } + this->audio_track_map[i] = buf->type; + this->audio_track_map_entries++; - j = this->audio_track_map_entries; - while (j>i) { - this->audio_track_map[j] = this->audio_track_map[j-1]; - j--; + if (i<=this->audio_channel) { + /* close old audio decoder */ + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; } - this->audio_track_map[i] = buf->type; - this->audio_track_map_entries++; - - if (i<=this->audio_channel) { - /* close old audio decoder */ - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; - } - } - } + + } - /* now, decode this buffer if it's the right track */ + /* now, decode this buffer if it's the right track */ - if (buf->type == this->audio_track_map[this->audio_channel]) { + if (buf->type == this->audio_track_map[this->audio_channel]) { - int streamtype = (buf->type>>16) & 0xFF; + int streamtype = (buf->type>>16) & 0xFF; - decoder = this->audio_decoder_plugins [streamtype]; + decoder = this->audio_decoder_plugins [streamtype]; - if (decoder) { - if (this->cur_audio_decoder_plugin != decoder) { + if (decoder) { + if (this->cur_audio_decoder_plugin != decoder) { - if (this->cur_audio_decoder_plugin) - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + if (this->cur_audio_decoder_plugin) + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = decoder; - this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out); + this->cur_audio_decoder_plugin = decoder; + this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out); - } - - decoder->decode_data (decoder, buf); } + + decoder->decode_data (decoder, buf); } - } else - printf ("audio_decoder: unknown buffer type: %08x\n", buf->type); - } - } - else { - /* No audio driver loaded */ - pthread_mutex_lock (&this->xine_lock); - - this->audio_finished = 1; - - if (this->video_finished) { - pthread_mutex_unlock (&this->xine_lock); - xine_notify_stream_finished (this); + } } else - pthread_mutex_unlock (&this->xine_lock); - - pthread_exit(NULL); + printf ("audio_decoder: unknown buffer type: %08x\n", buf->type); } buf->free_buffer (buf); @@ -184,20 +167,28 @@ void *audio_decoder_loop (void *this_gen) { } void audio_decoder_init (xine_t *this) { - if (this->audio_out == NULL) - return; + if (this->audio_out == NULL) { + this->audio_finished = 1; + this->audio_fifo = NULL; + return; + } + this->audio_fifo = fifo_buffer_new (1500, 4096); pthread_create (&this->audio_thread, NULL, audio_decoder_loop, this) ; } void audio_decoder_stop (xine_t *this) { - this->audio_fifo->clear(this->audio_fifo); - if (this->cur_audio_decoder_plugin) { - this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); - this->cur_audio_decoder_plugin = NULL; + if (this->audio_fifo) { + + this->audio_fifo->clear(this->audio_fifo); + + if (this->cur_audio_decoder_plugin) { + this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin); + this->cur_audio_decoder_plugin = NULL; + } } } @@ -206,13 +197,14 @@ void audio_decoder_shutdown (xine_t *this) { buf_element_t *buf; void *p; - this->audio_fifo->clear(this->audio_fifo); + if (this->audio_fifo) { + this->audio_fifo->clear(this->audio_fifo); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_QUIT; - this->audio_fifo->put (this->audio_fifo, buf); - - pthread_join (this->audio_thread, &p); + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_QUIT; + this->audio_fifo->put (this->audio_fifo, buf); + + pthread_join (this->audio_thread, &p); + } } - diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c deleted file mode 100644 index 6a84ddf6d..000000000 --- a/src/xine-engine/audio_out.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2000 the xine project - * - * This file is part of xine, a unix video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * 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_out.c,v 1.1 2001/04/24 20:57:11 f1rmb Exp $ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "audio_out.h" - -const char *ao_available[] = { - "null", - "oss", -#ifdef HAVE_ALSA - "alsa", -#endif -#ifdef HAVE_ESD - "esd", -#endif - NULL -}; - -ao_functions_t *gAudioOut; - -/* ------------------------------------------------------------------------- */ -/* - * - */ -void audio_out_init(int driver) { - - switch(driver) { - - case AO_DRIVER_OSS: - gAudioOut = audio_ossout_init(); - break; - case AO_DRIVER_NULL: - gAudioOut = NULL; - break; - case AO_DRIVER_UNSET: -#ifdef HAVE_ESD - // Assume that the user wants ESD if ESPEAKER is set - if(getenv("ESPEAKER") != NULL && (gAudioOut = audio_esdout_init()) != NULL) { - printf("autodetected ESD audio driver\n"); - break; - } -#endif -#ifdef HAVE_ALSA - if((gAudioOut = audio_alsaout_init()) != NULL) { - printf("autodetected ALSA audio driver\n"); - break; - } -#endif - if ((gAudioOut = audio_ossout_init()) != NULL) { - printf("autodetected OSS audio driver\n"); - break; - } - gAudioOut = NULL; - break; - default: - fprintf(stderr, "audio_out: illegal driver (%d) selected\n" - "Audio output off.\n", driver);; - break; -#ifdef HAVE_ALSA - case AO_DRIVER_ALSA: - gAudioOut = audio_alsaout_init(); - break; -#endif -#ifdef HAVE_ESD - case AO_DRIVER_ESD: - gAudioOut = audio_esdout_init(); - break; -#endif - } - -} - -- cgit v1.2.3