summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-04-22 02:42:49 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-04-22 02:42:49 +0000
commit6e6c22440014b3135d946f38cab015a99257daba (patch)
treed28cafd03da38fbead81611b0c2d7c4b32443ca8
parent2ec0d40dc7803a6c44da5d85de3c468a82fd17b8 (diff)
downloadxine-lib-6e6c22440014b3135d946f38cab015a99257daba.tar.gz
xine-lib-6e6c22440014b3135d946f38cab015a99257daba.tar.bz2
audio decoder code compiles again, more cleanups in xine_internal.h
CVS patchset: 13 CVS date: 2001/04/22 02:42:49
-rw-r--r--src/xine-engine/Makefile.am2
-rw-r--r--src/xine-engine/audio_decoder.c174
-rw-r--r--src/xine-engine/video_decoder.c6
-rw-r--r--src/xine-engine/xine_internal.h7
4 files changed, 77 insertions, 112 deletions
diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
index c253a8ff6..9cb427e5b 100644
--- a/src/xine-engine/Makefile.am
+++ b/src/xine-engine/Makefile.am
@@ -25,7 +25,7 @@ libxine_la_LDFLAGS = -version-info 5:0:5
# monitor.h cpu_accel.h attributes.h utils.h audio_decoder.h
noinst_HEADERS = xine_internal.h buffer.h metronom.h configfile.h \
- monitor.h cpu_accel.h attributes.h utils.h audio_decoder.h
+ monitor.h cpu_accel.h attributes.h utils.h
#cpu_accel.lo:
# $(CC) -DHAVE_CONFIG_H $(INCLUDES) -pipe `echo "@DEBUG_CFLAGS@" | sed -e 's/\-DDEBUG//' -e 's/\-g//'` -fomit-frame-pointer -Wall -Wp,-MD,.deps/cpu_accel.P -c $(basename $@).c -o $@
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index f879093e0..bcd51d1dc 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.1 2001/04/18 22:36:01 f1rmb Exp $
+ * $Id: audio_decoder.c,v 1.2 2001/04/22 02:42:49 guenter Exp $
*
*
* functions that implement audio decoding
@@ -27,168 +27,128 @@
#include "config.h"
#endif
-#include "audio_decoder.h"
+#include "xine_internal.h"
-#define MAX_NUM_DECODERS 10
+void *audio_decoder_loop (void *this_gen) {
-typedef struct ad_globals_s {
+ buf_element_t *buf;
+ xine_t *this = (xine_t *) this_gen;
+ int running = 1;
+ audio_decoder_t *decoder;
- pthread_t mAudioThread;
+ while (running) {
- fifo_buffer_t *mBufAudio;
+ buf = this->audio_fifo->get (this->audio_fifo);
- audio_decoder_t *mDecoders[MAX_NUM_DECODERS];
- audio_decoder_t *mCurDecoder;
+ if (this->audio_out) {
- uint32_t mnCurPos;
+ /* FIXME gAD.mnCurPos = pBuf->nInputPos; */
- ao_instance_t *mAudioOut
+ switch (buf->type) {
- gui_status_callback_func_t gui_status_callback;
-
- int mbStreamFinished;
-
- pthread_mutex_t mXineLock;
-
-} ad_globals_t;
-
-static ad_globals_t gAD;
-
-
-void *audio_decoder_loop (void *dummy) {
-
- buf_element_t *pBuf;
- int bRunning = 1;
-
- while (bRunning) {
-
- pBuf = gAD.mBufAudio->fifo_buffer_get (gAD.mBufAudio);
-
- if (gAD.mAudioOut) {
-
- gAD.mnCurPos = pBuf->nInputPos;
-
- /*
- if (gXine.mnStatus == XINE_PLAY)
- gXine.mStatusCallback (gXine.mnStatus);
- */
-
- switch (pBuf->nType) {
-
- case BUF_STREAMSTART:
- if (gAD.mCurDecoder) {
- gAD.mCurDecoder->close ();
- gAD.mCurDecoder = NULL;
+ case BUF_CONTROL_START:
+ if (this->audio_cur_decoder) {
+ this->audio_cur_decoder->close (this->audio_cur_decoder);
+ this->audio_cur_decoder = NULL;
}
- pthread_mutex_lock (&gAD.mXineLock);
- gAD.mbStreamFinished = 0;
- pthread_mutex_unlock (&gAD.mXineLock);
+ pthread_mutex_lock (&this->xine_lock);
+ this->audio_finished = 0;
+ pthread_mutex_unlock (&this->xine_lock);
break;
- case BUF_AC3AUDIO:
- case BUF_MPEGAUDIO:
- case BUF_MSAUDIO:
- case BUF_LINEARPCM:
+ case BUF_AUDIO_AC3:
+ case BUF_AUDIO_MPEG:
+ case BUF_AUDIO_LPCM:
+ case BUF_AUDIO_AVI:
- decoder = gAD.mDecoders [pBuf->nType];
+ decoder = this->audio_decoders [(buf->type>>16) & 0xFF];
if (decoder) {
- if (gAD.mCurDecoder != decoder) {
+ if (this->audio_cur_decoder != decoder) {
- if (gAD.mCurDecoder)
- gAD.mCurDecoder->close ();
+ if (this->audio_cur_decoder)
+ this->audio_cur_decoder->close (this->audio_cur_decoder);
- gAD.mCurDecoder = decoder;
- gAD.mCurDecoder->init (gAD.mVideoOut);
+ this->audio_cur_decoder = decoder;
+ this->audio_cur_decoder->init (this->audio_cur_decoder, this->audio_out);
}
- decoder->decode_data (pBuf);
+ decoder->decode_data (decoder, buf);
}
break;
- case BUF_STREAMEND:
- if (gAD.mCurDecoder) {
- gAD.mCurDecoder->close ();
- gAD.mCurDecoder = NULL;
+ case BUF_CONTROL_END:
+ if (this->audio_cur_decoder) {
+ this->audio_cur_decoder->close (this->audio_cur_decoder);
+ this->audio_cur_decoder = NULL;
}
- gAD.mbStreamFinished = 1;
-
- pthread_mutex_lock (&gAD.mXineLock);
+ pthread_mutex_lock (&this->xine_lock);
- gVD.mbStreamFinished = 1;
+ this->audio_finished = 1;
- if (video_decoder_is_stream_finished ()) {
- pthread_mutex_unlock (&gAD.mXineLock);
- xine_notify_stream_finished ();
+ if (this->video_finished) {
+ pthread_mutex_unlock (&this->xine_lock);
+ xine_notify_stream_finished (this);
} else
- pthread_mutex_unlock (&gAD.mXineLock);
+ pthread_mutex_unlock (&this->xine_lock);
break;
- case BUF_QUIT:
- if (gAD.mCurDecoder) {
- gAD.mCurDecoder->close ();
- gAD.mCurDecoder = NULL;
+ case BUF_CONTROL_QUIT:
+ if (this->audio_cur_decoder) {
+ this->audio_cur_decoder->close (this->audio_cur_decoder);
+ this->audio_cur_decoder = NULL;
}
- bRunning = 0;
+ running = 0;
break;
}
}
- pBuf->free_buffer (pBuf);
+ buf->free_buffer (buf);
}
return NULL;
}
-int audio_decoder_is_stream_finished () {
- return gAD.mbStreamFinished ;
-}
-
-uint32_t audio_decoder_get_pos () {
- return gAD.mnCurPos;
-}
+void audio_decoder_init (xine_t *this) {
-fifo_buffer_t *audio_decoder_init (ao_instance_t *audio_out,
- pthread_mutex_t xine_lock) {
+ int i;
- gAD.mAudioOut = audio_out;
- gAD.mXineLock = xine_lock;
+ this->audio_cur_decoder = NULL;
+ for (i=0; i<AUDIO_OUT_PLUGIN_MAX; i++)
+ this->audio_decoders[i] = NULL;
- gAD.mCurDecoder = NULL;
- for (i=0; i<MAX_NUM_DECODERS; i++)
- gAD.mDecoders[i] = NULL;
+ /* FIXME: dynamically load these
+ this->audio_decoders[BUF_AC3AUDIO] = init_audio_decoder_ac3dec ();
+ this->audio_decoders[BUF_MPEGAUDIO] = init_audio_decoder_mpg123 ();
+ this->audio_decoders[BUF_MSAUDIO] = init_audio_decoder_msaudio ();
+ this->audio_decoders[BUF_LINEARPCM] = init_audio_decoder_linearpcm ();
+ */
- gAD.mDecoders[BUF_AC3AUDIO] = init_audio_decoder_ac3dec ();
- gAD.mDecoders[BUF_MPEGAUDIO] = init_audio_decoder_mpg123 ();
- gAD.mDecoders[BUF_MSAUDIO] = init_audio_decoder_msaudio ();
- gAD.mDecoders[BUF_LINEARPCM] = init_audio_decoder_linearpcm ();
+ this->audio_fifo = fifo_buffer_new ();
- gAD.mBufAudio = fifo_buffer_new ();
-
- pthread_create (&gAD.mAudioThread, NULL, audio_decoder_loop, NULL) ;
+ pthread_create (&this->audio_thread, NULL, audio_decoder_loop, this) ;
printf ("audio_decoder_init: audio thread created\n");
-
- return gAD.mBufAudio;
}
-void audio_decoder_shutdown () {
+void audio_decoder_shutdown (xine_t *this) {
- buf_element_t *pBuf;
+ buf_element_t *buf;
+ void *p;
- gAD.mBufAudio->fifo_buffer_clear(gAD.mBufAudio);
+ this->audio_fifo->clear(this->audio_fifo);
- pBuf = gAD.mBufAudio->buffer_pool_alloc ();
- pBuf->nType = BUF_QUIT;
- gAD.mBufAudio->fifo_buffer_put (gAD.mBufAudio, pBuf);
+ buf = this->audio_fifo->buffer_pool_alloc ();
+ buf->type = BUF_CONTROL_QUIT;
+ this->audio_fifo->put (this->audio_fifo, buf);
- pthread_join (gAD.mAudioThread, &p);
+ pthread_join (this->audio_thread, &p);
}
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index e668942de..dab46d628 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.3 2001/04/22 00:31:44 guenter Exp $
+ * $Id: video_decoder.c,v 1.4 2001/04/22 02:42:49 guenter Exp $
*
*/
@@ -65,11 +65,11 @@ void *video_decoder_loop (void *this_gen) {
this->video_cur_decoder->close ();
this->video_cur_decoder = decoder;
- this->video_cur_decoder->init (this->video_out);
+ this->video_cur_decoder->init (this->video_cur_decoder, this->video_out);
}
- decoder->decode_data (buf);
+ decoder->decode_data (this->video_cur_decoder, buf);
}
break;
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index b02948bb0..36c04b108 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.5 2001/04/22 00:31:44 guenter Exp $
+ * $Id: xine_internal.h,v 1.6 2001/04/22 02:42:49 guenter Exp $
*
*/
@@ -131,6 +131,11 @@ typedef struct xine_s {
video_decoder_t *video_cur_decoder;
int video_finished;
+ ao_functions_t *audio_out;
+ fifo_buffer_t *audio_fifo;
+ pthread_t audio_thread;
+ audio_decoder_t *audio_decoders[DECODER_PLUGIN_MAX];
+ audio_decoder_t *audio_cur_decoder;
int audio_finished;
gui_status_callback_func_t gui_status_callback;