diff --git a/src/context.h b/src/context.h --- a/src/context.h +++ b/src/context.h @@ -86,6 +86,9 @@ void setGenericVolume(quint32 index, int channel, qint64 newVolume, pa_cvolume cVolume, PAFunction pa_set_volume) { + if (!m_context) { + return; + } newVolume = qBound(0, newVolume, PA_VOLUME_MAX); pa_cvolume newCVolume = cVolume; if (channel == -1) { // -1 all channels @@ -105,6 +108,9 @@ template void setGenericMute(quint32 index, bool mute, PAFunction pa_set_mute) { + if (!m_context) { + return; + } if (!PAOperation(pa_set_mute(m_context, index, mute, nullptr, nullptr))) { qCWarning(PLASMAPA) << "pa_set_mute failed"; return; @@ -114,6 +120,9 @@ template void setGenericPort(quint32 index, const QString &portName, PAFunction pa_set_port) { + if (!m_context) { + return; + } if (!PAOperation(pa_set_port(m_context, index, portName.toUtf8().constData(), @@ -129,6 +138,9 @@ quint32 deviceIndex, PAFunction pa_move_stream_to_device) { + if (!m_context) { + return; + } if (!PAOperation(pa_move_stream_to_device(m_context, streamIndex, deviceIndex, diff --git a/src/context.cpp b/src/context.cpp --- a/src/context.cpp +++ b/src/context.cpp @@ -431,6 +431,9 @@ void Context::setCardProfile(quint32 index, const QString &profile) { + if (!m_context) { + return; + } qCDebug(PLASMAPA) << index << profile; if (!PAOperation(pa_context_set_card_profile_by_index(m_context, index, @@ -443,6 +446,9 @@ void Context::setDefaultSink(const QString &name) { + if (!m_context) { + return; + } const QByteArray nameData = name.toUtf8(); if (!PAOperation(pa_context_set_default_sink(m_context, nameData.constData(), @@ -454,6 +460,9 @@ void Context::setDefaultSource(const QString &name) { + if (!m_context) { + return; + } const QByteArray nameData = name.toUtf8(); if (!PAOperation(pa_context_set_default_source(m_context, nameData.constData(), @@ -465,6 +474,9 @@ void Context::streamRestoreWrite(const pa_ext_stream_restore_info *info) { + if (!m_context) { + return; + } if (!PAOperation(pa_ext_stream_restore_write(m_context, PA_UPDATE_REPLACE, info,