From cf78216d782f2268dfb03f786625d220092901ba Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Fri, 27 Jan 2023 18:03:57 +0100 Subject: [PATCH] Sound(Linux): Don't abuse manufactor --- src/detection/bluetooth/bluetooth_linux.c | 56 ++++++++++++----------- src/detection/sound/sound.h | 1 + src/detection/sound/sound_linux.c | 5 +- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index 4751db6c0..ba0ba3bf8 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -8,32 +8,36 @@ array [ //root dict entry( //object object path "/org/bluez/hci0/dev_03_21_8B_91_16_4D" array [ - dict entry( //property - string "org.bluez.Device1" - array [ - dict entry( - string "Address" - variant string "03:21:8B:91:16:4D" - ) - dict entry( - string "Name" - variant string "JBL TUNE160BT" - ) - dict entry( - string "Connected" - variant boolean true - ) - ] - ) - dict entry( //property - string "org.bluez.Battery1" - array [ - dict entry( - string "Percentage" - variant byte 100 - ) - ] - ) + dict entry( //property + string "org.bluez.Device1" + array [ + dict entry( + string "Address" + variant string "03:21:8B:91:16:4D" + ) + dict entry( + string "Name" + variant string "JBL TUNE160BT" + ) + dict entry( + string "Icon" + variant string "audio-headset" + ) + dict entry( + string "Connected" + variant boolean true + ) + ] + ) + dict entry( //property + string "org.bluez.Battery1" + array [ + dict entry( + string "Percentage" + variant byte 100 + ) + ] + ) ] ) ] diff --git a/src/detection/sound/sound.h b/src/detection/sound/sound.h index 6247ed299..f40f6af5c 100644 --- a/src/detection/sound/sound.h +++ b/src/detection/sound/sound.h @@ -7,6 +7,7 @@ typedef struct FFSoundDevice { + FFstrbuf identifier; // Used internally, not guaranteed to be initialized FFstrbuf name; FFstrbuf manufacturer; uint8_t volume; // 0-100% diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index 0e25d5629..0aa10b753 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -12,8 +12,9 @@ static void paSinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, vo return; FFSoundDevice* device = ffListAdd(userdata); + ffStrbufInitS(&device->identifier, i->name); ffStrbufInitS(&device->name, i->description); - ffStrbufInitS(&device->manufacturer, i->name); + ffStrbufInitS(&device->manufacturer, i->driver); device->volume = i->mute ? 0 : (uint8_t) (i->volume.values[0] * 100 / PA_VOLUME_NORM); device->active = i->active_port && i->active_port->available == PA_PORT_AVAILABLE_YES; device->main = false; @@ -28,7 +29,7 @@ static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *u FF_LIST_FOR_EACH(FFSoundDevice, device, *(FFlist*)userdata) { - if(ffStrbufEqualS(&device->manufacturer, i->default_sink_name)) + if(ffStrbufEqualS(&device->identifier, i->default_sink_name)) { device->main = true; device->active = true; // Treat the default sink as always active