*/
+#include <new>
+
#include "CAudioIODef.h"
+#include <sched.h>
+#include "cpp_audio_in_privilege.h"
+#define RECORDER_PRIVILEGE "http://tizen.org/privilege/recorder"
+#define CLIENT_NAME "AUDIO_IO_PA_CLIENT"
using namespace std;
using namespace tizen_media_audio;
-
/**
* class CAudioInput inherited by CAudioIO
*/
-CAudioInput::CAudioInput(CAudioInfo& info)
- : CAudioIO(info),
- mpSyncReadDataPtr(NULL),
- mSyncReadIndex(0),
- mSyncReadLength(0),
- mIsUsedSyncRead(true) {
-}
-
-CAudioInput::CAudioInput(
- unsigned int sampleRate,
- CAudioInfo::EChannel channel,
- CAudioInfo::ESampleType type,
- CAudioInfo::EAudioType audioType)
- : mpSyncReadDataPtr(NULL),
- mSyncReadIndex(0),
- mSyncReadLength(0),
- mIsUsedSyncRead(true) {
- mAudioInfo = CAudioInfo(sampleRate, channel, type, audioType, -1);
-}
-
-CAudioInput::~CAudioInput() {
+CAudioInput::CAudioInput(CAudioInfo& info) :
+ CAudioIO(info),
+ __mIsUsedSyncRead(true),
+ __mIsInit(false) {
+ mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN;
}
void CAudioInput::onStream(CPulseAudioClient* pClient, size_t length) {
* Does not call CAudioIO::onStream() for synchronization
* if a user is using read()
*/
- if (mIsUsedSyncRead == true) {
+ if (__mIsUsedSyncRead) {
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("Sync Read Mode! - signal! - pClient:[%p], length:[%d]", pClient, length);
+ AUDIO_IO_LOGD("Sync Read Mode! - pClient:[%p], length:[%zu]", pClient, length);
#endif
- internalSignal();
return;
}
* Accrues callback function
*/
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("pClient:[%p], length:[%d]", pClient, length);
+ AUDIO_IO_LOGD("pClient:[%p], length:[%zu]", pClient, length);
#endif
CAudioIO::onStream(pClient, length);
}
-void CAudioInput::onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info) {
- assert(pHandler);
- AUDIO_IO_LOGD("[pHandler:0x%x], [focus_type:%d], [state:%d], [reason_for_change:%s], [additional_info:%s]", pHandler, focus_type, state, reason_for_change, additional_info);
- CAudioIO::onInterrupt(pHandler, id, focus_type, state, reason_for_change, additional_info);
-}
-
-void CAudioInput::onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value) {
- assert(pHandler);
- AUDIO_IO_LOGD("[pHandler:0x%x], [signal:%d], [value:%d]", pHandler, signal, value);
- CAudioIO::onSignal(pHandler, signal, value);
+void CAudioInput::__setInit(bool flag) noexcept {
+ __mIsInit = flag;
}
-void CAudioInput::setInit(bool flag) {
- mIsInit = flag;
+bool CAudioInput::__IsInit() noexcept {
+ return (CAudioIO::isInit() && __mIsInit);
}
-bool CAudioInput::IsInit() {
- return (CAudioIO::isInit() == true && mIsInit == true);
-}
-
-bool CAudioInput::IsReady() {
+bool CAudioInput::__IsReady() noexcept {
return CAudioIO::IsReady();
}
-void CAudioInput::initialize() throw (CAudioError) {
- if (IsInit() == true) {
+void CAudioInput::initialize() {
+ if (__IsInit())
return;
- }
+
+ if (!cpp_audio_in_has_record_privilege())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_PERMISSION_DENIED, "No privilege for record");
try {
CAudioIO::initialize();
-
- // Create ASM Handler
- mpAudioSessionHandler = new CAudioSessionHandler(CAudioSessionHandler::AUDIO_SESSION_TYPE_CAPTURE, mAudioInfo, this);
- if (mpAudioSessionHandler == NULL) {
- THROW_ERROR_MSG(CAudioError::ERROR_OUT_OF_MEMORY, "Failed to allocate CAudioSessionHandler object");
- }
-
- // Initialize ASM Handler
- mpAudioSessionHandler->initialize();
-
- setInit(true);
- CAudioIO::onStateChanged(CAudioInfo::AUDIO_IO_STATE_IDLE);
- } catch (CAudioError err) {
+ __setInit(true);
+ } catch (CAudioError& e) {
finalize();
- throw err;
+ throw;
}
+
+ CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
}
void CAudioInput::finalize() {
- if (IsInit() == false) {
+ if (!__IsInit()) {
AUDIO_IO_LOGD("Did not initialize");
return;
}
- SAFE_FINALIZE(mpAudioSessionHandler);
- SAFE_DELETE(mpAudioSessionHandler);
-
CAudioIO::finalize();
- setInit(false);
+ __setInit(false);
}
-void CAudioInput::prepare() throw (CAudioError) {
- if (IsInit() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- }
+void CAudioInput::prepare() {
+ if (!__IsInit())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- if (IsReady() == true) {
+ if (__IsReady()) {
AUDIO_IO_LOGD("Already prepared CAudioInput");
+ CAudioIO::prepare();
return;
}
+ /* Check invalid AudioType */
+ CAudioInfo::EAudioType audioType = mAudioInfo.getAudioType();
+ if (audioType < CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA ||
+ audioType >= CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
+ "The audioType is invalid [type:%d]", static_cast<int>(audioType));
+
try {
- internalLock();
+ /* Init StreamSpec */
+ AUDIO_IO_LOGD("Set Stream Spec : CPulseStreamSpec::STREAM_LATENCY_INPUT_DEFAULT");
+ CPulseStreamSpec::EStreamLatency streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_INPUT_DEFAULT;
+ /* Override the default value by audio type */
+ if (audioType == CAudioInfo::EAudioType::AUDIO_IN_TYPE_VOIP)
+ streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_INPUT_VOIP;
- // Check to invalid AudioType
- CAudioInfo::EAudioType audioType = mAudioInfo.getAudioType();
- if (audioType < CAudioInfo::AUDIO_IN_TYPE_MEDIA || audioType > CAudioInfo::AUDIO_IN_TYPE_LOOPBACK) {
- THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "The audioType is invalid [type:%d]", static_cast<int>(audioType));
- }
-
- if (mpAudioSessionHandler->getId() < 0) { //Did not registerSound()
- // Check session to skip registration
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
- // Register ASM Listener
- AUDIO_IO_LOGD("Register ASM Listener");
- mpAudioSessionHandler->registerSound();
- }
- }
-
- // Init StreamSpec
- AUDIO_IO_LOGD("Set Strem Spec : CPulseStreamSpec::STREAM_LATENCY_INPUT_MID");
- CPulseStreamSpec::EStreamLatency streamSpec = CPulseStreamSpec::STREAM_LATENCY_INPUT_MID;
CPulseStreamSpec spec(streamSpec, mAudioInfo);
- // Create PulseAudio Handler
- mpPulseAudioClient = new CPulseAudioClient(CPulseAudioClient::STREAM_DIRECTION_RECORD, spec, this);
- if (mpPulseAudioClient == NULL) {
- THROW_ERROR_MSG(CAudioError::ERROR_OUT_OF_MEMORY, "Failed to allocate CPulseAudioClient object");
- }
-
- // Initialize PulseAudio Handler
+ internalLock();
+ mpPulseAudioClient = new CPulseAudioClient(CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_RECORD, spec, this);
mpPulseAudioClient->initialize();
-
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
- /* Updates ASM to PLAYING */
- mpAudioSessionHandler->updatePlaying();
- }
-
+#ifndef DISABLE_MOBILE_BACK_COMP
+ /* Uncork stream which is created with CORKED flag */
+ mpPulseAudioClient->cork(false);
+#endif
internalUnlock();
- // Do Prepare
CAudioIO::prepare();
- } catch (CAudioError e) {
+ } catch (CAudioError& e) {
+ SAFE_FINALIZE(mpPulseAudioClient);
+ SAFE_DELETE(mpPulseAudioClient);
+ internalUnlock();
+ throw;
+ } catch (const std::bad_alloc&) {
+//LCOV_EXCL_START
internalUnlock();
- throw e;
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed to allocate CPulseAudioClient object");
+//LCOV_EXCL_STOP
}
}
-void CAudioInput::unprepare() throw (CAudioError) {
- if (IsInit() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- }
+void CAudioInput::unprepare() {
+ if (!__IsInit())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize CAudioInput");
- if (IsReady() == false) {
+ if (!__IsReady()) {
AUDIO_IO_LOGD("Already unprepared");
return;
}
- try{
- // Do unprepare
- CAudioIO::unprepare();
+ CAudioIO::unprepare();
+ try {
internalLock();
-
+ if (mpPulseAudioClient && mpPulseAudioClient->isInThread())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't unprepare inside pulseaudio thread");
SAFE_FINALIZE(mpPulseAudioClient);
SAFE_DELETE(mpPulseAudioClient);
-
- if (mpAudioSessionHandler->getId() >= 0) {
- /* Updates ASM to STOP */
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
- mpAudioSessionHandler->updateStop();
- }
-
- bool isSkip = mpAudioSessionHandler->isSkipSessionEvent();
- if (isSkip == false) {
- mpAudioSessionHandler->unregisterSound();
- }
- }
-
internalUnlock();
-
- CAudioIO::onStateChanged(CAudioInfo::AUDIO_IO_STATE_IDLE);
- } catch (CAudioError e) {
+ } catch (CAudioError& e) {
internalUnlock();
- throw e;
+ throw;
}
-}
-void CAudioInput::pause() throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
+ CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
+}
- try{
- CAudioIO::pause();
+void CAudioInput::pause() {
+ if (!__IsInit() || !__IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize or prepare CAudioInput");
- internalLock();
+ if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE,
+ "Can't pause if not in Running state");
- /* Updates ASM to STOP */
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
- mpAudioSessionHandler->updateStop();
- }
+ if (mpPulseAudioClient->isInThread())
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't pause in thread");
- internalUnlock();
-
- CAudioIO::onStateChanged(CAudioInfo::AUDIO_IO_STATE_PAUSED);
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
+ CAudioIO::pause();
+ CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
}
-void CAudioInput::resume() throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
-
- try {
- internalLock();
-
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
-
- /* Updates ASM to PLAYING */
- mpAudioSessionHandler->updatePlaying();
- }
+void CAudioInput::resume() {
+ if (!__IsInit() || !__IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize or prepare CAudioInput");
- internalUnlock();
+ if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE,
+ "Can't resume if not in Paused state");
- CAudioIO::resume();
+ if (mpPulseAudioClient->isInThread())
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't resume in thread");
- CAudioIO::onStateChanged(CAudioInfo::AUDIO_IO_STATE_RUNNING);
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
+ CAudioIO::resume();
+ CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
}
-void CAudioInput::drain() throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
+void CAudioInput::flush() {
+ if (!__IsInit() || !__IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize or prepare CAudioInput");
- try{
- CAudioIO::drain();
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
+ CAudioIO::flush();
}
-void CAudioInput::flush() throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
+int CAudioInput::getBufferSize() {
+ if (!__IsInit())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- try {
- CAudioIO::flush();
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
+ /* FIXME : return calculated size here to satisfy backward compatibility */
+ return (mAudioInfo.getSampleRate() * DEFAULT_PERIOD_SIZE) / 1000 * mAudioInfo.getSampleSize();
}
-int CAudioInput::getBufferSize() throw (CAudioError) {
- if (IsInit() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- }
-
- if (IsReady() == false) {
- AUDIO_IO_LOGD("Warning: Did not prepare CAudioInput, then return zero");
- return 0;
- }
+void CAudioInput::setStreamCallback(SStreamCallback callback) {
+ if (!__IsInit())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- int size = 0;
+ __mIsUsedSyncRead = (callback.onStream == nullptr);
- try {
- internalLock();
- size = mpPulseAudioClient->getBufferSize();
- internalUnlock();
- } catch (CAudioError err) {
- internalUnlock();
- throw err;
- }
-
- return size;
-}
-
-void CAudioInput::setStreamCallback(SStreamCallback callback) throw (CAudioError) {
- if (IsInit() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
- }
-
- internalLock();
- if (callback.onStream == NULL) {
- AUDIO_IO_LOGD("mIsUsedSyncRead = true");
- mIsUsedSyncRead = true;
- } else {
- AUDIO_IO_LOGD("mIsUsedSyncRead = false");
- mIsUsedSyncRead = false;
- }
- internalUnlock();
+ AUDIO_IO_LOGD("__mIsUsedSyncRead = %d", __mIsUsedSyncRead);
CAudioIO::setStreamCallback(callback);
}
-size_t CAudioInput::read(void* buffer, size_t length) throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
+size_t CAudioInput::read(void* buffer, size_t length) {
+ if (!__IsInit() || !__IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize or prepare CAudioInput");
- if (buffer == NULL) {
- THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are invalid - buffer:%p, length:%d", buffer, length);
- }
+ if (!buffer)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
+ "Parameters are NULL buffer:%p", buffer);
- /* Checks synchronous flag */
- if (mIsUsedSyncRead == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Does not support read() if receive stream callback");
- }
+ if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION,
+ "Can't read if not in Running state");
- internalLock();
+ /* Checks synchronous flag */
+ if (!__mIsUsedSyncRead)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION,
+ "Invalid operation of read() if receive stream callback");
- size_t lengthIter = length;
int ret = 0;
try {
- while (lengthIter > 0) {
- size_t l;
-
- while (mpSyncReadDataPtr == NULL) {
- ret = mpPulseAudioClient->peek(&mpSyncReadDataPtr, &mSyncReadLength);
- if (ret != 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INTERNAL_OPERATION, "Failed CPulseAudioClient::peek() ret:[%d]", ret);
- }
-
- if (mSyncReadLength <= 0) {
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("readLength(%d byte) is not valid.. wait..", mSyncReadLength);
-#endif
- internalWait();
- } else if (mpSyncReadDataPtr == NULL) {
- /* There's a hole in the stream, skip it. We could generate
- * silence, but that wouldn't work for compressed streams.
- */
- ret = mpPulseAudioClient->drop();
- if (ret != 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INTERNAL_OPERATION, "Failed CPulseAudioClient::drop() ret:[%d]", ret);
- }
- } else {
- mSyncReadIndex = 0;
- }
- }//end of while (pReadData == NULL)
-
- if (mSyncReadLength < lengthIter) {
- l = mSyncReadLength;
- } else {
- l = lengthIter;
- }
-
- // Copy partial pcm data on out parameter
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("memcpy() that a peeked buffer(%p), index(%d), length(%d), on out buffer", (const uint8_t*)(mpSyncReadDataPtr) + mSyncReadIndex, mSyncReadIndex, l);
-#endif
- memcpy(buffer, (const uint8_t*)mpSyncReadDataPtr + mSyncReadIndex, l);
+ internalLock();
- // Move next position
- buffer = (uint8_t*)buffer + l;
- lengthIter -= l;
+ // If another thread did call unprepare, do not read
+ if (!mpPulseAudioClient)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize CPulseAudioClient");
- // Adjusts the rest length
- mSyncReadIndex += l;
- mSyncReadLength -= l;
+ // Block until read done
+ ret = mpPulseAudioClient->read(buffer, length);
+ internalUnlock();
- if (mSyncReadLength == 0) {
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("mSyncReadLength is zero - Do drop()");
-#endif
- ret = mpPulseAudioClient->drop();
- if (ret != 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INTERNAL_OPERATION, "Failed CPulseAudioClient::drop() ret:[%d]", ret);
- }
-
- // Reset the internal pointer
- mpSyncReadDataPtr = NULL;
- mSyncReadLength = 0;
- mSyncReadIndex = 0;
- }
- }//end of while (length > 0)
- } catch (CAudioError e) {
+ sched_yield();
+ } catch (CAudioError& e) {
internalUnlock();
- throw e;
+ throw;
}
- internalUnlock();
-
- return length;
+ return ret;
}
-int CAudioInput::peek(const void** buffer, size_t* length) throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
+int CAudioInput::peek(const void** buffer, size_t* length) {
+ if (!__IsInit() || !__IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize or prepare CAudioInput");
- if (buffer == NULL || length == NULL) {
- THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL buffer:%p, length:%p", buffer, length);
- }
+ if (buffer == nullptr || length == nullptr)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
+ "Parameters are NULL buffer:%p, length:%p", buffer, length);
/* Checks synchronous flag */
- internalLock();
- if (mIsUsedSyncRead == true) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Does not support peek() if does not receive a stream callback");
- }
- internalUnlock();
-
- int ret = 0;
-
- try {
- internalLock();
- ret = mpPulseAudioClient->peek(buffer, length);
- internalUnlock();
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
+ if (__mIsUsedSyncRead)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION,
+ "Invalid operation of peek() if does not receive a stream callback");
- return ret;
+ return mpPulseAudioClient->peek(buffer, length);
}
-int CAudioInput::drop() throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
+int CAudioInput::drop() {
+ if (!__IsInit() || !__IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED,
+ "Did not initialize or prepare CAudioInput");
/* Checks synchronous flag */
- internalLock();
- if (mIsUsedSyncRead == true) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Does not support drop() if does not receive a stream callback");
- }
- internalUnlock();
-
- int ret = 0;
+ if (__mIsUsedSyncRead)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION,
+ "Invalid operation of drop() if does not receive a stream callback");
- try {
- internalLock();
- ret = mpPulseAudioClient->drop();
- internalUnlock();
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
-
- return ret;
+ return mpPulseAudioClient->drop();
}