mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
ALSA: Fix a bug where a default device is not detected properly.
This commit is contained in:
+19
-4
@@ -28937,6 +28937,8 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu
|
|||||||
ma_device_id* pUniqueIDs = NULL;
|
ma_device_id* pUniqueIDs = NULL;
|
||||||
ma_uint32 uniqueIDCount = 0;
|
ma_uint32 uniqueIDCount = 0;
|
||||||
char** ppNextDeviceHint;
|
char** ppNextDeviceHint;
|
||||||
|
ma_bool32 hasEnumeratedDefaultPlaybackDevice = MA_FALSE;
|
||||||
|
ma_bool32 hasEnumeratedDefaultCaptureDevice = MA_FALSE;
|
||||||
|
|
||||||
MA_ASSERT(pContextStateALSA != NULL);
|
MA_ASSERT(pContextStateALSA != NULL);
|
||||||
MA_ASSERT(callback != NULL);
|
MA_ASSERT(callback != NULL);
|
||||||
@@ -29008,18 +29010,31 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu
|
|||||||
|
|
||||||
MA_ZERO_OBJECT(&deviceInfo);
|
MA_ZERO_OBJECT(&deviceInfo);
|
||||||
|
|
||||||
|
/* ID. */
|
||||||
|
ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Defualt.
|
Defualt.
|
||||||
|
|
||||||
There's no good way to determine whether or not a device is the default with ALSA. We're just going to do
|
There's no good way to determine whether or not a device is the default with ALSA. We're just going to do
|
||||||
something simple and just use the name of "default" as the indicator.
|
something simple and just use the name of "default" as the indicator.
|
||||||
*/
|
*/
|
||||||
if (ma_strcmp(deviceInfo.id.alsa, "default") == 0) {
|
if ((deviceType == ma_device_type_playback && !hasEnumeratedDefaultPlaybackDevice) || (deviceType == ma_device_type_capture && !hasEnumeratedDefaultCaptureDevice)) {
|
||||||
deviceInfo.isDefault = MA_TRUE;
|
/* */ if (ma_strcmp(deviceInfo.id.alsa, "default") == 0) {
|
||||||
|
deviceInfo.isDefault = MA_TRUE;
|
||||||
|
} else if (ma_strcmp(deviceInfo.id.alsa, "sysdefault") == 0) {
|
||||||
|
deviceInfo.isDefault = MA_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ID. */
|
if (deviceInfo.isDefault) {
|
||||||
ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1);
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
hasEnumeratedDefaultPlaybackDevice = MA_TRUE;
|
||||||
|
}
|
||||||
|
if (deviceType == ma_device_type_capture) {
|
||||||
|
hasEnumeratedDefaultCaptureDevice = MA_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Name.
|
Name.
|
||||||
|
|||||||
Reference in New Issue
Block a user