summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2018-03-11 11:21:10 +0100
committerAndré Hartmann <aha_1980@gmx.de>2018-03-23 10:37:31 +0000
commit58d83703d7d5435a74d59bdb906ca6a76b54f78f (patch)
tree3d60c6623235c8df131cd9b746f48326713f6a4a
parent3b1f2ac5d3b78c33392a625a134c2a09390f3fba (diff)
downloadqtmultimedia-58d83703d7d5435a74d59bdb906ca6a76b54f78f.tar.gz
QSoundEffectPrivate: Use nullptr instead 0 or NULL
Change-Id: I62e3d4d1284adeea457d754d63650b5c9b81e276 Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io> Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp70
-rw-r--r--src/multimedia/audio/qsoundeffect_qaudio_p.cpp6
2 files changed, 39 insertions, 37 deletions
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index 981d4c01f..77f8607a6 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -164,9 +164,9 @@ private Q_SLOTS:
if (m_prepared)
return;
- m_context = 0;
+ m_context = nullptr;
m_mainLoop = pa_threaded_mainloop_new();
- if (m_mainLoop == 0) {
+ if (m_mainLoop == nullptr) {
qWarning("PulseAudioService: unable to create pulseaudio mainloop");
return;
}
@@ -182,11 +182,11 @@ private Q_SLOTS:
lock();
m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toLatin1().constData());
- if (m_context == 0) {
+ if (m_context == nullptr) {
qWarning("PulseAudioService: Unable to create new pulseaudio context");
unlock();
pa_threaded_mainloop_free(m_mainLoop);
- m_mainLoop = 0;
+ m_mainLoop = nullptr;
onContextFailed();
return;
}
@@ -194,16 +194,16 @@ private Q_SLOTS:
pa_context_set_state_callback(m_context, context_state_callback, this);
const QByteArray srvStrEnv = qgetenv("QT_PULSE_SERVER_STRING");
- const char *srvStr = srvStrEnv.isNull() ? 0 : srvStrEnv.constData();
+ const char *srvStr = srvStrEnv.isNull() ? nullptr : srvStrEnv.constData();
pa_context_flags_t flags = qEnvironmentVariableIsSet("QT_PULSE_NOAUTOSPAWN") ? PA_CONTEXT_NOAUTOSPAWN : (pa_context_flags_t)0;
- if (pa_context_connect(m_context, srvStr, flags, 0) < 0) {
+ if (pa_context_connect(m_context, srvStr, flags, nullptr) < 0) {
qWarning("PulseAudioService: pa_context_connect() failed");
pa_context_unref(m_context);
unlock();
pa_threaded_mainloop_free(m_mainLoop);
- m_mainLoop = 0;
- m_context = 0;
+ m_mainLoop = nullptr;
+ m_context = nullptr;
return;
}
unlock();
@@ -226,12 +226,12 @@ private:
if (m_mainLoop) {
pa_threaded_mainloop_stop(m_mainLoop);
pa_threaded_mainloop_free(m_mainLoop);
- m_mainLoop = 0;
+ m_mainLoop = nullptr;
}
if (m_context) {
pa_context_unref(m_context);
- m_context = 0;
+ m_context = nullptr;
}
m_prepared = false;
@@ -338,7 +338,7 @@ public:
qDebug() << "QSoundEffectRef(" << this << ") notifyDeleted";
#endif
QMutexLocker locker(&m_mutex);
- m_target = NULL;
+ m_target = nullptr;
}
private:
@@ -349,7 +349,7 @@ private:
QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent),
- m_pulseStream(0),
+ m_pulseStream(nullptr),
m_sinkInputId(-1),
m_emptying(false),
m_sampleReady(false),
@@ -362,7 +362,7 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
m_loopCount(1),
m_runningCount(0),
m_reloadCategory(false),
- m_sample(0),
+ m_sample(nullptr),
m_position(0),
m_resourcesAvailable(false)
{
@@ -397,7 +397,7 @@ void QSoundEffectPrivate::release()
unloadPulseStream();
if (m_sample) {
m_sample->release();
- m_sample = 0;
+ m_sample = nullptr;
}
this->deleteLater();
@@ -435,7 +435,7 @@ void QSoundEffectPrivate::setCategory(const QString &category)
QSoundEffectPrivate::~QSoundEffectPrivate()
{
QMediaResourcePolicy::destroyResourceSet(m_resources);
- m_resources = 0;
+ m_resources = nullptr;
m_ref->release();
pulseDaemon()->deref();
@@ -474,7 +474,7 @@ void QSoundEffectPrivate::setSource(const QUrl &url)
disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady()));
}
m_sample->release();
- m_sample = 0;
+ m_sample = nullptr;
}
m_source = url;
@@ -482,9 +482,9 @@ void QSoundEffectPrivate::setSource(const QUrl &url)
setLoopsRemaining(0);
if (m_pulseStream && !pa_stream_is_corked(m_pulseStream)) {
- pa_stream_set_write_callback(m_pulseStream, 0, 0);
- pa_stream_set_underflow_callback(m_pulseStream, 0, 0);
- pa_operation *op = pa_stream_cork(m_pulseStream, 1, 0, 0);
+ pa_stream_set_write_callback(m_pulseStream, nullptr, nullptr);
+ pa_stream_set_underflow_callback(m_pulseStream, nullptr, nullptr);
+ pa_operation *op = pa_stream_cork(m_pulseStream, 1, nullptr, nullptr);
if (op)
pa_operation_unref(op);
else
@@ -676,8 +676,8 @@ void QSoundEffectPrivate::emptyStream(EmptyStreamOptions options)
PulseDaemonLocker locker;
m_emptying = true;
- pa_stream_set_write_callback(m_pulseStream, 0, 0);
- pa_stream_set_underflow_callback(m_pulseStream, 0, 0);
+ pa_stream_set_write_callback(m_pulseStream, nullptr, nullptr);
+ pa_stream_set_underflow_callback(m_pulseStream, nullptr, nullptr);
pa_operation *op = pa_stream_flush(m_pulseStream, flushCompleteCb, m_ref->getRef());
if (op)
pa_operation_unref(op);
@@ -696,7 +696,8 @@ void QSoundEffectPrivate::emptyComplete(void *stream, bool reload)
m_emptying = false;
if ((pa_stream *)stream == m_pulseStream) {
- pa_operation *op = pa_stream_cork(m_pulseStream, 1, reload ? stream_cork_callback : 0, m_ref->getRef());
+ pa_operation *op = pa_stream_cork(m_pulseStream, 1,
+ reload ? stream_cork_callback : nullptr, m_ref->getRef());
if (op)
pa_operation_unref(op);
else
@@ -780,13 +781,13 @@ void QSoundEffectPrivate::unloadPulseStream()
m_sinkInputId = -1;
PulseDaemonLocker locker;
if (m_pulseStream) {
- pa_stream_set_state_callback(m_pulseStream, 0, 0);
- pa_stream_set_write_callback(m_pulseStream, 0, 0);
- pa_stream_set_underflow_callback(m_pulseStream, 0, 0);
+ pa_stream_set_state_callback(m_pulseStream, nullptr, nullptr);
+ pa_stream_set_write_callback(m_pulseStream, nullptr, nullptr);
+ pa_stream_set_underflow_callback(m_pulseStream, nullptr, nullptr);
pa_stream_disconnect(m_pulseStream);
pa_stream_unref(m_pulseStream);
disconnect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed()));
- m_pulseStream = 0;
+ m_pulseStream = nullptr;
m_reloadCategory = false; // category will be reloaded when we connect anyway
}
}
@@ -896,7 +897,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size)
if (volume < 1.0f) {
// Don't use PulseAudio volume, as it might affect all other streams of the same category
// or even affect the system volume if flat volumes are enabled
- void *dest = NULL;
+ void *dest = nullptr;
size_t nbytes = size;
if (pa_stream_begin_write(m_pulseStream, &dest, &nbytes) < 0) {
qWarning("QSoundEffect(pulseaudio): pa_stream_begin_write, error = %s",
@@ -907,7 +908,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size)
size = int(nbytes);
QAudioHelperInternal::qMultiplySamples(volume, m_sample->format(), data, dest, size);
data = dest;
- writeDoneCb = NULL;
+ writeDoneCb = nullptr;
}
if (pa_stream_write(m_pulseStream, data, size, writeDoneCb, 0, PA_SEEK_RELATIVE) < 0) {
@@ -928,7 +929,7 @@ void QSoundEffectPrivate::playSample()
#endif
Q_ASSERT(m_pulseStream);
Q_ASSERT(pa_stream_get_state(m_pulseStream) == PA_STREAM_READY);
- pa_operation *o = pa_stream_cork(m_pulseStream, 0, 0, 0);
+ pa_operation *o = pa_stream_cork(m_pulseStream, 0, nullptr, nullptr);
if (o)
pa_operation_unref(o);
}
@@ -999,14 +1000,15 @@ void QSoundEffectPrivate::createPulseStream()
pa_proplist *propList = pa_proplist_new();
if (!m_category.isNull())
pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, m_category.toLatin1().constData());
- pa_stream *stream = pa_stream_new_with_proplist(pulseDaemon()->context(), m_name.constData(), &m_pulseSpec, 0, propList);
+ pa_stream *stream = pa_stream_new_with_proplist(pulseDaemon()->context(), m_name.constData(),
+ &m_pulseSpec, nullptr, propList);
pa_proplist_free(propList);
connect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed()));
- if (stream == 0) {
+ if (stream == nullptr) {
qWarning("QSoundEffect(pulseaudio): Failed to create stream");
- m_pulseStream = 0;
+ m_pulseStream = nullptr;
setStatus(QSoundEffect::Error);
setPlaying(false);
return;
@@ -1018,8 +1020,8 @@ void QSoundEffectPrivate::createPulseStream()
}
m_pulseStream = stream;
- if (pa_stream_connect_playback(m_pulseStream, 0, 0,
- PA_STREAM_START_CORKED, 0, 0) < 0) {
+ if (pa_stream_connect_playback(m_pulseStream, nullptr, nullptr,
+ PA_STREAM_START_CORKED, nullptr, nullptr) < 0) {
qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s",
pa_strerror(pa_context_errno(pulseDaemon()->context())));
}
diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
index 7dcbf934a..bf96f16ae 100644
--- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
@@ -129,7 +129,7 @@ void QSoundEffectPrivate::setSource(const QUrl &url)
disconnect(d->m_sample, SIGNAL(ready()), d, SLOT(sampleReady()));
}
d->m_sample->release();
- d->m_sample = 0;
+ d->m_sample = nullptr;
}
setStatus(QSoundEffect::Loading);
@@ -308,8 +308,8 @@ PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate* s):
m_runningCount(0),
m_playing(false),
m_status(QSoundEffect::Null),
- m_audioOutput(0),
- m_sample(0),
+ m_audioOutput(nullptr),
+ m_sample(nullptr),
m_muted(false),
m_volume(1.0),
m_sampleReady(false),