Add method to get device index if using system default mode.

This commit is contained in:
2026-07-26 21:22:37 -05:00
parent 679eb2b76f
commit b646c07bf1
2 changed files with 21 additions and 1 deletions
+14
View File
@@ -120,6 +120,20 @@ int32 Audio::GetActiveDeviceIndex()
return ActiveDeviceIndex;
}
int32 Audio::GetActiveDeviceResolvedIndex()
{
AudioDevice* active = GetActiveDevice();
if (active != nullptr)
{
for (int32 i = 0; i < Devices.Count(); i++)
{
if (&Devices[i] == active)
return i;
}
}
return -1;
}
void Audio::SetActiveDeviceIndex(int32 index)
{
index = Math::Clamp(index, -1, Devices.Count() - 1);
+7 -1
View File
@@ -61,11 +61,17 @@ public:
API_PROPERTY() static AudioDevice* GetActiveDevice();
/// <summary>
/// Gets the index of the active device.
/// Gets the index of the active device. Returns -1 if set to system default mode.
/// </summary>
/// <returns>The active device index.</returns>
API_PROPERTY() static int32 GetActiveDeviceIndex();
/// <summary>
/// Gets the resolved index in Devices array of the device currently playing (resolves system default mode to the actual device index).
/// </summary>
/// <returns>The resolved active device index.</returns>
API_PROPERTY() static int32 GetActiveDeviceResolvedIndex();
/// <summary>
/// Sets the index of the active device.
/// </summary>