[FFmpeg-devel] [PATCH] avdevice/avfoundation: continue to try get packet if not in observed_quit mode

Steven Liu liuqi05 at kuaishou.com
Mon Jul 19 10:15:41 EEST 2021


move unlock_frames before return in observed_quit mode.
before patch:
./ffmpeg -f avfoundation -i ":0" -y out.wav
say something to microphone
ffplay out.wav will hear some noise, because not get enough samples from
devices

after patch:
./ffmpeg -f avfoundation -i ":0" -y out.wav
say something to microphone
ffplay out.wav will ok.

Signed-off-by: Steven Liu <liuqi05 at kuaishou.com>
---
 libavdevice/avfoundation.m | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index bad3760159..ddde640c80 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -1170,11 +1170,9 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt)
             ctx->current_audio_frame = nil;
         } else {
             pkt->data = NULL;
-            unlock_frames(ctx);
             if (ctx->observed_quit) {
+                unlock_frames(ctx);
                 return AVERROR_EOF;
-            } else {
-                return AVERROR(EAGAIN);
             }
         }
 
-- 
2.25.0





More information about the ffmpeg-devel mailing list