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
c56205ff
Commit
c56205ff
authored
Mar 03, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WASAPI: Fix some errors when stopping the device.
parent
c95afa6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
mini_al.h
mini_al.h
+34
-4
No files found.
mini_al.h
View file @
c56205ff
...
@@ -8197,6 +8197,13 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice)
...
@@ -8197,6 +8197,13 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice)
break;
break;
}
}
/* TODO: How do we handle the capture flags returned by GetBuffer()? In particular, AUDCLNT_BUFFERFLAGS_SILENT (1). */
#ifdef MAL_DEBUG_OUTPUT
if (flagsCapture != 0) {
printf("[WASAPI] Capture Flags: %d\n", flagsCapture);
}
#endif
mappedBufferFramesRemainingCapture = mappedBufferSizeInFramesCapture;
mappedBufferFramesRemainingCapture = mappedBufferSizeInFramesCapture;
pDevice->capture._dspFrameCount = mappedBufferSizeInFramesCapture;
pDevice->capture._dspFrameCount = mappedBufferSizeInFramesCapture;
...
@@ -8380,6 +8387,11 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice)
...
@@ -8380,6 +8387,11 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice)
/* Here is where the device needs to be stopped. */
/* Here is where the device needs to be stopped. */
if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) {
if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) {
/* Any mapped buffers need to be released. */
if (pMappedBufferCapture != NULL) {
hr = mal_IAudioCaptureClient_ReleaseBuffer((mal_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedBufferSizeInFramesCapture);
}
hr = mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
hr = mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
if (FAILED(hr)) {
if (FAILED(hr)) {
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE);
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE);
...
@@ -8388,16 +8400,34 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice)
...
@@ -8388,16 +8400,34 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice)
/* The audio client needs to be reset otherwise restarting will fail. */
/* The audio client needs to be reset otherwise restarting will fail. */
hr = mal_IAudioClient_Reset((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
hr = mal_IAudioClient_Reset((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
if (FAILED(hr)) {
if (FAILED(hr)) {
#ifdef MAL_DEBUG_OUTPUT
printf("IAudioClient_Reset (Capture) Returned %d\n", (int)hr);
#endif
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE);
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE);
}
}
}
}
if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) {
if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) {
/* Any mapped buffers need to be released. */
if (pMappedBufferPlayback != NULL) {
hr = mal_IAudioRenderClient_ReleaseBuffer((mal_IAudioRenderClient*)pDevice->wasapi.pRenderClient, mappedBufferSizeInFramesPlayback, 0);
}
if (isPlaybackDeviceStarted) {
if (isPlaybackDeviceStarted) {
/* TODO: Drain the playback device.*/
if (pDevice->playback.shareMode == mal_share_mode_exclusive) {
WaitForSingleObject(pDevice->wasapi.hEventPlayback, INFINITE);
} else {
for (;;) {
mal_uint32 framesAvailablePlayback;
result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
if (result != MAL_SUCCESS) {
break;
}
if (framesAvailablePlayback >= pDevice->playback.internalBufferSizeInFrames) {
break;
}
WaitForSingleObject(pDevice->wasapi.hEventPlayback, INFINITE);
}
}
}
}
hr = mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
hr = mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
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