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
3d4ab9d9
Commit
3d4ab9d9
authored
Aug 20, 2022
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iOS: Try to improve the default session category.
parent
334ed4fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
miniaudio.h
miniaudio.h
+28
-3
No files found.
miniaudio.h
View file @
3d4ab9d9
...
...
@@ -6460,7 +6460,7 @@ typedef enum
/* iOS/tvOS/watchOS session categories. */
typedef enum
{
ma_ios_session_category_default = 0, /* AVAudioSessionCategoryPlayAndRecord
with AVAudioSessionCategoryOptionDefaultToSpeaker
. */
ma_ios_session_category_default = 0, /* AVAudioSessionCategoryPlayAndRecord. */
ma_ios_session_category_none, /* Leave the session category unchanged. */
ma_ios_session_category_ambient, /* AVAudioSessionCategoryAmbient */
ma_ios_session_category_solo_ambient, /* AVAudioSessionCategorySoloAmbient */
...
...
@@ -33506,11 +33506,9 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte
I'm going to use trial and error to determine our default session category. First we'll try PlayAndRecord. If that fails
we'll try Playback and if that fails we'll try record. If all of these fail we'll just not set the category.
*/
#if 0
#if !defined(MA_APPLE_TV) && !defined(MA_APPLE_WATCH)
options |= AVAudioSessionCategoryOptionDefaultToSpeaker;
#endif
#endif
if ([pAudioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:options error:nil]) {
/* Using PlayAndRecord */
...
...
@@ -40412,6 +40410,33 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen
result = MA_NO_BACKEND;
for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
/*
This is a hack for iOS. If the context config is null, there's a good chance the
`ma_device_init(NULL, &deviceConfig, pDevice);` pattern is being used. In this
case, set the session category based on the device type.
*/
#if defined(MA_APPLE_MOBILE)
ma_context_config contextConfig;
if (pContextConfig == NULL) {
contextConfig = ma_context_config_init();
switch (pConfig->deviceType) {
case ma_device_type_duplex: {
contextConfig.coreaudio.sessionCategory = ma_ios_session_category_play_and_record;
} break;
case ma_device_type_capture: {
contextConfig.coreaudio.sessionCategory = ma_ios_session_category_record;
} break;
case ma_device_type_playback:
default: {
contextConfig.coreaudio.sessionCategory = ma_ios_session_category_playback;
} break;
}
pContextConfig = &contextConfig;
}
#endif
result = ma_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext);
if (result == MA_SUCCESS) {
result = ma_device_init(pContext, pConfig, pDevice);
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