static gboolean gst_pulsesrc_get_stream_mute (GstPulseSrc * pulsesrc) { pa_operation *o = NULL; gboolean mute; if (!pulsesrc->mainloop) goto no_mainloop; if (pulsesrc->source_output_idx == PA_INVALID_INDEX) goto no_index; pa_threaded_mainloop_lock (pulsesrc->mainloop); if (!(o = pa_context_get_source_output_info (pulsesrc->context, pulsesrc->source_output_idx, gst_pulsesrc_source_output_info_cb, pulsesrc))) goto info_failed; while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { pa_threaded_mainloop_wait (pulsesrc->mainloop); if (gst_pulsesrc_is_dead (pulsesrc, TRUE)) goto unlock; } unlock: mute = pulsesrc->mute; if (o) pa_operation_unref (o); pa_threaded_mainloop_unlock (pulsesrc->mainloop); return mute; /* ERRORS */ no_mainloop: { mute = pulsesrc->mute; GST_DEBUG_OBJECT (pulsesrc, "we have no mainloop"); return mute; } no_index: { mute = pulsesrc->mute; GST_DEBUG_OBJECT (pulsesrc, "we don't have a stream index"); return mute; } info_failed: { GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("pa_context_get_source_output_info() failed: %s", pa_strerror (pa_context_errno (pulsesrc->context))), (NULL)); goto unlock; } }
void backend_volume_set(context_t *c, backend_entry_type type, uint32_t idx, int i, int v) { volume_callback_t *volume = (volume_callback_t*)malloc(sizeof(volume_callback_t)); volume->index = i; volume->value = v; switch(type) { case SINK: pa_context_get_sink_info_by_index(c->context, idx, _cb_s_sink, volume); break; case SINK_INPUT: pa_context_get_sink_input_info(c->context, idx, _cb_s_sink_input, volume); break; case SOURCE: pa_context_get_source_info_by_index(c->context, idx, _cb_s_source, volume); break; case SOURCE_OUTPUT: pa_context_get_source_output_info(c->context, idx, _cb_s_source_output, volume); break; default: break; } }
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; } }
static gdouble gst_pulsesrc_get_stream_volume (GstPulseSrc * pulsesrc) { pa_operation *o = NULL; gdouble v; if (!pulsesrc->mainloop) goto no_mainloop; if (pulsesrc->source_output_idx == PA_INVALID_INDEX) goto no_index; pa_threaded_mainloop_lock (pulsesrc->mainloop); if (!(o = pa_context_get_source_output_info (pulsesrc->context, pulsesrc->source_output_idx, gst_pulsesrc_source_output_info_cb, pulsesrc))) goto info_failed; while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { pa_threaded_mainloop_wait (pulsesrc->mainloop); if (gst_pulsesrc_is_dead (pulsesrc, TRUE)) goto unlock; } unlock: v = pulsesrc->volume; if (o) pa_operation_unref (o); pa_threaded_mainloop_unlock (pulsesrc->mainloop); if (v > MAX_VOLUME) { GST_WARNING_OBJECT (pulsesrc, "Clipped volume from %f to %f", v, MAX_VOLUME); v = MAX_VOLUME; } return v; /* ERRORS */ no_mainloop: { v = pulsesrc->volume; GST_DEBUG_OBJECT (pulsesrc, "we have no mainloop"); return v; } no_index: { v = pulsesrc->volume; GST_DEBUG_OBJECT (pulsesrc, "we don't have a stream index"); return v; } info_failed: { GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("pa_context_get_source_output_info() failed: %s", pa_strerror (pa_context_errno (pulsesrc->context))), (NULL)); goto unlock; } }