Loading media/libaaudio/include/aaudio/AAudio.h +26 −2 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ enum { /** * This format uses the int16_t data type. * The maximum range of the data is -32768 to 32767. * The maximum range of the data is -32768 (0x8000) to 32767 (0x7FFF). */ AAUDIO_FORMAT_PCM_I16, Loading @@ -77,7 +77,31 @@ enum { * See also 'floatData' at * https://developer.android.com/reference/android/media/AudioTrack#write(float[],%20int,%20int,%20int) */ AAUDIO_FORMAT_PCM_FLOAT AAUDIO_FORMAT_PCM_FLOAT, /** * This format uses 24-bit samples packed into 3 bytes. * The bytes are in the native endian order. * The maximum range of the data is -8388608 (0x800000) * to 8388607 (0x7FFFFF). * * Note that the lower precision bits may be ignored by the device. * * Available since API level 31. */ AAUDIO_FORMAT_PCM_I24_PACKED, /** * This format uses 32-bit samples stored in an int32_t data type. * The maximum range of the data is -2147483648 (0x80000000) * to 2147483647 (0x7FFFFFFF). * * Note that the lower precision bits may be ignored by the device. * * Available since API level 31. */ AAUDIO_FORMAT_PCM_I32 }; typedef int32_t aaudio_format_t; Loading media/libaaudio/src/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -130,9 +130,11 @@ cc_library { "flowgraph/SinkFloat.cpp", "flowgraph/SinkI16.cpp", "flowgraph/SinkI24.cpp", "flowgraph/SinkI32.cpp", "flowgraph/SourceFloat.cpp", "flowgraph/SourceI16.cpp", "flowgraph/SourceI24.cpp", "flowgraph/SourceI32.cpp", ], sanitize: { integer_overflow: true, Loading media/libaaudio/src/client/AAudioFlowGraph.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ #include <flowgraph/SinkFloat.h> #include <flowgraph/SinkI16.h> #include <flowgraph/SinkI24.h> #include <flowgraph/SinkI32.h> #include <flowgraph/SourceFloat.h> #include <flowgraph/SourceI16.h> #include <flowgraph/SourceI24.h> #include <flowgraph/SourceI32.h> using namespace flowgraph; Loading @@ -38,7 +40,8 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, int32_t sinkChannelCount) { AudioFloatOutputPort *lastOutput = nullptr; ALOGV("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d", // TODO change back to ALOGD ALOGI("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d", __func__, sourceFormat, sourceChannelCount, sinkFormat, sinkChannelCount); switch (sourceFormat) { Loading @@ -51,7 +54,10 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, case AUDIO_FORMAT_PCM_24_BIT_PACKED: mSource = std::make_unique<SourceI24>(sourceChannelCount); break; default: // TODO add I32 case AUDIO_FORMAT_PCM_32_BIT: mSource = std::make_unique<SourceI32>(sourceChannelCount); break; default: ALOGE("%s() Unsupported source format = %d", __func__, sourceFormat); return AAUDIO_ERROR_UNIMPLEMENTED; } Loading Loading @@ -90,7 +96,10 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, case AUDIO_FORMAT_PCM_24_BIT_PACKED: mSink = std::make_unique<SinkI24>(sinkChannelCount); break; default: // TODO add I32 case AUDIO_FORMAT_PCM_32_BIT: mSink = std::make_unique<SinkI32>(sinkChannelCount); break; default: ALOGE("%s() Unsupported sink format = %d", __func__, sinkFormat); return AAUDIO_ERROR_UNIMPLEMENTED; } Loading media/libaaudio/src/client/AudioStreamInternal.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { if (getFormat() == AUDIO_FORMAT_DEFAULT) { setFormat(AUDIO_FORMAT_PCM_FLOAT); } // Request FLOAT for the shared mixer. // Request FLOAT for the shared mixer or the device. request.getConfiguration().setFormat(AUDIO_FORMAT_PCM_FLOAT); // Build the request to send to the server. Loading media/libaaudio/src/core/AAudioStreamParameters.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -54,7 +54,9 @@ static aaudio_result_t isFormatValid(audio_format_t format) { switch (format) { case AUDIO_FORMAT_DEFAULT: case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: break; // valid default: ALOGD("audioFormat not valid, audio_format_t = 0x%08x", format); Loading Loading
media/libaaudio/include/aaudio/AAudio.h +26 −2 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ enum { /** * This format uses the int16_t data type. * The maximum range of the data is -32768 to 32767. * The maximum range of the data is -32768 (0x8000) to 32767 (0x7FFF). */ AAUDIO_FORMAT_PCM_I16, Loading @@ -77,7 +77,31 @@ enum { * See also 'floatData' at * https://developer.android.com/reference/android/media/AudioTrack#write(float[],%20int,%20int,%20int) */ AAUDIO_FORMAT_PCM_FLOAT AAUDIO_FORMAT_PCM_FLOAT, /** * This format uses 24-bit samples packed into 3 bytes. * The bytes are in the native endian order. * The maximum range of the data is -8388608 (0x800000) * to 8388607 (0x7FFFFF). * * Note that the lower precision bits may be ignored by the device. * * Available since API level 31. */ AAUDIO_FORMAT_PCM_I24_PACKED, /** * This format uses 32-bit samples stored in an int32_t data type. * The maximum range of the data is -2147483648 (0x80000000) * to 2147483647 (0x7FFFFFFF). * * Note that the lower precision bits may be ignored by the device. * * Available since API level 31. */ AAUDIO_FORMAT_PCM_I32 }; typedef int32_t aaudio_format_t; Loading
media/libaaudio/src/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -130,9 +130,11 @@ cc_library { "flowgraph/SinkFloat.cpp", "flowgraph/SinkI16.cpp", "flowgraph/SinkI24.cpp", "flowgraph/SinkI32.cpp", "flowgraph/SourceFloat.cpp", "flowgraph/SourceI16.cpp", "flowgraph/SourceI24.cpp", "flowgraph/SourceI32.cpp", ], sanitize: { integer_overflow: true, Loading
media/libaaudio/src/client/AAudioFlowGraph.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ #include <flowgraph/SinkFloat.h> #include <flowgraph/SinkI16.h> #include <flowgraph/SinkI24.h> #include <flowgraph/SinkI32.h> #include <flowgraph/SourceFloat.h> #include <flowgraph/SourceI16.h> #include <flowgraph/SourceI24.h> #include <flowgraph/SourceI32.h> using namespace flowgraph; Loading @@ -38,7 +40,8 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, int32_t sinkChannelCount) { AudioFloatOutputPort *lastOutput = nullptr; ALOGV("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d", // TODO change back to ALOGD ALOGI("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d", __func__, sourceFormat, sourceChannelCount, sinkFormat, sinkChannelCount); switch (sourceFormat) { Loading @@ -51,7 +54,10 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, case AUDIO_FORMAT_PCM_24_BIT_PACKED: mSource = std::make_unique<SourceI24>(sourceChannelCount); break; default: // TODO add I32 case AUDIO_FORMAT_PCM_32_BIT: mSource = std::make_unique<SourceI32>(sourceChannelCount); break; default: ALOGE("%s() Unsupported source format = %d", __func__, sourceFormat); return AAUDIO_ERROR_UNIMPLEMENTED; } Loading Loading @@ -90,7 +96,10 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, case AUDIO_FORMAT_PCM_24_BIT_PACKED: mSink = std::make_unique<SinkI24>(sinkChannelCount); break; default: // TODO add I32 case AUDIO_FORMAT_PCM_32_BIT: mSink = std::make_unique<SinkI32>(sinkChannelCount); break; default: ALOGE("%s() Unsupported sink format = %d", __func__, sinkFormat); return AAUDIO_ERROR_UNIMPLEMENTED; } Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { if (getFormat() == AUDIO_FORMAT_DEFAULT) { setFormat(AUDIO_FORMAT_PCM_FLOAT); } // Request FLOAT for the shared mixer. // Request FLOAT for the shared mixer or the device. request.getConfiguration().setFormat(AUDIO_FORMAT_PCM_FLOAT); // Build the request to send to the server. Loading
media/libaaudio/src/core/AAudioStreamParameters.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -54,7 +54,9 @@ static aaudio_result_t isFormatValid(audio_format_t format) { switch (format) { case AUDIO_FORMAT_DEFAULT: case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: break; // valid default: ALOGD("audioFormat not valid, audio_format_t = 0x%08x", format); Loading