summaryrefslogtreecommitdiffstats
path: root/src/plugins/pulseaudio/qpulseaudioengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/pulseaudio/qpulseaudioengine.cpp')
-rw-r--r--src/plugins/pulseaudio/qpulseaudioengine.cpp65
1 files changed, 48 insertions, 17 deletions
diff --git a/src/plugins/pulseaudio/qpulseaudioengine.cpp b/src/plugins/pulseaudio/qpulseaudioengine.cpp
index 286f310b..41aba378 100644
--- a/src/plugins/pulseaudio/qpulseaudioengine.cpp
+++ b/src/plugins/pulseaudio/qpulseaudioengine.cpp
@@ -176,15 +176,30 @@ static void event_cb(pa_context* context, pa_subscription_event_type_t t, uint32
case PA_SUBSCRIPTION_EVENT_NEW:
case PA_SUBSCRIPTION_EVENT_CHANGE:
switch (facility) {
- case PA_SUBSCRIPTION_EVENT_SERVER:
- pa_operation_unref(pa_context_get_server_info(context, serverInfoCallback, userdata));
+ case PA_SUBSCRIPTION_EVENT_SERVER: {
+ pa_operation *op = pa_context_get_server_info(context, serverInfoCallback, userdata);
+ if (op)
+ pa_operation_unref(op);
+ else
+ qWarning("PulseAudioService: failed to get server info");
break;
- case PA_SUBSCRIPTION_EVENT_SINK:
- pa_operation_unref(pa_context_get_sink_info_by_index(context, index, sinkInfoCallback, userdata));
+ }
+ case PA_SUBSCRIPTION_EVENT_SINK: {
+ pa_operation *op = pa_context_get_sink_info_by_index(context, index, sinkInfoCallback, userdata);
+ if (op)
+ pa_operation_unref(op);
+ else
+ qWarning("PulseAudioService: failed to get sink info");
break;
- case PA_SUBSCRIPTION_EVENT_SOURCE:
- pa_operation_unref(pa_context_get_source_info_by_index(context, index, sourceInfoCallback, userdata));
+ }
+ case PA_SUBSCRIPTION_EVENT_SOURCE: {
+ pa_operation *op = pa_context_get_source_info_by_index(context, index, sourceInfoCallback, userdata);
+ if (op)
+ pa_operation_unref(op);
+ else
+ qWarning("PulseAudioService: failed to get source info");
break;
+ }
default:
break;
}
@@ -334,11 +349,15 @@ void QPulseAudioEngine::prepare()
pa_context_set_state_callback(m_context, contextStateCallback, this);
pa_context_set_subscribe_callback(m_context, event_cb, this);
- pa_operation_unref(pa_context_subscribe(m_context,
+ pa_operation *op = pa_context_subscribe(m_context,
pa_subscription_mask_t(PA_SUBSCRIPTION_MASK_SINK |
PA_SUBSCRIPTION_MASK_SOURCE |
PA_SUBSCRIPTION_MASK_SERVER),
- NULL, NULL));
+ NULL, NULL);
+ if (op)
+ pa_operation_unref(op);
+ else
+ qWarning("PulseAudioService: failed to subscribe to context notifications");
} else {
pa_context_unref(m_context);
m_context = 0;
@@ -382,21 +401,33 @@ void QPulseAudioEngine::updateDevices()
// Get default input and output devices
pa_operation *operation = pa_context_get_server_info(m_context, serverInfoCallback, this);
- while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
- pa_threaded_mainloop_wait(m_mainLoop);
- pa_operation_unref(operation);
+ if (operation) {
+ while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait(m_mainLoop);
+ pa_operation_unref(operation);
+ } else {
+ qWarning("PulseAudioService: failed to get server info");
+ }
// Get output devices
operation = pa_context_get_sink_info_list(m_context, sinkInfoCallback, this);
- while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
- pa_threaded_mainloop_wait(m_mainLoop);
- pa_operation_unref(operation);
+ if (operation) {
+ while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait(m_mainLoop);
+ pa_operation_unref(operation);
+ } else {
+ qWarning("PulseAudioService: failed to get sink info");
+ }
// Get input devices
operation = pa_context_get_source_info_list(m_context, sourceInfoCallback, this);
- while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
- pa_threaded_mainloop_wait(m_mainLoop);
- pa_operation_unref(operation);
+ if (operation) {
+ while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait(m_mainLoop);
+ pa_operation_unref(operation);
+ } else {
+ qWarning("PulseAudioService: failed to get source info");
+ }
unlock();
}