summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_cda.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_cda.c')
-rw-r--r--src/demuxers/demux_cda.c130
1 files changed, 13 insertions, 117 deletions
diff --git a/src/demuxers/demux_cda.c b/src/demuxers/demux_cda.c
index 35c28fe21..655f51371 100644
--- a/src/demuxers/demux_cda.c
+++ b/src/demuxers/demux_cda.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_cda.c,v 1.29 2002/10/27 16:14:22 tmmm Exp $
+ * $Id: demux_cda.c,v 1.30 2002/10/28 03:24:43 miguelfreitas Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -27,8 +27,6 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
-#include <pthread.h>
-#include <sched.h>
#include <string.h>
#include <stdlib.h>
@@ -50,14 +48,9 @@ typedef struct {
input_plugin_t *input;
- pthread_t thread;
- int thread_running;
- pthread_mutex_t mutex;
-
off_t start;
int status;
- int send_end_buffers;
int blocksize;
char last_mrl[1024];
@@ -98,127 +91,34 @@ static int demux_cda_next (demux_cda_t *this) {
/*
*
*/
-static void *demux_cda_loop (void *this_gen) {
+static int demux_cda_send_chunk (demux_plugin_t *this_gen) {
demux_cda_t *this = (demux_cda_t *) this_gen;
- pthread_mutex_lock( &this->mutex );
- /* do-while needed to seek after demux finished */
- do {
-
- /* main demuxer loop */
- while(this->status == DEMUX_OK) {
-
- xine_usec_sleep(100000);
- if (!demux_cda_next(this))
- this->status = DEMUX_FINISHED;
-
- /* someone may want to interrupt us */
- pthread_mutex_unlock( &this->mutex );
- /* give demux_*_stop a chance to interrupt us */
- sched_yield();
- pthread_mutex_lock( &this->mutex );
- }
-
- /* wait before sending end buffers: user might want to do a new seek */
- while(this->send_end_buffers && this->audio_fifo->size(this->audio_fifo) &&
- this->status != DEMUX_OK){
- pthread_mutex_unlock( &this->mutex );
- xine_usec_sleep(100000);
- pthread_mutex_lock( &this->mutex );
- }
-
- } while( this->status == DEMUX_OK );
-
- this->status = DEMUX_FINISHED;
-
- if (this->send_end_buffers) {
- xine_demux_control_end(this->stream, BUF_FLAG_END_STREAM);
- }
-
- this->thread_running = 0;
- pthread_mutex_unlock( &this->mutex );
+ if (!demux_cda_next(this))
+ this->status = DEMUX_FINISHED;
- pthread_exit(NULL);
-}
-
-/*
- *
- */
-static void demux_cda_stop (demux_plugin_t *this_gen) {
- demux_cda_t *this = (demux_cda_t *) this_gen;
- void *p;
-
- pthread_mutex_lock( &this->mutex );
-
- if (!this->thread_running) {
- printf ("demux_cda: stop...ignored\n");
- return;
- }
-
- /* Force stop */
-/* this->input->stop(this->input);*/
-
- this->send_end_buffers = 0;
- this->status = DEMUX_FINISHED;
-
- pthread_mutex_unlock( &this->mutex );
- pthread_join (this->thread, &p);
-
- xine_demux_flush_engine(this->stream);
-
- xine_demux_control_end(this->stream, BUF_FLAG_END_USER);
+ return this->status;
}
/*
*
*/
-static int demux_cda_start (demux_plugin_t *this_gen,
+static int demux_cda_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
demux_cda_t *this = (demux_cda_t *) this_gen;
- int err;
- int status;
-
- pthread_mutex_lock( &this->mutex );
this->start = start_pos;
this->blocksize = this->input->get_blocksize(this->input);
- if( !this->thread_running ) {
- xine_demux_control_start(this->stream);
- }
-
/*
* now start demuxing
*/
this->input->seek(this->input, this->start, SEEK_SET);
- if( !this->thread_running ) {
-
- this->status = DEMUX_OK;
- this->send_end_buffers = 1;
- this->thread_running = 1;
- if ((err = pthread_create (&this->thread,
- NULL, demux_cda_loop, this)) != 0) {
- printf ("demux_cda: can't create new thread (%s)\n", strerror(err));
- abort();
- }
- }
-
- /* this->status is saved because we can be interrupted between
- * pthread_mutex_unlock and return
- */
- status = this->status;
- pthread_mutex_unlock( &this->mutex );
- return status;
-}
-
-
-static int demux_cda_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
-
- return demux_cda_start (this_gen,
- start_pos, start_time);
+ this->status = DEMUX_OK;
+
+ return this->status;
}
/*
@@ -228,12 +128,12 @@ static void demux_cda_send_headers(demux_plugin_t *this_gen) {
demux_cda_t *this = (demux_cda_t *) this_gen;
- pthread_mutex_lock(&this->mutex);
-
this->video_fifo = this->stream->video_fifo;
this->audio_fifo = this->stream->audio_fifo;
this->status = DEMUX_OK;
+
+ xine_demux_control_start(this->stream);
/* hardwired stream information */
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
@@ -243,8 +143,6 @@ static void demux_cda_send_headers(demux_plugin_t *this_gen) {
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = 16;
xine_demux_control_headers_done (this->stream);
-
- pthread_mutex_unlock (&this->mutex);
}
/*
@@ -287,16 +185,14 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->input = input;
this->demux_plugin.send_headers = demux_cda_send_headers;
- this->demux_plugin.start = demux_cda_start;
+ this->demux_plugin.send_chunk = demux_cda_send_chunk;
this->demux_plugin.seek = demux_cda_seek;
- this->demux_plugin.stop = demux_cda_stop;
this->demux_plugin.dispose = demux_cda_dispose;
this->demux_plugin.get_status = demux_cda_get_status;
this->demux_plugin.get_stream_length = demux_cda_get_stream_length;
this->demux_plugin.demux_class = class_gen;
this->status = DEMUX_FINISHED;
- pthread_mutex_init (&this->mutex, NULL);
switch (stream->content_detection_method) {
@@ -378,6 +274,6 @@ static void *init_plugin (xine_t *xine, void *data) {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 14, "cda", XINE_VERSION_CODE, NULL, init_plugin },
+ { PLUGIN_DEMUX, 15, "cda", XINE_VERSION_CODE, NULL, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};