__mSyncReadLength(0),
__mIsUsedSyncRead(false),
__mIsFirstStream(false),
- __mIsDraining(false) {
+ __mIsDraining(false),
+ __mIsStarted(false) {
}
CPulseAudioClient::~CPulseAudioClient() {
CPulseAudioClient* pClient = static_cast<CPulseAudioClient*>(user_data);
AUDIO_IO_LOGD("stream %p started.", pClient);
+
+ pClient->__mIsStarted = true;
}
void CPulseAudioClient::__streamUnderflowCb(pa_stream* s, void* user_data) {
CPulseAudioClient* pClient = static_cast<CPulseAudioClient*>(user_data);
AUDIO_IO_LOGD("stream %p UnderFlow...", pClient);
+
+ pClient->__mIsStarted = false;
}
void CPulseAudioClient::__streamEventCb(pa_stream* s, const char *name, pa_proplist *pl, void *user_data) {
if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
pa_stream_set_started_callback(__mpStream, __streamStartedCb, this);
pa_stream_set_underflow_callback(__mpStream, __streamUnderflowCb, this);
- }
+ }
// Connect stream with PA Server
return true;
}
+ if (!__mIsStarted) {
+ AUDIO_IO_LOGW("stream not started yet...skip drain");
+ return true;
+ }
+
if (isInThread() == false) {
AUDIO_IO_LOGD("drain");
pa_threaded_mainloop_lock(__mpMainloop);
}
pa_operation_unref(o);
pa_threaded_mainloop_unlock(__mpMainloop);
+ AUDIO_IO_LOGD("drain done");
} else {
AUDIO_IO_LOGD("drain in thread");
pa_operation_unref(pa_stream_drain(__mpStream, __successDrainCbInThread, this));