diff options
author | wm4 <wm4@nowhere> | 2020-05-25 01:54:04 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-25 01:54:37 +0200 |
commit | afb6f1c7e988b4499abd0673339c53e4b08db43a (patch) | |
tree | 1024a5c8b79b0fae2cde31b26706e61895413f7a /audio/aframe.c | |
parent | 7c9543577a9aae1dabdeeb27c658844f9bb89ed0 (diff) | |
download | mpv-afb6f1c7e988b4499abd0673339c53e4b08db43a.tar.bz2 mpv-afb6f1c7e988b4499abd0673339c53e4b08db43a.tar.xz |
audio: add frame alloc function
Meh, why is this so roundabout?
Diffstat (limited to 'audio/aframe.c')
-rw-r--r-- | audio/aframe.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/audio/aframe.c b/audio/aframe.c index 35259ba208..0bb2f872b4 100644 --- a/audio/aframe.c +++ b/audio/aframe.c @@ -100,6 +100,19 @@ void mp_aframe_unref_data(struct mp_aframe *frame) talloc_free(tmp); } +// Allocate this much data. Returns false for failure (data already allocated, +// invalid sample count or format, allocation failures). +// Normally you're supposed to use a frame pool and mp_aframe_pool_allocate(). +bool mp_aframe_alloc_data(struct mp_aframe *frame, int samples) +{ + if (mp_aframe_is_allocated(frame)) + return false; + struct mp_aframe_pool *p = mp_aframe_pool_create(NULL); + int r = mp_aframe_pool_allocate(p, frame, samples); + talloc_free(p); + return r >= 0; +} + // Return a new reference to the data in av_frame. av_frame itself is not // touched. Returns NULL if not representable, or if input is NULL. // Does not copy the timestamps. |