mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
ALSA: Add basic support for detecting default devices.
Public issue https://github.com/mackron/miniaudio/issues/126
This commit is contained in:
+13
@@ -18242,6 +18242,15 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu
|
|||||||
MA_ZERO_OBJECT(&deviceInfo);
|
MA_ZERO_OBJECT(&deviceInfo);
|
||||||
ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1);
|
ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
There's no good way to determine whether or not a device is the default on Linux. We're just going to do something simple and
|
||||||
|
just use the name of "default" as the indicator.
|
||||||
|
*/
|
||||||
|
if (ma_strcmp(deviceInfo.id.alsa, "default") == 0) {
|
||||||
|
deviceInfo._private.isDefault = MA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DESC is the friendly name. We treat this slightly differently depending on whether or not we are using verbose
|
DESC is the friendly name. We treat this slightly differently depending on whether or not we are using verbose
|
||||||
device enumeration. In verbose mode we want to take the entire description so that the end-user can distinguish
|
device enumeration. In verbose mode we want to take the entire description so that the end-user can distinguish
|
||||||
@@ -18377,6 +18386,10 @@ static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_devic
|
|||||||
return MA_NO_DEVICE;
|
return MA_NO_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) {
|
||||||
|
pDeviceInfo->_private.isDefault = MA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* For detailed info we need to open the device. */
|
/* For detailed info we need to open the device. */
|
||||||
result = ma_context_open_pcm__alsa(pContext, shareMode, deviceType, pDeviceID, 0, &pPCM);
|
result = ma_context_open_pcm__alsa(pContext, shareMode, deviceType, pDeviceID, 0, &pPCM);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user