[pulseaudio-commits] src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Sun Apr 2 18:15:06 UTC 2017
src/modules/bluetooth/bluez4-util.c | 31 -----------------------
src/modules/bluetooth/bluez4-util.h | 2 -
src/modules/bluetooth/module-bluez4-device.c | 3 +-
src/modules/bluetooth/module-bluez5-device.c | 35 +--------------------------
4 files changed, 4 insertions(+), 67 deletions(-)
New commits:
commit d7e85813bd1ba10915a7069103ab8621b6e0ee36
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Tue Oct 11 17:27:06 2016 +0300
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
diff --git a/src/modules/bluetooth/bluez4-util.c b/src/modules/bluetooth/bluez4-util.c
index 06108f4b..82654508 100644
--- a/src/modules/bluetooth/bluez4-util.c
+++ b/src/modules/bluetooth/bluez4-util.c
@@ -1841,34 +1841,3 @@ const char *pa_bluez4_form_factor_to_string(pa_bluez4_form_factor_t ff) {
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;
-}
diff --git a/src/modules/bluetooth/bluez4-util.h b/src/modules/bluetooth/bluez4-util.h
index ed588f17..f4b5ca34 100644
--- a/src/modules/bluetooth/bluez4-util.h
+++ b/src/modules/bluetooth/bluez4-util.h
@@ -155,8 +155,6 @@ typedef enum pa_bluez4_form_factor {
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);
-char *pa_bluez4_cleanup_name(const char *name);
-
const char *pa_bluez4_profile_to_string(pa_bluez4_profile_t profile);
#endif
diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
index ac4ed63f..4c8ec8c7 100644
--- a/src/modules/bluetooth/module-bluez4-device.c
+++ b/src/modules/bluetooth/module-bluez4-device.c
@@ -31,6 +31,7 @@
#include <pulse/rtclock.h>
#include <pulse/sample.h>
#include <pulse/timeval.h>
+#include <pulse/utf8.h>
#include <pulse/xmalloc.h>
#include <pulsecore/i18n.h>
@@ -2280,7 +2281,7 @@ static int add_card(struct userdata *u) {
data.driver = __FILE__;
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_xfree(n);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, device->address);
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index 97fe8beb..afcc4576 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -29,6 +29,7 @@
#include <pulse/rtclock.h>
#include <pulse/timeval.h>
+#include <pulse/utf8.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core-rtclock.h>
@@ -1619,38 +1620,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 */
static pa_available_t get_port_availability(struct userdata *u, pa_direction_t direction) {
pa_available_t result = PA_AVAILABLE_NO;
unsigned i;
@@ -1944,7 +1913,7 @@ static int add_card(struct userdata *u) {
data.driver = __FILE__;
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_xfree(alias);
More information about the pulseaudio-commits
mailing list