Commit 7ed9c78a authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files
parents d94c232a 08883397
...@@ -178,14 +178,18 @@ void PulseLayer::updateSinkList() ...@@ -178,14 +178,18 @@ void PulseLayer::updateSinkList()
{ {
sinkList_.clear(); sinkList_.clear();
enumeratingSinks_ = true; enumeratingSinks_ = true;
pa_context_get_sink_info_list(context_, sink_input_info_callback, this); pa_operation *op = pa_context_get_sink_info_list(context_, sink_input_info_callback, this);
if (op != NULL)
pa_operation_unref(op);
} }
void PulseLayer::updateSourceList() void PulseLayer::updateSourceList()
{ {
sourceList_.clear(); sourceList_.clear();
enumeratingSources_ = true; enumeratingSources_ = true;
pa_context_get_source_info_list(context_, source_input_info_callback, this); pa_operation *op = pa_context_get_source_info_list(context_, source_input_info_callback, this);
if (op != NULL)
pa_operation_unref(op);
} }
bool PulseLayer::inSinkList(const std::string &deviceName) const bool PulseLayer::inSinkList(const std::string &deviceName) const
...@@ -494,69 +498,56 @@ void PulseLayer::ringtoneToSpeaker() ...@@ -494,69 +498,56 @@ void PulseLayer::ringtoneToSpeaker()
pa_stream_write(s, data, bytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, bytes, NULL, 0, PA_SEEK_RELATIVE);
} }
void PulseLayer::context_changed_callback(pa_context* c, pa_subscription_event_type_t t, uint32_t idx UNUSED, void *userdata) void
PulseLayer::context_changed_callback(pa_context* c,
pa_subscription_event_type_t type,
uint32_t idx UNUSED, void *userdata)
{ {
PulseLayer *context = static_cast<PulseLayer*>(userdata); PulseLayer *context = static_cast<PulseLayer*>(userdata);
switch (t) { switch (type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
pa_operation *op;
case PA_SUBSCRIPTION_EVENT_SINK: case PA_SUBSCRIPTION_EVENT_SINK:
DEBUG("PA_SUBSCRIPTION_EVENT_SINK"); switch (type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) {
context->sinkList_.clear(); case PA_SUBSCRIPTION_EVENT_NEW:
pa_context_get_sink_info_list(c, sink_input_info_callback, userdata); case PA_SUBSCRIPTION_EVENT_REMOVE:
DEBUG("Updating sink list");
context->sinkList_.clear();
op = pa_context_get_sink_info_list(c, sink_input_info_callback, userdata);
if (op != NULL)
pa_operation_unref(op);
default:
break;
}
break; break;
case PA_SUBSCRIPTION_EVENT_SOURCE: case PA_SUBSCRIPTION_EVENT_SOURCE:
DEBUG("PA_SUBSCRIPTION_EVENT_SOURCE"); switch (type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) {
context->sourceList_.clear(); case PA_SUBSCRIPTION_EVENT_NEW:
pa_context_get_source_info_list(c, source_input_info_callback, userdata); case PA_SUBSCRIPTION_EVENT_REMOVE:
break; DEBUG("Updating source list");
case PA_SUBSCRIPTION_EVENT_SINK_INPUT: context->sourceList_.clear();
DEBUG("PA_SUBSCRIPTION_EVENT_SINK_INPUT"); op = pa_context_get_source_info_list(c, source_input_info_callback, userdata);
break; if (op != NULL)
case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: pa_operation_unref(op);
DEBUG("PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT"); default:
break; break;
case PA_SUBSCRIPTION_EVENT_MODULE: }
DEBUG("PA_SUBSCRIPTION_EVENT_MODULE");
break;
case PA_SUBSCRIPTION_EVENT_CLIENT:
DEBUG("PA_SUBSCRIPTION_EVENT_CLIENT");
break;
case PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE:
DEBUG("PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE");
break;
case PA_SUBSCRIPTION_EVENT_SERVER:
DEBUG("PA_SUBSCRIPTION_EVENT_SERVER");
break;
case PA_SUBSCRIPTION_EVENT_CARD:
DEBUG("PA_SUBSCRIPTION_EVENT_CARD");
break;
case PA_SUBSCRIPTION_EVENT_FACILITY_MASK:
DEBUG("PA_SUBSCRIPTION_EVENT_FACILITY_MASK");
break;
case PA_SUBSCRIPTION_EVENT_CHANGE:
DEBUG("PA_SUBSCRIPTION_EVENT_CHANGE");
break;
case PA_SUBSCRIPTION_EVENT_REMOVE:
DEBUG("PA_SUBSCRIPTION_EVENT_REMOVE");
context->sinkList_.clear();
context->sourceList_.clear();
pa_context_get_sink_info_list(c, sink_input_info_callback, userdata);
pa_context_get_source_info_list(c, source_input_info_callback, userdata);
break;
case PA_SUBSCRIPTION_EVENT_TYPE_MASK:
DEBUG("PA_SUBSCRIPTION_EVENT_TYPE_MASK");
break; break;
default: default:
DEBUG("Unknown event type 0x%x", t); DEBUG("Unhandled event type 0x%x", type);
break;
} }
} }
void PulseLayer::source_input_info_callback(pa_context *c UNUSED, const pa_source_info *i, int eol, void *userdata) void PulseLayer::source_input_info_callback(pa_context *c UNUSED, const pa_source_info *i, int eol, void *userdata)
{ {
char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
PulseLayer *context = static_cast<PulseLayer*>(userdata);
if (eol) { if (eol) {
static_cast<PulseLayer *>(userdata)->enumeratingSources_ = false; context->enumeratingSources_ = false;
return; return;
} }
...@@ -585,15 +576,16 @@ void PulseLayer::source_input_info_callback(pa_context *c UNUSED, const pa_sourc ...@@ -585,15 +576,16 @@ void PulseLayer::source_input_info_callback(pa_context *c UNUSED, const pa_sourc
i->flags & PA_SOURCE_LATENCY ? "LATENCY " : "", i->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
i->flags & PA_SOURCE_HARDWARE ? "HARDWARE" : ""); i->flags & PA_SOURCE_HARDWARE ? "HARDWARE" : "");
static_cast<PulseLayer *>(userdata)->sourceList_.push_back(i->name); context->sourceList_.push_back(i->name);
} }
void PulseLayer::sink_input_info_callback(pa_context *c UNUSED, const pa_sink_info *i, int eol, void *userdata) void PulseLayer::sink_input_info_callback(pa_context *c UNUSED, const pa_sink_info *i, int eol, void *userdata)
{ {
char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
PulseLayer *context = static_cast<PulseLayer*>(userdata);
if (eol) { if (eol) {
static_cast<PulseLayer *>(userdata)->enumeratingSinks_ = false; context->enumeratingSinks_ = false;
return; return;
} }
...@@ -622,7 +614,7 @@ void PulseLayer::sink_input_info_callback(pa_context *c UNUSED, const pa_sink_in ...@@ -622,7 +614,7 @@ void PulseLayer::sink_input_info_callback(pa_context *c UNUSED, const pa_sink_in
i->flags & PA_SINK_LATENCY ? "LATENCY " : "", i->flags & PA_SINK_LATENCY ? "LATENCY " : "",
i->flags & PA_SINK_HARDWARE ? "HARDWARE" : ""); i->flags & PA_SINK_HARDWARE ? "HARDWARE" : "");
static_cast<PulseLayer *>(userdata)->sinkList_.push_back(i->name); context->sinkList_.push_back(i->name);
} }
void PulseLayer::updatePreference(AudioPreference &preference, int index, PCMType type) void PulseLayer::updatePreference(AudioPreference &preference, int index, PCMType type)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment