1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 10:02:17 +00:00

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.
This commit is contained in:
wm4 2017-01-10 11:54:34 +01:00
parent 9c5cbbf5d7
commit 0e8b9ed228

View File

@ -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;
}