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
39edf6d8
Commit
39edf6d8
authored
Sep 28, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Core Audio: Fix some issues with full duplex.
parent
1860292d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
miniaudio.h
miniaudio.h
+24
-2
No files found.
miniaudio.h
View file @
39edf6d8
...
@@ -19311,8 +19311,8 @@ ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_device_typ
...
@@ -19311,8 +19311,8 @@ ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_device_typ
/* Core audio doesn't really use the notion of a period so we can leave this unmodified, but not too over the top. */
/* Core audio doesn't really use the notion of a period so we can leave this unmodified, but not too over the top. */
pData->periodsOut = pData->periodsIn;
pData->periodsOut = pData->periodsIn;
if (pData->periodsOut
< 1
) {
if (pData->periodsOut
== 0
) {
pData->periodsOut =
1
;
pData->periodsOut =
MA_DEFAULT_PERIODS
;
}
}
if (pData->periodsOut > 16) {
if (pData->periodsOut > 16) {
pData->periodsOut = 16;
pData->periodsOut = 16;
...
@@ -19659,6 +19659,11 @@ ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_typ
...
@@ -19659,6 +19659,11 @@ ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_typ
data.bufferSizeInMillisecondsIn = pDevice->coreaudio.originalBufferSizeInMilliseconds;
data.bufferSizeInMillisecondsIn = pDevice->coreaudio.originalBufferSizeInMilliseconds;
data.periodsIn = pDevice->coreaudio.originalPeriods;
data.periodsIn = pDevice->coreaudio.originalPeriods;
/* Need at least 3 periods for duplex. */
if (data.periodsIn < 3 && pDevice->type == ma_device_type_duplex) {
data.periodsIn = 3;
}
result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice);
result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice);
if (result != MA_SUCCESS) {
if (result != MA_SUCCESS) {
return result;
return result;
...
@@ -19727,7 +19732,13 @@ ma_result ma_device_init__coreaudio(ma_context* pContext, const ma_device_config
...
@@ -19727,7 +19732,13 @@ ma_result ma_device_init__coreaudio(ma_context* pContext, const ma_device_config
data.shareMode = pConfig->capture.shareMode;
data.shareMode = pConfig->capture.shareMode;
data.bufferSizeInFramesIn = pConfig->bufferSizeInFrames;
data.bufferSizeInFramesIn = pConfig->bufferSizeInFrames;
data.bufferSizeInMillisecondsIn = pConfig->bufferSizeInMilliseconds;
data.bufferSizeInMillisecondsIn = pConfig->bufferSizeInMilliseconds;
data.periodsIn = pConfig->periods;
data.registerStopEvent = MA_TRUE;
data.registerStopEvent = MA_TRUE;
/* Need at least 3 periods for duplex. */
if (data.periodsIn < 3 && pConfig->deviceType == ma_device_type_duplex) {
data.periodsIn = 3;
}
result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_capture, pConfig->capture.pDeviceID, &data, (void*)pDevice);
result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_capture, pConfig->capture.pDeviceID, &data, (void*)pDevice);
if (result != MA_SUCCESS) {
if (result != MA_SUCCESS) {
...
@@ -19836,6 +19847,17 @@ ma_result ma_device_init__coreaudio(ma_context* pContext, const ma_device_config
...
@@ -19836,6 +19847,17 @@ ma_result ma_device_init__coreaudio(ma_context* pContext, const ma_device_config
if (result != MA_SUCCESS) {
if (result != MA_SUCCESS) {
return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[Core Audio] Failed to initialize ring buffer.", result);
return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[Core Audio] Failed to initialize ring buffer.", result);
}
}
/* We need a period to act as a buffer for cases where the playback and capture device's end up desyncing. */
{
ma_uint32 bufferSizeInFrames = rbSizeInFrames / pDevice->capture.internalPeriods;
void* pBufferData;
ma_pcm_rb_acquire_write(&pDevice->coreaudio.duplexRB, &bufferSizeInFrames, &pBufferData);
{
ma_zero_memory(pBufferData, bufferSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels));
}
ma_pcm_rb_commit_write(&pDevice->coreaudio.duplexRB, bufferSizeInFrames, pBufferData);
}
}
}
return MA_SUCCESS;
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