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
ce085084
Commit
ce085084
authored
Feb 27, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WASAPI: Fix some errors with automatic stream routing.
parent
957de48d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
mini_al.h
mini_al.h
+25
-11
tests/mal_duplex.c
tests/mal_duplex.c
+2
-1
No files found.
mini_al.h
View file @
ce085084
...
@@ -6424,8 +6424,8 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_I
...
@@ -6424,8 +6424,8 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_I
}
}
// We only care about devices with the same data flow and role as the current device.
// We only care about devices with the same data flow and role as the current device.
if (
((pThis->pDevice->type == mal_device_type_playback || pThis->pDevice->type == mal_device_type_duplex) && dataFlow != mal_eRender )
||
if (
pThis->pDevice->type == mal_device_type_playback && dataFlow != mal_eRender
||
((pThis->pDevice->type == mal_device_type_capture || pThis->pDevice->type == mal_device_type_duplex) && dataFlow != mal_eCapture)
) {
pThis->pDevice->type == mal_device_type_capture && dataFlow != mal_eCapture
) {
return S_OK;
return S_OK;
}
}
...
@@ -6446,10 +6446,6 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_I
...
@@ -6446,10 +6446,6 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_I
mal_atomic_exchange_32(&pThis->pDevice->wasapi.hasDefaultCaptureDeviceChanged, MAL_TRUE);
mal_atomic_exchange_32(&pThis->pDevice->wasapi.hasDefaultCaptureDeviceChanged, MAL_TRUE);
}
}
#if 0
SetEvent(pThis->pDevice->wasapi.hBreakEvent); // <-- The main loop will be waiting on some events. We want to break from this wait ASAP so we can change the device as quickly as possible.
#endif
(void)pDefaultDeviceID;
(void)pDefaultDeviceID;
return S_OK;
return S_OK;
}
}
...
@@ -7391,6 +7387,14 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device
...
@@ -7391,6 +7387,14 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device
pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
mal_IAudioClient_GetBufferSize((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualBufferSizeInFramesCapture);
mal_IAudioClient_GetBufferSize((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualBufferSizeInFramesCapture);
/* The device may be in a started state. If so we need to immediately restart it. */
if (pDevice->wasapi.isStarted) {
HRESULT hr = mal_IAudioClient_Start((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
if (FAILED(hr)) {
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device after reinitialization.", MAL_FAILED_TO_START_BACKEND_DEVICE);
}
}
}
}
if (deviceType == mal_device_type_playback) {
if (deviceType == mal_device_type_playback) {
...
@@ -7419,9 +7423,15 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device
...
@@ -7419,9 +7423,15 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device
pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
mal_IAudioClient_GetBufferSize((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualBufferSizeInFramesPlayback);
mal_IAudioClient_GetBufferSize((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualBufferSizeInFramesPlayback);
}
mal_atomic_exchange_32(&pDevice->wasapi.isStarted, MAL_FALSE);
/* The device may be in a started state. If so we need to immediately restart it. */
if (pDevice->wasapi.isStarted) {
HRESULT hr = mal_IAudioClient_Start((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
if (FAILED(hr)) {
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device after reinitialization.", MAL_FAILED_TO_START_BACKEND_DEVICE);
}
}
}
return MAL_SUCCESS;
return MAL_SUCCESS;
}
}
...
@@ -7844,8 +7854,8 @@ mal_result mal_device_write__wasapi(mal_device* pDevice, const void* pPCMFrames,
...
@@ -7844,8 +7854,8 @@ mal_result mal_device_write__wasapi(mal_device* pDevice, const void* pPCMFrames,
}
}
/* We may need to reroute the device. */
/* We may need to reroute the device. */
if (mal_device_is_reroute_required__wasapi(pDevice, mal_device_type_
capture
)) {
if (mal_device_is_reroute_required__wasapi(pDevice, mal_device_type_
playback
)) {
result = mal_device_reroute__wasapi(pDevice, mal_device_type_
capture
);
result = mal_device_reroute__wasapi(pDevice, mal_device_type_
playback
);
if (result != MAL_SUCCESS) {
if (result != MAL_SUCCESS) {
break;
break;
}
}
...
@@ -21761,7 +21771,11 @@ void mal_device__post_init_setup(mal_device* pDevice, mal_device_type deviceType
...
@@ -21761,7 +21771,11 @@ void mal_device__post_init_setup(mal_device* pDevice, mal_device_type deviceType
converterConfig.sampleRateOut = pDevice->playback.internalSampleRate;
converterConfig.sampleRateOut = pDevice->playback.internalSampleRate;
mal_channel_map_copy(converterConfig.channelMapOut, pDevice->playback.internalChannelMap, pDevice->playback.internalChannels);
mal_channel_map_copy(converterConfig.channelMapOut, pDevice->playback.internalChannelMap, pDevice->playback.internalChannels);
if (deviceType == mal_device_type_playback) {
if (deviceType == mal_device_type_playback) {
converterConfig.onRead = mal_device__on_read_from_client;
if (pDevice->type == mal_device_type_playback) {
converterConfig.onRead = mal_device__on_read_from_client;
} else {
converterConfig.onRead = mal_device__pcm_converter__on_read_from_buffer_playback;
}
} else {
} else {
converterConfig.onRead = mal_device__pcm_converter__on_read_from_buffer_playback;
converterConfig.onRead = mal_device__pcm_converter__on_read_from_buffer_playback;
}
}
tests/mal_duplex.c
View file @
ce085084
#include <stdio.h>
#include <stdio.h>
#define MAL_DEBUG_OUTPUT
#define MINI_AL_IMPLEMENTATION
#define MINI_AL_IMPLEMENTATION
#include "../mini_al.h"
#include "../mini_al.h"
...
@@ -60,7 +61,7 @@ int main(int argc, char** argv)
...
@@ -60,7 +61,7 @@ int main(int argc, char** argv)
#endif
#endif
mal_backend
backend
=
mal_backend_
dsound
;
mal_backend
backend
=
mal_backend_
wasapi
;
mal_context_config
contextConfig
=
mal_context_config_init
();
mal_context_config
contextConfig
=
mal_context_config_init
();
contextConfig
.
logCallback
=
log_callback
;
contextConfig
.
logCallback
=
log_callback
;
...
...
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