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 | expand

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(-)

Comments

Thilo Borgmann Sept. 17, 2021, 4:12 p.m. UTC | #1
Hi,

On 19 Jul 2021, at 9:15, Steven Liu wrote:

> 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(-)

I just applied some fixes related to the locking. Can you retest this, 
as it appears not really related to the locking but to behavior of 
EAGAIN if this changes things for you?

Thanks,
Thilo
Steven Liu Sept. 18, 2021, 2:01 a.m. UTC | #2
Thilo Borgmann <thilo.borgmann@mail.de> 于2021年9月18日周六 上午12:12写道:
>
> Hi,
Hi Thilo,
>
> On 19 Jul 2021, at 9:15, Steven Liu wrote:
>
> > 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(-)
>
> I just applied some fixes related to the locking. Can you retest this,
> as it appears not really related to the locking but to behavior of
> EAGAIN if this changes things for you?
Yes, your are right, I have re-submit new version:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210918015137.18968-1-lq@chinaffmpeg.org/

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