summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rosca <nowrep@gmail.com>2017-02-02 09:04:15 (GMT)
committerDavid Rosca <nowrep@gmail.com>2017-02-02 13:25:41 (GMT)
commit1c1a76775cb566b30aa412761494116570e7c49d (patch)
tree91f23a4e83c5e5b09374e487fbebb8f6f7ed9d01
parent1c9f50c88e969735cdf254c35ef700e34cc276ab (diff)
Always check if context is valid when calling pa functions
If pa_context is null, pulseaudio aborts. BUG: 375872 FIXED-IN: 5.8.6 Differential Revision: https://phabricator.kde.org/D4402
-rw-r--r--src/context.cpp12
-rw-r--r--src/context.h12
2 files changed, 24 insertions, 0 deletions
diff --git a/src/context.cpp b/src/context.cpp
index e56cd74..ece8cd9 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -431,6 +431,9 @@ void Context::serverCallback(const pa_server_info *info)
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::setCardProfile(quint32 index, const QString &profile)
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::setDefaultSink(const QString &name)
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::setDefaultSource(const QString &name)
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,
diff --git a/src/context.h b/src/context.h
index b53c64e..9579c44 100644
--- a/src/context.h
+++ b/src/context.h
@@ -86,6 +86,9 @@ public:
void setGenericVolume(quint32 index, int channel, qint64 newVolume,
pa_cvolume cVolume, PAFunction pa_set_volume)
{
+ if (!m_context) {
+ return;
+ }
newVolume = qBound<qint64>(0, newVolume, PA_VOLUME_MAX);
pa_cvolume newCVolume = cVolume;
if (channel == -1) { // -1 all channels
@@ -105,6 +108,9 @@ public:
template <typename PAFunction>
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 @@ public:
template <typename PAFunction>
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 @@ public:
quint32 deviceIndex,
PAFunction pa_move_stream_to_device)
{
+ if (!m_context) {
+ return;
+ }
if (!PAOperation(pa_move_stream_to_device(m_context,
streamIndex,
deviceIndex,