[vlc-commits] [Git][videolan/vlc][master] 2 commits: avsb: move long operation to the open callback

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Aug 13 07:18:42 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
fcfa2b5d by Thomas Guillem at 2024-08-13T07:06:06+00:00
avsb: move long operation to the open callback

- - - - -
e04bdb36 by Thomas Guillem at 2024-08-13T07:06:06+00:00
avsb: move sync setup call

- - - - -


1 changed file:

- modules/audio_output/apple/avsamplebuffer.m


Changes:

=====================================
modules/audio_output/apple/avsamplebuffer.m
=====================================
@@ -98,6 +98,26 @@ API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILA
     _outChain = NULL;
     _outChainLast = &_outChain;
 
+    /* The first call to CMAudioFormatDescriptionCreate() might take some time
+     * (between 200 and 600ms) as it is initializing some static context/libs.
+     * Therefore, call it from the Open() callback with dummy params. Indeed,
+     * the playback is not yet started and a longer Open() call won't mess with
+     * playback timings. */
+    static const AudioStreamBasicDescription dummyDesc = {
+        .mSampleRate = 48000,
+        .mFormatID = kAudioFormatLinearPCM,
+        .mFormatFlags = kAudioFormatFlagsNativeFloatPacked,
+        .mChannelsPerFrame = 2,
+        .mFramesPerPacket = 1,
+        .mBitsPerChannel = 32,
+    };
+    CMAudioFormatDescriptionRef dummyFmtDesc;
+    OSStatus status =
+        CMAudioFormatDescriptionCreate(kCFAllocatorDefault, &dummyDesc, 0, nil,
+                                       0, nil, nil, &dummyFmtDesc);
+    if (status == noErr)
+        CFRelease(dummyFmtDesc);
+
     self = [super init];
     if (self == nil)
         return nil;
@@ -295,8 +315,6 @@ customBlock_Free(void *refcon, void *doomedMemoryBlock, size_t sizeInBytes)
         CMTime hostTime = CMTimeAdd(CMClockGetTime(CMClockGetHostTimeClock()),
                                     CMTimeMake(delta, CLOCK_FREQ));
         CMTime time = CMTimeMake(_ptsSamples, _sampleRate);
-
-        _sync.delaysRateChangeUntilHasSufficientMediaData = NO;
         [_sync setRate:1.0f time:time atHostTime:hostTime];
     }
 
@@ -445,6 +463,7 @@ customBlock_Free(void *refcon, void *doomedMemoryBlock, size_t sizeInBytes)
         goto error;
     }
 
+    _sync.delaysRateChangeUntilHasSufficientMediaData = NO;
     [_sync addRenderer:_renderer];
 
     _ptsSamples = -1;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9b737741e3afa3cd58e6804e7a33283839276fb8...e04bdb364062a46def18a7167d58e9baba0b5592

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9b737741e3afa3cd58e6804e7a33283839276fb8...e04bdb364062a46def18a7167d58e9baba0b5592
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list