summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xine-engine/demux.c26
-rw-r--r--src/xine-engine/xine.c4
-rw-r--r--src/xine-engine/xine_internal.h3
3 files changed, 30 insertions, 3 deletions
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index 40ee9f7d3..3232c497f 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -20,7 +20,7 @@
* Demuxer helper functions
* hide some xine engine details from demuxers and reduce code duplication
*
- * $Id: demux.c,v 1.62 2006/04/05 22:12:20 valtri Exp $
+ * $Id: demux.c,v 1.63 2006/08/08 03:25:03 miguelfreitas Exp $
*/
@@ -85,6 +85,8 @@ void _x_demux_flush_engine (xine_stream_t *stream) {
stream->video_fifo->clear(stream->video_fifo);
stream->audio_fifo->clear(stream->audio_fifo);
+ pthread_mutex_lock(&stream->demux_mutex);
+
buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo);
buf->type = BUF_CONTROL_RESET_DECODER;
stream->video_fifo->put (stream->video_fifo, buf);
@@ -93,6 +95,8 @@ void _x_demux_flush_engine (xine_stream_t *stream) {
buf->type = BUF_CONTROL_RESET_DECODER;
stream->audio_fifo->put (stream->audio_fifo, buf);
+ pthread_mutex_unlock(&stream->demux_mutex);
+
/* on seeking we must wait decoder fifos to process before doing flush.
* otherwise we flush too early (before the old data has left decoders)
*/
@@ -124,6 +128,8 @@ void _x_demux_control_newpts( xine_stream_t *stream, int64_t pts, uint32_t flags
buf_element_t *buf;
+ pthread_mutex_lock(&stream->demux_mutex);
+
buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo);
buf->type = BUF_CONTROL_NEWPTS;
buf->decoder_flags = flags;
@@ -135,6 +141,8 @@ void _x_demux_control_newpts( xine_stream_t *stream, int64_t pts, uint32_t flags
buf->decoder_flags = flags;
buf->disc_off = pts;
stream->audio_fifo->put (stream->audio_fifo, buf);
+
+ pthread_mutex_unlock(&stream->demux_mutex);
}
/* sync with decoder fifos, making sure everything gets processed */
@@ -165,12 +173,16 @@ void _x_demux_control_headers_done (xine_stream_t *stream) {
header_count_audio = 0;
}
+ pthread_mutex_lock(&stream->demux_mutex);
+
buf_video->type = BUF_CONTROL_HEADERS_DONE;
stream->video_fifo->put (stream->video_fifo, buf_video);
buf_audio->type = BUF_CONTROL_HEADERS_DONE;
stream->audio_fifo->put (stream->audio_fifo, buf_audio);
+ pthread_mutex_unlock(&stream->demux_mutex);
+
while ((stream->header_count_audio < header_count_audio) ||
(stream->header_count_video < header_count_video)) {
struct timeval tv;
@@ -198,6 +210,8 @@ void _x_demux_control_start( xine_stream_t *stream ) {
buf_element_t *buf;
+ pthread_mutex_lock(&stream->demux_mutex);
+
buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo);
buf->type = BUF_CONTROL_START;
stream->video_fifo->put (stream->video_fifo, buf);
@@ -205,12 +219,16 @@ void _x_demux_control_start( xine_stream_t *stream ) {
buf = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo);
buf->type = BUF_CONTROL_START;
stream->audio_fifo->put (stream->audio_fifo, buf);
+
+ pthread_mutex_unlock(&stream->demux_mutex);
}
void _x_demux_control_end( xine_stream_t *stream, uint32_t flags ) {
buf_element_t *buf;
+ pthread_mutex_lock(&stream->demux_mutex);
+
buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo);
buf->type = BUF_CONTROL_END;
buf->decoder_flags = flags;
@@ -220,12 +238,16 @@ void _x_demux_control_end( xine_stream_t *stream, uint32_t flags ) {
buf->type = BUF_CONTROL_END;
buf->decoder_flags = flags;
stream->audio_fifo->put (stream->audio_fifo, buf);
+
+ pthread_mutex_unlock(&stream->demux_mutex);
}
void _x_demux_control_nop( xine_stream_t *stream, uint32_t flags ) {
buf_element_t *buf;
+ pthread_mutex_lock(&stream->demux_mutex);
+
buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo);
buf->type = BUF_CONTROL_NOP;
buf->decoder_flags = flags;
@@ -235,6 +257,8 @@ void _x_demux_control_nop( xine_stream_t *stream, uint32_t flags ) {
buf->type = BUF_CONTROL_NOP;
buf->decoder_flags = flags;
stream->audio_fifo->put (stream->audio_fifo, buf);
+
+ pthread_mutex_unlock(&stream->demux_mutex);
}
static void *demux_loop (void *stream_gen) {
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index e6bf5f26d..a0075765e 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.324 2006/07/03 10:55:37 dgp85 Exp $
+ * $Id: xine.c,v 1.325 2006/08/08 03:25:03 miguelfreitas Exp $
*/
/*
@@ -533,6 +533,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
pthread_mutex_init (&stream->info_mutex, NULL);
pthread_mutex_init (&stream->meta_mutex, NULL);
pthread_mutex_init (&stream->demux_lock, NULL);
+ pthread_mutex_init (&stream->demux_mutex, NULL);
pthread_mutex_init (&stream->event_queues_lock, NULL);
pthread_mutex_init (&stream->counter_lock, NULL);
pthread_cond_init (&stream->counter_changed, NULL);
@@ -1270,6 +1271,7 @@ void xine_dispose_internal (xine_stream_t *stream) {
pthread_mutex_destroy (&stream->event_queues_lock);
pthread_mutex_destroy (&stream->current_extra_info_lock);
pthread_cond_destroy (&stream->counter_changed);
+ pthread_mutex_destroy (&stream->demux_mutex);
pthread_mutex_destroy (&stream->demux_lock);
pthread_mutex_destroy (&stream->first_frame_lock);
pthread_cond_destroy (&stream->first_frame_reached);
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 9ad198143..05a9144d6 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.172 2006/04/21 22:46:33 dsalt Exp $
+ * $Id: xine_internal.h,v 1.173 2006/08/08 03:25:03 miguelfreitas Exp $
*
*/
@@ -320,6 +320,7 @@ struct xine_stream_s {
int demux_thread_running;
pthread_mutex_t demux_lock;
int demux_action_pending;
+ pthread_mutex_t demux_mutex; /* used in _x_demux_... functions to synchronize order of pairwise A/V buffer operations */
extra_info_t *current_extra_info;
pthread_mutex_t current_extra_info_lock;