return PA_BLUEZ4_AUDIO_STATE_INVALID;
}
-const char *pa_bluez4_profile_to_string(enum profile profile) {
+const char *pa_bluez4_profile_to_string(pa_bluez4_profile_t profile) {
switch(profile) {
- case PROFILE_A2DP:
+ case PA_BLUEZ4_PROFILE_A2DP:
return "a2dp";
- case PROFILE_A2DP_SOURCE:
+ case PA_BLUEZ4_PROFILE_A2DP_SOURCE:
return "a2dp_source";
- case PROFILE_HSP:
+ case PA_BLUEZ4_PROFILE_HSP:
return "hsp";
- case PROFILE_HFGW:
+ case PA_BLUEZ4_PROFILE_HFGW:
return "hfgw";
- case PROFILE_OFF:
+ case PA_BLUEZ4_PROFILE_OFF:
pa_assert_not_reached();
}
pa_assert_not_reached();
}
-static int profile_from_interface(const char *interface, enum profile *p) {
+static int profile_from_interface(const char *interface, pa_bluez4_profile_t *p) {
pa_assert(interface);
pa_assert(p);
if (pa_streq(interface, "org.bluez.AudioSink")) {
- *p = PROFILE_A2DP;
+ *p = PA_BLUEZ4_PROFILE_A2DP;
return 0;
} else if (pa_streq(interface, "org.bluez.AudioSource")) {
- *p = PROFILE_A2DP_SOURCE;
+ *p = PA_BLUEZ4_PROFILE_A2DP_SOURCE;
return 0;
} else if (pa_streq(interface, "org.bluez.Headset")) {
- *p = PROFILE_HSP;
+ *p = PA_BLUEZ4_PROFILE_HSP;
return 0;
} else if (pa_streq(interface, "org.bluez.HandsfreeGateway")) {
- *p = PROFILE_HFGW;
+ *p = PA_BLUEZ4_PROFILE_HFGW;
return 0;
}
const char *key;
DBusMessageIter variant_i;
bool is_audio_interface;
- enum profile p = PROFILE_OFF;
+ pa_bluez4_profile_t p = PA_BLUEZ4_PROFILE_OFF;
pa_assert(d);
pa_assert(interface);
if (key == NULL)
return -1;
- transport = p == PROFILE_OFF ? NULL : d->transports[p];
+ transport = p == PA_BLUEZ4_PROFILE_OFF ? NULL : d->transports[p];
dbus_message_iter_recurse(i, &variant_i);
break;
}
- pa_assert(p != PROFILE_OFF);
+ pa_assert(p != PA_BLUEZ4_PROFILE_OFF);
d->profile_state[p] = state;
dbus_uint16_t gain = PA_MIN(value, HSP_MAX_GAIN);
pa_assert(t);
- pa_assert(t->profile == PROFILE_HSP);
+ pa_assert(t->profile == PA_BLUEZ4_PROFILE_HSP);
set_property(t->device->discovery, "org.bluez", t->device->path, "org.bluez.Headset",
"MicrophoneGain", DBUS_TYPE_UINT16, &gain);
dbus_uint16_t gain = PA_MIN(value, HSP_MAX_GAIN);
pa_assert(t);
- pa_assert(t->profile == PROFILE_HSP);
+ pa_assert(t->profile == PA_BLUEZ4_PROFILE_HSP);
set_property(t->device->discovery, "org.bluez", t->device->path, "org.bluez.Headset",
"SpeakerGain", DBUS_TYPE_UINT16, &gain);
return 0;
}
-static pa_bluez4_transport *transport_new(pa_bluez4_device *d, const char *owner, const char *path, enum profile p,
+static pa_bluez4_transport *transport_new(pa_bluez4_device *d, const char *owner, const char *path, pa_bluez4_profile_t p,
const uint8_t *config, int size) {
pa_bluez4_transport *t;
uint8_t *config = NULL;
int size = 0;
bool nrec = false;
- enum profile p;
+ pa_bluez4_profile_t p;
DBusMessageIter args, props;
DBusMessage *r;
bool old_any_connected;
goto fail;
if (dbus_message_has_path(m, ENDPOINT_PATH_HFP_AG))
- p = PROFILE_HSP;
+ p = PA_BLUEZ4_PROFILE_HSP;
else if (dbus_message_has_path(m, ENDPOINT_PATH_HFP_HS))
- p = PROFILE_HFGW;
+ p = PA_BLUEZ4_PROFILE_HFGW;
else if (dbus_message_has_path(m, ENDPOINT_PATH_A2DP_SOURCE))
- p = PROFILE_A2DP;
+ p = PA_BLUEZ4_PROFILE_A2DP;
else
- p = PROFILE_A2DP_SOURCE;
+ p = PA_BLUEZ4_PROFILE_A2DP_SOURCE;
if (d->transports[p] != NULL) {
pa_log("Cannot configure transport %s because profile %d is already used", path, p);
struct a2dp_info a2dp;
struct hsp_info hsp;
- enum profile profile;
+ pa_bluez4_profile_t profile;
pa_modargs *modargs;
#define MAX_PLAYBACK_CATCH_UP_USEC (100*PA_USEC_PER_MSEC)
-#define USE_SCO_OVER_PCM(u) (u->profile == PROFILE_HSP && (u->hsp.sco_sink && u->hsp.sco_source))
+#define USE_SCO_OVER_PCM(u) (u->profile == PA_BLUEZ4_PROFILE_HSP && (u->hsp.sco_sink && u->hsp.sco_source))
static int init_profile(struct userdata *u);
/* from IO thread, except in SCO over PCM */
static void bt_transport_config_mtu(struct userdata *u) {
/* Calculate block sizes */
- if (u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW) {
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP || u->profile == PA_BLUEZ4_PROFILE_HFGW) {
u->read_block_size = u->read_link_mtu;
u->write_block_size = u->write_link_mtu;
} else {
if (u->sink) {
pa_sink_set_max_request_within_thread(u->sink, u->write_block_size);
pa_sink_set_fixed_latency_within_thread(u->sink,
- (u->profile == PROFILE_A2DP ?
+ (u->profile == PA_BLUEZ4_PROFILE_A2DP ?
FIXED_LATENCY_PLAYBACK_A2DP : FIXED_LATENCY_PLAYBACK_HSP) +
pa_bytes_to_usec(u->write_block_size, &u->sample_spec));
}
if (u->source)
pa_source_set_fixed_latency_within_thread(u->source,
- (u->profile == PROFILE_A2DP_SOURCE ?
+ (u->profile == PA_BLUEZ4_PROFILE_A2DP_SOURCE ?
FIXED_LATENCY_RECORD_A2DP : FIXED_LATENCY_RECORD_HSP) +
pa_bytes_to_usec(u->read_block_size, &u->sample_spec));
}
pa_log_debug("Stream properly set up, we're ready to roll!");
- if (u->profile == PROFILE_A2DP)
+ if (u->profile == PA_BLUEZ4_PROFILE_A2DP)
a2dp_set_bitpool(u, u->a2dp.max_bitpool);
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
int ret = 0;
pa_assert(u);
- pa_assert(u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW);
+ pa_assert(u->profile == PA_BLUEZ4_PROFILE_HSP || u->profile == PA_BLUEZ4_PROFILE_HFGW);
pa_assert(u->sink);
/* First, render some data */
pa_memchunk memchunk;
pa_assert(u);
- pa_assert(u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW);
+ pa_assert(u->profile == PA_BLUEZ4_PROFILE_HSP || u->profile == PA_BLUEZ4_PROFILE_HFGW);
pa_assert(u->source);
pa_assert(u->read_smoother);
int ret = 0;
pa_assert(u);
- pa_assert(u->profile == PROFILE_A2DP);
+ pa_assert(u->profile == PA_BLUEZ4_PROFILE_A2DP);
pa_assert(u->sink);
/* First, render some data */
pa_memchunk memchunk;
pa_assert(u);
- pa_assert(u->profile == PROFILE_A2DP_SOURCE);
+ pa_assert(u->profile == PA_BLUEZ4_PROFILE_A2DP_SOURCE);
pa_assert(u->source);
pa_assert(u->read_smoother);
if (pollfd && (pollfd->revents & POLLIN)) {
int n_read;
- if (u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW)
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP || u->profile == PA_BLUEZ4_PROFILE_HFGW)
n_read = hsp_process_push(u);
else
n_read = a2dp_process_push(u);
pa_memblock_unref(tmp.memblock);
u->write_index += skip_bytes;
- if (u->profile == PROFILE_A2DP)
+ if (u->profile == PA_BLUEZ4_PROFILE_A2DP)
a2dp_reduce_bitpool(u);
}
}
if (u->write_index <= 0)
u->started_at = pa_rtclock_now();
- if (u->profile == PROFILE_A2DP) {
+ if (u->profile == PA_BLUEZ4_PROFILE_A2DP) {
if ((n_written = a2dp_process_render(u)) < 0)
goto io_fail;
} else {
return PA_AVAILABLE_UNKNOWN;
}
-static pa_direction_t get_profile_direction(enum profile p) {
+static pa_direction_t get_profile_direction(pa_bluez4_profile_t p) {
static const pa_direction_t profile_direction[] = {
- [PROFILE_A2DP] = PA_DIRECTION_OUTPUT,
- [PROFILE_A2DP_SOURCE] = PA_DIRECTION_INPUT,
- [PROFILE_HSP] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
- [PROFILE_HFGW] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
- [PROFILE_OFF] = 0
+ [PA_BLUEZ4_PROFILE_A2DP] = PA_DIRECTION_OUTPUT,
+ [PA_BLUEZ4_PROFILE_A2DP_SOURCE] = PA_DIRECTION_INPUT,
+ [PA_BLUEZ4_PROFILE_HSP] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
+ [PA_BLUEZ4_PROFILE_HFGW] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
+ [PA_BLUEZ4_PROFILE_OFF] = 0
};
return profile_direction[p];
static void handle_transport_state_change(struct userdata *u, struct pa_bluez4_transport *transport) {
bool acquire = false;
bool release = false;
- enum profile profile;
+ pa_bluez4_profile_t profile;
pa_card_profile *cp;
pa_bluez4_transport_state_t state;
pa_device_port *port;
pa_assert(u);
pa_assert(u->sink == s);
- pa_assert(u->profile == PROFILE_HSP);
+ pa_assert(u->profile == PA_BLUEZ4_PROFILE_HSP);
pa_assert(u->transport);
gain = (dbus_uint16_t) round((double) pa_cvolume_max(&s->real_volume) * HSP_MAX_GAIN / PA_VOLUME_NORM);
pa_assert(u);
pa_assert(u->source == s);
- pa_assert(u->profile == PROFILE_HSP);
+ pa_assert(u->profile == PA_BLUEZ4_PROFILE_HSP);
pa_assert(u->transport);
gain = (dbus_uint16_t) round((double) pa_cvolume_max(&s->real_volume) * HSP_MAX_GAIN / PA_VOLUME_NORM);
data.module = u->module;
pa_sink_new_data_set_sample_spec(&data, &u->sample_spec);
pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bluez4_profile_to_string(u->profile));
- if (u->profile == PROFILE_HSP)
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP)
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
data.card = u->card;
data.name = get_name("sink", u->modargs, u->address, &b);
if (!u->transport_acquired)
switch (u->profile) {
- case PROFILE_A2DP:
- case PROFILE_HSP:
+ case PA_BLUEZ4_PROFILE_A2DP:
+ case PA_BLUEZ4_PROFILE_HSP:
pa_assert_not_reached(); /* Profile switch should have failed */
break;
- case PROFILE_HFGW:
+ case PA_BLUEZ4_PROFILE_HFGW:
data.suspend_cause = PA_SUSPEND_USER;
break;
- case PROFILE_A2DP_SOURCE:
- case PROFILE_OFF:
+ case PA_BLUEZ4_PROFILE_A2DP_SOURCE:
+ case PA_BLUEZ4_PROFILE_OFF:
pa_assert_not_reached();
}
u->sink->set_port = sink_set_port_cb;
}
- if (u->profile == PROFILE_HSP) {
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP) {
pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
u->sink->n_volume_steps = 16;
data.module = u->module;
pa_source_new_data_set_sample_spec(&data, &u->sample_spec);
pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bluez4_profile_to_string(u->profile));
- if (u->profile == PROFILE_HSP)
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP)
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
data.card = u->card;
if (!u->transport_acquired)
switch (u->profile) {
- case PROFILE_HSP:
+ case PA_BLUEZ4_PROFILE_HSP:
pa_assert_not_reached(); /* Profile switch should have failed */
break;
- case PROFILE_A2DP_SOURCE:
- case PROFILE_HFGW:
+ case PA_BLUEZ4_PROFILE_A2DP_SOURCE:
+ case PA_BLUEZ4_PROFILE_HFGW:
data.suspend_cause = PA_SUSPEND_USER;
break;
- case PROFILE_A2DP:
- case PROFILE_OFF:
+ case PA_BLUEZ4_PROFILE_A2DP:
+ case PA_BLUEZ4_PROFILE_OFF:
pa_assert_not_reached();
}
u->source->set_port = source_set_port_cb;
}
- if ((u->profile == PROFILE_HSP) || (u->profile == PROFILE_HFGW)) {
+ if ((u->profile == PA_BLUEZ4_PROFILE_HSP) || (u->profile == PA_BLUEZ4_PROFILE_HFGW)) {
pa_bluez4_transport *t = u->transport;
pa_proplist_sets(u->source->proplist, "bluetooth.nrec", t->nrec ? "1" : "0");
}
- if (u->profile == PROFILE_HSP) {
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP) {
pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
u->source->n_volume_steps = 16;
a2dp->max_bitpool = config->max_bitpool;
/* Set minimum bitpool for source to get the maximum possible block_size */
- a2dp->sbc.bitpool = u->profile == PROFILE_A2DP ? a2dp->max_bitpool : a2dp->min_bitpool;
+ a2dp->sbc.bitpool = u->profile == PA_BLUEZ4_PROFILE_A2DP ? a2dp->max_bitpool : a2dp->min_bitpool;
a2dp->codesize = sbc_get_codesize(&a2dp->sbc);
a2dp->frame_length = sbc_get_frame_length(&a2dp->sbc);
}
static void bt_transport_config(struct userdata *u) {
- if (u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW) {
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP || u->profile == PA_BLUEZ4_PROFILE_HFGW) {
u->sample_spec.format = PA_SAMPLE_S16LE;
u->sample_spec.channels = 1;
u->sample_spec.rate = 8000;
pa_assert(u);
pa_assert(!u->transport);
- pa_assert(u->profile != PROFILE_OFF);
+ pa_assert(u->profile != PA_BLUEZ4_PROFILE_OFF);
/* check if profile has a transport */
t = u->device->transports[u->profile];
u->transport = t;
- if (u->profile == PROFILE_A2DP_SOURCE || u->profile == PROFILE_HFGW)
+ if (u->profile == PA_BLUEZ4_PROFILE_A2DP_SOURCE || u->profile == PA_BLUEZ4_PROFILE_HFGW)
bt_transport_acquire(u, true); /* In case of error, the sink/sources will be created suspended */
else if (bt_transport_acquire(u, false) < 0)
return -1; /* We need to fail here until the interactions with module-suspend-on-idle and alike get improved */
static int init_profile(struct userdata *u) {
int r = 0;
pa_assert(u);
- pa_assert(u->profile != PROFILE_OFF);
+ pa_assert(u->profile != PA_BLUEZ4_PROFILE_OFF);
if (setup_transport(u) < 0)
return -1;
pa_assert(u->transport);
- if (u->profile == PROFILE_A2DP ||
- u->profile == PROFILE_HSP ||
- u->profile == PROFILE_HFGW)
+ if (u->profile == PA_BLUEZ4_PROFILE_A2DP ||
+ u->profile == PA_BLUEZ4_PROFILE_HSP ||
+ u->profile == PA_BLUEZ4_PROFILE_HFGW)
if (add_sink(u) < 0)
r = -1;
- if (u->profile == PROFILE_HSP ||
- u->profile == PROFILE_A2DP_SOURCE ||
- u->profile == PROFILE_HFGW)
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP ||
+ u->profile == PA_BLUEZ4_PROFILE_A2DP_SOURCE ||
+ u->profile == PA_BLUEZ4_PROFILE_HFGW)
if (add_source(u) < 0)
r = -1;
}
if (u->sink) {
- if (u->profile == PROFILE_HSP) {
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP) {
k = pa_sprintf_malloc("bluetooth-device@%p", (void*) u->sink);
pa_shared_remove(u->core, k);
pa_xfree(k);
}
if (u->source) {
- if (u->profile == PROFILE_HSP) {
+ if (u->profile == PA_BLUEZ4_PROFILE_HSP) {
k = pa_sprintf_malloc("bluetooth-device@%p", (void*) u->source);
pa_shared_remove(u->core, k);
pa_xfree(k);
/* Run from main thread */
static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
struct userdata *u;
- enum profile *d;
+ pa_bluez4_profile_t *d;
pa_assert(c);
pa_assert(new_profile);
d = PA_CARD_PROFILE_DATA(new_profile);
- if (*d != PROFILE_OFF) {
+ if (*d != PA_BLUEZ4_PROFILE_OFF) {
const pa_bluez4_device *device = u->device;
if (!device->transports[*d] || device->transports[*d]->state == PA_BLUEZ4_TRANSPORT_STATE_DISCONNECTED) {
if (USE_SCO_OVER_PCM(u))
save_sco_volume_callbacks(u);
- if (u->profile != PROFILE_OFF)
+ if (u->profile != PA_BLUEZ4_PROFILE_OFF)
if (init_profile(u) < 0)
goto off;
static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid, pa_hashmap *ports) {
pa_device_port *input_port, *output_port;
pa_card_profile *p = NULL;
- enum profile *d;
+ pa_bluez4_profile_t *d;
pa_assert(u->input_port_name);
pa_assert(u->output_port_name);
pa_assert_se(output_port = pa_hashmap_get(ports, u->output_port_name));
if (pa_streq(uuid, A2DP_SINK_UUID)) {
- p = pa_card_profile_new("a2dp", _("High Fidelity Playback (A2DP)"), sizeof(enum profile));
+ p = pa_card_profile_new("a2dp", _("High Fidelity Playback (A2DP)"), sizeof(pa_bluez4_profile_t));
p->priority = 10;
p->n_sinks = 1;
p->n_sources = 0;
pa_hashmap_put(output_port->profiles, p->name, p);
d = PA_CARD_PROFILE_DATA(p);
- *d = PROFILE_A2DP;
+ *d = PA_BLUEZ4_PROFILE_A2DP;
} else if (pa_streq(uuid, A2DP_SOURCE_UUID)) {
- p = pa_card_profile_new("a2dp_source", _("High Fidelity Capture (A2DP)"), sizeof(enum profile));
+ p = pa_card_profile_new("a2dp_source", _("High Fidelity Capture (A2DP)"), sizeof(pa_bluez4_profile_t));
p->priority = 10;
p->n_sinks = 0;
p->n_sources = 1;
pa_hashmap_put(input_port->profiles, p->name, p);
d = PA_CARD_PROFILE_DATA(p);
- *d = PROFILE_A2DP_SOURCE;
+ *d = PA_BLUEZ4_PROFILE_A2DP_SOURCE;
} else if (pa_streq(uuid, HSP_HS_UUID) || pa_streq(uuid, HFP_HS_UUID)) {
- p = pa_card_profile_new("hsp", _("Telephony Duplex (HSP/HFP)"), sizeof(enum profile));
+ p = pa_card_profile_new("hsp", _("Telephony Duplex (HSP/HFP)"), sizeof(pa_bluez4_profile_t));
p->priority = 20;
p->n_sinks = 1;
p->n_sources = 1;
pa_hashmap_put(output_port->profiles, p->name, p);
d = PA_CARD_PROFILE_DATA(p);
- *d = PROFILE_HSP;
+ *d = PA_BLUEZ4_PROFILE_HSP;
} else if (pa_streq(uuid, HFP_AG_UUID)) {
- p = pa_card_profile_new("hfgw", _("Handsfree Gateway"), sizeof(enum profile));
+ p = pa_card_profile_new("hfgw", _("Handsfree Gateway"), sizeof(pa_bluez4_profile_t));
p->priority = 20;
p->n_sinks = 1;
p->n_sources = 1;
pa_hashmap_put(output_port->profiles, p->name, p);
d = PA_CARD_PROFILE_DATA(p);
- *d = PROFILE_HFGW;
+ *d = PA_BLUEZ4_PROFILE_HFGW;
}
if (p) {
pa_card_new_data data;
bool b;
pa_card_profile *p;
- enum profile *d;
+ pa_bluez4_profile_t *d;
pa_bluez4_form_factor_t ff;
char *n;
const char *default_profile;
pa_assert(!pa_hashmap_isempty(data.profiles));
- p = pa_card_profile_new("off", _("Off"), sizeof(enum profile));
+ p = pa_card_profile_new("off", _("Off"), sizeof(pa_bluez4_profile_t));
p->available = PA_AVAILABLE_YES;
d = PA_CARD_PROFILE_DATA(p);
- *d = PROFILE_OFF;
+ *d = PA_BLUEZ4_PROFILE_OFF;
pa_hashmap_put(data.profiles, p->name, p);
if ((default_profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
d = PA_CARD_PROFILE_DATA(u->card->active_profile);
- if (*d != PROFILE_OFF && (!device->transports[*d] ||
+ if (*d != PA_BLUEZ4_PROFILE_OFF && (!device->transports[*d] ||
device->transports[*d]->state == PA_BLUEZ4_TRANSPORT_STATE_DISCONNECTED)) {
pa_log_warn("Default profile not connected, selecting off profile");
u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");
u->msg->parent.process_msg = device_process_msg;
u->msg->card = u->card;
- if (u->profile != PROFILE_OFF)
+ if (u->profile != PA_BLUEZ4_PROFILE_OFF)
if (init_profile(u) < 0)
goto off;