diff options
author | wm4 <wm4@nowhere> | 2017-01-10 11:54:34 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-01-10 11:54:34 +0100 |
commit | 0e8b9ed2283210c946a5d48310372b52adaf64df (patch) | |
tree | c33ad68e73a3dbb21955dff1938e907a0078d4f1 /demux | |
parent | 9c5cbbf5d77fce4f795cd7148170ee27666d689b (diff) |
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.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 49 |
1 files changed, 22 insertions, 27 deletions
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; } |