Fix/macos - #5
Merged
Merged
Conversation
…and add unit tests - Introduced CoreAudioBufferPolicy to manage audio buffer count based on sample rate and buffer frames. - Updated SdlCoreAudioDriver to utilize CoreAudioBufferPolicy for calculating buffer count. - Enhanced SdlWasapiDriver to maintain consistent coding style and error handling. - Refactored SdlAudioDevice to support callback thread management. - Added AssemblyInfo.cs to expose internal members for testing. - Implemented unit tests for CoreAudioBufferPolicy to validate buffer count calculations.
…es in CoreAudio driver
| /// Reference: SDL_coreaudio.m AssignDeviceToAudioQueue -> kAudioQueueProperty_CurrentDevice. | ||
| /// </summary> | ||
| [DllImport(AudioToolboxLib, EntryPoint = "AudioQueueSetProperty")] | ||
| internal static extern int AudioQueueSetProperty( |
| /// Used for default device identifiers and boolean-style device flags. | ||
| /// </summary> | ||
| [DllImport(CoreAudioLib, EntryPoint = "AudioObjectGetPropertyData")] | ||
| internal static extern int AudioObjectGetPropertyData( |
| /// Used for hog-mode process identifiers. | ||
| /// </summary> | ||
| [DllImport(CoreAudioLib, EntryPoint = "AudioObjectGetPropertyData")] | ||
| internal static extern int AudioObjectGetPropertyData( |
| /// Used for CFStringRef device UID values. | ||
| /// </summary> | ||
| [DllImport(CoreAudioLib, EntryPoint = "AudioObjectGetPropertyData")] | ||
| internal static extern int AudioObjectGetPropertyData( |
| /// Releases a CoreFoundation object retained by a property query. | ||
| /// </summary> | ||
| [DllImport(CoreFoundationLib, EntryPoint = "CFRelease")] | ||
| internal static extern void CFRelease(IntPtr cf); |
| } | ||
|
|
||
| _currentBuffer = IntPtr.Zero; | ||
| CoreAudioNativeMethods.AudioQueueEnqueueBuffer(_audioQueue, currentBuffer, 0, IntPtr.Zero); |
Comment on lines
+414
to
+417
| CoreAudioNativeMethods.CFRunLoopRunInMode( | ||
| _defaultRunLoopMode, | ||
| seconds, | ||
| (byte)(returnAfterSourceHandled ? 1 : 0)); |
| // Set channel layout | ||
| if (!AssignDeviceToAudioQueue()) | ||
| { | ||
| CoreAudioNativeMethods.AudioQueueDispose(_audioQueue, 1); |
| if (result != CoreAudioConstants.NoErr) | ||
| { | ||
| _threadError = $"CoreAudio: AudioQueueSetProperty (kAudioQueueProperty_ChannelLayout) failed with error {result}"; | ||
| CoreAudioNativeMethods.AudioQueueDispose(_audioQueue, 1); |
| SilenceValue); | ||
| } | ||
|
|
||
| CoreAudioNativeMethods.AudioQueueEnqueueBuffer(inAudioQueue, currentBuffer, 0, IntPtr.Zero); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.