static void handle_source_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata);
-enum device_type {
- DEVICE_TYPE_SINK,
- DEVICE_TYPE_SOURCE
-};
-
struct pa_dbusiface_device {
pa_dbusiface_core *core;
pa_sink *sink;
pa_source *source;
};
- enum device_type type;
+ pa_device_type_t type;
char *path;
pa_cvolume volume;
dbus_bool_t mute;
pa_assert(msg);
pa_assert(d);
- idx = (d->type == DEVICE_TYPE_SINK) ? d->sink->index : d->source->index;
+ idx = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->index : d->source->index;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &idx);
}
pa_assert(msg);
pa_assert(d);
- name = (d->type == DEVICE_TYPE_SINK) ? d->sink->name : d->source->name;
+ name = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->name : d->source->name;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_STRING, &name);
}
pa_assert(msg);
pa_assert(d);
- driver = (d->type == DEVICE_TYPE_SINK) ? d->sink->driver : d->source->driver;
+ driver = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->driver : d->source->driver;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_STRING, &driver);
}
pa_assert(msg);
pa_assert(d);
- owner_module = (d->type == DEVICE_TYPE_SINK) ? d->sink->module : d->source->module;
+ owner_module = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->module : d->source->module;
if (!owner_module) {
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
"Sink %s doesn't have an owner module.", d->sink->name);
else
pa_assert(msg);
pa_assert(d);
- card = (d->type == DEVICE_TYPE_SINK) ? d->sink->card : d->source->card;
+ card = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->card : d->source->card;
if (!card) {
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
"Sink %s doesn't belong to any card.", d->sink->name);
else
pa_assert(msg);
pa_assert(d);
- sample_format = (d->type == DEVICE_TYPE_SINK) ? d->sink->sample_spec.format : d->source->sample_spec.format;
+ sample_format = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->sample_spec.format : d->source->sample_spec.format;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &sample_format);
}
pa_assert(msg);
pa_assert(d);
- sample_rate = (d->type == DEVICE_TYPE_SINK) ? d->sink->sample_spec.rate : d->source->sample_spec.rate;
+ sample_rate = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->sample_spec.rate : d->source->sample_spec.rate;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &sample_rate);
}
pa_assert(msg);
pa_assert(d);
- channel_map = (d->type == DEVICE_TYPE_SINK) ? &d->sink->channel_map : &d->source->channel_map;
+ channel_map = (d->type == PA_DEVICE_TYPE_SINK) ? &d->sink->channel_map : &d->source->channel_map;
for (i = 0; i < channel_map->channels; ++i)
channels[i] = channel_map->map[i];
pa_assert(iter);
pa_assert(d);
- device_channels = (d->type == DEVICE_TYPE_SINK) ? d->sink->channel_map.channels : d->source->channel_map.channels;
+ device_channels = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->channel_map.channels : d->source->channel_map.channels;
dbus_message_iter_recurse(iter, &array_iter);
dbus_message_iter_get_fixed_array(&array_iter, &volume, &n_volume_entries);
new_vol.values[i] = volume[i];
}
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_sink_set_volume(d->sink, &new_vol, TRUE, TRUE);
else
pa_source_set_volume(d->source, &new_vol, TRUE, TRUE);
pa_assert(msg);
pa_assert(d);
- has_flat_volume = (d->type == DEVICE_TYPE_SINK) ? (d->sink->flags & PA_SINK_FLAT_VOLUME) : FALSE;
+ has_flat_volume = (d->type == PA_DEVICE_TYPE_SINK) ? (d->sink->flags & PA_SINK_FLAT_VOLUME) : FALSE;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_BOOLEAN, &has_flat_volume);
}
pa_assert(msg);
pa_assert(d);
- has_convertible_to_decibel_volume = (d->type == DEVICE_TYPE_SINK)
+ has_convertible_to_decibel_volume = (d->type == PA_DEVICE_TYPE_SINK)
? (d->sink->flags & PA_SINK_DECIBEL_VOLUME)
: (d->source->flags & PA_SOURCE_DECIBEL_VOLUME);
pa_assert(msg);
pa_assert(d);
- base_volume = (d->type == DEVICE_TYPE_SINK) ? d->sink->base_volume : d->source->base_volume;
+ base_volume = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->base_volume : d->source->base_volume;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &base_volume);
}
pa_assert(msg);
pa_assert(d);
- volume_steps = (d->type == DEVICE_TYPE_SINK) ? d->sink->n_volume_steps : d->source->n_volume_steps;
+ volume_steps = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->n_volume_steps : d->source->n_volume_steps;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &volume_steps);
}
dbus_message_iter_get_basic(iter, &mute);
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_sink_set_mute(d->sink, mute, TRUE);
else
pa_source_set_mute(d->source, mute, TRUE);
pa_assert(msg);
pa_assert(d);
- has_hardware_volume = (d->type == DEVICE_TYPE_SINK)
+ has_hardware_volume = (d->type == PA_DEVICE_TYPE_SINK)
? (d->sink->flags & PA_SINK_HW_VOLUME_CTRL)
: (d->source->flags & PA_SOURCE_HW_VOLUME_CTRL);
pa_assert(msg);
pa_assert(d);
- has_hardware_mute = (d->type == DEVICE_TYPE_SINK)
+ has_hardware_mute = (d->type == PA_DEVICE_TYPE_SINK)
? (d->sink->flags & PA_SINK_HW_MUTE_CTRL)
: (d->source->flags & PA_SOURCE_HW_MUTE_CTRL);
pa_assert(msg);
pa_assert(d);
- configured_latency = (d->type == DEVICE_TYPE_SINK)
+ configured_latency = (d->type == PA_DEVICE_TYPE_SINK)
? pa_sink_get_requested_latency(d->sink)
: pa_source_get_requested_latency(d->source);
pa_assert(msg);
pa_assert(d);
- has_dynamic_latency = (d->type == DEVICE_TYPE_SINK)
+ has_dynamic_latency = (d->type == PA_DEVICE_TYPE_SINK)
? (d->sink->flags & PA_SINK_DYNAMIC_LATENCY)
: (d->source->flags & PA_SOURCE_DYNAMIC_LATENCY);
pa_assert(msg);
pa_assert(d);
- if (d->type == DEVICE_TYPE_SINK && !(d->sink->flags & PA_SINK_LATENCY))
+ if (d->type == PA_DEVICE_TYPE_SINK && !(d->sink->flags & PA_SINK_LATENCY))
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
"Sink %s doesn't support latency querying.", d->sink->name);
- else if (d->type == DEVICE_TYPE_SOURCE && !(d->source->flags & PA_SOURCE_LATENCY))
+ else if (d->type == PA_DEVICE_TYPE_SOURCE && !(d->source->flags & PA_SOURCE_LATENCY))
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
"Source %s doesn't support latency querying.", d->source->name);
return;
- latency = (d->type == DEVICE_TYPE_SINK) ? pa_sink_get_latency(d->sink) : pa_source_get_latency(d->source);
+ latency = (d->type == PA_DEVICE_TYPE_SINK) ? pa_sink_get_latency(d->sink) : pa_source_get_latency(d->source);
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT64, &latency);
}
pa_assert(msg);
pa_assert(d);
- is_hardware_device = (d->type == DEVICE_TYPE_SINK)
+ is_hardware_device = (d->type == PA_DEVICE_TYPE_SINK)
? (d->sink->flags & PA_SINK_HARDWARE)
: (d->source->flags & PA_SOURCE_HARDWARE);
pa_assert(msg);
pa_assert(d);
- is_network_device = (d->type == DEVICE_TYPE_SINK)
+ is_network_device = (d->type == PA_DEVICE_TYPE_SINK)
? (d->sink->flags & PA_SINK_NETWORK)
: (d->source->flags & PA_SOURCE_NETWORK);
pa_assert(msg);
pa_assert(d);
- state = (d->type == DEVICE_TYPE_SINK) ? d->sink_state : d->source_state;
+ state = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink_state : d->source_state;
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &state);
}
if (!d->active_port) {
pa_assert(pa_hashmap_isempty(d->ports));
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
"The sink %s has no ports, and therefore there's no active port either.", d->sink->name);
else
if (!d->active_port) {
pa_assert(pa_hashmap_isempty(d->ports));
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
"The sink %s has no ports, and therefore there's no active port either.", d->sink->name);
else
return;
}
- if (d->type == DEVICE_TYPE_SINK) {
+ if (d->type == PA_DEVICE_TYPE_SINK) {
if ((r = pa_sink_set_port(d->sink, pa_dbusiface_device_port_get_name(new_active), TRUE)) < 0) {
pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED,
"Internal error in PulseAudio: pa_sink_set_port() failed with error code %i.", r);
pa_assert(msg);
pa_assert(d);
- if (d->type == DEVICE_TYPE_SINK) {
+ if (d->type == PA_DEVICE_TYPE_SINK) {
idx = d->sink->index;
name = d->sink->name;
driver = d->sink->driver;
pa_assert_se(dbus_message_get_args(msg, NULL, DBUS_TYPE_BOOLEAN, &suspend, DBUS_TYPE_INVALID));
- if ((d->type == DEVICE_TYPE_SINK) && (pa_sink_suspend(d->sink, suspend, PA_SUSPEND_USER) < 0)) {
+ if ((d->type == PA_DEVICE_TYPE_SINK) && (pa_sink_suspend(d->sink, suspend, PA_SUSPEND_USER) < 0)) {
pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "Internal error in PulseAudio: pa_sink_suspend() failed.");
return;
- } else if ((d->type == DEVICE_TYPE_SOURCE) && (pa_source_suspend(d->source, suspend, PA_SUSPEND_USER) < 0)) {
+ } else if ((d->type == PA_DEVICE_TYPE_SOURCE) && (pa_source_suspend(d->source, suspend, PA_SUSPEND_USER) < 0)) {
pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "Internal error in PulseAudio: pa_source_suspend() failed.");
return;
}
pa_assert_se(dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &port_name, DBUS_TYPE_INVALID));
if (!(port = pa_hashmap_get(d->ports, port_name))) {
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NOT_FOUND,
"%s: No such port on sink %s.", port_name, d->sink->name);
else
pa_assert(conn);
pa_assert(msg);
pa_assert(d);
- pa_assert(d->type == DEVICE_TYPE_SINK);
+ pa_assert(d->type == PA_DEVICE_TYPE_SINK);
monitor_source = pa_dbusiface_core_get_source_path(d->core, d->sink->monitor_source);
pa_assert(conn);
pa_assert(msg);
pa_assert(d);
- pa_assert(d->type == DEVICE_TYPE_SINK);
+ pa_assert(d->type == PA_DEVICE_TYPE_SINK);
monitor_source = pa_dbusiface_core_get_source_path(d->core, d->sink->monitor_source);
pa_assert(conn);
pa_assert(msg);
pa_assert(d);
- pa_assert(d->type == DEVICE_TYPE_SOURCE);
+ pa_assert(d->type == PA_DEVICE_TYPE_SOURCE);
if (!d->source->monitor_of) {
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY, "Source %s is not a monitor source.", d->source->name);
pa_assert(conn);
pa_assert(msg);
pa_assert(d);
- pa_assert(d->type == DEVICE_TYPE_SOURCE);
+ pa_assert(d->type == PA_DEVICE_TYPE_SOURCE);
if (d->source->monitor_of)
monitor_of_sink = pa_dbusiface_core_get_sink_path(d->core, d->source->monitor_of);
pa_assert(c);
pa_assert(d);
- if ((d->type == DEVICE_TYPE_SINK && idx != d->sink->index) || (d->type == DEVICE_TYPE_SOURCE && idx != d->source->index))
+ if ((d->type == PA_DEVICE_TYPE_SINK && idx != d->sink->index) || (d->type == PA_DEVICE_TYPE_SOURCE && idx != d->source->index))
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) != PA_SUBSCRIPTION_EVENT_CHANGE)
return;
- pa_assert(((d->type == DEVICE_TYPE_SINK)
+ pa_assert(((d->type == PA_DEVICE_TYPE_SINK)
&& ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK))
- || ((d->type == DEVICE_TYPE_SOURCE)
+ || ((d->type == PA_DEVICE_TYPE_SOURCE)
&& ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE)));
- new_volume = (d->type == DEVICE_TYPE_SINK)
+ new_volume = (d->type == PA_DEVICE_TYPE_SINK)
? pa_sink_get_volume(d->sink, FALSE)
: pa_source_get_volume(d->source, FALSE);
signal_msg = NULL;
}
- new_mute = (d->type == DEVICE_TYPE_SINK) ? pa_sink_get_mute(d->sink, FALSE) : pa_source_get_mute(d->source, FALSE);
+ new_mute = (d->type == PA_DEVICE_TYPE_SINK) ? pa_sink_get_mute(d->sink, FALSE) : pa_source_get_mute(d->source, FALSE);
if (d->mute != new_mute) {
d->mute = new_mute;
signal_msg = NULL;
}
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
new_sink_state = pa_sink_get_state(d->sink);
else
new_source_state = pa_source_get_state(d->source);
- if ((d->type == DEVICE_TYPE_SINK && d->sink_state != new_sink_state)
- || (d->type == DEVICE_TYPE_SOURCE && d->source_state != new_source_state)) {
+ if ((d->type == PA_DEVICE_TYPE_SINK && d->sink_state != new_sink_state)
+ || (d->type == PA_DEVICE_TYPE_SOURCE && d->source_state != new_source_state)) {
dbus_uint32_t state = 0;
- if (d->type == DEVICE_TYPE_SINK)
+ if (d->type == PA_DEVICE_TYPE_SINK)
d->sink_state = new_sink_state;
else
d->source_state = new_source_state;
- state = (d->type == DEVICE_TYPE_SINK) ? d->sink_state : d->source_state;
+ state = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink_state : d->source_state;
pa_assert_se(signal_msg = dbus_message_new_signal(d->path,
PA_DBUSIFACE_DEVICE_INTERFACE,
signal_msg = NULL;
}
- new_active_port = (d->type == DEVICE_TYPE_SINK) ? d->sink->active_port : d->source->active_port;
+ new_active_port = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->active_port : d->source->active_port;
if (d->active_port != new_active_port) {
const char *object_path = NULL;
signal_msg = NULL;
}
- new_proplist = (d->type == DEVICE_TYPE_SINK) ? d->sink->proplist : d->source->proplist;
+ new_proplist = (d->type == PA_DEVICE_TYPE_SINK) ? d->sink->proplist : d->source->proplist;
if (!pa_proplist_equal(d->proplist, new_proplist)) {
DBusMessageIter msg_iter;
d = pa_xnew0(pa_dbusiface_device, 1);
d->core = core;
d->sink = pa_sink_ref(sink);
- d->type = DEVICE_TYPE_SINK;
+ d->type = PA_DEVICE_TYPE_SINK;
d->path = pa_sprintf_malloc("%s/%s%u", PA_DBUS_CORE_OBJECT_PATH, SINK_OBJECT_NAME, sink->index);
d->volume = *pa_sink_get_volume(sink, FALSE);
d->mute = pa_sink_get_mute(sink, FALSE);
d = pa_xnew0(pa_dbusiface_device, 1);
d->core = core;
d->source = pa_source_ref(source);
- d->type = DEVICE_TYPE_SOURCE;
+ d->type = PA_DEVICE_TYPE_SOURCE;
d->path = pa_sprintf_malloc("%s/%s%u", PA_DBUS_CORE_OBJECT_PATH, SOURCE_OBJECT_NAME, source->index);
d->volume = *pa_source_get_volume(source, FALSE);
d->mute = pa_source_get_mute(source, FALSE);
pa_assert_se(pa_dbus_protocol_remove_interface(d->dbus_protocol, d->path, device_interface_info.name) >= 0);
- if (d->type == DEVICE_TYPE_SINK) {
+ if (d->type == PA_DEVICE_TYPE_SINK) {
pa_assert_se(pa_dbus_protocol_remove_interface(d->dbus_protocol, d->path, sink_interface_info.name) >= 0);
pa_sink_unref(d->sink);
pa_sink *pa_dbusiface_device_get_sink(pa_dbusiface_device *d) {
pa_assert(d);
- pa_assert(d->type == DEVICE_TYPE_SINK);
+ pa_assert(d->type == PA_DEVICE_TYPE_SINK);
return d->sink;
}
pa_source *pa_dbusiface_device_get_source(pa_dbusiface_device *d) {
pa_assert(d);
- pa_assert(d->type == DEVICE_TYPE_SOURCE);
+ pa_assert(d->type == PA_DEVICE_TYPE_SOURCE);
return d->source;
}