Loading media/libaaudio/include/aaudio/AAudio.h +184 −0 Original line number Diff line number Diff line Loading @@ -565,6 +565,145 @@ enum { }; typedef int32_t aaudio_session_id_t; /** * Defines the audio channel mask. * Channel masks are used to describe the samples and their * arrangement in the audio frame. They are also used in the endpoint * (e.g. a USB audio interface, a DAC connected to headphones) to * specify allowable configurations of a particular device. * * Added in API level 32. */ enum { /** * Invalid channel mask */ AAUDIO_CHANNEL_INVALID = -1, /** * Output audio channel mask */ AAUDIO_CHANNEL_FRONT_LEFT = 1 << 0, AAUDIO_CHANNEL_FRONT_RIGHT = 1 << 1, AAUDIO_CHANNEL_FRONT_CENTER = 1 << 2, AAUDIO_CHANNEL_LOW_FREQUENCY = 1 << 3, AAUDIO_CHANNEL_BACK_LEFT = 1 << 4, AAUDIO_CHANNEL_BACK_RIGHT = 1 << 5, AAUDIO_CHANNEL_FRONT_LEFT_OF_CENTER = 1 << 6, AAUDIO_CHANNEL_FRONT_RIGHT_OF_CENTER = 1 << 7, AAUDIO_CHANNEL_BACK_CENTER = 1 << 8, AAUDIO_CHANNEL_SIDE_LEFT = 1 << 9, AAUDIO_CHANNEL_SIDE_RIGHT = 1 << 10, AAUDIO_CHANNEL_TOP_CENTER = 1 << 11, AAUDIO_CHANNEL_TOP_FRONT_LEFT = 1 << 12, AAUDIO_CHANNEL_TOP_FRONT_CENTER = 1 << 13, AAUDIO_CHANNEL_TOP_FRONT_RIGHT = 1 << 14, AAUDIO_CHANNEL_TOP_BACK_LEFT = 1 << 15, AAUDIO_CHANNEL_TOP_BACK_CENTER = 1 << 16, AAUDIO_CHANNEL_TOP_BACK_RIGHT = 1 << 17, AAUDIO_CHANNEL_TOP_SIDE_LEFT = 1 << 18, AAUDIO_CHANNEL_TOP_SIDE_RIGHT = 1 << 19, AAUDIO_CHANNEL_BOTTOM_FRONT_LEFT = 1 << 20, AAUDIO_CHANNEL_BOTTOM_FRONT_CENTER = 1 << 21, AAUDIO_CHANNEL_BOTTOM_FRONT_RIGHT = 1 << 22, AAUDIO_CHANNEL_LOW_FREQUENCY_2 = 1 << 23, AAUDIO_CHANNEL_FRONT_WIDE_LEFT = 1 << 24, AAUDIO_CHANNEL_FRONT_WIDE_RIGHT = 1 << 25, AAUDIO_CHANNEL_MONO = AAUDIO_CHANNEL_FRONT_LEFT, AAUDIO_CHANNEL_STEREO = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT, AAUDIO_CHANNEL_2POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_TRI = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER, AAUDIO_CHANNEL_TRI_BACK = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_BACK_CENTER, AAUDIO_CHANNEL_3POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_2POINT0POINT2 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_2POINT1POINT2 = AAUDIO_CHANNEL_2POINT0POINT2 | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_3POINT0POINT2 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_3POINT1POINT2 = AAUDIO_CHANNEL_3POINT0POINT2 | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_QUAD = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT, AAUDIO_CHANNEL_QUAD_SIDE = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT, AAUDIO_CHANNEL_SURROUND = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_BACK_CENTER, AAUDIO_CHANNEL_PENTA = AAUDIO_CHANNEL_QUAD | AAUDIO_CHANNEL_FRONT_CENTER, // aka 5POINT1_BACK AAUDIO_CHANNEL_5POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT, AAUDIO_CHANNEL_5POINT1_SIDE = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT, AAUDIO_CHANNEL_6POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT | AAUDIO_CHANNEL_BACK_CENTER, AAUDIO_CHANNEL_7POINT1 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT, AAUDIO_CHANNEL_5POINT1POINT2 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_5POINT1POINT4 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT, AAUDIO_CHANNEL_7POINT1POINT2 = AAUDIO_CHANNEL_7POINT1 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_7POINT1POINT4 = AAUDIO_CHANNEL_7POINT1 | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT, AAUDIO_CHANNEL_9POINT1POINT4 = AAUDIO_CHANNEL_7POINT1POINT4 | AAUDIO_CHANNEL_FRONT_WIDE_LEFT | AAUDIO_CHANNEL_FRONT_WIDE_RIGHT, AAUDIO_CHANNEL_9POINT1POINT6 = AAUDIO_CHANNEL_9POINT1POINT4 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_FRONT_BACK = AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_BACK_CENTER, }; typedef uint32_t aaudio_channel_mask_t; typedef struct AAudioStreamStruct AAudioStream; typedef struct AAudioStreamBuilderStruct AAudioStreamBuilder; Loading Loading @@ -699,6 +838,11 @@ AAUDIO_API void AAudioStreamBuilder_setSampleRate(AAudioStreamBuilder* builder, * If an exact value is specified then an opened stream will use that value. * If a stream cannot be opened with the specified value then the open will fail. * * As the channel count provided here may be different from the corresponding channel count * of channel mask used in {@link AAudioStreamBuilder_setChannelMask}, the last called function * will be respected if both this function and {@link AAudioStreamBuilder_setChannelMask} are * called. * * Available since API level 26. * * @param builder reference provided by AAudio_createStreamBuilder() Loading @@ -714,6 +858,8 @@ AAUDIO_API void AAudioStreamBuilder_setChannelCount(AAudioStreamBuilder* builder * * @param builder reference provided by AAudio_createStreamBuilder() * @param samplesPerFrame Number of samples in a frame. * * @deprecated use {@link AAudioStreamBuilder_setChannelCount} */ AAUDIO_API void AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder* builder, int32_t samplesPerFrame) __INTRODUCED_IN(26); Loading Loading @@ -1136,6 +1282,32 @@ AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* AAUDIO_API aaudio_result_t AAudioStreamBuilder_delete(AAudioStreamBuilder* builder) __INTRODUCED_IN(26); /** * Set audio channel mask for the stream. * * The default, if you do not call this function, is {@link #AAUDIO_UNSPECIFIED}. * If both channel mask and count are not set, then stereo will then be chosen when the * stream is opened. * After opening a stream with an unspecified value, the application must query for the * actual value, which may vary by device. * * If an exact value is specified then an opened stream will use that value. * If a stream cannot be opened with the specified value then the open will fail. * * As the corresponding channel count of provided channel mask here may be different * from the channel count used in {@link AAudioStreamBuilder_setChannelCount} or * {@link AAudioStreamBuilder_setSamplesPerFrame}, the last called function will be * respected if this function and {@link AAudioStreamBuilder_setChannelCount} or * {@link AAudioStreamBuilder_setSamplesPerFrame} are called. * * Available since API level 32. * * @param builder reference provided by AAudio_createStreamBuilder() * @param channelMask Audio channel mask desired. */ AAUDIO_API void AAudioStreamBuilder_setChannelMask(AAudioStreamBuilder* builder, aaudio_channel_mask_t channelMask) __INTRODUCED_IN(32); // ============================================================ // Stream Control // ============================================================ Loading Loading @@ -1652,6 +1824,18 @@ AAUDIO_API aaudio_allowed_capture_policy_t AAudioStream_getAllowedCapturePolicy( AAUDIO_API bool AAudioStream_isPrivacySensitive(AAudioStream* stream) __INTRODUCED_IN(30); /** * Return the channel mask for the stream. This will be the mask set using * {@link #AAudioStreamBuilder_setChannelMask}, or {@link #AAUDIO_UNSPECIFIED} otherwise. * * Available since API level 32. * * @param stream reference provided by AAudioStreamBuilder_openStream() * @return actual channel mask */ AAUDIO_API aaudio_channel_mask_t AAudioStream_getChannelMask(AAudioStream* stream) __INTRODUCED_IN(32); #ifdef __cplusplus } #endif Loading media/libaaudio/src/binding/AAudioStreamConfiguration.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ using namespace aaudio; using android::media::audio::common::AudioFormat; AAudioStreamConfiguration::AAudioStreamConfiguration(const StreamParameters& parcelable) { setSamplesPerFrame(parcelable.samplesPerFrame); setChannelMask(parcelable.channelMask); setSampleRate(parcelable.sampleRate); setDeviceId(parcelable.deviceId); static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(parcelable.sharingMode)); Loading Loading @@ -63,7 +63,7 @@ AAudioStreamConfiguration::operator=(const StreamParameters& parcelable) { StreamParameters AAudioStreamConfiguration::parcelable() const { StreamParameters result; result.samplesPerFrame = getSamplesPerFrame(); result.channelMask = getChannelMask(); result.sampleRate = getSampleRate(); result.deviceId = getDeviceId(); static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(result.sharingMode)); Loading media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package aaudio; import android.media.audio.common.AudioFormat; parcelable StreamParameters { int samplesPerFrame; // = AAUDIO_UNSPECIFIED; int channelMask; // = AAUDIO_UNSPECIFIED; int sampleRate; // = AAUDIO_UNSPECIFIED; int deviceId; // = AAUDIO_UNSPECIFIED; int /* aaudio_sharing_mode_t */ sharingMode; // = AAUDIO_SHARING_MODE_SHARED; Loading media/libaaudio/src/client/AudioStreamInternal.cpp +7 −5 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { request.getConfiguration().setDeviceId(getDeviceId()); request.getConfiguration().setSampleRate(getSampleRate()); request.getConfiguration().setSamplesPerFrame(getSamplesPerFrame()); request.getConfiguration().setDirection(getDirection()); request.getConfiguration().setSharingMode(getSharingMode()); request.getConfiguration().setChannelMask(getChannelMask()); request.getConfiguration().setUsage(getUsage()); request.getConfiguration().setContentType(getContentType()); Loading @@ -138,7 +138,8 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { mServiceStreamHandle = mServiceInterface.openStream(request, configurationOutput); if (mServiceStreamHandle < 0 && request.getConfiguration().getSamplesPerFrame() == 1 // mono? && (request.getConfiguration().getSamplesPerFrame() == 1 || request.getConfiguration().getChannelMask() == AAUDIO_CHANNEL_MONO) && getDirection() == AAUDIO_DIRECTION_OUTPUT && !isInService()) { // if that failed then try switching from mono to stereo if OUTPUT. Loading @@ -146,7 +147,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { // that writes to a stereo MMAP stream. ALOGD("%s() - openStream() returned %d, try switching from MONO to STEREO", __func__, mServiceStreamHandle); request.getConfiguration().setSamplesPerFrame(2); // stereo request.getConfiguration().setChannelMask(AAUDIO_CHANNEL_STEREO); mServiceStreamHandle = mServiceInterface.openStream(request, configurationOutput); } if (mServiceStreamHandle < 0) { Loading @@ -171,9 +172,10 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { goto error; } // Save results of the open. if (getSamplesPerFrame() == AAUDIO_UNSPECIFIED) { setSamplesPerFrame(configurationOutput.getSamplesPerFrame()); if (getChannelMask() == AAUDIO_UNSPECIFIED) { setChannelMask(configurationOutput.getChannelMask()); } mDeviceChannelCount = configurationOutput.getSamplesPerFrame(); setSampleRate(configurationOutput.getSampleRate()); Loading media/libaaudio/src/core/AAudioAudio.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,8 @@ AAUDIO_API void AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder* buil int32_t samplesPerFrame) { AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder); streamBuilder->setSamplesPerFrame(samplesPerFrame); const aaudio_channel_mask_t channelMask = AAudioConvert_channelCountToMask(samplesPerFrame); streamBuilder->setChannelMask(channelMask); } AAUDIO_API void AAudioStreamBuilder_setDirection(AAudioStreamBuilder* builder, Loading Loading @@ -223,6 +224,13 @@ AAUDIO_API void AAudioStreamBuilder_setFramesPerDataCallback(AAudioStreamBuilder streamBuilder->setFramesPerDataCallback(frames); } AAUDIO_API void AAudioStreamBuilder_setChannelMask(AAudioStreamBuilder* builder, aaudio_channel_mask_t channelMask) { AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder); streamBuilder->setChannelMask(channelMask); } AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* builder, AAudioStream** streamPtr) { Loading Loading @@ -562,3 +570,11 @@ AAUDIO_API bool AAudioStream_isPrivacySensitive(AAudioStream* stream) AudioStream *audioStream = convertAAudioStreamToAudioStream(stream); return audioStream->isPrivacySensitive(); } AAUDIO_API aaudio_channel_mask_t AAudioStream_getChannelMask(AAudioStream* stream) { AudioStream *audioStream = convertAAudioStreamToAudioStream(stream); const aaudio_channel_mask_t channelMask = audioStream->getChannelMask(); // Do not return channel index masks as they are not public. return AAudio_isChannelIndexMask(channelMask) ? AAUDIO_UNSPECIFIED : channelMask; } Loading
media/libaaudio/include/aaudio/AAudio.h +184 −0 Original line number Diff line number Diff line Loading @@ -565,6 +565,145 @@ enum { }; typedef int32_t aaudio_session_id_t; /** * Defines the audio channel mask. * Channel masks are used to describe the samples and their * arrangement in the audio frame. They are also used in the endpoint * (e.g. a USB audio interface, a DAC connected to headphones) to * specify allowable configurations of a particular device. * * Added in API level 32. */ enum { /** * Invalid channel mask */ AAUDIO_CHANNEL_INVALID = -1, /** * Output audio channel mask */ AAUDIO_CHANNEL_FRONT_LEFT = 1 << 0, AAUDIO_CHANNEL_FRONT_RIGHT = 1 << 1, AAUDIO_CHANNEL_FRONT_CENTER = 1 << 2, AAUDIO_CHANNEL_LOW_FREQUENCY = 1 << 3, AAUDIO_CHANNEL_BACK_LEFT = 1 << 4, AAUDIO_CHANNEL_BACK_RIGHT = 1 << 5, AAUDIO_CHANNEL_FRONT_LEFT_OF_CENTER = 1 << 6, AAUDIO_CHANNEL_FRONT_RIGHT_OF_CENTER = 1 << 7, AAUDIO_CHANNEL_BACK_CENTER = 1 << 8, AAUDIO_CHANNEL_SIDE_LEFT = 1 << 9, AAUDIO_CHANNEL_SIDE_RIGHT = 1 << 10, AAUDIO_CHANNEL_TOP_CENTER = 1 << 11, AAUDIO_CHANNEL_TOP_FRONT_LEFT = 1 << 12, AAUDIO_CHANNEL_TOP_FRONT_CENTER = 1 << 13, AAUDIO_CHANNEL_TOP_FRONT_RIGHT = 1 << 14, AAUDIO_CHANNEL_TOP_BACK_LEFT = 1 << 15, AAUDIO_CHANNEL_TOP_BACK_CENTER = 1 << 16, AAUDIO_CHANNEL_TOP_BACK_RIGHT = 1 << 17, AAUDIO_CHANNEL_TOP_SIDE_LEFT = 1 << 18, AAUDIO_CHANNEL_TOP_SIDE_RIGHT = 1 << 19, AAUDIO_CHANNEL_BOTTOM_FRONT_LEFT = 1 << 20, AAUDIO_CHANNEL_BOTTOM_FRONT_CENTER = 1 << 21, AAUDIO_CHANNEL_BOTTOM_FRONT_RIGHT = 1 << 22, AAUDIO_CHANNEL_LOW_FREQUENCY_2 = 1 << 23, AAUDIO_CHANNEL_FRONT_WIDE_LEFT = 1 << 24, AAUDIO_CHANNEL_FRONT_WIDE_RIGHT = 1 << 25, AAUDIO_CHANNEL_MONO = AAUDIO_CHANNEL_FRONT_LEFT, AAUDIO_CHANNEL_STEREO = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT, AAUDIO_CHANNEL_2POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_TRI = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER, AAUDIO_CHANNEL_TRI_BACK = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_BACK_CENTER, AAUDIO_CHANNEL_3POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_2POINT0POINT2 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_2POINT1POINT2 = AAUDIO_CHANNEL_2POINT0POINT2 | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_3POINT0POINT2 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_3POINT1POINT2 = AAUDIO_CHANNEL_3POINT0POINT2 | AAUDIO_CHANNEL_LOW_FREQUENCY, AAUDIO_CHANNEL_QUAD = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT, AAUDIO_CHANNEL_QUAD_SIDE = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT, AAUDIO_CHANNEL_SURROUND = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_BACK_CENTER, AAUDIO_CHANNEL_PENTA = AAUDIO_CHANNEL_QUAD | AAUDIO_CHANNEL_FRONT_CENTER, // aka 5POINT1_BACK AAUDIO_CHANNEL_5POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT, AAUDIO_CHANNEL_5POINT1_SIDE = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT, AAUDIO_CHANNEL_6POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT | AAUDIO_CHANNEL_BACK_CENTER, AAUDIO_CHANNEL_7POINT1 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT, AAUDIO_CHANNEL_5POINT1POINT2 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_5POINT1POINT4 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT, AAUDIO_CHANNEL_7POINT1POINT2 = AAUDIO_CHANNEL_7POINT1 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_7POINT1POINT4 = AAUDIO_CHANNEL_7POINT1 | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT, AAUDIO_CHANNEL_9POINT1POINT4 = AAUDIO_CHANNEL_7POINT1POINT4 | AAUDIO_CHANNEL_FRONT_WIDE_LEFT | AAUDIO_CHANNEL_FRONT_WIDE_RIGHT, AAUDIO_CHANNEL_9POINT1POINT6 = AAUDIO_CHANNEL_9POINT1POINT4 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT, AAUDIO_CHANNEL_FRONT_BACK = AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_BACK_CENTER, }; typedef uint32_t aaudio_channel_mask_t; typedef struct AAudioStreamStruct AAudioStream; typedef struct AAudioStreamBuilderStruct AAudioStreamBuilder; Loading Loading @@ -699,6 +838,11 @@ AAUDIO_API void AAudioStreamBuilder_setSampleRate(AAudioStreamBuilder* builder, * If an exact value is specified then an opened stream will use that value. * If a stream cannot be opened with the specified value then the open will fail. * * As the channel count provided here may be different from the corresponding channel count * of channel mask used in {@link AAudioStreamBuilder_setChannelMask}, the last called function * will be respected if both this function and {@link AAudioStreamBuilder_setChannelMask} are * called. * * Available since API level 26. * * @param builder reference provided by AAudio_createStreamBuilder() Loading @@ -714,6 +858,8 @@ AAUDIO_API void AAudioStreamBuilder_setChannelCount(AAudioStreamBuilder* builder * * @param builder reference provided by AAudio_createStreamBuilder() * @param samplesPerFrame Number of samples in a frame. * * @deprecated use {@link AAudioStreamBuilder_setChannelCount} */ AAUDIO_API void AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder* builder, int32_t samplesPerFrame) __INTRODUCED_IN(26); Loading Loading @@ -1136,6 +1282,32 @@ AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* AAUDIO_API aaudio_result_t AAudioStreamBuilder_delete(AAudioStreamBuilder* builder) __INTRODUCED_IN(26); /** * Set audio channel mask for the stream. * * The default, if you do not call this function, is {@link #AAUDIO_UNSPECIFIED}. * If both channel mask and count are not set, then stereo will then be chosen when the * stream is opened. * After opening a stream with an unspecified value, the application must query for the * actual value, which may vary by device. * * If an exact value is specified then an opened stream will use that value. * If a stream cannot be opened with the specified value then the open will fail. * * As the corresponding channel count of provided channel mask here may be different * from the channel count used in {@link AAudioStreamBuilder_setChannelCount} or * {@link AAudioStreamBuilder_setSamplesPerFrame}, the last called function will be * respected if this function and {@link AAudioStreamBuilder_setChannelCount} or * {@link AAudioStreamBuilder_setSamplesPerFrame} are called. * * Available since API level 32. * * @param builder reference provided by AAudio_createStreamBuilder() * @param channelMask Audio channel mask desired. */ AAUDIO_API void AAudioStreamBuilder_setChannelMask(AAudioStreamBuilder* builder, aaudio_channel_mask_t channelMask) __INTRODUCED_IN(32); // ============================================================ // Stream Control // ============================================================ Loading Loading @@ -1652,6 +1824,18 @@ AAUDIO_API aaudio_allowed_capture_policy_t AAudioStream_getAllowedCapturePolicy( AAUDIO_API bool AAudioStream_isPrivacySensitive(AAudioStream* stream) __INTRODUCED_IN(30); /** * Return the channel mask for the stream. This will be the mask set using * {@link #AAudioStreamBuilder_setChannelMask}, or {@link #AAUDIO_UNSPECIFIED} otherwise. * * Available since API level 32. * * @param stream reference provided by AAudioStreamBuilder_openStream() * @return actual channel mask */ AAUDIO_API aaudio_channel_mask_t AAudioStream_getChannelMask(AAudioStream* stream) __INTRODUCED_IN(32); #ifdef __cplusplus } #endif Loading
media/libaaudio/src/binding/AAudioStreamConfiguration.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ using namespace aaudio; using android::media::audio::common::AudioFormat; AAudioStreamConfiguration::AAudioStreamConfiguration(const StreamParameters& parcelable) { setSamplesPerFrame(parcelable.samplesPerFrame); setChannelMask(parcelable.channelMask); setSampleRate(parcelable.sampleRate); setDeviceId(parcelable.deviceId); static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(parcelable.sharingMode)); Loading Loading @@ -63,7 +63,7 @@ AAudioStreamConfiguration::operator=(const StreamParameters& parcelable) { StreamParameters AAudioStreamConfiguration::parcelable() const { StreamParameters result; result.samplesPerFrame = getSamplesPerFrame(); result.channelMask = getChannelMask(); result.sampleRate = getSampleRate(); result.deviceId = getDeviceId(); static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(result.sharingMode)); Loading
media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package aaudio; import android.media.audio.common.AudioFormat; parcelable StreamParameters { int samplesPerFrame; // = AAUDIO_UNSPECIFIED; int channelMask; // = AAUDIO_UNSPECIFIED; int sampleRate; // = AAUDIO_UNSPECIFIED; int deviceId; // = AAUDIO_UNSPECIFIED; int /* aaudio_sharing_mode_t */ sharingMode; // = AAUDIO_SHARING_MODE_SHARED; Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +7 −5 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { request.getConfiguration().setDeviceId(getDeviceId()); request.getConfiguration().setSampleRate(getSampleRate()); request.getConfiguration().setSamplesPerFrame(getSamplesPerFrame()); request.getConfiguration().setDirection(getDirection()); request.getConfiguration().setSharingMode(getSharingMode()); request.getConfiguration().setChannelMask(getChannelMask()); request.getConfiguration().setUsage(getUsage()); request.getConfiguration().setContentType(getContentType()); Loading @@ -138,7 +138,8 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { mServiceStreamHandle = mServiceInterface.openStream(request, configurationOutput); if (mServiceStreamHandle < 0 && request.getConfiguration().getSamplesPerFrame() == 1 // mono? && (request.getConfiguration().getSamplesPerFrame() == 1 || request.getConfiguration().getChannelMask() == AAUDIO_CHANNEL_MONO) && getDirection() == AAUDIO_DIRECTION_OUTPUT && !isInService()) { // if that failed then try switching from mono to stereo if OUTPUT. Loading @@ -146,7 +147,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { // that writes to a stereo MMAP stream. ALOGD("%s() - openStream() returned %d, try switching from MONO to STEREO", __func__, mServiceStreamHandle); request.getConfiguration().setSamplesPerFrame(2); // stereo request.getConfiguration().setChannelMask(AAUDIO_CHANNEL_STEREO); mServiceStreamHandle = mServiceInterface.openStream(request, configurationOutput); } if (mServiceStreamHandle < 0) { Loading @@ -171,9 +172,10 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { goto error; } // Save results of the open. if (getSamplesPerFrame() == AAUDIO_UNSPECIFIED) { setSamplesPerFrame(configurationOutput.getSamplesPerFrame()); if (getChannelMask() == AAUDIO_UNSPECIFIED) { setChannelMask(configurationOutput.getChannelMask()); } mDeviceChannelCount = configurationOutput.getSamplesPerFrame(); setSampleRate(configurationOutput.getSampleRate()); Loading
media/libaaudio/src/core/AAudioAudio.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,8 @@ AAUDIO_API void AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder* buil int32_t samplesPerFrame) { AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder); streamBuilder->setSamplesPerFrame(samplesPerFrame); const aaudio_channel_mask_t channelMask = AAudioConvert_channelCountToMask(samplesPerFrame); streamBuilder->setChannelMask(channelMask); } AAUDIO_API void AAudioStreamBuilder_setDirection(AAudioStreamBuilder* builder, Loading Loading @@ -223,6 +224,13 @@ AAUDIO_API void AAudioStreamBuilder_setFramesPerDataCallback(AAudioStreamBuilder streamBuilder->setFramesPerDataCallback(frames); } AAUDIO_API void AAudioStreamBuilder_setChannelMask(AAudioStreamBuilder* builder, aaudio_channel_mask_t channelMask) { AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder); streamBuilder->setChannelMask(channelMask); } AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* builder, AAudioStream** streamPtr) { Loading Loading @@ -562,3 +570,11 @@ AAUDIO_API bool AAudioStream_isPrivacySensitive(AAudioStream* stream) AudioStream *audioStream = convertAAudioStreamToAudioStream(stream); return audioStream->isPrivacySensitive(); } AAUDIO_API aaudio_channel_mask_t AAudioStream_getChannelMask(AAudioStream* stream) { AudioStream *audioStream = convertAAudioStreamToAudioStream(stream); const aaudio_channel_mask_t channelMask = audioStream->getChannelMask(); // Do not return channel index masks as they are not public. return AAudio_isChannelIndexMask(channelMask) ? AAUDIO_UNSPECIFIED : channelMask; }