diff options
author | wm4 <wm4@nowhere> | 2019-05-16 16:36:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:04 +0200 |
commit | 781e9fcd6663cac6f36c5f554bd19237a4102d19 (patch) | |
tree | 82bccda76e14fefb69bbf2f37db3fa2cf425c6cf /demux/demux.c | |
parent | d91a82c206cc7cc976cec04604b1a8bf5671a49c (diff) | |
download | mpv-781e9fcd6663cac6f36c5f554bd19237a4102d19.tar.bz2 mpv-781e9fcd6663cac6f36c5f554bd19237a4102d19.tar.xz |
demux: factor out a some packet queue code
Might be helpful for later. The "duplicated" ds->reader_head check above
the function call is redundant, but leaving it also for later.
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/demux/demux.c b/demux/demux.c index 97e5116bab..ff1573dca5 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1821,6 +1821,27 @@ static void *demux_thread(void *pctx) return NULL; } +// Low-level part of dequeueing a packet. +static struct demux_packet *advance_reader_head(struct demux_stream *ds) +{ + struct demux_packet *pkt = ds->reader_head; + if (!pkt) + return NULL; + + ds->reader_head = pkt->next; + + // Update cached packet queue state. + ds->fw_packs--; + size_t bytes = demux_packet_estimate_total_size(pkt); + ds->fw_bytes -= bytes; + ds->in->fw_bytes -= bytes; + + ds->last_ret_pos = pkt->pos; + ds->last_ret_dts = pkt->dts; + + return pkt; +} + static struct demux_packet *dequeue_packet(struct demux_stream *ds) { if (ds->sh->attached_picture) { @@ -1836,17 +1857,7 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds) } if (!ds->reader_head || ds->in->blocked) return NULL; - struct demux_packet *pkt = ds->reader_head; - ds->reader_head = pkt->next; - - // Update cached packet queue state. - ds->fw_packs--; - size_t bytes = demux_packet_estimate_total_size(pkt); - ds->fw_bytes -= bytes; - ds->in->fw_bytes -= bytes; - - ds->last_ret_pos = pkt->pos; - ds->last_ret_dts = pkt->dts; + struct demux_packet *pkt = advance_reader_head(ds); // The returned packet is mutated etc. and will be owned by the user. pkt = demux_copy_packet(pkt); |