From: Romain Beauxis <toots@rastageeks.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Thilo Borgmann <thilo.borgmann@mail.de>, Aman Karmani <ffmpeg@tmm1.net> Subject: Re: [FFmpeg-devel] [PATCH v8 2/3] libavdevice/avfoundation.m: Replace mutex-based concurrency handling in avfoundation.m by a thread-safe fifo queue with maximum length Date: Thu, 6 Jan 2022 08:43:39 -0600 Message-ID: <CABWZ6ORAPKrJvjmaDGv60RbV0ZsknzrZqxKB+MvwmFhxUNYp-A@mail.gmail.com> (raw) In-Reply-To: <58D02B2C-1A9B-402B-B26C-47C44E8E9F73@gmail.com> Le mer. 5 janv. 2022 à 08:50, Marvin Scholz <epirat07@gmail.com> a écrit : > > On 31 Dec 2021, at 18:43, Romain Beauxis wrote: > > > * Use a CMSimpleQueueEnqueue with maximum length to queue and process > > incoming audio and video frames. > > * Log avfoundation errors. > > * Use AVERROR_EXTERNAL instead of AVERROR(EIO) in avfoundation errors. > > > > Signed-off-by: Romain Beauxis <toots@rastageeks.org> > > — > > [Sorry for the noise but an issue came up with the previous set] > > > > This is the second patch of a series of 3 that fix, cleanup and > > enhance the > > avfoundation implementation for libavdevice. > > > > These patches come from an actual user-facing application relying on > > libavdevice’s implementation of avfoundation audio input. Without > > them, > > Avfoundation is practically unusable as it will: > > * Refuse to process certain specific audio input format that are > > actually > > returned by the OS for some users (packed PCM audio) > > * Drop audio frames, resulting in corrupted audio input. This might > > have been > > unnoticed with video frames but this makes avfoundation essentially > > unusable > > for audio. > > > > The patches are now being included in our production build so they are > > tested > > and usable in production. > > > > Changelog for this patch: > > * v2: None > > * v3: None > > * v4: None > > * v5: Fix indentation/wrapping > > * v6: None > > * v7: Removed use of kAudioConverterPropertyCalculateOutputBufferSize > > to calculate output buffer size. The calculation is trivial and this > > call was > > randomly failing for no reason > > * v8: Fix memory leak when video or audio queue is full > > > > libavdevice/avfoundation.m | 194 +++++++++++++++++++------------------ > > 1 file changed, 100 insertions(+), 94 deletions(-) > > > > diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m > > index 738cd93375..36f9fdc53d 100644 > > --- a/libavdevice/avfoundation.m > > +++ b/libavdevice/avfoundation.m > > @@ -26,7 +26,7 @@ > > */ > > > > #import <AVFoundation/AVFoundation.h> > > -#include <pthread.h> > > +#import <CoreMedia/CoreMedia.h> > > > > #include "libavutil/channel_layout.h" > > #include "libavutil/pixdesc.h" > > @@ -39,6 +39,11 @@ > > #include "libavutil/imgutils.h" > > #include "avdevice.h" > > > > +#define av_log_avfoundation_error(s, str, err) \ > > + av_log(s, AV_LOG_ERROR, "Avfoundation: %s, %s\n", str, \ > > nitpick: should probably be AVFoundation, no? Done! > > + [[[NSError errorWithDomain:NSOSStatusErrorDomain code:err > > userInfo:nil] localizedDescription] UTF8String] \ > > + ) > > + > > The errorWithDomain: returns an autorelease NSError, however there is no > autorelease pool. > Either make this a function with an @autorelease pool or use [[… > alloc] init…] instead, and > release the NSError. That's right, thanks for pointing that out. Just sent a v9 version of the patchset fixing that and also dropping the log level for the error returned when the queue is full. In practice, the queue can become full pretty often, for instance when waiting on a remote output connection so these logs end up polluting the output in situations that are not really problematic. Thanks for looking into this! -- Romain _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2022-01-06 14:44 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-31 17:43 Romain Beauxis 2022-01-05 14:50 ` Marvin Scholz 2022-01-06 14:43 ` Romain Beauxis [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CABWZ6ORAPKrJvjmaDGv60RbV0ZsknzrZqxKB+MvwmFhxUNYp-A@mail.gmail.com \ --to=toots@rastageeks.org \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=ffmpeg@tmm1.net \ --cc=thilo.borgmann@mail.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git