diff --git a/services/src/client/audio_service_client.cpp b/services/src/client/audio_service_client.cpp index cc63a15612c42369325581998fc493e47a0b9f21..0276be3d059cc803d399568807f44856c90716ec 100644 --- a/services/src/client/audio_service_client.cpp +++ b/services/src/client/audio_service_client.cpp @@ -889,7 +889,7 @@ int32_t AudioServiceClient::ReadStream(StreamBuffer &stream, bool isBlocking) pa_threaded_mainloop_wait(mainLoop); else { pa_threaded_mainloop_unlock(mainLoop); - return 0; + return readSize; } } else if (!internalReadBuffer) { retVal = pa_stream_drop(paStream); diff --git a/services/test/audio_recorder_test.cpp b/services/test/audio_recorder_test.cpp index e7640fe6059ab06ba747a02ef9cac1bea48a08f6..9c355b3fd4be8d72b916fdf985c04715044c24fd 100644 --- a/services/test/audio_recorder_test.cpp +++ b/services/test/audio_recorder_test.cpp @@ -109,11 +109,22 @@ public: size_t size = 1; size_t numBuffersToRecord = 1024; - int32_t bytesRead = 0; + int32_t len = 0; while (numBuffersToRecord) { - bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlocking); + size_t bytesRead = 0; + while (bytesRead < bufferLen) { + len = audioRecorder->Read(*(buffer + bytesRead), bufferLen - bytesRead, isBlocking); + if (len >= 0) { + bytesRead += len; + } else { + bytesRead = -1; + MEDIA_INFO_LOG("Bytes read failed"); + break; + } + } MEDIA_INFO_LOG("Bytes read: %{public}d", bytesRead); if (bytesRead < 0) { + MEDIA_INFO_LOG("Bytes read less than 0"); break; } if (bytesRead > 0) {