diff --git a/src/detection/sound/sound.h b/src/detection/sound/sound.h index f40f6af5c..76c17627c 100644 --- a/src/detection/sound/sound.h +++ b/src/detection/sound/sound.h @@ -7,7 +7,7 @@ typedef struct FFSoundDevice { - FFstrbuf identifier; // Used internally, not guaranteed to be initialized + FFstrbuf identifier; FFstrbuf name; FFstrbuf manufacturer; uint8_t volume; // 0-100% diff --git a/src/detection/sound/sound_apple.c b/src/detection/sound/sound_apple.c index 78ab54740..305e991bf 100644 --- a/src/detection/sound/sound_apple.c +++ b/src/detection/sound/sound_apple.c @@ -40,6 +40,7 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de device->main = deviceId == mainDeviceId; device->active = device->main; device->volume = 0; + ffStrbufInitF(&device->identifier, "%u", (unsigned) deviceId); ffStrbufInit(&device->name); ffStrbufInit(&device->manufacturer); diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index 57b8fa45b..2b9e95be1 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -63,9 +63,12 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U device->main = wcscmp(mainDeviceId, immDeviceId) == 0; device->active = !!(immState & DEVICE_STATE_ACTIVE); device->volume = 0; + ffStrbufInit(&device->identifier); ffStrbufInit(&device->name); ffStrbufInit(&device->manufacturer); + ffStrbufSetWS(&device->identifier, immDeviceId); + { PROPVARIANT __attribute__((__cleanup__(PropVariantClear))) friendlyName; PropVariantInit(&friendlyName); diff --git a/src/modules/sound.c b/src/modules/sound.c index 3bc478145..d9ee35d37 100644 --- a/src/modules/sound.c +++ b/src/modules/sound.c @@ -2,7 +2,7 @@ #include "detection/sound/sound.h" #define FF_SOUND_MODULE_NAME "Sound" -#define FF_SOUND_NUM_FORMAT_ARGS 4 +#define FF_SOUND_NUM_FORMAT_ARGS 5 static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8_t index) { @@ -27,7 +27,8 @@ static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8 {FF_FORMAT_ARG_TYPE_BOOL, &device->main}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_UINT8, &device->volume}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->manufacturer} + {FF_FORMAT_ARG_TYPE_STRBUF, &device->manufacturer}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier} }); } } @@ -72,6 +73,7 @@ void ffPrintSound(FFinstance* instance) FF_LIST_FOR_EACH(FFSoundDevice, device, result) { + ffStrbufDestroy(&device->identifier); ffStrbufDestroy(&device->name); ffStrbufDestroy(&device->manufacturer); }