mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
bluetooth: allow UTF-8 in device descriptions
Users may configure the device alias to have characters outside the ASCII range, so our name cleanup routine was too aggressive. Let's just make sure that the device description is a valid UTF-8 string. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98160
This commit is contained in:
parent
b53dd1f0df
commit
d7e85813bd
4 changed files with 4 additions and 67 deletions
|
|
@ -1841,34 +1841,3 @@ const char *pa_bluez4_form_factor_to_string(pa_bluez4_form_factor_t ff) {
|
||||||
|
|
||||||
pa_assert_not_reached();
|
pa_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_bluez4_cleanup_name(const char *name) {
|
|
||||||
char *t, *s, *d;
|
|
||||||
bool space = false;
|
|
||||||
|
|
||||||
pa_assert(name);
|
|
||||||
|
|
||||||
while ((*name >= 1 && *name <= 32) || *name >= 127)
|
|
||||||
name++;
|
|
||||||
|
|
||||||
t = pa_xstrdup(name);
|
|
||||||
|
|
||||||
for (s = d = t; *s; s++) {
|
|
||||||
|
|
||||||
if (*s <= 32 || *s >= 127 || *s == '_') {
|
|
||||||
space = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (space) {
|
|
||||||
*(d++) = ' ';
|
|
||||||
space = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*(d++) = *s;
|
|
||||||
}
|
|
||||||
|
|
||||||
*d = 0;
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,6 @@ typedef enum pa_bluez4_form_factor {
|
||||||
pa_bluez4_form_factor_t pa_bluez4_get_form_factor(uint32_t class);
|
pa_bluez4_form_factor_t pa_bluez4_get_form_factor(uint32_t class);
|
||||||
const char *pa_bluez4_form_factor_to_string(pa_bluez4_form_factor_t ff);
|
const char *pa_bluez4_form_factor_to_string(pa_bluez4_form_factor_t ff);
|
||||||
|
|
||||||
char *pa_bluez4_cleanup_name(const char *name);
|
|
||||||
|
|
||||||
const char *pa_bluez4_profile_to_string(pa_bluez4_profile_t profile);
|
const char *pa_bluez4_profile_to_string(pa_bluez4_profile_t profile);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include <pulse/rtclock.h>
|
#include <pulse/rtclock.h>
|
||||||
#include <pulse/sample.h>
|
#include <pulse/sample.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
#include <pulse/utf8.h>
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/i18n.h>
|
#include <pulsecore/i18n.h>
|
||||||
|
|
@ -2280,7 +2281,7 @@ static int add_card(struct userdata *u) {
|
||||||
data.driver = __FILE__;
|
data.driver = __FILE__;
|
||||||
data.module = u->module;
|
data.module = u->module;
|
||||||
|
|
||||||
n = pa_bluez4_cleanup_name(device->alias);
|
n = pa_utf8_filter(device->alias);
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, n);
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, n);
|
||||||
pa_xfree(n);
|
pa_xfree(n);
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, device->address);
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, device->address);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <pulse/rtclock.h>
|
#include <pulse/rtclock.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
#include <pulse/utf8.h>
|
||||||
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/core-rtclock.h>
|
#include <pulsecore/core-rtclock.h>
|
||||||
|
|
@ -1618,38 +1619,6 @@ static void stop_thread(struct userdata *u) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run from main thread */
|
|
||||||
static char *cleanup_name(const char *name) {
|
|
||||||
char *t, *s, *d;
|
|
||||||
bool space = false;
|
|
||||||
|
|
||||||
pa_assert(name);
|
|
||||||
|
|
||||||
while ((*name >= 1 && *name <= 32) || *name >= 127)
|
|
||||||
name++;
|
|
||||||
|
|
||||||
t = pa_xstrdup(name);
|
|
||||||
|
|
||||||
for (s = d = t; *s; s++) {
|
|
||||||
|
|
||||||
if (*s <= 32 || *s >= 127 || *s == '_') {
|
|
||||||
space = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (space) {
|
|
||||||
*(d++) = ' ';
|
|
||||||
space = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*(d++) = *s;
|
|
||||||
}
|
|
||||||
|
|
||||||
*d = 0;
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run from main thread */
|
/* Run from main thread */
|
||||||
static pa_available_t get_port_availability(struct userdata *u, pa_direction_t direction) {
|
static pa_available_t get_port_availability(struct userdata *u, pa_direction_t direction) {
|
||||||
pa_available_t result = PA_AVAILABLE_NO;
|
pa_available_t result = PA_AVAILABLE_NO;
|
||||||
|
|
@ -1944,7 +1913,7 @@ static int add_card(struct userdata *u) {
|
||||||
data.driver = __FILE__;
|
data.driver = __FILE__;
|
||||||
data.module = u->module;
|
data.module = u->module;
|
||||||
|
|
||||||
alias = cleanup_name(d->alias);
|
alias = pa_utf8_filter(d->alias);
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, alias);
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, alias);
|
||||||
pa_xfree(alias);
|
pa_xfree(alias);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue