From 0e8b9ed2283210c946a5d48310372b52adaf64df Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jan 2017 11:54:34 +0100 Subject: demux: uninline ds_get_packets() It has only 1 caller, and is too far appart within the file. I think it used to have multiple callers, but now it just doesn't make any sense to keep it separate anymore. --- demux/demux.c | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'demux') diff --git a/demux/demux.c b/demux/demux.c index 18c9b3b5c1..4b6536ef29 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -677,28 +677,6 @@ static bool read_packet(struct demux_internal *in) return true; } -// must be called locked; may temporarily unlock -static void ds_get_packets(struct demux_stream *ds) -{ - const char *t = stream_type_name(ds->type); - struct demux_internal *in = ds->in; - MP_DBG(in, "reading packet for %s\n", t); - in->eof = false; // force retry - while (ds->selected && !ds->head) { - ds->active = true; - // Note: the following code marks EOF if it can't continue - if (in->threading) { - MP_VERBOSE(in, "waiting for demux thread (%s)\n", t); - pthread_cond_signal(&in->wakeup); - pthread_cond_wait(&in->wakeup, &in->lock); - } else { - read_packet(in); - } - if (ds->eof) - break; - } -} - static void execute_trackswitch(struct demux_internal *in) { in->tracks_switched = false; @@ -843,12 +821,29 @@ struct demux_packet *demux_read_packet(struct sh_stream *sh) struct demux_stream *ds = sh ? sh->ds : NULL; struct demux_packet *pkt = NULL; if (ds) { - pthread_mutex_lock(&ds->in->lock); - if (!use_lazy_subtitle_reading(ds)) - ds_get_packets(ds); + struct demux_internal *in = ds->in; + pthread_mutex_lock(&in->lock); + if (!use_lazy_subtitle_reading(ds)) { + const char *t = stream_type_name(ds->type); + MP_DBG(in, "reading packet for %s\n", t); + in->eof = false; // force retry + while (ds->selected && !ds->head) { + ds->active = true; + // Note: the following code marks EOF if it can't continue + if (in->threading) { + MP_VERBOSE(in, "waiting for demux thread (%s)\n", t); + pthread_cond_signal(&in->wakeup); + pthread_cond_wait(&in->wakeup, &in->lock); + } else { + read_packet(in); + } + if (ds->eof) + break; + } + } pkt = dequeue_packet(ds); - pthread_cond_signal(&ds->in->wakeup); // possibly read more - pthread_mutex_unlock(&ds->in->lock); + pthread_cond_signal(&in->wakeup); // possibly read more + pthread_mutex_unlock(&in->lock); } return pkt; } -- cgit v1.2.3