Loading media/libaaudio/examples/utils/AAudioArgsParser.h +7 −0 Original line number Diff line number Diff line Loading @@ -424,6 +424,13 @@ public: printf(" 2 = PCM_FLOAT\n"); printf(" 3 = PCM_I24_PACKED\n"); printf(" 4 = PCM_I32\n"); printf(" 6 = MP3\n"); printf(" 7 = AAC_LC\n"); printf(" 8 = AAC_HE_V1\n"); printf(" 9 = AAC_HE_V2\n"); printf(" 10 = AAC_ELD\n"); printf(" 12 = AAC_XHE\n"); printf(" 13 = OPUS\n"); printf(" -i{inputPreset} eg. 5 for AAUDIO_INPUT_PRESET_CAMCORDER\n"); printf(" -m{0|1|2|3} set MMAP policy\n"); printf(" 0 = _UNSPECIFIED, use aaudio.mmap_policy system property, default\n"); Loading media/libaaudio/examples/utils/AAudioSimplePlayer.h +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ static float s_burnCPU(int32_t workload) { class AAudioSimplePlayer { public: AAudioSimplePlayer() {} ~AAudioSimplePlayer() { virtual ~AAudioSimplePlayer() { close(); }; Loading media/libaaudio/src/legacy/AudioStreamLegacy.cpp +19 −13 Original line number Diff line number Diff line Loading @@ -105,27 +105,33 @@ size_t AudioStreamLegacy::onMoreData(const android::AudioTrack::Buffer& buffer) // If the caller specified an exact size then use a block size adapter. if (mBlockAdapter != nullptr) { int32_t byteCount = buffer.getFrameCount() * getBytesPerDeviceFrame(); callbackResult = mBlockAdapter->processVariableBlock( std::tie(callbackResult, written) = mBlockAdapter->processVariableBlock( buffer.data(), byteCount); } else { // Call using the AAudio callback interface. callbackResult = callDataCallbackFrames(buffer.data(), buffer.getFrameCount()); written = callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE ? buffer.getFrameCount() * getBytesPerDeviceFrame() : 0; } if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { written = buffer.getFrameCount() * getBytesPerDeviceFrame(); } else { if (callbackResult != AAUDIO_CALLBACK_RESULT_CONTINUE) { if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { ALOGD("%s() callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__); } else { ALOGW("%s() callback returned invalid result = %d", __func__, callbackResult); } written = 0; if (callbackResult != AAUDIO_CALLBACK_RESULT_STOP || shouldStopStream()) { // If the callback result is STOP, stop the stream if it should be stopped. // Currently, the framework will not call stop if the client is doing offload // playback and waiting for stream end. The client will already be STOPPING // state when waiting for stream end. systemStopInternal(); // Disable the callback just in case the system keeps trying to call us. mCallbackEnabled.store(false); } } if (processCommands() != AAUDIO_OK) { forceDisconnect(); Loading Loading @@ -170,23 +176,23 @@ size_t AudioStreamLegacy::onMoreData(const android::AudioRecord::Buffer& buffer) // If the caller specified an exact size then use a block size adapter. if (mBlockAdapter != nullptr) { int32_t byteCount = buffer.getFrameCount() * getBytesPerDeviceFrame(); callbackResult = mBlockAdapter->processVariableBlock( std::tie(callbackResult, written) = mBlockAdapter->processVariableBlock( buffer.data(), byteCount); } else { // Call using the AAudio callback interface. callbackResult = callDataCallbackFrames(buffer.data(), buffer.getFrameCount()); written = callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE ? buffer.getFrameCount() * getBytesPerDeviceFrame() : 0; } if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { written = buffer.getFrameCount() * getBytesPerDeviceFrame(); } else { if (callbackResult != AAUDIO_CALLBACK_RESULT_CONTINUE) { if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { ALOGD("%s() callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__); } else { ALOGW("%s() callback returned invalid result = %d", __func__, callbackResult); } written = 0; // Always stop the recording case if callback result is not CONTINUE. systemStopInternal(); // Disable the callback just in case the system keeps trying to call us. mCallbackEnabled.store(false); Loading media/libaaudio/src/legacy/AudioStreamLegacy.h +2 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,8 @@ protected: */ virtual int32_t getBufferCapacityFromDevice() const = 0; virtual bool shouldStopStream() const { return true; } // This is used for exact matching by MediaMetrics. So do not change it. // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO static constexpr char kCallerName[] = "aaudio"; Loading media/libaaudio/src/legacy/AudioStreamTrack.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -686,6 +686,7 @@ aaudio_result_t AudioStreamTrack::setOffloadEndOfStream() { return result; } mOffloadEosPending = true; setState(AAUDIO_STREAM_STATE_STOPPING); return AAUDIO_OK; } Loading Loading
media/libaaudio/examples/utils/AAudioArgsParser.h +7 −0 Original line number Diff line number Diff line Loading @@ -424,6 +424,13 @@ public: printf(" 2 = PCM_FLOAT\n"); printf(" 3 = PCM_I24_PACKED\n"); printf(" 4 = PCM_I32\n"); printf(" 6 = MP3\n"); printf(" 7 = AAC_LC\n"); printf(" 8 = AAC_HE_V1\n"); printf(" 9 = AAC_HE_V2\n"); printf(" 10 = AAC_ELD\n"); printf(" 12 = AAC_XHE\n"); printf(" 13 = OPUS\n"); printf(" -i{inputPreset} eg. 5 for AAUDIO_INPUT_PRESET_CAMCORDER\n"); printf(" -m{0|1|2|3} set MMAP policy\n"); printf(" 0 = _UNSPECIFIED, use aaudio.mmap_policy system property, default\n"); Loading
media/libaaudio/examples/utils/AAudioSimplePlayer.h +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ static float s_burnCPU(int32_t workload) { class AAudioSimplePlayer { public: AAudioSimplePlayer() {} ~AAudioSimplePlayer() { virtual ~AAudioSimplePlayer() { close(); }; Loading
media/libaaudio/src/legacy/AudioStreamLegacy.cpp +19 −13 Original line number Diff line number Diff line Loading @@ -105,27 +105,33 @@ size_t AudioStreamLegacy::onMoreData(const android::AudioTrack::Buffer& buffer) // If the caller specified an exact size then use a block size adapter. if (mBlockAdapter != nullptr) { int32_t byteCount = buffer.getFrameCount() * getBytesPerDeviceFrame(); callbackResult = mBlockAdapter->processVariableBlock( std::tie(callbackResult, written) = mBlockAdapter->processVariableBlock( buffer.data(), byteCount); } else { // Call using the AAudio callback interface. callbackResult = callDataCallbackFrames(buffer.data(), buffer.getFrameCount()); written = callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE ? buffer.getFrameCount() * getBytesPerDeviceFrame() : 0; } if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { written = buffer.getFrameCount() * getBytesPerDeviceFrame(); } else { if (callbackResult != AAUDIO_CALLBACK_RESULT_CONTINUE) { if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { ALOGD("%s() callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__); } else { ALOGW("%s() callback returned invalid result = %d", __func__, callbackResult); } written = 0; if (callbackResult != AAUDIO_CALLBACK_RESULT_STOP || shouldStopStream()) { // If the callback result is STOP, stop the stream if it should be stopped. // Currently, the framework will not call stop if the client is doing offload // playback and waiting for stream end. The client will already be STOPPING // state when waiting for stream end. systemStopInternal(); // Disable the callback just in case the system keeps trying to call us. mCallbackEnabled.store(false); } } if (processCommands() != AAUDIO_OK) { forceDisconnect(); Loading Loading @@ -170,23 +176,23 @@ size_t AudioStreamLegacy::onMoreData(const android::AudioRecord::Buffer& buffer) // If the caller specified an exact size then use a block size adapter. if (mBlockAdapter != nullptr) { int32_t byteCount = buffer.getFrameCount() * getBytesPerDeviceFrame(); callbackResult = mBlockAdapter->processVariableBlock( std::tie(callbackResult, written) = mBlockAdapter->processVariableBlock( buffer.data(), byteCount); } else { // Call using the AAudio callback interface. callbackResult = callDataCallbackFrames(buffer.data(), buffer.getFrameCount()); written = callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE ? buffer.getFrameCount() * getBytesPerDeviceFrame() : 0; } if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { written = buffer.getFrameCount() * getBytesPerDeviceFrame(); } else { if (callbackResult != AAUDIO_CALLBACK_RESULT_CONTINUE) { if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { ALOGD("%s() callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__); } else { ALOGW("%s() callback returned invalid result = %d", __func__, callbackResult); } written = 0; // Always stop the recording case if callback result is not CONTINUE. systemStopInternal(); // Disable the callback just in case the system keeps trying to call us. mCallbackEnabled.store(false); Loading
media/libaaudio/src/legacy/AudioStreamLegacy.h +2 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,8 @@ protected: */ virtual int32_t getBufferCapacityFromDevice() const = 0; virtual bool shouldStopStream() const { return true; } // This is used for exact matching by MediaMetrics. So do not change it. // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO static constexpr char kCallerName[] = "aaudio"; Loading
media/libaaudio/src/legacy/AudioStreamTrack.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -686,6 +686,7 @@ aaudio_result_t AudioStreamTrack::setOffloadEndOfStream() { return result; } mOffloadEosPending = true; setState(AAUDIO_STREAM_STATE_STOPPING); return AAUDIO_OK; } Loading