Name: capi-media-audio-io
Summary: An Audio Input & Audio Output library in Tizen Native API
-Version: 0.3.8
+Version: 0.3.9
Release: 0
Group: Multimedia/API
License: Apache-2.0
THROW_ERROR_MSG(CAudioError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()");
}
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_RED"LOCK"COLOR_END);
+ AUDIO_IO_LOGD(COLOR_RED "LOCK" COLOR_END);
#endif
}
THROW_ERROR_MSG(CAudioError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()");
}
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_GREEN"UNLOCK"COLOR_END);
+ AUDIO_IO_LOGD(COLOR_GREEN "UNLOCK" COLOR_END);
#endif
}
}
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_RED"WAIT"COLOR_END);
+ AUDIO_IO_LOGD(COLOR_RED "WAIT" COLOR_END);
#endif
pthread_cond_wait(&mCond, &mMutex);
}
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_GREEN"SIGNAL"COLOR_END);
+ AUDIO_IO_LOGD(COLOR_GREEN "SIGNAL" COLOR_END);
#endif
pthread_cond_signal(&mCond);
assert(pClient != NULL);
assert(length > 0);
+#ifdef _AUDIO_IO_DEBUG_TIMING_
+ AUDIO_IO_LOGD("mStreamCallback.onStream(%p), pClient(%p), length(%zu)", mStreamCallback.onStream, pClient, length);
+#endif
+
if (mStreamCallback.onStream != NULL) {
mStreamCallback.onStream(length, mStreamCallback.mUserData);
}
} else if (state == FOCUS_IS_ACQUIRED) {
// Focus handle(id) of the other application was acquired, do pause if possible
internalLock();
+
if (mpPulseAudioClient->getStreamDirection() == CPulseAudioClient::STREAM_DIRECTION_PLAYBACK) {
if (mpPulseAudioClient->drain() == false) {
AUDIO_IO_LOGE("Failed CPulseAudioClient::drain()");
if (state == FOCUS_IS_RELEASED) {
// Focus handle(id) was released, do pause here
internalLock();
+
if (mpPulseAudioClient->getStreamDirection() == CPulseAudioClient::STREAM_DIRECTION_PLAYBACK) {
if (mpPulseAudioClient->drain() == false) {
AUDIO_IO_LOGE("Failed CPulseAudioClient::drain()");
}
try {
- internalLock();
AUDIO_IO_LOGD("prepare");
/* Do nothing */
- internalUnlock();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
}
}
try {
- internalLock();
AUDIO_IO_LOGD("unprepare");
/* Do nothing */
- internalUnlock();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
}
THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
}
- internalLock();
mStreamCallback = callback;
- internalUnlock();
}
CAudioIO::SStreamCallback CAudioIO::getStreamCallback() throw (CAudioError) {
THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
}
- internalLock();
mStateChangedCallback = callback;
- internalUnlock();
}
CAudioIO::SStateChangedCallback CAudioIO::getStateChangedCallback() throw (CAudioError) {
THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
}
- internalLock();
-
try {
+ internalLock();
+
if (mpPulseAudioClient != NULL && mpPulseAudioClient->isCorked() == false) {
THROW_ERROR_MSG(CAudioError::ERROR_INVALID_OPERATION, "An Operation is not permitted while started");
}
mpAudioSessionHandler->unregisterSound();
mForceIgnore = true;
}
+
+ internalUnlock();
} catch (CAudioError e) {
internalUnlock();
-
throw e;
}
-
- internalUnlock();
}
}
void CAudioInput::drain() throw (CAudioError) {
- if (IsInit() == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
- }
-
- try{
- CAudioIO::drain();
- } catch (CAudioError e) {
- internalUnlock();
- throw e;
- }
+ THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Did not support drain of CAudioInput");
}
void CAudioInput::flush() throw (CAudioError) {
try {
CAudioIO::flush();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
}
int size = 0;
try {
- internalLock();
size = mpPulseAudioClient->getBufferSize();
- internalUnlock();
} catch (CAudioError err) {
- internalUnlock();
throw err;
}
THROW_ERROR_MSG(CAudioError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
}
- internalLock();
if (callback.onStream == NULL) {
AUDIO_IO_LOGD("mIsUsedSyncRead = true");
mIsUsedSyncRead = true;
AUDIO_IO_LOGD("mIsUsedSyncRead = false");
mIsUsedSyncRead = false;
}
- internalUnlock();
CAudioIO::setStreamCallback(callback);
}
THROW_ERROR_MSG(CAudioError::ERROR_INVALID_OPERATION, "Invalid operation of read() if receive stream callback");
}
- internalLock();
-
size_t lengthIter = length;
int ret = 0;
try {
+ internalLock();
+
while (lengthIter > 0) {
size_t l;
mSyncReadLength = 0;
mSyncReadIndex = 0;
}
- }//end of while (length > 0)
+ } // End of while (length > 0)
+
+ internalUnlock();
} catch (CAudioError e) {
internalUnlock();
throw e;
}
- internalUnlock();
-
return length;
}
int ret = 0;
try {
- internalLock();
ret = mpPulseAudioClient->peek(buffer, length);
- internalUnlock();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
int ret = 0;
try {
- internalLock();
ret = mpPulseAudioClient->drop();
- internalUnlock();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
internalUnlock();
CAudioIO::resume();
+
CAudioIO::onStateChanged(CAudioInfo::AUDIO_IO_STATE_RUNNING);
} catch (CAudioError e) {
internalUnlock();
try {
CAudioIO::drain();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
}
try {
CAudioIO::flush();
} catch (CAudioError e) {
- internalUnlock();
throw e;
}
}
int size = 0;
try {
- internalLock();
size = mpPulseAudioClient->getBufferSize();
- internalUnlock();
} catch (CAudioError err) {
- internalUnlock();
throw err;
}
}
}
- /* When write() is called in PulseAudio callback, bypass a pcm data to PulseAudioClient (For Asynchronous) */
+ /* When write() is called in PulseAudio callback, bypass a pcm data to PulseAudioClient (For Asynchronous) */
if (mpPulseAudioClient->isInThread() == true) {
int ret = mpPulseAudioClient->write(buffer, length);
if (ret == 0) {
}
}
- /* For synchronization */
- internalLock();
+ try {
+ /* For synchronization */
+ internalLock();
- // Sets synchronous flag
- mIsUsedSyncWrite = true;
+ // Sets synchronous flag
+ mIsUsedSyncWrite = true;
+
+ size_t lengthIter = length;
- size_t lengthIter = length;
- try {
while (lengthIter > 0) {
size_t l;
buffer = static_cast<const uint8_t*>(buffer) + l;
lengthIter -= l;
- }//end of while (length > 0)
+ } // End of while (length > 0)
+
+ // Unsets synchronous flag
+ mIsUsedSyncWrite = false;
+ internalUnlock();
} catch (CAudioError e) {
// Unsets synchronous flag
mIsUsedSyncWrite = false;
throw e;
}
- // Unsets synchronous flag
- mIsUsedSyncWrite = false;
- internalUnlock();
-
return length;
}
static void _audio_io_stream_read_cb (audio_in_h handle, size_t nbytes, void *user_data)
{
- const void * buffer = NULL;
+ const void *buffer = NULL;
+ unsigned int len = (unsigned int) nbytes;
-// printf("_audio_io_stream_read_cb : handle=%p, nbytes=%d, user_data=%p\n", handle, nbytes, user_data);
+ //printf("_audio_io_stream_read_cb : handle=%p, nbytes=%d, user_data=%p\n", handle, nbytes, user_data);
- if (nbytes > 0) {
- audio_in_peek (handle, &buffer, &nbytes);
+ if (len > 0) {
+ audio_in_peek (handle, &buffer, &len);
if (fp_w) {
- fwrite(buffer, sizeof(char), nbytes, fp_w);
+ fwrite(buffer, sizeof(char), len, fp_w);
}
audio_in_drop (handle);
}
int ret = 0;
int i = 0;
-// printf("_audio_io_stream_write_cb : handle=%p, nbytes=%d, user_data=%p\n", handle, nbytes, user_data);
+ //printf("_audio_io_stream_write_cb : handle=%p, nbytes=%d, user_data=%p\n", handle, nbytes, user_data);
if (nbytes > 0) {
buffer = (short *) malloc(nbytes);
ret = audio_out_write(handle, buffer, nbytes);
if(ret > AUDIO_IO_ERROR_NONE) {
-// printf("audio write success. buffer(%p), nbytes(%d)\n", buffer, nbytes);
+ //printf("audio write success. buffer(%p), nbytes(%d)\n", buffer, nbytes);
}
free (buffer);