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
afc0fc10
Commit
afc0fc10
authored
Dec 29, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iOS: Initial work on interruption detection.
parent
d077e92f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
36 deletions
+42
-36
miniaudio.h
miniaudio.h
+42
-36
No files found.
miniaudio.h
View file @
afc0fc10
...
...
@@ -5781,19 +5781,19 @@ typedef struct
{
struct
{
int _
_
unused;
int _unused;
} started;
struct
{
int _
_
unused;
int _unused;
} stopped;
struct
{
int _
_
unused;
int _unused;
} rerouted;
struct
{
int _
_
unused;
int _unused;
} interruption;
} data;
} ma_device_notification;
...
...
@@ -6906,7 +6906,7 @@ struct ma_device
ma_bool32 isDefaultCaptureDevice;
ma_bool32 isSwitchingPlaybackDevice; /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
ma_bool32 isSwitchingCaptureDevice; /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
void* p
RouteChange
Handler; /* Only used on mobile platforms. Obj-C object for handling route changes. */
void* p
Notification
Handler; /* Only used on mobile platforms. Obj-C object for handling route changes. */
} coreaudio;
#endif
#ifdef MA_SUPPORT_SNDIO
...
...
@@ -30922,7 +30922,7 @@ static ma_result ma_device_realloc_AudioBufferList__coreaudio(ma_device* pDevice
AudioBufferList* pNewAudioBufferList;
pNewAudioBufferList = ma_allocate_AudioBufferList__coreaudio(sizeInFrames, format, channels, layout, &pDevice->pContext->allocationCallbacks);
if (pNewAudioBufferList
!
= NULL) {
if (pNewAudioBufferList
=
= NULL) {
return MA_OUT_OF_MEMORY;
}
...
...
@@ -31053,6 +31053,9 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
return noErr;
}
pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList;
MA_ASSERT(pRenderedBufferList);
/*
When you call AudioUnitRender(), Core Audio tries to be helpful by setting the mDataByteSize to the number of bytes
that were actually rendered. The problem with this is that the next call can fail with -50 due to the size no longer
...
...
@@ -31424,19 +31427,23 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
#endif
#if defined(MA_APPLE_MOBILE)
@interface ma_
router_change
_handler:NSObject {
@interface ma_
ios_notification
_handler:NSObject {
ma_device* m_pDevice;
}
@end
@implementation ma_
router_change
_handler
@implementation ma_
ios_notification
_handler
-(id)init:(ma_device*)pDevice
{
self = [super init];
m_pDevice = pDevice;
/* For route changes. */
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_route_change:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
/* For interruptions. */
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_interruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
return self;
}
...
...
@@ -31448,6 +31455,26 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
-(void)remove_handler
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionRouteChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionInterruptionNotification object:nil];
}
-(void)handle_interruption:(NSNotification*)pNotification
{
NSInteger type = [[[pNotification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] integerValue];
switch (type)
{
case AVAudioSessionInterruptionTypeBegan:
{
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Interruption: AVAudioSessionInterruptionTypeBegan\n");
ma_device__on_notification_interruption_began(m_pDevice);
} break;
case AVAudioSessionInterruptionTypeEnded:
{
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Interruption: AVAudioSessionInterruptionTypeEnded\n");
ma_device__on_notification_interruption_ended(m_pDevice);
} break;
}
}
-(void)handle_route_change:(NSNotification*)pNotification
...
...
@@ -31496,29 +31523,8 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Changing Route. inputNumberChannels=%d; outputNumberOfChannels=%d\n", (int)pSession.inputNumberOfChannels, (int)pSession.outputNumberOfChannels);
/* Temporarily disabling this section of code because it appears to be causing errors. */
#if 0
ma_uint32 previousState = ma_device_get_state(m_pDevice);
if (previousState == ma_device_state_started) {
ma_device_stop(m_pDevice);
}
if (m_pDevice->type == ma_device_type_capture || m_pDevice->type == ma_device_type_duplex) {
m_pDevice->capture.internalChannels = (ma_uint32)pSession.inputNumberOfChannels;
m_pDevice->capture.internalSampleRate = (ma_uint32)pSession.sampleRate;
ma_device__post_init_setup(m_pDevice, ma_device_type_capture);
}
if (m_pDevice->type == ma_device_type_playback || m_pDevice->type == ma_device_type_duplex) {
m_pDevice->playback.internalChannels = (ma_uint32)pSession.outputNumberOfChannels;
m_pDevice->playback.internalSampleRate = (ma_uint32)pSession.sampleRate;
ma_device__post_init_setup(m_pDevice, ma_device_type_playback);
}
if (previousState == ma_device_state_started) {
ma_device_start(m_pDevice);
}
#endif
/* Let the application know about the route change. */
ma_device__on_notification_rerouted(m_pDevice);
}
@end
#endif
...
...
@@ -31536,9 +31542,9 @@ static ma_result ma_device_uninit__coreaudio(ma_device* pDevice)
ma_device__untrack__coreaudio(pDevice);
#endif
#if defined(MA_APPLE_MOBILE)
if (pDevice->coreaudio.p
RouteChange
Handler != NULL) {
ma_
router_change_handler* pRouteChangeHandler = (MA_BRIDGE_TRANSFER ma_router_change_handler*)pDevice->coreaudio.pRouteChange
Handler;
[p
RouteChange
Handler remove_handler];
if (pDevice->coreaudio.p
Notification
Handler != NULL) {
ma_
ios_notification_handler* pNotificationHandler = (MA_BRIDGE_TRANSFER ma_ios_notification_handler*)pDevice->coreaudio.pNotification
Handler;
[p
Notification
Handler remove_handler];
}
#endif
...
...
@@ -32212,7 +32218,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c
differently on non-Desktop Apple platforms.
*/
#if defined(MA_APPLE_MOBILE)
pDevice->coreaudio.p
RouteChangeHandler = (MA_BRIDGE_RETAINED void*)[[ma_router_change
_handler alloc] init:pDevice];
pDevice->coreaudio.p
NotificationHandler = (MA_BRIDGE_RETAINED void*)[[ma_ios_notification
_handler alloc] init:pDevice];
#endif
return MA_SUCCESS;
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