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
e15fd218
Commit
e15fd218
authored
Feb 02, 2025
by
Andrew Opalach
Committed by
David Reid
Feb 17, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WASAPI: Fix drain on device stop
parent
4c7021e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
miniaudio.h
miniaudio.h
+6
-7
No files found.
miniaudio.h
View file @
e15fd218
...
...
@@ -23157,13 +23157,12 @@ static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice)
*/
if (ma_atomic_bool32_get(&pDevice->wasapi.isStartedPlayback)) {
/* We need to make sure we put a timeout here or else we'll risk getting stuck in a deadlock in some cases. */
DWORD waitTime = pDevice->wasapi.actualBufferSizeInFramesPlayback /
pDevice->playback.internalSampleRate
;
DWORD waitTime = pDevice->wasapi.actualBufferSizeInFramesPlayback /
(pDevice->playback.internalSampleRate / 1000)
;
if (pDevice->playback.shareMode == ma_share_mode_exclusive) {
WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime);
}
else {
ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
} else {
ma_uint32 prevFramesAvailablePlayback = (ma_uint32)-1;
ma_uint32 framesAvailablePlayback;
for (;;) {
result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
...
...
@@ -23179,13 +23178,13 @@ static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice)
Just a safety check to avoid an infinite loop. If this iteration results in a situation where the number of available frames
has not changed, get out of the loop. I don't think this should ever happen, but I think it's nice to have just in case.
*/
if (framesAvailablePlayback == prevFramesAvai
a
lablePlayback) {
if (framesAvailablePlayback == prevFramesAvailablePlayback) {
break;
}
prevFramesAvai
a
lablePlayback = framesAvailablePlayback;
prevFramesAvailablePlayback = framesAvailablePlayback;
WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime * 1000);
ResetEvent((HANDLE)pDevice->wasapi.hEventPlayback); /* Manual reset. */
WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime);
}
}
}
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