Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add channel mask support for API 32. #1548

Merged
merged 4 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 119 additions & 118 deletions include/oboe/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,149 +496,150 @@ namespace oboe {
Unspecified = kUnspecified,

/**
* Channel position masks. Use the combinations of the channel position masks.
*/
FRONT_LEFT = 1 << 0,
FRONT_RIGHT = 1 << 1,
FRONT_CENTER = 1 << 2,
LOW_FREQUENCY = 1 << 3,
BACK_LEFT = 1 << 4,
BACK_RIGHT = 1 << 5,
FRONT_LEFT_OF_CENTER = 1 << 6,
FRONT_RIGHT_OF_CENTER = 1 << 7,
BACK_CENTER = 1 << 8,
SIDE_LEFT = 1 << 9,
SIDE_RIGHT = 1 << 10,
TOP_CENTER = 1 << 11,
TOP_FRONT_LEFT = 1 << 12,
TOP_FRONT_CENTER = 1 << 13,
TOP_FRONT_RIGHT = 1 << 14,
TOP_BACK_LEFT = 1 << 15,
TOP_BACK_CENTER = 1 << 16,
TOP_BACK_RIGHT = 1 << 17,
TOP_SIDE_LEFT = 1 << 18,
TOP_SIDE_RIGHT = 1 << 19,
BOTTOM_FRONT_LEFT = 1 << 20,
BOTTOM_FRONT_CENTER = 1 << 21,
BOTTOM_FRONT_RIGHT = 1 << 22,
LOW_FREQUENCY_2 = 1 << 23,
FRONT_WIDE_LEFT = 1 << 24,
FRONT_WIDE_RIGHT = 1 << 25,

Mono = FRONT_LEFT,

Stereo = FRONT_LEFT |
FRONT_RIGHT,

CM2Point1 = FRONT_LEFT |
FRONT_RIGHT |
LOW_FREQUENCY,

Tri = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER,

Tri_back = FRONT_LEFT |
FRONT_RIGHT |
BACK_CENTER,

CM3Point1 = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER |
LOW_FREQUENCY,

CM2Point0Point2 = FRONT_LEFT |
FRONT_RIGHT |
TOP_SIDE_LEFT |
TOP_SIDE_RIGHT,
* Channel position masks. Use the combinations of the channel position masks
* defined below instead of using those values directly.
*/
FrontLeft = 1 << 0,
FrontRight = 1 << 1,
FrontCenter = 1 << 2,
LowFrequency = 1 << 3,
BackLeft = 1 << 4,
BackRight = 1 << 5,
FrontLeftOfCenter = 1 << 6,
FrontRightOfCenter = 1 << 7,
BackCenter = 1 << 8,
SideLeft = 1 << 9,
SideRight = 1 << 10,
TopCenter = 1 << 11,
TopFrontLeft = 1 << 12,
TopFrontCenter = 1 << 13,
TopFrontRight = 1 << 14,
TopBackLeft = 1 << 15,
TopBackCenter = 1 << 16,
TopBackRight = 1 << 17,
TopSideLeft = 1 << 18,
TopSideRight = 1 << 19,
BottomFrontLeft = 1 << 20,
BottomFrontCenter = 1 << 21,
BottomFrontRight = 1 << 22,
LowFrequency2 = 1 << 23,
FrontWideLeft = 1 << 24,
FrontWideRight = 1 << 25,

Mono = FrontLeft,

Stereo = FrontLeft |
FrontRight,

CM2Point1 = FrontLeft |
FrontRight |
LowFrequency,

Tri = FrontLeft |
FrontRight |
FrontCenter,

Tri_back = FrontLeft |
flamme marked this conversation as resolved.
Show resolved Hide resolved
FrontRight |
BackCenter,

CM3Point1 = FrontLeft |
FrontRight |
FrontCenter |
LowFrequency,

CM2Point0Point2 = FrontLeft |
FrontRight |
TopSideLeft |
TopSideRight,

CM2Point1Point2 = CM2Point0Point2 |
LOW_FREQUENCY,
LowFrequency,

CM3Point0Point2 = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER |
TOP_SIDE_LEFT |
TOP_SIDE_RIGHT,
CM3Point0Point2 = FrontLeft |
FrontRight |
FrontCenter |
TopSideLeft |
TopSideRight,

CM3Point1Point2 = CM3Point0Point2 |
LOW_FREQUENCY,
LowFrequency,

Quad = FRONT_LEFT |
FRONT_RIGHT |
BACK_LEFT |
BACK_RIGHT,
Quad = FrontLeft |
FrontRight |
BackLeft |
BackRight,

QuadSide = FRONT_LEFT |
FRONT_RIGHT |
SIDE_LEFT |
SIDE_RIGHT,
QuadSide = FrontLeft |
FrontRight |
SideLeft |
SideRight,

Surround = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER |
BACK_CENTER,
Surround = FrontLeft |
FrontRight |
FrontCenter |
BackCenter,

Penta = Quad |
FRONT_CENTER,

// aka 5POINT1_BACK
CM5Point1 = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER |
LOW_FREQUENCY |
BACK_LEFT |
BACK_RIGHT,

CM5Point1Side = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER |
LOW_FREQUENCY |
SIDE_LEFT |
SIDE_RIGHT,

CM6Point1 = FRONT_LEFT |
FRONT_RIGHT |
FRONT_CENTER |
LOW_FREQUENCY |
BACK_LEFT |
BACK_RIGHT |
BACK_CENTER,
FrontCenter,

// aka 5Point1Back
CM5Point1 = FrontLeft |
FrontRight |
FrontCenter |
LowFrequency |
BackLeft |
BackRight,

CM5Point1Side = FrontLeft |
FrontRight |
FrontCenter |
LowFrequency |
SideLeft |
SideRight,

CM6Point1 = FrontLeft |
FrontRight |
FrontCenter |
LowFrequency |
BackLeft |
BackRight |
BackCenter,

CM7Point1 = CM5Point1 |
SIDE_LEFT |
SIDE_RIGHT,
SideLeft |
SideRight,

CM5Point1Point2 = CM5Point1 |
TOP_SIDE_LEFT |
TOP_SIDE_RIGHT,
TopSideLeft |
TopSideRight,

CM5Point1Point4 = CM5Point1 |
TOP_FRONT_LEFT |
TOP_FRONT_RIGHT |
TOP_BACK_LEFT |
TOP_BACK_RIGHT,
TopFrontLeft |
TopFrontRight |
TopBackLeft |
TopBackRight,

CM7Point1Point2 = CM7Point1 |
TOP_SIDE_LEFT |
TOP_SIDE_RIGHT,
TopSideLeft |
TopSideRight,

CM7Point1Point4 = CM7Point1 |
TOP_FRONT_LEFT |
TOP_FRONT_RIGHT |
TOP_BACK_LEFT |
TOP_BACK_RIGHT,
TopFrontLeft |
TopFrontRight |
TopBackLeft |
TopBackRight,

CM9Point1Point4 = CM7Point1Point4 |
FRONT_WIDE_LEFT |
FRONT_WIDE_RIGHT,
FrontWideLeft |
FrontWideRight,

CM9Point1Point6 = CM9Point1Point4 |
TOP_SIDE_LEFT |
TOP_SIDE_RIGHT,
TopSideLeft |
TopSideRight,

FrontBack = FRONT_CENTER |
BACK_CENTER,
FrontBack = FrontCenter |
BackCenter,
};

/**
Expand Down
26 changes: 26 additions & 0 deletions src/aaudio/AAudioLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,32 @@ AAudioLoader::signature_U_PS AAudioLoader::load_U_PS(const char *functionName) {

ASSERT_UINT32(aaudio_channel_mask_t);

static_assert((uint32_t)ChannelMask::FrontLeft == AAUDIO_CHANNEL_FRONT_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontRight == AAUDIO_CHANNEL_FRONT_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontCenter == AAUDIO_CHANNEL_FRONT_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::LowFrequency == AAUDIO_CHANNEL_LOW_FREQUENCY, ERRMSG);
static_assert((uint32_t)ChannelMask::BackLeft == AAUDIO_CHANNEL_BACK_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::BackRight == AAUDIO_CHANNEL_BACK_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontLeftOfCenter == AAUDIO_CHANNEL_FRONT_LEFT_OF_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontRightOfCenter == AAUDIO_CHANNEL_FRONT_RIGHT_OF_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::BackCenter == AAUDIO_CHANNEL_BACK_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::SideLeft == AAUDIO_CHANNEL_SIDE_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::SideRight == AAUDIO_CHANNEL_SIDE_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::TopCenter == AAUDIO_CHANNEL_TOP_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::TopFrontLeft == AAUDIO_CHANNEL_TOP_FRONT_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::TopFrontCenter == AAUDIO_CHANNEL_TOP_FRONT_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::TopFrontRight == AAUDIO_CHANNEL_TOP_FRONT_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::TopBackLeft == AAUDIO_CHANNEL_TOP_BACK_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::TopBackCenter == AAUDIO_CHANNEL_TOP_BACK_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::TopBackRight == AAUDIO_CHANNEL_TOP_BACK_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::TopSideLeft == AAUDIO_CHANNEL_TOP_SIDE_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::TopSideRight == AAUDIO_CHANNEL_TOP_SIDE_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::BottomFrontLeft == AAUDIO_CHANNEL_BOTTOM_FRONT_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::BottomFrontCenter == AAUDIO_CHANNEL_BOTTOM_FRONT_CENTER, ERRMSG);
static_assert((uint32_t)ChannelMask::BottomFrontRight == AAUDIO_CHANNEL_BOTTOM_FRONT_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::LowFrequency2 == AAUDIO_CHANNEL_LOW_FREQUENCY_2, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontWideLeft == AAUDIO_CHANNEL_FRONT_WIDE_LEFT, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontWideRight == AAUDIO_CHANNEL_FRONT_WIDE_RIGHT, ERRMSG);
static_assert((uint32_t)ChannelMask::Mono == AAUDIO_CHANNEL_MONO, ERRMSG);
static_assert((uint32_t)ChannelMask::Stereo == AAUDIO_CHANNEL_STEREO, ERRMSG);
static_assert((uint32_t)ChannelMask::CM2Point1 == AAUDIO_CHANNEL_2POINT1, ERRMSG);
Expand Down
6 changes: 5 additions & 1 deletion src/aaudio/AudioStreamAAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ Result AudioStreamAAudio::open() {
}
mLibLoader->builder_setBufferCapacityInFrames(aaudioBuilder, capacity);

// Channel mask was added in SC_V2. In that case, only set channel mask when the API
// Channel mask was added in SC_V2. Given the corresponding channel count of selected channel
// mask may be different from selected channel count, the last set value will be respected.
// If channel count is set after channel mask, the previously set channel mask will be cleared.
// If channel mask is set after channel count, the channel count will be automatically
// calculated from selected channel mask. In that case, only set channel mask when the API
// is available and the channel mask is specified.
if (mLibLoader->builder_setChannelMask != nullptr && mChannelMask != ChannelMask::Unspecified) {
mLibLoader->builder_setChannelMask(aaudioBuilder,
flamme marked this conversation as resolved.
Show resolved Hide resolved
Expand Down