demux/packet_pool: always return default packet state from pop

This is not functional change, as pop() is only used in packet_create()
which already cleared the packet, but it's better to make it explcit.
This commit is contained in:
Kacper Michajłow committed 2026-01-28 18:40:19 +01:00
1 parent 3b17ab5d3b
commit a1ea4f3aec
3 files changed
+7 -8

No files matched your search

+3 -3
View File
@@ -85,13 +85,13 @@ void demux_packet_unref(struct demux_packet *dp)
static struct demux_packet *packet_create(struct demux_packet_pool *pool)
{
struct demux_packet *dp = pool ? demux_packet_pool_pop(pool) : NULL;
struct AVPacket *avpkt = dp ? dp->avpacket : NULL;
if (!dp) {
dp = talloc(NULL, struct demux_packet);
talloc_set_destructor(dp, packet_destroy);
set_packet_defaults(dp);
}
set_packet_defaults(dp);
dp->avpacket = avpkt ? avpkt : av_packet_alloc();
if (!dp->avpacket)
dp->avpacket = av_packet_alloc();
MP_HANDLE_OOM(dp->avpacket);
return dp;
}
+1 -5
View File
@@ -120,11 +120,7 @@ struct demux_packet *demux_packet_pool_pop(struct demux_packet_pool *pool)
// a single packet at a time. This avoids the need to clear potentially
// hundreds of thousands of packets at once when file playback is stopped,
// which would require a significant amount of time to iterate over all packets.
if (dp) {
if (dp->avpacket)
av_packet_unref(dp->avpacket);
ta_free_children(dp);
}
demux_packet_unref(dp);
return dp;
}
+3
View File
@@ -82,6 +82,9 @@ void demux_packet_pool_prepend(struct demux_packet_pool *pool,
* This function removes and returns the first packet from the pool's
* linked list. This function is thread-safe.
*
* The packet's contents are cleared of any external references before
* being returned.
*
* @param pool Pointer to the demux packet pool.
* @return Pointer to the demux packet, or NULL if the pool is empty.
*/