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
efe9d9e0
Commit
efe9d9e0
authored
Jul 11, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small improvements to Core Audio.
parent
37d6bb6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
mini_al.h
mini_al.h
+10
-12
No files found.
mini_al.h
View file @
efe9d9e0
...
@@ -4263,7 +4263,7 @@ static MAL_INLINE void mal_device__send_frames_to_client(mal_device* pDevice, ma
...
@@ -4263,7 +4263,7 @@ static MAL_INLINE void mal_device__send_frames_to_client(mal_device* pDevice, ma
pDevice->_dspFrames = (const mal_uint8*)pSamples;
pDevice->_dspFrames = (const mal_uint8*)pSamples;
mal_uint8 chunkBuffer[4096];
mal_uint8 chunkBuffer[4096];
mal_uint32 chunkFrameCount = sizeof(chunkBuffer) / mal_get_bytes_per_
sample(pDevice->format) / pDevice->channels
;
mal_uint32 chunkFrameCount = sizeof(chunkBuffer) / mal_get_bytes_per_
frame(pDevice->format, pDevice->channels)
;
for (;;) {
for (;;) {
mal_uint32 framesJustRead = (mal_uint32)mal_dsp_read(&pDevice->dsp, chunkFrameCount, chunkBuffer, pDevice->dsp.pUserData);
mal_uint32 framesJustRead = (mal_uint32)mal_dsp_read(&pDevice->dsp, chunkFrameCount, chunkBuffer, pDevice->dsp.pUserData);
...
@@ -13395,14 +13395,13 @@ mal_result mal_set_AudioObject_buffer_size_in_frames(mal_context* pContext, Audi
...
@@ -13395,14 +13395,13 @@ mal_result mal_set_AudioObject_buffer_size_in_frames(mal_context* pContext, Audi
propAddress.mScope = (deviceType == mal_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
propAddress.mScope = (deviceType == mal_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
propAddress.mElement = kAudioObjectPropertyElementMaster;
propAddress.mElement = kAudioObjectPropertyElementMaster;
OSStatus status = ((mal_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames);
((mal_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames);
// Get the actual size of the buffer.
UInt32 dataSize = sizeof(*pBufferSizeInOut);
OSStatus status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &chosenBufferSizeInFrames);
if (status != noErr) {
if (status != noErr) {
// Getting here means we were unable to set the buffer size. In this case just use whatever is currently selected.
return mal_result_from_OSStatus(status);
UInt32 dataSize = sizeof(*pBufferSizeInOut);
OSStatus status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pBufferSizeInOut);
if (status != noErr) {
return mal_result_from_OSStatus(status);
}
}
}
*pBufferSizeInOut = chosenBufferSizeInFrames;
*pBufferSizeInOut = chosenBufferSizeInFrames;
...
@@ -13903,7 +13902,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext)
...
@@ -13903,7 +13902,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext)
// It looks like Apple has moved some APIs from AudioUnit into AudioToolbox on more recent versions of macOS. They are still
// It looks like Apple has moved some APIs from AudioUnit into AudioToolbox on more recent versions of macOS. They are still
// defined in AudioUnit, but just in case they decide
d to remove them from there entirely I'm going to d
o implement a fallback.
// defined in AudioUnit, but just in case they decide
to remove them from there entirely I'm going t
o implement a fallback.
// The way it'll work is that it'll first try AudioUnit, and if the required symbols are not present there we'll fall back to
// The way it'll work is that it'll first try AudioUnit, and if the required symbols are not present there we'll fall back to
// AudioToolbox.
// AudioToolbox.
pContext->coreaudio.hAudioUnit = mal_dlopen("AudioUnit.framework/AudioUnit");
pContext->coreaudio.hAudioUnit = mal_dlopen("AudioUnit.framework/AudioUnit");
...
@@ -14213,7 +14212,6 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, mal_device_type dev
...
@@ -14213,7 +14212,6 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, mal_device_type dev
}
}
bestFormat.mSampleRate = origFormat.mSampleRate;
bestFormat.mSampleRate = origFormat.mSampleRate;
//bestFormat = origFormat;
status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)((AudioUnit)pDevice->coreaudio.audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat));
status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)((AudioUnit)pDevice->coreaudio.audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat));
if (status != noErr) {
if (status != noErr) {
...
@@ -14305,7 +14303,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, mal_device_type dev
...
@@ -14305,7 +14303,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, mal_device_type dev
}
}
}
}
actualBufferSizeInFrames =
mal_next_power_of_2(actualBufferSizeInFrames / pDevice->periods)
;
actualBufferSizeInFrames =
actualBufferSizeInFrames / pDevice->periods
;
result = mal_set_AudioObject_buffer_size_in_frames(pContext, deviceObjectID, deviceType, &actualBufferSizeInFrames);
result = mal_set_AudioObject_buffer_size_in_frames(pContext, deviceObjectID, deviceType, &actualBufferSizeInFrames);
if (result != MAL_SUCCESS) {
if (result != MAL_SUCCESS) {
return result;
return result;
...
@@ -23566,7 +23564,7 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount
...
@@ -23566,7 +23564,7 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount
if (framesReadFromClient != 0) {
if (framesReadFromClient != 0) {
pSRC->sinc.inputFrameCount += framesReadFromClient;
pSRC->sinc.inputFrameCount += framesReadFromClient;
} else {
} else {
// We couldn't get anything more from the client. If no
t
more output samples can be computed from the available input samples
// We couldn't get anything more from the client. If no more output samples can be computed from the available input samples
// we need to return.
// we need to return.
if (((pSRC->sinc.timeIn - pSRC->sinc.inputFrameCount) * inverseFactor) < 1) {
if (((pSRC->sinc.timeIn - pSRC->sinc.inputFrameCount) * inverseFactor) < 1) {
break;
break;
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