summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiggi Langauf <siggi@users.sourceforge.net>2002-05-21 00:12:31 +0000
committerSiggi Langauf <siggi@users.sourceforge.net>2002-05-21 00:12:31 +0000
commit3a1cff5f8ea76ca1caab68df8fe64cc17848587f (patch)
tree1486cd5eaa8471d15ea5c4c988ffce5b39ec5f68
parentf21031711ce3524cc9480fedf3e6103df831ed28 (diff)
downloadxine-lib-3a1cff5f8ea76ca1caab68df8fe64cc17848587f.tar.gz
xine-lib-3a1cff5f8ea76ca1caab68df8fe64cc17848587f.tar.bz2
atomic status code on demux start/seek
(demux_avi by Thibaut Mattern) CVS patchset: 1914 CVS date: 2002/05/21 00:12:31
-rw-r--r--src/demuxers/demux.h12
-rw-r--r--src/demuxers/demux_avi.c22
-rw-r--r--src/demuxers/demux_ogg.c17
-rw-r--r--src/xine-engine/xine.c24
4 files changed, 47 insertions, 28 deletions
diff --git a/src/demuxers/demux.h b/src/demuxers/demux.h
index 8f7d9b480..d8622eeb8 100644
--- a/src/demuxers/demux.h
+++ b/src/demuxers/demux.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: demux.h,v 1.13 2002/04/09 03:37:59 miguelfreitas Exp $
+ * $Id: demux.h,v 1.14 2002/05/21 00:12:31 siggi Exp $
*/
#ifndef HAVE_DEMUX_H
@@ -86,9 +86,12 @@ struct demux_plugin_s
*
* if both parameters are !=0 start_pos will be used
* for non-seekable streams both values will be ignored
+ *
+ * returns the demux status (like get_status, but immediately after
+ * starting the demuxer)
*/
- void (*start) (demux_plugin_t *this, fifo_buffer_t *video_fifo,
+ int (*start) (demux_plugin_t *this, fifo_buffer_t *video_fifo,
fifo_buffer_t *audio_fifo,
off_t start_pos, int start_time);
@@ -102,9 +105,12 @@ struct demux_plugin_s
*
* if both parameters are !=0 start_pos will be used
* for non-seekable streams both values will be ignored
+ *
+ * returns the demux status (like get_status, but immediately after
+ * starting the demuxer)
*/
- void (*seek) (demux_plugin_t *this,
+ int (*seek) (demux_plugin_t *this,
off_t start_pos, int start_time);
/*
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 053a6d891..dab5d091a 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.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_avi.c,v 1.87 2002/05/20 16:58:02 miguelfreitas Exp $
+ * $Id: demux_avi.c,v 1.88 2002/05/21 00:12:31 siggi Exp $
*
* demultiplexer for avi streams
*
@@ -1122,8 +1122,8 @@ static int demux_avi_next (demux_avi_t *this) {
}
static void *demux_avi_loop (void *this_gen) {
-
buf_element_t *buf = NULL;
+
demux_avi_t *this = (demux_avi_t *) this_gen;
pthread_mutex_lock( &this->mutex );
@@ -1231,10 +1231,10 @@ static int demux_avi_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-static void demux_avi_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time) {
+static int demux_avi_start (demux_plugin_t *this_gen,
+ fifo_buffer_t *video_fifo,
+ fifo_buffer_t *audio_fifo,
+ off_t start_pos, int start_time) {
demux_avi_t *this = (demux_avi_t *) this_gen;
int i;
@@ -1243,6 +1243,7 @@ static void demux_avi_start (demux_plugin_t *this_gen,
int err;
unsigned char *sub;
video_index_entry_t *vie = NULL;
+ int status;
pthread_mutex_lock( &this->mutex );
@@ -1472,7 +1473,12 @@ static void demux_avi_start (demux_plugin_t *this_gen,
}
}
+ /* 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;
}
@@ -1480,8 +1486,8 @@ static void demux_avi_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
demux_avi_t *this = (demux_avi_t *) this_gen;
- demux_avi_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_avi_start (this_gen, this->video_fifo, this->audio_fifo,
+ start_pos, start_time);
}
static int demux_avi_open(demux_plugin_t *this_gen,
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index 1764fb6d4..db81328bb 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.24 2002/05/16 22:32:31 tmattern Exp $
+ * $Id: demux_ogg.c,v 1.25 2002/05/21 00:12:32 siggi Exp $
*
* demultiplexer for ogg streams
*
@@ -485,7 +485,7 @@ static int demux_ogg_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-static void demux_ogg_start (demux_plugin_t *this_gen,
+static int demux_ogg_start (demux_plugin_t *this_gen,
fifo_buffer_t *video_fifo,
fifo_buffer_t *audio_fifo,
off_t start_pos, int start_time) {
@@ -495,6 +495,7 @@ static void demux_ogg_start (demux_plugin_t *this_gen,
int err, i;
pthread_mutex_lock( &this->mutex );
+ err = 1;
if( !this->thread_running ) {
this->video_fifo = video_fifo;
@@ -578,19 +579,23 @@ static void demux_ogg_start (demux_plugin_t *this_gen,
strerror(err));
abort();
}
- } else {
+ }
+ else {
xine_flush_engine(this->xine);
+ err = 0;
}
pthread_mutex_unlock( &this->mutex );
+
+ return err ? DEMUX_FINISHED : DEMUX_OK;
}
-static void demux_ogg_seek (demux_plugin_t *this_gen,
+static int demux_ogg_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
demux_ogg_t *this = (demux_ogg_t *) this_gen;
- demux_ogg_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_ogg_start (this_gen, this->video_fifo, this->audio_fifo,
+ start_pos, start_time);
}
static int demux_ogg_open(demux_plugin_t *this_gen,
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index f9c291248..d54ab3d45 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.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: xine.c,v 1.128 2002/05/14 14:55:47 esnel Exp $
+ * $Id: xine.c,v 1.129 2002/05/21 00:12:32 siggi Exp $
*
* top-level xine functions
*
@@ -354,6 +354,7 @@ int xine_play_internal (xine_t *this, char *mrl,
double share ;
off_t pos, len;
int i;
+ int demux_status;
printf ("xine_play: xine open %s, start pos = %d, start time = %d (sec)\n",
mrl, start_pos, start_time);
@@ -443,16 +444,17 @@ int xine_play_internal (xine_t *this, char *mrl,
} else
pos = 0;
- if( this->status == XINE_STOP )
- this->cur_demuxer_plugin->start (this->cur_demuxer_plugin,
- this->video_fifo,
- this->audio_fifo,
- pos, start_time);
- else
- this->cur_demuxer_plugin->seek (this->cur_demuxer_plugin,
- pos, start_time);
-
- if (this->cur_demuxer_plugin->get_status(this->cur_demuxer_plugin) != DEMUX_OK) {
+ if( this->status == XINE_STOP ) {
+ demux_status = this->cur_demuxer_plugin->start (this->cur_demuxer_plugin,
+ this->video_fifo,
+ this->audio_fifo,
+ pos, start_time);
+ }
+ else {
+ demux_status = this->cur_demuxer_plugin->seek (this->cur_demuxer_plugin,
+ pos, start_time);
+ }
+ if (demux_status != DEMUX_OK) {
xine_log (this, XINE_LOG_MSG,
_("xine_play: demuxer failed to start\n"));