void on_sink_input_update(pa_context * c, const pa_sink_input_info * info, int eol, void * userdata) { if (eol) { view_update(); } else { if(info->has_volume) { if(info->index != PA_INVALID_INDEX) { sink_input_t * sink_input = sink_input_by_index(info->index); if(sink_input == NULL) { sink_input_add(info); if(info->client != PA_INVALID_INDEX) pa_context_get_client_info(c, info->client, on_client_update, NULL); } else { sink_input->volume = info->volume; if(sink_input->name == NULL || strcmp(sink_input->name, info->name) != 0) { free(sink_input->name); sink_input->name = strdup(info->name); } } } } } }
void Context::subscribeCallback(pa_context *context, pa_subscription_event_type_t type, uint32_t index) { Q_ASSERT(context == m_context); switch (type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { case PA_SUBSCRIPTION_EVENT_SINK: if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { m_sinks.removeEntry(index); } else { if (!PAOperation(pa_context_get_sink_info_by_index(context, index, sink_cb, this))) { qCWarning(PLASMAPA) << "pa_context_get_sink_info_by_index() failed"; return; } } break; case PA_SUBSCRIPTION_EVENT_SOURCE: if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { m_sources.removeEntry(index); } else { if (!PAOperation(pa_context_get_source_info_by_index(context, index, source_cb, this))) { qCWarning(PLASMAPA) << "pa_context_get_source_info_by_index() failed"; return; } } break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { m_sinkInputs.removeEntry(index); } else { if (!PAOperation(pa_context_get_sink_input_info(context, index, sink_input_callback, this))) { qCWarning(PLASMAPA) << "pa_context_get_sink_input_info() failed"; return; } } break; case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { m_sourceOutputs.removeEntry(index); } else { if (!PAOperation(pa_context_get_source_output_info(context, index, source_output_cb, this))) { qCWarning(PLASMAPA) << "pa_context_get_sink_input_info() failed"; return; } } break; case PA_SUBSCRIPTION_EVENT_CLIENT: if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { m_clients.removeEntry(index); } else { if (!PAOperation(pa_context_get_client_info(context, index, client_cb, this))) { qCWarning(PLASMAPA) << "pa_context_get_client_info() failed"; return; } } break; case PA_SUBSCRIPTION_EVENT_CARD: if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { m_cards.removeEntry(index); } else { if (!PAOperation(pa_context_get_card_info_by_index(context, index, card_cb, this))) { qCWarning(PLASMAPA) << "pa_context_get_card_info_by_index() failed"; return; } } break; case PA_SUBSCRIPTION_EVENT_SERVER: if (!PAOperation(pa_context_get_server_info(context, server_cb, this))) { qCWarning(PLASMAPA) << "pa_context_get_server_info() failed"; return; } break; } }
void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index) { switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { case PA_SUBSCRIPTION_EVENT_SINK: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) //w->removeSink(index); printf("INF: suppose to removeSink(index)\n"); else { pa_operation *o; if (!(o = pa_context_get_sink_info_by_index(c, index, sink_cb, NULL))) { //show_error("pa_context_get_sink_info_by_index() failed"); printf("func.c:<error> pa_context_get_sink_info_by_index() failed\n"); return; } pa_operation_unref(o); } break; case PA_SUBSCRIPTION_EVENT_SOURCE: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) //w->removeSource(index); printf("func.c:INF: suppose to removeSource(index)\n"); else { pa_operation *o; if (!(o = pa_context_get_source_info_by_index(c, index, source_cb, NULL))) { //show_error("pa_context_get_source_info_by_index() failed"); printf("func.c:<error> pa_context_get_source_info_by_index() failed\n"); return; } pa_operation_unref(o); } break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) //w->removeSinkInput(index); printf("func.c:INF: suppose to removeSinkInput(index)\n"); else { pa_operation *o; if (!(o = pa_context_get_sink_input_info(c, index, sink_input_cb, NULL))) { //show_error("pa_context_get_sink_input_info() failed"); printf("func.c:<error> pa_context_get_sink_input_info() failed"); return; } pa_operation_unref(o); } break; case PA_SUBSCRIPTION_EVENT_CLIENT: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) //w->removeClient(index); printf("func.c:INF: suppose to removeClient(index)\n"); else { pa_operation *o; if (!(o = pa_context_get_client_info(c, index, client_cb, NULL))) { //show_error("pa_context_get_client_info() failed"); printf("func.c:<error> pa_context_get_client_info() failed\n"); return; } pa_operation_unref(o); } break; case PA_SUBSCRIPTION_EVENT_SERVER: printf("func.c: pa_subscription_event_server triggered\n"); { pa_operation *o; if (!(o = pa_context_get_server_info(c, server_info_cb, NULL))) { //show_error("pa_context_get_server_info() failed"); printf("func.c:<error> pa_context_get_server_info() failed\n"); return; } pa_operation_unref(o); } break; } }