summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThibaut Mattern <tmattern@users.sourceforge.net>2002-05-16 22:32:31 +0000
committerThibaut Mattern <tmattern@users.sourceforge.net>2002-05-16 22:32:31 +0000
commit2d7c730d9ae4ff94d8e74a17c733dfd389a65e5e (patch)
treec044c05c4715b5b747911871ef175329f3c5b778 /src
parent6f4688ba40763408cefb06a50bc91323795ac42a (diff)
downloadxine-lib-2d7c730d9ae4ff94d8e74a17c733dfd389a65e5e.tar.gz
xine-lib-2d7c730d9ae4ff94d8e74a17c733dfd389a65e5e.tar.bz2
Fix seeking problem after demuxer finished.
Change get_status to return thread_running instead of demux status. Send a new pts when seeking. CVS patchset: 1902 CVS date: 2002/05/16 22:32:31
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_ogg.c81
1 files changed, 54 insertions, 27 deletions
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index 306322bb2..1764fb6d4 100644
--- a/src/demuxers/demux_ogg.c
+++ b/src/demuxers/demux_ogg.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_ogg.c,v 1.23 2002/04/29 23:31:59 jcdutton Exp $
+ * $Id: demux_ogg.c,v 1.24 2002/05/16 22:32:31 tmattern Exp $
*
* demultiplexer for ogg streams
*
@@ -101,6 +101,7 @@ typedef struct demux_ogg_s {
input_plugin_t *input;
pthread_t thread;
+ int thread_running;
pthread_mutex_t mutex;
int status;
@@ -121,6 +122,7 @@ typedef struct demux_ogg_s {
} demux_ogg_t ;
+
static void hex_dump (uint8_t *p, int length) {
int i;
@@ -380,21 +382,30 @@ static void *demux_ogg_loop (void *this_gen) {
printf ("demux_ogg: demux loop starting...\n");
#endif
- this->send_end_buffers = 1;
+ pthread_mutex_lock( &this->mutex );
+ /* do-while needed to seek after demux finished */
+ do {
- while(1) {
-
- pthread_mutex_lock( &this->mutex );
-
- if( this->status != DEMUX_OK)
- break;
-
- demux_ogg_send_package (this);
-
- pthread_mutex_unlock( &this->mutex );
-
- }
+ /* main demuxer loop */
+ while(this->status == DEMUX_OK) {
+
+ demux_ogg_send_package (this);
+
+ /* someone may want to interrupt us */
+ pthread_mutex_unlock( &this->mutex );
+ 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 );
+
#ifdef LOG
printf ("demux_ogg: demux loop finished (status: %d)\n",
this->status);
@@ -417,6 +428,7 @@ static void *demux_ogg_loop (void *this_gen) {
}
+ this->thread_running = 0;
pthread_mutex_unlock( &this->mutex );
pthread_exit(NULL);
@@ -440,7 +452,7 @@ static void demux_ogg_stop (demux_plugin_t *this_gen) {
printf ("demux_ogg: demux_ogg_stop\n");
- if (this->status != DEMUX_OK) {
+ if (!this->thread_running) {
printf ("demux_ogg: stop...ignored\n");
pthread_mutex_unlock( &this->mutex );
return;
@@ -470,7 +482,7 @@ static void demux_ogg_stop (demux_plugin_t *this_gen) {
static int demux_ogg_get_status (demux_plugin_t *this_gen) {
demux_ogg_t *this = (demux_ogg_t *) this_gen;
- return this->status;
+ return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
static void demux_ogg_start (demux_plugin_t *this_gen,
@@ -484,7 +496,7 @@ static void demux_ogg_start (demux_plugin_t *this_gen,
pthread_mutex_lock( &this->mutex );
- if( this->status != DEMUX_OK ) {
+ if( !this->thread_running ) {
this->video_fifo = video_fifo;
this->audio_fifo = audio_fifo;
@@ -505,7 +517,6 @@ static void demux_ogg_start (demux_plugin_t *this_gen,
/*
* initialize ogg engine
*/
-
ogg_sync_init(&this->oy);
this->num_streams = 0;
@@ -521,30 +532,46 @@ static void demux_ogg_start (demux_plugin_t *this_gen,
/*
* seek to start position
*/
-
if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
off_t cur_pos = this->input->get_current_pos (this->input);
- /*
- if ( (!start_pos) && (start_time))
- start_pos = start_time * this->rate;
- */
-
+/*
+ if ( (!start_pos) && (start_time)) {
+ start_pos = start_time * this->rate;
+ }
+*/
+/*
if (start_pos<cur_pos)
start_pos = cur_pos;
+*/
this->input->seek (this->input, start_pos, SEEK_SET);
+
+ /* send a new pts */
+ if( this->thread_running ) {
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = BUF_CONTROL_NEWPTS;
+ buf->disc_off = start_pos / 90;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ if (this->audio_fifo) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_CONTROL_NEWPTS;
+ buf->disc_off = start_pos / 90;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+ }
}
-
- if( this->status != DEMUX_OK ) {
+ if( !this->thread_running ) {
/*
* now start demuxing
*/
this->status = DEMUX_OK;
-
+ this->send_end_buffers = 1;
+ this->thread_running = 1;
if ((err = pthread_create (&this->thread,
NULL, demux_ogg_loop, this)) != 0) {
printf ("demux_ogg: can't create new thread (%s)\n",