- 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);