1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

avcodec/mediacodec: return error when buffer is released a second time

If the caller does any further processing (e.g. with AImageReader), it's very important
to know if he can expect the frame to actually arrive at the surface or not.
This provides a clearly detectable error in case the buffer was released multiple times
*or* the codec was flushed in the meantime.
This commit is contained in:
sfan5
2026-09-07 21:28:04 +02:00
committed by Kacper Michajłow
parent 08cd8df29d
commit 053585bc91
3 changed files with 9 additions and 3 deletions

View File

@@ -96,6 +96,8 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
"Releasing output buffer %zd (%p) ts=%"PRId64" with render=%d [%d pending]\n",
buffer->index, buffer, buffer->pts, render, atomic_load(&ctx->hw_buffer_count));
return ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, render);
} else if (render) {
return AVERROR(ENOENT);
}
return 0;
@@ -114,7 +116,7 @@ int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time
return ff_AMediaCodec_releaseOutputBufferAtTime(ctx->codec, buffer->index, time);
}
return 0;
return AVERROR(ENOENT);
}
#else

View File

@@ -81,7 +81,9 @@ typedef struct MediaCodecBuffer AVMediaCodecBuffer;
* @param buffer the buffer to render
* @param render 1 to release and render the buffer to the surface or 0 to
* discard the buffer
* @return 0 on success, < 0 otherwise
* @return 0 on success, < 0 otherwise.
* AVERROR(ENOENT) is returned when trying to render a buffer that has already
* been released.
*/
int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);
@@ -95,6 +97,8 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);
* @param buffer the buffer to render
* @param time timestamp in nanoseconds of when to render the buffer
* @return 0 on success, < 0 otherwise
* AVERROR(ENOENT) is returned when trying to render a buffer that has already
* been released.
*
* [0]: https://developer.android.com/reference/android/media/MediaCodec#releaseOutputBuffer(int,%20long)
*/

View File

@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 11
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \