if (__IsReady() == true) {
AUDIO_IO_LOGD("Already prepared CAudioOutput");
+ CAudioIO::prepare();
return;
}
- try {
- internalLock();
-
- // Check to invalid AudioType
- CAudioInfo::EAudioType audioType = mAudioInfo.getAudioType();
- if (audioType < CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA || audioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
- "The audioType is invalid [type:%d]", static_cast<int>(audioType));
- }
+ /* Check invalid AudioType */
+ CAudioInfo::EAudioType audioType = mAudioInfo.getAudioType();
+ if (audioType < CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA || audioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX) {
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
+ "The audioType is invalid [type:%d]", static_cast<int>(audioType));
+ }
+ try {
if (mpAudioSessionHandler->getId() < 0) { // Did not registerSound()
if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false) {
- // Register ASM Listener
+ /* Register ASM Listener */
AUDIO_IO_LOGD("Register ASM Listener");
mpAudioSessionHandler->registerSound();
}
CAudioIO::setInternalStreamInfo();
- // Init StreamSpec
- AUDIO_IO_LOGD("Set Stream Spec : CPulseStreamSpec::STREAM_LATENCY_OUTPUT_DEFAULT");
+ if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
+ mpAudioSessionHandler->updatePlaying();
+ } catch (CAudioError& e) {
+ throw;
+ }
+
+ try {
+ /* Init StreamSpec */
CPulseStreamSpec::EStreamLatency streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT;
+#ifndef DISABLE_MOBILE_BACK_COMP
+ if (!mStreamCallback.onStream) {
+ AUDIO_IO_LOGD("Set Stream Spec : CPulseStreamSpec::STREAM_LATENCY_OUTPUT_DEFAULT");
+ streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT;
+ } else {
+ AUDIO_IO_LOGD("Set Stream Spec : CPulseStreamSpec::STREAM_LATENCY_OUTPUT_DEFAULT_ASYNC");
+ streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT_ASYNC;
+ }
+#endif
CPulseStreamSpec spec(streamSpec, mAudioInfo);
- // Create PulseAudio Handler
+ internalLock();
+
+ /* Create PulseAudio Handler */
mpPulseAudioClient = new CPulseAudioClient(CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_PLAYBACK, spec, this);
- // Initialize PulseAudio Handler
+ /* Initialize PulseAudio Handler */
mpPulseAudioClient->initialize();
-
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->updatePlaying();
-
+#ifndef DISABLE_MOBILE_BACK_COMP
+ /* Uncork stream which is created with CORKED flag */
+ mpPulseAudioClient->cork(false);
+#endif
internalUnlock();
CAudioIO::prepare();
} catch (CAudioError& e) {
+ SAFE_FINALIZE(mpPulseAudioClient);
+ SAFE_DELETE(mpPulseAudioClient);
internalUnlock();
throw;
} catch (const std::bad_alloc&) {
}
try {
+ if (mpAudioSessionHandler->getId() >= 0 && !mIsInterrupted) {
+ if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false) {
+ if (mStreamCallback.onStream == NULL)
+ CAudioIO::drain();
+ }
+ }
CAudioIO::unprepare();
internalLock();
internalUnlock();
+ } catch (CAudioError& e) {
+ internalUnlock();
+ throw;
+ }
+
+ try {
if (mpAudioSessionHandler->getId() >= 0) {
if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
mpAudioSessionHandler->updateStop();
-
- if (mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->unregisterSound();
}
-
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
} catch (CAudioError& e) {
internalUnlock();
try {
CAudioIO::pause();
- internalLock();
-
- /* Updates ASM to STOP */
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->updateStop();
-
- internalUnlock();
-
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
} catch (CAudioError& e) {
- internalUnlock();
throw;
}
}
}
try {
- internalLock();
-
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->updatePlaying();
-
- internalUnlock();
-
CAudioIO::resume();
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
} catch (CAudioError& e) {
- internalUnlock();
throw;
}
}
"Did not initialize or prepare CAudioOutput");
}
+ if (mStreamCallback.onStream)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION, "async type don't support drain");
+
try {
CAudioIO::drain();
} catch (CAudioError& e) {
try {
/* For synchronization */
internalLock();
+ if (mIsInterrupted) {
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_POLICY_BLOCKED, "audio io is interrupted");
+ }
// If another thread did call unprepare, do not write
if (mpPulseAudioClient == NULL)