mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 17:42:17 +00:00
d33e5972b3
Them being separate is just dumb. Replace them with a single demux_free() function, and free its stream by default. Not freeing the stream is only needed in 1 special case (demux_disc.c), use a special flag to not free the stream in this case.
43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
#include "common/common.h"
|
|
#include "stream/stream.h"
|
|
#include "demux.h"
|
|
|
|
#include "timeline.h"
|
|
|
|
struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log,
|
|
struct demuxer *demuxer)
|
|
{
|
|
if (!demuxer->desc->load_timeline)
|
|
return NULL;
|
|
|
|
struct timeline *tl = talloc_ptrtype(NULL, tl);
|
|
*tl = (struct timeline){
|
|
.global = global,
|
|
.log = log,
|
|
.cancel = demuxer->cancel,
|
|
.demuxer = demuxer,
|
|
.track_layout = demuxer,
|
|
};
|
|
|
|
demuxer->desc->load_timeline(tl);
|
|
|
|
if (tl->num_parts)
|
|
return tl;
|
|
timeline_destroy(tl);
|
|
return NULL;
|
|
}
|
|
|
|
void timeline_destroy(struct timeline *tl)
|
|
{
|
|
if (!tl)
|
|
return;
|
|
for (int n = 0; n < tl->num_sources; n++) {
|
|
struct demuxer *d = tl->sources[n];
|
|
if (d != tl->demuxer && d != tl->track_layout)
|
|
demux_free(d);
|
|
}
|
|
if (tl->track_layout && tl->track_layout != tl->demuxer)
|
|
demux_free(tl->track_layout);
|
|
talloc_free(tl);
|
|
}
|