/**
* class CMainloopLocker
*/
-CPulseAudioClient::CPulseThreadLocker::CPulseThreadLocker(pa_threaded_mainloop *mainloop) : ml(nullptr) {
+CPulseAudioClient::CPulseThreadLocker::CPulseThreadLocker(pa_threaded_mainloop* mainloop) : ml(nullptr) {
if (!mainloop || pa_threaded_mainloop_in_thread(mainloop))
return;
CPulseAudioClient::CPulseThreadLocker::~CPulseThreadLocker() {
if (ml)
- pa_threaded_mainloop_unlock(const_cast<pa_threaded_mainloop *>(ml));
+ pa_threaded_mainloop_unlock(const_cast<pa_threaded_mainloop*>(ml));
ml = nullptr;
}
}
//LCOV_EXCL_START
-void CPulseAudioClient::__streamEventCb(pa_stream* s, const char *name, pa_proplist *pl, void *user_data) {
+void CPulseAudioClient::__streamEventCb(pa_stream* s, const char* name, pa_proplist* pl, void* user_data) {
assert(s);
assert(user_data);
AUDIO_IO_LOGW("pClient[%p] pa_stream[%p] : name[%s], proplist[%p]", pClient, s, name, pl);
- if (strcmp(name, PA_STREAM_EVENT_POP_TIMEOUT) == 0)
- pa_operation_unref(pa_stream_cork(pClient->__mpStream, 1, NULL, NULL));
+ if (strcmp(name, PA_STREAM_EVENT_POP_TIMEOUT) == 0) {
+ pa_operation* o = pa_stream_cork(pClient->__mpStream, 1, NULL, NULL);
+ if (!o) {
+ AUDIO_IO_LOGE("pa_stream[%p] : cork failed", pClient->__mpStream);
+ return;
+ }
+ pa_operation_unref(o);
+ }
}
//LCOV_EXCL_STOP
pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
}
-void CPulseAudioClient::__successVolumeCb(pa_context *c, int success, void *user_data) {
+void CPulseAudioClient::__successVolumeCb(pa_context* c, int success, void* user_data) {
AUDIO_IO_LOGD("pa_context[%p], success[%d], user_data[%p]", c, success, user_data);
}
if (!isInThread()) {
CPulseThreadLocker locker{__mpMainloop};
if (pa_stream_is_corked(__mpStream)) {
- AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
- pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
+ AUDIO_IO_LOGW("pa_stream[%p] is corked...do uncork here first!!!!", __mpStream);
+ pa_operation* o = pa_stream_cork(__mpStream, 0, NULL, NULL);
+ if (!o)
+ AUDIO_IO_LOGE("pa_stream[%p] : uncork failed", __mpStream);
+ else
+ pa_operation_unref(o);
}
ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
} else {
// LCOV_EXCL_START
if (pa_stream_is_corked(__mpStream)) {
- AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
- pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
+ AUDIO_IO_LOGW("pa_stream[%p] is corked...do uncork here first!!!!", __mpStream);
+ pa_operation* o = pa_stream_cork(__mpStream, 0, NULL, NULL);
+ if (!o)
+ AUDIO_IO_LOGE("pa_stream[%p] : uncork failed", __mpStream);
+ else
+ pa_operation_unref(o);
}
if (__mIsFirstStream) {
CPulseThreadLocker locker{__mpMainloop};
/* FIXME: wait for completion like drain? */
- pa_operation_unref(pa_stream_cork(__mpStream, static_cast<int>(cork), __successStreamCb, this));
-
+ pa_operation* o = pa_stream_cork(__mpStream, static_cast<int>(cork), __successStreamCb, this);
+ if (!o) {
+ AUDIO_IO_LOGE("pa_stream[%p] : cork[%d] failed", __mpStream, cork);
+ return;
+ }
+ pa_operation_unref(o);
AUDIO_IO_LOGD("cork[%d] done", cork);
}
AUDIO_IO_LOGD("drain done");
} else {
AUDIO_IO_LOGD("drain in thread");
- pa_operation_unref(pa_stream_drain(__mpStream, __successDrainCbInThread, this));
+ pa_operation* o = pa_stream_drain(__mpStream, __successDrainCbInThread, this);
+ if (!o) {
+ AUDIO_IO_LOGE("pa_stream[%p] : drain failed", __mpStream);
+ return false;
+ }
+ pa_operation_unref(o);
__mIsDraining = true;
}
CPulseThreadLocker locker{__mpMainloop};
/* FIXME: wait for completion like drain? */
- pa_operation_unref(pa_stream_flush(__mpStream, __successStreamCb, this));
+ pa_operation* o = pa_stream_flush(__mpStream, __successStreamCb, this);
+ if (!o) {
+ AUDIO_IO_LOGE("pa_stream[%p] : flush failed", __mpStream);
+ return false;
+ }
+ pa_operation_unref(o);
return true;
}