Commit 58d83703 authored by Andre Hartmann's avatar Andre Hartmann Committed by André Hartmann
Browse files

QSoundEffectPrivate: Use nullptr instead 0 or NULL


Change-Id: I62e3d4d1284adeea457d754d63650b5c9b81e276
Reviewed-by: default avatarVaL Doroshchuk <valentyn.doroshchuk@qt.io>
Reviewed-by: default avatarChristian Stromme <christian.stromme@qt.io>
Showing with 39 additions and 37 deletions
...@@ -164,9 +164,9 @@ private Q_SLOTS: ...@@ -164,9 +164,9 @@ private Q_SLOTS:
if (m_prepared) if (m_prepared)
return; return;
m_context = 0; m_context = nullptr;
m_mainLoop = pa_threaded_mainloop_new(); m_mainLoop = pa_threaded_mainloop_new();
if (m_mainLoop == 0) { if (m_mainLoop == nullptr) {
qWarning("PulseAudioService: unable to create pulseaudio mainloop"); qWarning("PulseAudioService: unable to create pulseaudio mainloop");
return; return;
} }
...@@ -182,11 +182,11 @@ private Q_SLOTS: ...@@ -182,11 +182,11 @@ private Q_SLOTS:
lock(); lock();
m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toLatin1().constData()); 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"); qWarning("PulseAudioService: Unable to create new pulseaudio context");
unlock(); unlock();
pa_threaded_mainloop_free(m_mainLoop); pa_threaded_mainloop_free(m_mainLoop);
m_mainLoop = 0; m_mainLoop = nullptr;
onContextFailed(); onContextFailed();
return; return;
} }
...@@ -194,16 +194,16 @@ private Q_SLOTS: ...@@ -194,16 +194,16 @@ private Q_SLOTS:
pa_context_set_state_callback(m_context, context_state_callback, this); pa_context_set_state_callback(m_context, context_state_callback, this);
const QByteArray srvStrEnv = qgetenv("QT_PULSE_SERVER_STRING"); 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; 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"); qWarning("PulseAudioService: pa_context_connect() failed");
pa_context_unref(m_context); pa_context_unref(m_context);
unlock(); unlock();
pa_threaded_mainloop_free(m_mainLoop); pa_threaded_mainloop_free(m_mainLoop);
m_mainLoop = 0; m_mainLoop = nullptr;
m_context = 0; m_context = nullptr;
return; return;
} }
unlock(); unlock();
...@@ -226,12 +226,12 @@ private: ...@@ -226,12 +226,12 @@ private:
if (m_mainLoop) { if (m_mainLoop) {
pa_threaded_mainloop_stop(m_mainLoop); pa_threaded_mainloop_stop(m_mainLoop);
pa_threaded_mainloop_free(m_mainLoop); pa_threaded_mainloop_free(m_mainLoop);
m_mainLoop = 0; m_mainLoop = nullptr;
} }
if (m_context) { if (m_context) {
pa_context_unref(m_context); pa_context_unref(m_context);
m_context = 0; m_context = nullptr;
} }
m_prepared = false; m_prepared = false;
...@@ -338,7 +338,7 @@ public: ...@@ -338,7 +338,7 @@ public:
qDebug() << "QSoundEffectRef(" << this << ") notifyDeleted"; qDebug() << "QSoundEffectRef(" << this << ") notifyDeleted";
#endif #endif
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
m_target = NULL; m_target = nullptr;
} }
private: private:
...@@ -349,7 +349,7 @@ private: ...@@ -349,7 +349,7 @@ private:
QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent), QObject(parent),
m_pulseStream(0), m_pulseStream(nullptr),
m_sinkInputId(-1), m_sinkInputId(-1),
m_emptying(false), m_emptying(false),
m_sampleReady(false), m_sampleReady(false),
...@@ -362,7 +362,7 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): ...@@ -362,7 +362,7 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
m_loopCount(1), m_loopCount(1),
m_runningCount(0), m_runningCount(0),
m_reloadCategory(false), m_reloadCategory(false),
m_sample(0), m_sample(nullptr),
m_position(0), m_position(0),
m_resourcesAvailable(false) m_resourcesAvailable(false)
{ {
...@@ -397,7 +397,7 @@ void QSoundEffectPrivate::release() ...@@ -397,7 +397,7 @@ void QSoundEffectPrivate::release()
unloadPulseStream(); unloadPulseStream();
if (m_sample) { if (m_sample) {
m_sample->release(); m_sample->release();
m_sample = 0; m_sample = nullptr;
} }
this->deleteLater(); this->deleteLater();
...@@ -435,7 +435,7 @@ void QSoundEffectPrivate::setCategory(const QString &category) ...@@ -435,7 +435,7 @@ void QSoundEffectPrivate::setCategory(const QString &category)
QSoundEffectPrivate::~QSoundEffectPrivate() QSoundEffectPrivate::~QSoundEffectPrivate()
{ {
QMediaResourcePolicy::destroyResourceSet(m_resources); QMediaResourcePolicy::destroyResourceSet(m_resources);
m_resources = 0; m_resources = nullptr;
m_ref->release(); m_ref->release();
pulseDaemon()->deref(); pulseDaemon()->deref();
...@@ -474,7 +474,7 @@ void QSoundEffectPrivate::setSource(const QUrl &url) ...@@ -474,7 +474,7 @@ void QSoundEffectPrivate::setSource(const QUrl &url)
disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady()));
} }
m_sample->release(); m_sample->release();
m_sample = 0; m_sample = nullptr;
} }
m_source = url; m_source = url;
...@@ -482,9 +482,9 @@ void QSoundEffectPrivate::setSource(const QUrl &url) ...@@ -482,9 +482,9 @@ void QSoundEffectPrivate::setSource(const QUrl &url)
setLoopsRemaining(0); setLoopsRemaining(0);
if (m_pulseStream && !pa_stream_is_corked(m_pulseStream)) { if (m_pulseStream && !pa_stream_is_corked(m_pulseStream)) {
pa_stream_set_write_callback(m_pulseStream, 0, 0); pa_stream_set_write_callback(m_pulseStream, nullptr, nullptr);
pa_stream_set_underflow_callback(m_pulseStream, 0, 0); pa_stream_set_underflow_callback(m_pulseStream, nullptr, nullptr);
pa_operation *op = pa_stream_cork(m_pulseStream, 1, 0, 0); pa_operation *op = pa_stream_cork(m_pulseStream, 1, nullptr, nullptr);
if (op) if (op)
pa_operation_unref(op); pa_operation_unref(op);
else else
...@@ -676,8 +676,8 @@ void QSoundEffectPrivate::emptyStream(EmptyStreamOptions options) ...@@ -676,8 +676,8 @@ void QSoundEffectPrivate::emptyStream(EmptyStreamOptions options)
PulseDaemonLocker locker; PulseDaemonLocker locker;
m_emptying = true; m_emptying = true;
pa_stream_set_write_callback(m_pulseStream, 0, 0); pa_stream_set_write_callback(m_pulseStream, nullptr, nullptr);
pa_stream_set_underflow_callback(m_pulseStream, 0, 0); pa_stream_set_underflow_callback(m_pulseStream, nullptr, nullptr);
pa_operation *op = pa_stream_flush(m_pulseStream, flushCompleteCb, m_ref->getRef()); pa_operation *op = pa_stream_flush(m_pulseStream, flushCompleteCb, m_ref->getRef());
if (op) if (op)
pa_operation_unref(op); pa_operation_unref(op);
...@@ -696,7 +696,8 @@ void QSoundEffectPrivate::emptyComplete(void *stream, bool reload) ...@@ -696,7 +696,8 @@ void QSoundEffectPrivate::emptyComplete(void *stream, bool reload)
m_emptying = false; m_emptying = false;
if ((pa_stream *)stream == m_pulseStream) { 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) if (op)
pa_operation_unref(op); pa_operation_unref(op);
else else
...@@ -780,13 +781,13 @@ void QSoundEffectPrivate::unloadPulseStream() ...@@ -780,13 +781,13 @@ void QSoundEffectPrivate::unloadPulseStream()
m_sinkInputId = -1; m_sinkInputId = -1;
PulseDaemonLocker locker; PulseDaemonLocker locker;
if (m_pulseStream) { if (m_pulseStream) {
pa_stream_set_state_callback(m_pulseStream, 0, 0); pa_stream_set_state_callback(m_pulseStream, nullptr, nullptr);
pa_stream_set_write_callback(m_pulseStream, 0, 0); pa_stream_set_write_callback(m_pulseStream, nullptr, nullptr);
pa_stream_set_underflow_callback(m_pulseStream, 0, 0); pa_stream_set_underflow_callback(m_pulseStream, nullptr, nullptr);
pa_stream_disconnect(m_pulseStream); pa_stream_disconnect(m_pulseStream);
pa_stream_unref(m_pulseStream); pa_stream_unref(m_pulseStream);
disconnect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed())); disconnect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed()));
m_pulseStream = 0; m_pulseStream = nullptr;
m_reloadCategory = false; // category will be reloaded when we connect anyway m_reloadCategory = false; // category will be reloaded when we connect anyway
} }
} }
...@@ -896,7 +897,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size) ...@@ -896,7 +897,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size)
if (volume < 1.0f) { if (volume < 1.0f) {
// Don't use PulseAudio volume, as it might affect all other streams of the same category // 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 // or even affect the system volume if flat volumes are enabled
void *dest = NULL; void *dest = nullptr;
size_t nbytes = size; size_t nbytes = size;
if (pa_stream_begin_write(m_pulseStream, &dest, &nbytes) < 0) { if (pa_stream_begin_write(m_pulseStream, &dest, &nbytes) < 0) {
qWarning("QSoundEffect(pulseaudio): pa_stream_begin_write, error = %s", qWarning("QSoundEffect(pulseaudio): pa_stream_begin_write, error = %s",
...@@ -907,7 +908,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size) ...@@ -907,7 +908,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size)
size = int(nbytes); size = int(nbytes);
QAudioHelperInternal::qMultiplySamples(volume, m_sample->format(), data, dest, size); QAudioHelperInternal::qMultiplySamples(volume, m_sample->format(), data, dest, size);
data = dest; data = dest;
writeDoneCb = NULL; writeDoneCb = nullptr;
} }
if (pa_stream_write(m_pulseStream, data, size, writeDoneCb, 0, PA_SEEK_RELATIVE) < 0) { if (pa_stream_write(m_pulseStream, data, size, writeDoneCb, 0, PA_SEEK_RELATIVE) < 0) {
...@@ -928,7 +929,7 @@ void QSoundEffectPrivate::playSample() ...@@ -928,7 +929,7 @@ void QSoundEffectPrivate::playSample()
#endif #endif
Q_ASSERT(m_pulseStream); Q_ASSERT(m_pulseStream);
Q_ASSERT(pa_stream_get_state(m_pulseStream) == PA_STREAM_READY); 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) if (o)
pa_operation_unref(o); pa_operation_unref(o);
} }
...@@ -999,14 +1000,15 @@ void QSoundEffectPrivate::createPulseStream() ...@@ -999,14 +1000,15 @@ void QSoundEffectPrivate::createPulseStream()
pa_proplist *propList = pa_proplist_new(); pa_proplist *propList = pa_proplist_new();
if (!m_category.isNull()) if (!m_category.isNull())
pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, m_category.toLatin1().constData()); 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); pa_proplist_free(propList);
connect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed())); connect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed()));
if (stream == 0) { if (stream == nullptr) {
qWarning("QSoundEffect(pulseaudio): Failed to create stream"); qWarning("QSoundEffect(pulseaudio): Failed to create stream");
m_pulseStream = 0; m_pulseStream = nullptr;
setStatus(QSoundEffect::Error); setStatus(QSoundEffect::Error);
setPlaying(false); setPlaying(false);
return; return;
...@@ -1018,8 +1020,8 @@ void QSoundEffectPrivate::createPulseStream() ...@@ -1018,8 +1020,8 @@ void QSoundEffectPrivate::createPulseStream()
} }
m_pulseStream = stream; m_pulseStream = stream;
if (pa_stream_connect_playback(m_pulseStream, 0, 0, if (pa_stream_connect_playback(m_pulseStream, nullptr, nullptr,
PA_STREAM_START_CORKED, 0, 0) < 0) { PA_STREAM_START_CORKED, nullptr, nullptr) < 0) {
qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s", qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s",
pa_strerror(pa_context_errno(pulseDaemon()->context()))); pa_strerror(pa_context_errno(pulseDaemon()->context())));
} }
......
...@@ -129,7 +129,7 @@ void QSoundEffectPrivate::setSource(const QUrl &url) ...@@ -129,7 +129,7 @@ void QSoundEffectPrivate::setSource(const QUrl &url)
disconnect(d->m_sample, SIGNAL(ready()), d, SLOT(sampleReady())); disconnect(d->m_sample, SIGNAL(ready()), d, SLOT(sampleReady()));
} }
d->m_sample->release(); d->m_sample->release();
d->m_sample = 0; d->m_sample = nullptr;
} }
setStatus(QSoundEffect::Loading); setStatus(QSoundEffect::Loading);
...@@ -308,8 +308,8 @@ PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate* s): ...@@ -308,8 +308,8 @@ PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate* s):
m_runningCount(0), m_runningCount(0),
m_playing(false), m_playing(false),
m_status(QSoundEffect::Null), m_status(QSoundEffect::Null),
m_audioOutput(0), m_audioOutput(nullptr),
m_sample(0), m_sample(nullptr),
m_muted(false), m_muted(false),
m_volume(1.0), m_volume(1.0),
m_sampleReady(false), m_sampleReady(false),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment