Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
fa73b3f0
Commit
fa73b3f0
authored
Jun 30, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Core Audio: Tweaks to the run loop logic.
parent
ee3848a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
mini_al.h
mini_al.h
+17
-3
No files found.
mini_al.h
View file @
fa73b3f0
...
...
@@ -13584,6 +13584,18 @@ mal_thread_result MAL_THREADCALL mal_AudioQueue_worker_thread__coreaudio(void* p
return (mal_thread_result)(size_t)pThreadData->initResult;
}
// In our loop below we use CFRunLoopRunInMode() so we can use a timeout (CFRunLoopRun() does not allow a timeout for some reason). The
// problem with this is that is requires a mode (kCFRunLoopDefaultMode or kCFRunLoopCommonModes) which is actually dynamically linked.
// This creates a problem for mini_al because we prefer to do run-time linking which would not be possible if we depended on
// kCFRunLoopDefaultMode, etc. Therefore we do something sneaky - we get the run loop modes for our run loop using CFRunLoopCopyAllModes
// which will give us a value we need.
CFArrayRef runLoopModes = CFRunLoopCopyAllModes((CFRunLoopRef)pDevice->coreaudio.runLoop);
if (CFArrayGetCount(runLoopModes) == 0) {
pThreadData->initResult = MAL_ERROR;
mal_event_signal(&pThreadData->initCompletionEvent);
return (mal_thread_result)(size_t)pThreadData->initResult;
}
OSStatus status;
if (pDevice->type == mal_device_type_playback) {
status = AudioQueueNewOutput(&streamFormat, mal_on_output__core_audio, pDevice, (CFRunLoopRef)pDevice->coreaudio.runLoop, NULL, 0, (AudioQueueRef*)&pDevice->coreaudio.audioQueue);
...
...
@@ -13694,12 +13706,13 @@ mal_thread_result MAL_THREADCALL mal_AudioQueue_worker_thread__coreaudio(void* p
// Just keep running the running loop indefinitely. We'll wake it up when we need to.
for (;;) {
// Getting here means the loop has timed out or was woken up. This gives us a chace to stop the device is requested.
if (mal_device__get_state(pDevice) != MAL_STATE_STARTED) {
goto stop_device_and_continue;
}
CFRunLoopRun();
// Just use the first reported mode. Using CFRunLoopRunInMode so we can specify a timeout for safety against an infinite loop.
CFTimeInterval timeout = 1.0f;
CFRunLoopRunInMode(CFArrayGetValueAtIndex(runLoopModes, 0), timeout, MAL_FALSE);
}
...
...
@@ -13731,6 +13744,7 @@ mal_thread_result MAL_THREADCALL mal_AudioQueue_worker_thread__coreaudio(void* p
}
// We'll get here when the device is uninitialized.
CFRelease(runLoopModes);
AudioQueueDispose((AudioQueueRef)pDevice->coreaudio.audioQueue, MAL_TRUE);
return 0;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment