diff mbox series

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

Message ID 20210719071541.80003-1-liuqi05@kuaishou.com
State New
Headers show
Series [FFmpeg-devel] avdevice/avfoundation: continue to try get packet if not in observed_quit mode
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Steven Liu July 19, 2021, 7:15 a.m. UTC
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@kuaishou.com>
---
 libavdevice/avfoundation.m | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

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);
             }
         }