On Saturday 20 October 2018 22:50:58 EHfive wrote: > +static bool disable_absolute_volume_match(const char * bt_addr_str) { > + bdaddr_t bt_addr; > + int i; > + static bdaddr_t affected_bt_addr_cache; > + static bool effected_bt_addr_cached = false; > + > + static const struct { > + bdaddr_t addr; > + size_t length; > + } database[] = { > + > + // Ausdom M05 - unacceptably loud volume > + {{{0xa0, 0xe9, 0xdb, 0, 0, 0}}, 3}, > + // iKross IKBT83B HS - unacceptably loud volume > + {{{0x00, 0x14, 0x02, 0, 0, 0}}, 3}, > + // JayBird BlueBuds X - low granularity on volume control > + {{{0x44, 0x5e, 0xf3, 0, 0, 0}}, 3}, > + {{{0xd4, 0x9c, 0x28, 0, 0, 0}}, 3}, > + // LG Tone HBS-730 - unacceptably loud volume > + {{{0x00, 0x18, 0x6b, 0, 0, 0}}, 3}, > + {{{0xb8, 0xad, 0x3e, 0, 0, 0}}, 3}, > + // LG Tone HV-800 - unacceptably loud volume > + {{{0xa0, 0xe9, 0xdb, 0, 0, 0}}, 3}, > + // Motorola Roadster > + {{{0x00, 0x24, 0x1C, 0, 0, 0}}, 3}, > + // Mpow Cheetah - unacceptably loud volume > + {{{0x00, 0x11, 0xb1, 0, 0, 0}}, 3}, > + // SOL REPUBLIC Tracks Air - unable to adjust volume back off > from max > + {{{0xa4, 0x15, 0x66, 0, 0, 0}}, 3}, > + // Swage Rokitboost HS - unacceptably loud volume > + {{{0x00, 0x14, 0xf1, 0, 0, 0}}, 3}, > + // VW Car Kit - not enough granularity with volume > + {{{0x00, 0x26, 0x7e, 0, 0, 0}}, 3}, > + {{{0x90, 0x03, 0xb7, 0, 0, 0}}, 3}, > + // deepblue2 - cannot change smoothly the volume, 0x b/37834035 > + {{{0x0c, 0xa6, 0x94, 0, 0, 0}}, 3} > + }; It would be better to store database in format suitable for pulseaudio. Code below converts pulseaudio bt_addr_str to format suitable for database. Why not not store database format in the same way as pulseaudio stores bt_addr_str internally? It could simplify that code. Plus, I think that device blacklist database should not be hardcoded in pulseaudio source code. But rather be in some text configuration file(s) which can be changed without recompilation. Similarly like alsa paths and profile-sets. > + > + for (i = 0; i < 6; ++i, bt_addr_str += 3) > + bt_addr.b[i] = (uint8_t) strtol(bt_addr_str, NULL, 16); > + > + if (effected_bt_addr_cached){ > + int j; > + bool flag = true; > + for (j = 0; j < 6; ++j) > + if (affected_bt_addr_cache.b[j] != bt_addr.b[j]){ > + flag = false; > + break; > + } > + if(flag) > + return true; > + } > + > + for(i = 0; i < PA_ELEMENTSOF(database); ++i){ > + int j; > + bool flag = true; > + for(j = 0; j < database[i].length; ++j) > + if(database[i].addr.b[j] != bt_addr.b[j]){ > + flag = false; > + break; > + } > + if(flag){ > + affected_bt_addr_cache = bt_addr; > + effected_bt_addr_cached = true; > + return true; > + } > + } > + return false; > +} > + -- Pali Rohár pali.rohar@xxxxxxxxx
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss