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
ee2e7694
Commit
ee2e7694
authored
Jan 26, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WASAPI: Another attempt at fixing exclusive mode.
Public issue
https://github.com/mackron/miniaudio/issues/265
parent
47dccc52
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
9 deletions
+29
-9
miniaudio.h
miniaudio.h
+29
-9
No files found.
miniaudio.h
View file @
ee2e7694
...
@@ -15074,21 +15074,41 @@ static ma_result ma_device__get_available_frames__wasapi(ma_device* pDevice, ma_
...
@@ -15074,21 +15074,41 @@ static ma_result ma_device__get_available_frames__wasapi(ma_device* pDevice, ma_
return MA_INVALID_OPERATION;
return MA_INVALID_OPERATION;
}
}
/*
I've had a report that GetCurrentPadding() is returning a frame count of 0 which is preventing
higher level function calls from doing anything because it thinks nothing is available. I have
taken a look at the documentation and it looks like this is unnecessary in exclusive mode.
From Microsoft's documentation:
For an exclusive-mode rendering or capture stream that was initialized with the
AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag, the client typically has no use for the padding
value reported by GetCurrentPadding. Instead, the client accesses an entire buffer during
each processing pass.
Considering this, I'm going to skip GetCurrentPadding() for exclusive mode and just report the
entire buffer. This depends on the caller making sure they wait on the event handler.
*/
shareMode = ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) ? pDevice->playback.shareMode : pDevice->capture.shareMode;
if (shareMode == ma_share_mode_shared) {
/* Shared mode. */
hr = ma_IAudioClient_GetCurrentPadding(pAudioClient, &paddingFramesCount);
hr = ma_IAudioClient_GetCurrentPadding(pAudioClient, &paddingFramesCount);
if (FAILED(hr)) {
if (FAILED(hr)) {
return ma_result_from_HRESULT(hr);
return ma_result_from_HRESULT(hr);
}
}
/* Slightly different rules for exclusive and shared modes. */
shareMode = ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) ? pDevice->playback.shareMode : pDevice->capture.shareMode;
if (shareMode == ma_share_mode_exclusive) {
*pFrameCount = paddingFramesCount;
} else {
if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
*pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback - paddingFramesCount;
*pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback - paddingFramesCount;
} else {
} else {
*pFrameCount = paddingFramesCount;
*pFrameCount = paddingFramesCount;
}
}
} else {
/* Exclusive mode. */
if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
*pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback;
} else {
*pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesCapture;
}
}
}
return MA_SUCCESS;
return MA_SUCCESS;
...
@@ -25637,7 +25657,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
...
@@ -25637,7 +25657,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
while (framesRemaining > 0) {
while (framesRemaining > 0) {
void* ppDeinterleavedBuffers[MA_MAX_CHANNELS];
void* ppDeinterleavedBuffers[MA_MAX_CHANNELS];
ma_uint32 iChannel;
ma_uint32 iChannel;
ma_uint32 framesToSend = sizeof(tempBuffer) / ma_get_bytes_per_
sample(pDevice->capture.internalFormat
);
ma_uint32 framesToSend = sizeof(tempBuffer) / ma_get_bytes_per_
frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels
);
if (framesToSend > framesRemaining) {
if (framesToSend > framesRemaining) {
framesToSend = framesRemaining;
framesToSend = framesRemaining;
}
}
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