Sound(Linux): Don't abuse manufactor

This commit is contained in:
Linus Dierheimer
2023-01-27 18:03:57 +01:00
parent 0c256e2908
commit cf78216d78
3 changed files with 34 additions and 28 deletions
+30 -26
View File
@@ -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
)
]
)
]
)
]
+1
View File
@@ -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%
+3 -2
View File
@@ -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