2 This file is part of PulseAudio.
4 Copyright 2008 Joao Paulo Rechi Vita
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 #include <pulsecore/core-util.h>
27 #include <modules/dbus-util.h>
29 #include "bluetooth-util.h"
37 struct pa_bluetooth_discovery
{
38 DBusConnection
*connection
;
39 PA_LLIST_HEAD(pa_dbus_pending
, pending
);
43 /* If mode == MODE_FIND look for a specific device by its address.
44 If mode == MODE_GET look for a specific device by its path. */
45 const char *looking_for
;
46 pa_bluetooth_device
*found_device
;
48 /* If looking_for is NULL we do long-time discovery */
50 pa_bluetooth_device_callback_t callback
;
51 struct userdata
*userdata
;
54 static pa_bluetooth_uuid
*uuid_new(const char *uuid
) {
57 u
= pa_xnew(pa_bluetooth_uuid
, 1);
58 u
->uuid
= pa_xstrdup(uuid
);
59 PA_LLIST_INIT(pa_bluetooth_uuid
, u
);
64 static void uuid_free(pa_bluetooth_uuid
*u
) {
71 static pa_bluetooth_device
* device_new(const char *path
) {
72 pa_bluetooth_device
*d
;
74 d
= pa_xnew(pa_bluetooth_device
, 1);
76 d
->device_info_valid
= d
->audio_sink_info_valid
= d
->headset_info_valid
= 0;
81 d
->path
= pa_xstrdup(path
);
84 d
->device_connected
= -1;
85 PA_LLIST_HEAD_INIT(pa_bluetooth_uuid
, d
->uuids
);
90 d
->audio_sink_connected
= -1;
92 d
->headset_connected
= -1;
97 void pa_bluetooth_device_free(pa_bluetooth_device
*d
) {
102 while ((u
= d
->uuids
)) {
103 PA_LLIST_REMOVE(pa_bluetooth_uuid
, d
->uuids
, u
);
110 pa_xfree(d
->address
);
114 static pa_bool_t
device_is_loaded(pa_bluetooth_device
*d
) {
117 return d
->device_info_valid
&& (d
->audio_sink_info_valid
|| d
->headset_info_valid
);
120 static pa_bool_t
device_is_audio(pa_bluetooth_device
*d
) {
123 pa_assert(d
->device_info_valid
);
124 pa_assert(d
->audio_sink_info_valid
|| d
->headset_info_valid
);
126 return d
->device_info_valid
> 0 &&
127 (d
->audio_sink_info_valid
> 0 || d
->headset_info_valid
> 0);
130 static int parse_device_property(pa_bluetooth_discovery
*y
, pa_bluetooth_device
*d
, DBusMessageIter
*i
) {
132 DBusMessageIter variant_i
;
138 if (dbus_message_iter_get_arg_type(i
) != DBUS_TYPE_STRING
) {
139 pa_log("Property name not a string.");
143 dbus_message_iter_get_basic(i
, &key
);
145 if (!dbus_message_iter_next(i
)) {
146 pa_log("Property value missing");
150 if (dbus_message_iter_get_arg_type(i
) != DBUS_TYPE_VARIANT
) {
151 pa_log("Property value not a variant.");
155 dbus_message_iter_recurse(i
, &variant_i
);
157 /* pa_log_debug("Parsing property org.bluez.Device.%s", key); */
159 switch (dbus_message_iter_get_arg_type(&variant_i
)) {
161 case DBUS_TYPE_STRING
: {
164 dbus_message_iter_get_basic(&variant_i
, &value
);
166 if (pa_streq(key
, "Name")) {
168 d
->name
= pa_xstrdup(value
);
169 } else if (pa_streq(key
, "Alias")) {
171 d
->alias
= pa_xstrdup(value
);
172 } else if (pa_streq(key
, "Address")) {
173 pa_xfree(d
->address
);
174 d
->address
= pa_xstrdup(value
);
177 /* pa_log_debug("Value %s", value); */
182 case DBUS_TYPE_BOOLEAN
: {
185 dbus_message_iter_get_basic(&variant_i
, &value
);
187 if (pa_streq(key
, "Paired"))
189 else if (pa_streq(key
, "Connected"))
190 d
->device_connected
= !!value
;
191 else if (pa_streq(key
, "Trusted"))
192 d
->trusted
= !!value
;
194 /* pa_log_debug("Value %s", pa_yes_no(value)); */
199 case DBUS_TYPE_UINT32
: {
202 dbus_message_iter_get_basic(&variant_i
, &value
);
204 if (pa_streq(key
, "Class"))
205 d
->class = (int) value
;
207 /* pa_log_debug("Value %u", (unsigned) value); */
212 case DBUS_TYPE_ARRAY
: {
215 dbus_message_iter_recurse(&variant_i
, &ai
);
217 if (dbus_message_iter_get_arg_type(&ai
) == DBUS_TYPE_STRING
&&
218 pa_streq(key
, "UUIDs")) {
220 while (dbus_message_iter_get_arg_type(&ai
) != DBUS_TYPE_INVALID
) {
221 pa_bluetooth_uuid
*node
;
224 dbus_message_iter_get_basic(&ai
, &value
);
225 node
= uuid_new(value
);
226 PA_LLIST_PREPEND(pa_bluetooth_uuid
, d
->uuids
, node
);
228 if (!dbus_message_iter_next(&ai
))
240 static int parse_audio_property(pa_bluetooth_discovery
*u
, int *connected
, DBusMessageIter
*i
) {
242 DBusMessageIter variant_i
;
245 pa_assert(connected
);
248 if (dbus_message_iter_get_arg_type(i
) != DBUS_TYPE_STRING
) {
249 pa_log("Property name not a string.");
253 dbus_message_iter_get_basic(i
, &key
);
255 if (!dbus_message_iter_next(i
)) {
256 pa_log("Property value missing");
260 if (dbus_message_iter_get_arg_type(i
) != DBUS_TYPE_VARIANT
) {
261 pa_log("Property value not a variant.");
265 dbus_message_iter_recurse(i
, &variant_i
);
267 /* pa_log_debug("Parsing property org.bluez.{AudioSink|Headset}.%s", key); */
269 switch (dbus_message_iter_get_arg_type(&variant_i
)) {
271 case DBUS_TYPE_BOOLEAN
: {
274 dbus_message_iter_get_basic(&variant_i
, &value
);
276 if (pa_streq(key
, "Connected"))
277 *connected
= !!value
;
279 /* pa_log_debug("Value %s", pa_yes_no(value)); */
288 static void run_callback(pa_bluetooth_discovery
*y
, pa_bluetooth_device
*d
, pa_bool_t good
) {
292 if (y
->mode
!= MODE_DISCOVER
)
295 if (!device_is_loaded(d
))
298 if (!device_is_audio(d
))
301 y
->callback(y
->userdata
, d
, good
);
305 static void get_properties_reply(DBusPendingCall
*pending
, void *userdata
) {
307 DBusMessageIter arg_i
, element_i
;
309 pa_bluetooth_device
*d
;
310 pa_bluetooth_discovery
*y
;
313 pa_assert_se(p
= userdata
);
314 pa_assert_se(y
= p
->context_data
);
315 pa_assert_se(r
= dbus_pending_call_steal_reply(pending
));
317 /* pa_log_debug("Got %s.GetProperties response for %s", */
318 /* dbus_message_get_interface(p->message), */
319 /* dbus_message_get_path(p->message)); */
323 valid
= dbus_message_get_type(r
) == DBUS_MESSAGE_TYPE_ERROR
? -1 : 1;
325 if (dbus_message_is_method_call(p
->message
, "org.bluez.Device", "GetProperties"))
326 d
->device_info_valid
= valid
;
327 else if (dbus_message_is_method_call(p
->message
, "org.bluez.Headset", "GetProperties"))
328 d
->headset_info_valid
= valid
;
329 else if (dbus_message_is_method_call(p
->message
, "org.bluez.AudioSink", "GetProperties"))
330 d
->audio_sink_info_valid
= valid
;
332 if (dbus_message_get_type(r
) == DBUS_MESSAGE_TYPE_ERROR
) {
334 if (!dbus_message_is_error(r
, DBUS_ERROR_UNKNOWN_METHOD
))
335 pa_log("Error from GetProperties reply: %s", dbus_message_get_error_name(r
));
340 if (!dbus_message_iter_init(r
, &arg_i
)) {
341 pa_log("GetProperties reply has no arguments.");
345 if (dbus_message_iter_get_arg_type(&arg_i
) != DBUS_TYPE_ARRAY
) {
346 pa_log("GetProperties argument is not an array.");
350 dbus_message_iter_recurse(&arg_i
, &element_i
);
351 while (dbus_message_iter_get_arg_type(&element_i
) != DBUS_TYPE_INVALID
) {
353 if (dbus_message_iter_get_arg_type(&element_i
) == DBUS_TYPE_DICT_ENTRY
) {
354 DBusMessageIter dict_i
;
356 dbus_message_iter_recurse(&element_i
, &dict_i
);
358 if (dbus_message_has_interface(p
->message
, "org.bluez.Device")) {
359 if (parse_device_property(y
, d
, &dict_i
) < 0)
362 } else if (dbus_message_has_interface(p
->message
, "org.bluez.Headset")) {
363 if (parse_audio_property(y
, &d
->headset_connected
, &dict_i
) < 0)
366 } else if (dbus_message_has_interface(p
->message
, "org.bluez.AudioSink")) {
367 if (parse_audio_property(y
, &d
->audio_sink_connected
, &dict_i
) < 0)
372 if (!dbus_message_iter_next(&element_i
))
377 run_callback(y
, d
, TRUE
);
379 dbus_message_unref(r
);
381 PA_LLIST_REMOVE(pa_dbus_pending
, y
->pending
, p
);
382 pa_dbus_pending_free(p
);
385 static pa_dbus_pending
* send_and_add_to_pending(pa_bluetooth_discovery
*y
, pa_bluetooth_device
*d
, DBusMessage
*m
, DBusPendingCallNotifyFunction func
) {
387 DBusPendingCall
*call
;
392 pa_assert_se(dbus_connection_send_with_reply(y
->connection
, m
, &call
, -1));
394 p
= pa_dbus_pending_new(m
, call
, y
, d
);
395 PA_LLIST_PREPEND(pa_dbus_pending
, y
->pending
, p
);
396 dbus_pending_call_set_notify(call
, func
, p
, NULL
);
401 static void found_device(pa_bluetooth_discovery
*y
, const char* path
) {
403 pa_bluetooth_device
*d
;
408 d
= device_new(path
);
410 if (y
->mode
== MODE_DISCOVER
) {
411 pa_assert(y
->devices
);
412 pa_hashmap_put(y
->devices
, d
->path
, d
);
414 pa_assert(!y
->found_device
);
418 pa_assert_se(m
= dbus_message_new_method_call("org.bluez", path
, "org.bluez.Device", "GetProperties"));
419 send_and_add_to_pending(y
, d
, m
, get_properties_reply
);
421 pa_assert_se(m
= dbus_message_new_method_call("org.bluez", path
, "org.bluez.Headset", "GetProperties"));
422 send_and_add_to_pending(y
, d
, m
, get_properties_reply
);
424 pa_assert_se(m
= dbus_message_new_method_call("org.bluez", path
, "org.bluez.AudioSink", "GetProperties"));
425 send_and_add_to_pending(y
, d
, m
, get_properties_reply
);
428 static void list_devices_reply(DBusPendingCall
*pending
, void *userdata
) {
434 pa_bluetooth_discovery
*y
;
440 pa_assert_se(p
= userdata
);
441 pa_assert_se(y
= p
->context_data
);
442 pa_assert_se(r
= dbus_pending_call_steal_reply(pending
));
444 if (dbus_message_get_type(r
) == DBUS_MESSAGE_TYPE_ERROR
) {
445 pa_log("Error from ListDevices reply: %s", dbus_message_get_error_name(r
));
449 if (!dbus_message_get_args(r
, &e
, DBUS_TYPE_ARRAY
, DBUS_TYPE_OBJECT_PATH
, &paths
, &num
, DBUS_TYPE_INVALID
)) {
450 pa_log("org.bluez.Adapter.ListDevices returned an error: '%s'\n", e
.message
);
455 for (i
= 0; i
< num
; ++i
)
456 found_device(y
, paths
[i
]);
461 dbus_free_string_array (paths
);
463 dbus_message_unref(r
);
465 PA_LLIST_REMOVE(pa_dbus_pending
, y
->pending
, p
);
466 pa_dbus_pending_free(p
);
469 static void find_device_reply(DBusPendingCall
*pending
, void *userdata
) {
474 pa_bluetooth_discovery
*y
;
480 pa_assert_se(p
= userdata
);
481 pa_assert_se(y
= p
->context_data
);
482 pa_assert_se(r
= dbus_pending_call_steal_reply(pending
));
484 if (dbus_message_get_type(r
) == DBUS_MESSAGE_TYPE_ERROR
) {
485 pa_log("Error from FindDevice reply: %s", dbus_message_get_error_name(r
));
489 if (!dbus_message_get_args(r
, &e
, DBUS_TYPE_OBJECT_PATH
, &path
, DBUS_TYPE_INVALID
)) {
490 pa_log("org.bluez.Adapter.FindDevice returned an error: '%s'\n", e
.message
);
493 found_device(y
, path
);
496 dbus_message_unref(r
);
498 PA_LLIST_REMOVE(pa_dbus_pending
, y
->pending
, p
);
499 pa_dbus_pending_free(p
);
502 static void found_adapter(pa_bluetooth_discovery
*y
, const char *path
) {
505 if (y
->mode
== MODE_FIND
) {
506 pa_assert_se(m
= dbus_message_new_method_call("org.bluez", path
, "org.bluez.Adapter", "FindDevice"));
508 pa_assert_se(dbus_message_append_args(m
,
509 DBUS_TYPE_STRING
, &y
->looking_for
,
512 send_and_add_to_pending(y
, NULL
, m
, find_device_reply
);
515 pa_assert(y
->mode
== MODE_DISCOVER
);
517 pa_assert_se(m
= dbus_message_new_method_call("org.bluez", path
, "org.bluez.Adapter", "ListDevices"));
518 send_and_add_to_pending(y
, NULL
, m
, list_devices_reply
);
522 static void list_adapters_reply(DBusPendingCall
*pending
, void *userdata
) {
528 pa_bluetooth_discovery
*y
;
534 pa_assert_se(p
= userdata
);
535 pa_assert_se(y
= p
->context_data
);
536 pa_assert_se(r
= dbus_pending_call_steal_reply(pending
));
538 if (dbus_message_get_type(r
) == DBUS_MESSAGE_TYPE_ERROR
) {
539 pa_log("Error from ListAdapters reply: %s", dbus_message_get_error_name(r
));
543 if (!dbus_message_get_args(r
, &e
, DBUS_TYPE_ARRAY
, DBUS_TYPE_OBJECT_PATH
, &paths
, &num
, DBUS_TYPE_INVALID
)) {
544 pa_log("org.bluez.Manager.ListAdapters returned an error: %s", e
.message
);
549 for (i
= 0; i
< num
; ++i
)
550 found_adapter(y
, paths
[i
]);
555 dbus_free_string_array (paths
);
557 dbus_message_unref(r
);
559 PA_LLIST_REMOVE(pa_dbus_pending
, y
->pending
, p
);
560 pa_dbus_pending_free(p
);
563 static void list_adapters(pa_bluetooth_discovery
*y
) {
567 pa_assert_se(m
= dbus_message_new_method_call("org.bluez", "/", "org.bluez.Manager", "ListAdapters"));
568 send_and_add_to_pending(y
, NULL
, m
, list_adapters_reply
);
571 static DBusHandlerResult
filter_cb(DBusConnection
*bus
, DBusMessage
*m
, void *userdata
) {
573 pa_bluetooth_discovery
*y
;
578 pa_assert_se(y
= userdata
);
580 dbus_error_init(&err
);
582 pa_log_debug("dbus: interface=%s, path=%s, member=%s\n",
583 dbus_message_get_interface(m
),
584 dbus_message_get_path(m
),
585 dbus_message_get_member(m
));
587 if (dbus_message_is_signal(m
, "org.bluez.Adapter", "DeviceRemoved")) {
589 pa_bluetooth_device
*d
;
591 if (!dbus_message_get_args(m
, &err
, DBUS_TYPE_OBJECT_PATH
, &path
, DBUS_TYPE_INVALID
)) {
592 pa_log("Failed to parse org.bluez.Adapter.DeviceRemoved: %s", err
.message
);
596 pa_log_debug("Device %s removed", path
);
598 if ((d
= pa_hashmap_remove(y
->devices
, path
))) {
600 pa_assert_se(y
->mode
== MODE_DISCOVER
);
601 run_callback(y
, d
, FALSE
);
603 pa_bluetooth_device_free(d
);
606 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
608 } else if (dbus_message_is_signal(m
, "org.bluez.Adapter", "DeviceCreated")) {
611 if (!dbus_message_get_args(m
, &err
, DBUS_TYPE_OBJECT_PATH
, &path
, DBUS_TYPE_INVALID
)) {
612 pa_log("Failed to parse org.bluez.Adapter.DeviceCreated: %s", err
.message
);
616 pa_log_debug("Device %s created", path
);
618 found_device(y
, path
);
619 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
621 } else if (dbus_message_is_signal(m
, "org.bluez.Manager", "AdapterAdded")) {
624 if (!dbus_message_get_args(m
, &err
, DBUS_TYPE_OBJECT_PATH
, &path
, DBUS_TYPE_INVALID
)) {
625 pa_log("Failed to parse org.bluez.Manager.AdapterAdded: %s", err
.message
);
629 pa_log_debug("Adapter %s created", path
);
631 found_adapter(y
, path
);
632 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
634 } else if (dbus_message_is_signal(m
, "org.bluez.Headset", "PropertyChanged") ||
635 dbus_message_is_signal(m
, "org.bluez.AudioSink", "PropertyChanged") ||
636 dbus_message_is_signal(m
, "org.bluez.Device", "PropertyChanged")) {
638 pa_bluetooth_device
*d
;
640 if ((d
= pa_hashmap_get(y
->devices
, dbus_message_get_path(m
)))) {
641 DBusMessageIter arg_i
;
643 if (!dbus_message_iter_init(m
, &arg_i
)) {
644 pa_log("Failed to parse PropertyChanged: %s", err
.message
);
648 if (dbus_message_has_interface(m
, "org.bluez.Device")) {
649 if (parse_device_property(y
, d
, &arg_i
) < 0)
652 } else if (dbus_message_has_interface(m
, "org.bluez.Headset")) {
653 if (parse_audio_property(y
, &d
->headset_connected
, &arg_i
) < 0)
655 d
->headset_info_valid
= 1;
657 } else if (dbus_message_has_interface(m
, "org.bluez.AudioSink")) {
658 if (parse_audio_property(y
, &d
->audio_sink_connected
, &arg_i
) < 0)
660 d
->audio_sink_info_valid
= 1;
663 pa_assert_se(y
->mode
== MODE_DISCOVER
);
664 run_callback(y
, d
, TRUE
);
667 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
671 dbus_error_free(&err
);
673 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
676 pa_bluetooth_device
* pa_bluetooth_find_device(DBusConnection
*c
, const char* address
) {
677 pa_bluetooth_discovery y
;
679 memset(&y
, 0, sizeof(y
));
681 y
.looking_for
= address
;
683 PA_LLIST_HEAD_INIT(pa_dbus_pending
, y
.pending
);
687 pa_dbus_sync_pending_list(&y
.pending
);
688 pa_assert(!y
.pending
);
690 if (y
.found_device
) {
691 pa_assert(device_is_loaded(y
.found_device
));
693 if (!device_is_audio(y
.found_device
)) {
694 pa_bluetooth_device_free(y
.found_device
);
699 return y
.found_device
;
702 pa_bluetooth_device
* pa_bluetooth_get_device(DBusConnection
*c
, const char* path
) {
703 pa_bluetooth_discovery y
;
705 memset(&y
, 0, sizeof(y
));
708 PA_LLIST_HEAD_INIT(pa_dbus_pending
, y
.pending
);
710 found_device(&y
, path
);
712 pa_dbus_sync_pending_list(&y
.pending
);
713 pa_assert(!y
.pending
);
715 if (y
.found_device
) {
716 pa_assert(device_is_loaded(y
.found_device
));
718 if (!device_is_audio(y
.found_device
)) {
719 pa_bluetooth_device_free(y
.found_device
);
724 return y
.found_device
;
727 pa_bluetooth_discovery
* pa_bluetooth_discovery_new(DBusConnection
*c
, pa_bluetooth_device_callback_t cb
, struct userdata
*u
) {
729 pa_bluetooth_discovery
*y
;
734 dbus_error_init(&err
);
736 y
= pa_xnew0(pa_bluetooth_discovery
, 1);
737 y
->mode
= MODE_DISCOVER
;
741 y
->devices
= pa_hashmap_new(pa_idxset_string_hash_func
, pa_idxset_string_compare_func
);
742 PA_LLIST_HEAD_INIT(pa_dbus_pending
, y
->pending
);
744 /* dynamic detection of bluetooth audio devices */
745 if (!dbus_connection_add_filter(c
, filter_cb
, y
, NULL
)) {
746 pa_log_error("Failed to add filter function");
750 if (pa_dbus_add_matches(
752 "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterAdded'",
753 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
754 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
755 "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
756 "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
757 "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", NULL
) < 0) {
758 pa_log("Failed to add D-Bus matches: %s", err
.message
);
767 dbus_error_free(&err
);
771 void pa_bluetooth_discovery_free(pa_bluetooth_discovery
*y
) {
772 pa_bluetooth_device
*d
;
776 pa_dbus_free_pending_list(&y
->pending
);
779 while ((d
= pa_hashmap_steal_first(y
->devices
))) {
780 run_callback(y
, d
, FALSE
);
781 pa_bluetooth_device_free(d
);
784 pa_hashmap_free(y
->devices
, NULL
, NULL
);
788 pa_dbus_remove_matches(y
->connection
,
789 "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterAdded'",
790 "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterRemoved'",
791 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
792 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
793 "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
794 "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
795 "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", NULL
);
797 dbus_connection_remove_filter(y
->connection
, filter_cb
, y
);
801 void pa_bluetooth_discovery_sync(pa_bluetooth_discovery
*y
) {
804 pa_dbus_sync_pending_list(&y
->pending
);
807 const char*pa_bluetooth_get_form_factor(uint32_t class) {
811 static const char * const table
[] = {
822 if (((class >> 8) & 31) != 4)
825 if ((i
= (class >> 2) & 63) > PA_ELEMENTSOF(table
))
831 pa_log_debug("Unknown Bluetooth minor device class %u", i
);
836 char *pa_bluetooth_cleanup_name(const char *name
) {
838 pa_bool_t space
= FALSE
;
842 while ((*name
>= 1 && *name
<= 32) || *name
>= 127)
845 t
= pa_xstrdup(name
);
847 for (s
= d
= t
; *s
; s
++) {
849 if (*s
<= 32 || *s
>= 127 || *s
== '_') {