summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_mpeg.c
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-10-28 03:24:42 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-10-28 03:24:42 +0000
commit7505ad157b1bc5b912430537e4aba444c1c23662 (patch)
treeaaa5c6d37ca43041184de561e72fef0a665b1fee /src/demuxers/demux_mpeg.c
parentc98152c4db1ea9651b79d44e06567df3fa2c62ce (diff)
downloadxine-lib-7505ad157b1bc5b912430537e4aba444c1c23662.tar.gz
xine-lib-7505ad157b1bc5b912430537e4aba444c1c23662.tar.bz2
hey, i want to join xine breakage party! (what do you wanna break today? tm)
- time to cleanup demuxer mess... no more pthread stuff on any demuxer. of course i haven't tested all demuxers, but they at least compile. (sorry Mike, we will need to move a few variables around to make most of your demuxers work again - not big deal i think) - make api more consistent by providing xine_open/xine_close and xine_start/xine_stop. CVS patchset: 3058 CVS date: 2002/10/28 03:24:42
Diffstat (limited to 'src/demuxers/demux_mpeg.c')
-rw-r--r--src/demuxers/demux_mpeg.c123
1 files changed, 11 insertions, 112 deletions
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 5ce7cc26a..53a796464 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.91 2002/10/27 00:01:13 guenter Exp $
+ * $Id: demux_mpeg.c,v 1.92 2002/10/28 03:24:43 miguelfreitas Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
@@ -34,8 +34,6 @@
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
-#include <pthread.h>
-#include <sched.h>
#include <string.h>
#include <unistd.h>
@@ -60,10 +58,6 @@ typedef struct demux_mpeg_s {
xine_stream_t *stream;
input_plugin_t *input;
- pthread_t thread;
- int thread_running;
- pthread_mutex_t mutex;
-
unsigned char dummy_space[100000];
int status;
@@ -71,8 +65,6 @@ typedef struct demux_mpeg_s {
int rate;
- int send_end_buffers;
-
int64_t last_pts[2];
int send_newpts;
int buf_flag_seek;
@@ -777,75 +769,17 @@ static void demux_mpeg_resync (demux_mpeg_t *this, uint32_t buf) {
}
}
-static void *demux_mpeg_loop (void *this_gen) {
-
- demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
- uint32_t w=0;
-
- pthread_mutex_lock( &this->mutex );
- /* do-while needed to seek after demux finished */
- do {
-
- /* main demuxer loop */
- while(this->status == DEMUX_OK) {
- w = parse_pack (this);
- if (w != 0x000001ba)
- demux_mpeg_resync (this, w);
-
- /* 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->video_fifo->size(this->video_fifo) &&
- this->status != DEMUX_OK){
- pthread_mutex_unlock( &this->mutex );
- xine_usec_sleep(100000);
- pthread_mutex_lock( &this->mutex );
- }
-
- } while( this->status == DEMUX_OK );
-
- if (this->send_end_buffers) {
- xine_demux_control_end(this->stream, BUF_FLAG_END_STREAM);
- }
-
- printf ("demux_mpeg: demux thread finished (status: %d, buf:%x)\n",
- this->status, w);
-
- this->thread_running = 0;
- pthread_mutex_unlock( &this->mutex );
-
- pthread_exit(NULL);
-
- return NULL;
-}
-
-static void demux_mpeg_stop (demux_plugin_t *this_gen) {
+static int demux_mpeg_send_chunk (demux_plugin_t *this_gen) {
demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
- void *p;
- pthread_mutex_lock( &this->mutex );
-
- if (!this->thread_running) {
- printf ("demux_mpeg: stop...ignored\n");
- pthread_mutex_unlock( &this->mutex );
- return;
- }
-
- this->send_end_buffers = 0;
- this->status = DEMUX_FINISHED;
-
- pthread_mutex_unlock( &this->mutex );
- pthread_join (this->thread, &p);
+ uint32_t w=0;
- xine_demux_flush_engine(this->stream);
+ w = parse_pack (this);
+ if (w != 0x000001ba)
+ demux_mpeg_resync (this, w);
- xine_demux_control_end(this->stream, BUF_FLAG_END_USER);
+ return this->status;
}
static int demux_mpeg_get_status (demux_plugin_t *this_gen) {
@@ -860,8 +794,6 @@ static void demux_mpeg_send_headers (demux_plugin_t *this_gen) {
uint32_t w;
int num_buffers = NUM_PREVIEW_BUFFERS;
- pthread_mutex_lock( &this->mutex );
-
this->video_fifo = this->stream->video_fifo;
this->audio_fifo = this->stream->audio_fifo;
@@ -900,18 +832,12 @@ static void demux_mpeg_send_headers (demux_plugin_t *this_gen) {
this->stream->stream_info[XINE_STREAM_INFO_BITRATE] = this->rate * 50 * 8;
xine_demux_control_headers_done (this->stream);
-
- pthread_mutex_unlock (&this->mutex);
}
-static int demux_mpeg_start (demux_plugin_t *this_gen,
+static int demux_mpeg_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
- int err;
- int status;
-
- pthread_mutex_lock( &this->mutex );
if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0 ) {
@@ -929,43 +855,20 @@ static int demux_mpeg_start (demux_plugin_t *this_gen,
this->send_newpts = 1;
this->status = DEMUX_OK ;
- if( !this->thread_running ) {
+ if( !this->stream->demux_thread_running ) {
this->preview_mode = 0;
- this->send_end_buffers = 1;
- this->thread_running = 1;
this->buf_flag_seek = 0;
-
- if ((err = pthread_create (&this->thread,
- NULL, demux_mpeg_loop, this)) != 0) {
- printf ("demux_mpeg: can't create new thread (%s)\n",
- strerror(err));
- abort();
- }
}
else {
this->buf_flag_seek = 1;
xine_demux_flush_engine(this->stream);
}
- /* 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_mpeg_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
- /* demux_mpeg_t *this = (demux_mpeg_t *) this_gen; */
-
- return demux_mpeg_start (this_gen, start_pos, start_time);
+ return this->status;
}
static void demux_mpeg_dispose (demux_plugin_t *this_gen) {
- demux_mpeg_stop (this_gen);
-
free (this_gen);
}
@@ -989,9 +892,8 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->input = input;
this->demux_plugin.send_headers = demux_mpeg_send_headers;
- this->demux_plugin.start = demux_mpeg_start;
+ this->demux_plugin.send_chunk = demux_mpeg_send_chunk;
this->demux_plugin.seek = demux_mpeg_seek;
- this->demux_plugin.stop = demux_mpeg_stop;
this->demux_plugin.dispose = demux_mpeg_dispose;
this->demux_plugin.get_status = demux_mpeg_get_status;
this->demux_plugin.get_stream_length = demux_mpeg_get_stream_length;
@@ -1000,9 +902,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->status = DEMUX_FINISHED;
this->has_pts = 0;
- pthread_mutex_init( &this->mutex, NULL );
-
-
switch (stream->content_detection_method) {
case METHOD_BY_CONTENT: {