diff --git a/src/channel_layout.c b/src/channel_layout.c index bcefa9a..b3a3257 100644 --- a/src/channel_layout.c +++ b/src/channel_layout.c @@ -9,23 +9,25 @@ #include -static struct SoundIoChannelLayout builtin_channel_layouts[] = { - [SoundIoChannelLayoutIdMono] = { +static struct SoundIoChannelLayout *make_builtin_channel_layouts() +{ + static struct SoundIoChannelLayout layouts[SoundIoChannelLayoutIdMax]; + layouts[SoundIoChannelLayoutIdMono] = { "Mono", 1, { SoundIoChannelIdFrontCenter, }, - }, - [SoundIoChannelLayoutIdStereo] = { + }; + layouts[SoundIoChannelLayoutIdStereo] = { "Stereo", 2, { SoundIoChannelIdFrontLeft, SoundIoChannelIdFrontRight, }, - }, - [SoundIoChannelLayoutId2Point1] = { + }; + layouts[SoundIoChannelLayoutId2Point1] = { "2.1", 3, { @@ -33,8 +35,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontRight, SoundIoChannelIdLfe, }, - }, - [SoundIoChannelLayoutId3Point0] = { + }; + layouts[SoundIoChannelLayoutId3Point0] = { "3.0", 3, { @@ -42,8 +44,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontRight, SoundIoChannelIdFrontCenter, } - }, - [SoundIoChannelLayoutId3Point0Back] = { + }; + layouts[SoundIoChannelLayoutId3Point0Back] = { "3.0 (back)", 3, { @@ -51,8 +53,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontRight, SoundIoChannelIdBackCenter, } - }, - [SoundIoChannelLayoutId3Point1] = { + }; + layouts[SoundIoChannelLayoutId3Point1] = { "3.1", 4, { @@ -61,8 +63,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId4Point0] = { + }; + layouts[SoundIoChannelLayoutId4Point0] = { "4.0", 4, { @@ -71,8 +73,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontCenter, SoundIoChannelIdBackCenter, } - }, - [SoundIoChannelLayoutIdQuad] = { + }; + layouts[SoundIoChannelLayoutIdQuad] = { "Quad", 4, { @@ -81,8 +83,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackLeft, SoundIoChannelIdBackRight, }, - }, - [SoundIoChannelLayoutIdQuadSide] = { + }; + layouts[SoundIoChannelLayoutIdQuadSide] = { "Quad (side)", 4, { @@ -91,8 +93,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdSideLeft, SoundIoChannelIdSideRight, } - }, - [SoundIoChannelLayoutId4Point1] = { + }; + layouts[SoundIoChannelLayoutId4Point1] = { "4.1", 5, { @@ -102,8 +104,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId5Point0Back] = { + }; + layouts[SoundIoChannelLayoutId5Point0Back] = { "5.0 (back)", 5, { @@ -113,8 +115,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackLeft, SoundIoChannelIdBackRight, } - }, - [SoundIoChannelLayoutId5Point0Side] = { + }; + layouts[SoundIoChannelLayoutId5Point0Side] = { "5.0 (side)", 5, { @@ -124,8 +126,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdSideLeft, SoundIoChannelIdSideRight, } - }, - [SoundIoChannelLayoutId5Point1] = { + }; + layouts[SoundIoChannelLayoutId5Point1] = { "5.1", 6, { @@ -136,8 +138,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdSideRight, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId5Point1Back] = { + }; + layouts[SoundIoChannelLayoutId5Point1Back] = { "5.1 (back)", 6, { @@ -148,8 +150,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackRight, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId6Point0Side] = { + }; + layouts[SoundIoChannelLayoutId6Point0Side] = { "6.0 (side)", 6, { @@ -160,8 +162,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdSideRight, SoundIoChannelIdBackCenter, } - }, - [SoundIoChannelLayoutId6Point0Front] = { + }; + layouts[SoundIoChannelLayoutId6Point0Front] = { "6.0 (front)", 6, { @@ -172,8 +174,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontLeftCenter, SoundIoChannelIdFrontRightCenter, } - }, - [SoundIoChannelLayoutIdHexagonal] = { + }; + layouts[SoundIoChannelLayoutIdHexagonal] = { "Hexagonal", 6, { @@ -184,8 +186,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackRight, SoundIoChannelIdBackCenter, } - }, - [SoundIoChannelLayoutId6Point1] = { + }; + layouts[SoundIoChannelLayoutId6Point1] = { "6.1", 7, { @@ -197,8 +199,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId6Point1Back] = { + }; + layouts[SoundIoChannelLayoutId6Point1Back] = { "6.1 (back)", 7, { @@ -210,8 +212,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId6Point1Front] = { + }; + layouts[SoundIoChannelLayoutId6Point1Front] = { "6.1 (front)", 7, { @@ -223,8 +225,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontRightCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId7Point0] = { + }; + layouts[SoundIoChannelLayoutId7Point0] = { "7.0", 7, { @@ -236,8 +238,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackLeft, SoundIoChannelIdBackRight, } - }, - [SoundIoChannelLayoutId7Point0Front] = { + }; + layouts[SoundIoChannelLayoutId7Point0Front] = { "7.0 (front)", 7, { @@ -249,8 +251,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontLeftCenter, SoundIoChannelIdFrontRightCenter, } - }, - [SoundIoChannelLayoutId7Point1] = { + }; + layouts[SoundIoChannelLayoutId7Point1] = { "7.1", 8, { @@ -263,8 +265,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackRight, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId7Point1Wide] = { + }; + layouts[SoundIoChannelLayoutId7Point1Wide] = { "7.1 (wide)", 8, { @@ -277,8 +279,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontRightCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutId7Point1WideBack] = { + }; + layouts[SoundIoChannelLayoutId7Point1WideBack] = { "7.1 (wide) (back)", 8, { @@ -291,8 +293,8 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdFrontRightCenter, SoundIoChannelIdLfe, } - }, - [SoundIoChannelLayoutIdOctagonal] = { + }; + layouts[SoundIoChannelLayoutIdOctagonal] = { "Octagonal", 8, { @@ -305,357 +307,226 @@ static struct SoundIoChannelLayout builtin_channel_layouts[] = { SoundIoChannelIdBackRight, SoundIoChannelIdBackCenter, } - }, + }; + return &layouts[0]; }; +static struct SoundIoChannelLayout *builtin_channel_layouts = make_builtin_channel_layouts(); #define CHANNEL_NAME_ALIAS_COUNT 3 -static const char *channel_names[][CHANNEL_NAME_ALIAS_COUNT] = { - [SoundIoChannelIdInvalid] = { - "(Invalid Channel)", - NULL, - NULL, - }, - [SoundIoChannelIdFrontLeft] = { - "Front Left", - "FL", - "front-left", - }, - [SoundIoChannelIdFrontRight] = { - "Front Right", - "FR", - "front-right", - }, - [SoundIoChannelIdFrontCenter] = { - "Front Center", - "FC", - "front-center", - }, - [SoundIoChannelIdLfe] = { - "LFE", - "LFE", - "lfe", - }, - [SoundIoChannelIdBackLeft] = { - "Back Left", - "BL", - "rear-left", - }, - [SoundIoChannelIdBackRight] = { - "Back Right", - "BR", - "rear-right", - }, - [SoundIoChannelIdFrontLeftCenter] = { - "Front Left Center", - "FLC", - "front-left-of-center", - }, - [SoundIoChannelIdFrontRightCenter] = { - "Front Right Center", - "FRC", - "front-right-of-center", - }, - [SoundIoChannelIdBackCenter] = { - "Back Center", - "BC", - "rear-center", - }, - [SoundIoChannelIdSideLeft] = { - "Side Left", - "SL", - "side-left", - }, - [SoundIoChannelIdSideRight] = { - "Side Right", - "SR", - "side-right", - }, - [SoundIoChannelIdTopCenter] = { - "Top Center", - "TC", - "top-center", - }, - [SoundIoChannelIdTopFrontLeft] = { - "Top Front Left", - "TFL", - "top-front-left", - }, - [SoundIoChannelIdTopFrontCenter] = { - "Top Front Center", - "TFC", - "top-front-center", - }, - [SoundIoChannelIdTopFrontRight] = { - "Top Front Right", - "TFR", - "top-front-right", - }, - [SoundIoChannelIdTopBackLeft] = { - "Top Back Left", - "TBL", - "top-rear-left", - }, - [SoundIoChannelIdTopBackCenter] = { - "Top Back Center", - "TBC", - "top-rear-center", - }, - [SoundIoChannelIdTopBackRight] = { - "Top Back Right", - "TBR", - "top-rear-right", - }, - [SoundIoChannelIdBackLeftCenter] = { - "Back Left Center", - NULL, - NULL, - }, - [SoundIoChannelIdBackRightCenter] = { - "Back Right Center", - NULL, - NULL, - }, - [SoundIoChannelIdFrontLeftWide] = { - "Front Left Wide", - NULL, - NULL, - }, - [SoundIoChannelIdFrontRightWide] = { - "Front Right Wide", - NULL, - NULL, - }, - [SoundIoChannelIdFrontLeftHigh] = { - "Front Left High", - NULL, - NULL, - }, - [SoundIoChannelIdFrontCenterHigh] = { - "Front Center High", - NULL, - NULL, - }, - [SoundIoChannelIdFrontRightHigh] = { - "Front Right High", - NULL, - NULL, - }, - [SoundIoChannelIdTopFrontLeftCenter] = { - "Top Front Left Center", - NULL, - NULL, - }, - [SoundIoChannelIdTopFrontRightCenter] = { - "Top Front Right Center", - NULL, - NULL, - }, - [SoundIoChannelIdTopSideLeft] = { - "Top Side Left", - NULL, - NULL, - }, - [SoundIoChannelIdTopSideRight] = { - "Top Side Right", - NULL, - NULL, - }, - [SoundIoChannelIdLeftLfe] = { - "Left LFE", - NULL, - NULL, - }, - [SoundIoChannelIdRightLfe] = { - "Right LFE", - NULL, - NULL, - }, - [SoundIoChannelIdLfe2] = { - "LFE 2", - NULL, - NULL, - }, - [SoundIoChannelIdBottomCenter] = { - "Bottom Center", - NULL, - NULL, - }, - [SoundIoChannelIdBottomLeftCenter] = { - "Bottom Left Center", - NULL, - NULL, - }, - [SoundIoChannelIdBottomRightCenter] = { - "Bottom Right Center", - NULL, - NULL, - }, - [SoundIoChannelIdMsMid] = { - "Mid/Side Mid", - NULL, - NULL, - }, - [SoundIoChannelIdMsSide] = { - "Mid/Side Side", - NULL, - NULL, - }, - [SoundIoChannelIdAmbisonicW] = { - "Ambisonic W", - NULL, - NULL, - }, - [SoundIoChannelIdAmbisonicX] = { - "Ambisonic X", - NULL, - NULL, - }, - [SoundIoChannelIdAmbisonicY] = { - "Ambisonic Y", - NULL, - NULL, - }, - [SoundIoChannelIdAmbisonicZ] = { - "Ambisonic Z", - NULL, - NULL, - }, - [SoundIoChannelIdXyX] = { - "X-Y X", - NULL, - NULL, - }, - [SoundIoChannelIdXyY] = { - "X-Y Y", - NULL, - NULL, - }, - [SoundIoChannelIdHeadphonesLeft] = { - "Headphones Left", - NULL, - NULL, - }, - [SoundIoChannelIdHeadphonesRight] = { - "Headphones Right", - NULL, - NULL, - }, - [SoundIoChannelIdClickTrack] = { - "Click Track", - NULL, - NULL, - }, - [SoundIoChannelIdForeignLanguage] = { - "Foreign Language", - NULL, - NULL, - }, - [SoundIoChannelIdHearingImpaired] = { - "Hearing Impaired", - NULL, - NULL, - }, - [SoundIoChannelIdNarration] = { - "Narration", - NULL, - NULL, - }, - [SoundIoChannelIdHaptic] = { - "Haptic", - NULL, - NULL, - }, - [SoundIoChannelIdDialogCentricMix] = { - "Dialog Centric Mix", - NULL, - NULL, - }, - [SoundIoChannelIdAux] = { - "Aux", - NULL, - NULL, - }, - [SoundIoChannelIdAux0] = { - "Aux 0", - NULL, - NULL, - }, - [SoundIoChannelIdAux1] = { - "Aux 1", - NULL, - NULL, - }, - [SoundIoChannelIdAux2] = { - "Aux 2", - NULL, - NULL, - }, - [SoundIoChannelIdAux3] = { - "Aux 3", - NULL, - NULL, - }, - [SoundIoChannelIdAux4] = { - "Aux 4", - NULL, - NULL, - }, - [SoundIoChannelIdAux5] = { - "Aux 5", - NULL, - NULL, - }, - [SoundIoChannelIdAux6] = { - "Aux 6", - NULL, - NULL, - }, - [SoundIoChannelIdAux7] = { - "Aux 7", - NULL, - NULL, - }, - [SoundIoChannelIdAux8] = { - "Aux 8", - NULL, - NULL, - }, - [SoundIoChannelIdAux9] = { - "Aux 9", - NULL, - NULL, - }, - [SoundIoChannelIdAux10] = { - "Aux 10", - NULL, - NULL, - }, - [SoundIoChannelIdAux11] = { - "Aux 11", - NULL, - NULL, - }, - [SoundIoChannelIdAux12] = { - "Aux 12", - NULL, - NULL, - }, - [SoundIoChannelIdAux13] = { - "Aux 13", - NULL, - NULL, - }, - [SoundIoChannelIdAux14] = { - "Aux 14", - NULL, - NULL, - }, - [SoundIoChannelIdAux15] = { - "Aux 15", - NULL, - NULL, - }, +typedef const char *channel_names_t[CHANNEL_NAME_ALIAS_COUNT]; +static channel_names_t *make_channel_names() +{ + static channel_names_t names[SoundIoChannelIdMax]; + names[SoundIoChannelIdInvalid][0] = "(Invalid Channel)"; + names[SoundIoChannelIdInvalid][1] = NULL; + names[SoundIoChannelIdInvalid][2] = NULL; + names[SoundIoChannelIdFrontLeft][0] = "Front Left"; + names[SoundIoChannelIdFrontLeft][1] = "FL"; + names[SoundIoChannelIdFrontLeft][2] = "front-left"; + names[SoundIoChannelIdFrontRight][0] = "Front Right"; + names[SoundIoChannelIdFrontRight][1] = "FR"; + names[SoundIoChannelIdFrontRight][2] = "front-right"; + names[SoundIoChannelIdFrontCenter][0] = "Front Center"; + names[SoundIoChannelIdFrontCenter][1] = "FC"; + names[SoundIoChannelIdFrontCenter][2] = "front-center"; + names[SoundIoChannelIdLfe][0] = "LFE"; + names[SoundIoChannelIdLfe][1] = "LFE"; + names[SoundIoChannelIdLfe][2] = "lfe"; + names[SoundIoChannelIdBackLeft][0] = "Back Left"; + names[SoundIoChannelIdBackLeft][1] = "BL"; + names[SoundIoChannelIdBackLeft][2] = "rear-left"; + names[SoundIoChannelIdBackRight][0] = "Back Right"; + names[SoundIoChannelIdBackRight][1] = "BR"; + names[SoundIoChannelIdBackRight][2] = "rear-right"; + names[SoundIoChannelIdFrontLeftCenter][0] = "Front Left Center"; + names[SoundIoChannelIdFrontLeftCenter][1] = "FLC"; + names[SoundIoChannelIdFrontLeftCenter][2] = "front-left-of-center"; + names[SoundIoChannelIdFrontRightCenter][0] = "Front Right Center"; + names[SoundIoChannelIdFrontRightCenter][1] = "FRC"; + names[SoundIoChannelIdFrontRightCenter][2] = "front-right-of-center"; + names[SoundIoChannelIdBackCenter][0] = "Back Center"; + names[SoundIoChannelIdBackCenter][1] = "BC"; + names[SoundIoChannelIdBackCenter][2] = "rear-center"; + names[SoundIoChannelIdSideLeft][0] = "Side Left"; + names[SoundIoChannelIdSideLeft][1] = "SL"; + names[SoundIoChannelIdSideLeft][2] = "side-left"; + names[SoundIoChannelIdSideRight][0] = "Side Right"; + names[SoundIoChannelIdSideRight][1] = "SR"; + names[SoundIoChannelIdSideRight][2] = "side-right"; + names[SoundIoChannelIdTopCenter][0] = "Top Center"; + names[SoundIoChannelIdTopCenter][1] = "TC"; + names[SoundIoChannelIdTopCenter][2] = "top-center"; + names[SoundIoChannelIdTopFrontLeft][0] = "Top Front Left"; + names[SoundIoChannelIdTopFrontLeft][1] = "TFL"; + names[SoundIoChannelIdTopFrontLeft][2] = "top-front-left"; + names[SoundIoChannelIdTopFrontCenter][0] = "Top Front Center"; + names[SoundIoChannelIdTopFrontCenter][1] = "TFC"; + names[SoundIoChannelIdTopFrontCenter][2] = "top-front-center"; + names[SoundIoChannelIdTopFrontRight][0] = "Top Front Right"; + names[SoundIoChannelIdTopFrontRight][1] = "TFR"; + names[SoundIoChannelIdTopFrontRight][2] = "top-front-right"; + names[SoundIoChannelIdTopBackLeft][0] = "Top Back Left"; + names[SoundIoChannelIdTopBackLeft][1] = "TBL"; + names[SoundIoChannelIdTopBackLeft][2] = "top-rear-left"; + names[SoundIoChannelIdTopBackCenter][0] = "Top Back Center"; + names[SoundIoChannelIdTopBackCenter][1] = "TBC"; + names[SoundIoChannelIdTopBackCenter][2] = "top-rear-center"; + names[SoundIoChannelIdTopBackRight][0] = "Top Back Right"; + names[SoundIoChannelIdTopBackRight][1] = "TBR"; + names[SoundIoChannelIdTopBackRight][2] = "top-rear-right"; + names[SoundIoChannelIdBackLeftCenter][0] = "Back Left Center"; + names[SoundIoChannelIdBackLeftCenter][1] = NULL; + names[SoundIoChannelIdBackLeftCenter][2] = NULL; + names[SoundIoChannelIdBackRightCenter][0] = "Back Right Center"; + names[SoundIoChannelIdBackRightCenter][1] = NULL; + names[SoundIoChannelIdBackRightCenter][2] = NULL; + names[SoundIoChannelIdFrontLeftWide][0] = "Front Left Wide"; + names[SoundIoChannelIdFrontLeftWide][1] = NULL; + names[SoundIoChannelIdFrontLeftWide][2] = NULL; + names[SoundIoChannelIdFrontRightWide][0] = "Front Right Wide"; + names[SoundIoChannelIdFrontRightWide][1] = NULL; + names[SoundIoChannelIdFrontRightWide][2] = NULL; + names[SoundIoChannelIdFrontLeftHigh][0] = "Front Left High"; + names[SoundIoChannelIdFrontLeftHigh][1] = NULL; + names[SoundIoChannelIdFrontLeftHigh][2] = NULL; + names[SoundIoChannelIdFrontCenterHigh][0] = "Front Center High"; + names[SoundIoChannelIdFrontCenterHigh][1] = NULL; + names[SoundIoChannelIdFrontCenterHigh][2] = NULL; + names[SoundIoChannelIdFrontRightHigh][0] = "Front Right High"; + names[SoundIoChannelIdFrontRightHigh][1] = NULL; + names[SoundIoChannelIdFrontRightHigh][2] = NULL; + names[SoundIoChannelIdTopFrontLeftCenter][0] = "Top Front Left Center"; + names[SoundIoChannelIdTopFrontLeftCenter][1] = NULL; + names[SoundIoChannelIdTopFrontLeftCenter][2] = NULL; + names[SoundIoChannelIdTopFrontRightCenter][0] = "Top Front Right Center"; + names[SoundIoChannelIdTopFrontRightCenter][1] = NULL; + names[SoundIoChannelIdTopFrontRightCenter][2] = NULL; + names[SoundIoChannelIdTopSideLeft][0] = "Top Side Left"; + names[SoundIoChannelIdTopSideLeft][1] = NULL; + names[SoundIoChannelIdTopSideLeft][2] = NULL; + names[SoundIoChannelIdTopSideRight][0] = "Top Side Right"; + names[SoundIoChannelIdTopSideRight][1] = NULL; + names[SoundIoChannelIdTopSideRight][2] = NULL; + names[SoundIoChannelIdLeftLfe][0] = "Left LFE"; + names[SoundIoChannelIdLeftLfe][1] = NULL; + names[SoundIoChannelIdLeftLfe][2] = NULL; + names[SoundIoChannelIdRightLfe][0] = "Right LFE"; + names[SoundIoChannelIdRightLfe][1] = NULL; + names[SoundIoChannelIdRightLfe][2] = NULL; + names[SoundIoChannelIdLfe2][0] = "LFE 2"; + names[SoundIoChannelIdLfe2][1] = NULL; + names[SoundIoChannelIdLfe2][2] = NULL; + names[SoundIoChannelIdBottomCenter][0] = "Bottom Center"; + names[SoundIoChannelIdBottomCenter][1] = NULL; + names[SoundIoChannelIdBottomCenter][2] = NULL; + names[SoundIoChannelIdBottomLeftCenter][0] = "Bottom Left Center"; + names[SoundIoChannelIdBottomLeftCenter][1] = NULL; + names[SoundIoChannelIdBottomLeftCenter][2] = NULL; + names[SoundIoChannelIdBottomRightCenter][0] = "Bottom Right Center"; + names[SoundIoChannelIdBottomRightCenter][1] = NULL; + names[SoundIoChannelIdBottomRightCenter][2] = NULL; + names[SoundIoChannelIdMsMid][0] = "Mid/Side Mid"; + names[SoundIoChannelIdMsMid][1] = NULL; + names[SoundIoChannelIdMsMid][2] = NULL; + names[SoundIoChannelIdMsSide][0] = "Mid/Side Side"; + names[SoundIoChannelIdMsSide][1] = NULL; + names[SoundIoChannelIdMsSide][2] = NULL; + names[SoundIoChannelIdAmbisonicW][0] = "Ambisonic W"; + names[SoundIoChannelIdAmbisonicW][1] = NULL; + names[SoundIoChannelIdAmbisonicW][2] = NULL; + names[SoundIoChannelIdAmbisonicX][0] = "Ambisonic X"; + names[SoundIoChannelIdAmbisonicX][1] = NULL; + names[SoundIoChannelIdAmbisonicX][2] = NULL; + names[SoundIoChannelIdAmbisonicY][0] = "Ambisonic Y"; + names[SoundIoChannelIdAmbisonicY][1] = NULL; + names[SoundIoChannelIdAmbisonicY][2] = NULL; + names[SoundIoChannelIdAmbisonicZ][0] = "Ambisonic Z"; + names[SoundIoChannelIdAmbisonicZ][1] = NULL; + names[SoundIoChannelIdAmbisonicZ][2] = NULL; + names[SoundIoChannelIdXyX][0] = "X-Y X"; + names[SoundIoChannelIdXyX][1] = NULL; + names[SoundIoChannelIdXyX][2] = NULL; + names[SoundIoChannelIdXyY][0] = "X-Y Y"; + names[SoundIoChannelIdXyY][1] = NULL; + names[SoundIoChannelIdXyY][2] = NULL; + names[SoundIoChannelIdHeadphonesLeft][0] = "Headphones Left"; + names[SoundIoChannelIdHeadphonesLeft][1] = NULL; + names[SoundIoChannelIdHeadphonesLeft][2] = NULL; + names[SoundIoChannelIdHeadphonesRight][0] = "Headphones Right"; + names[SoundIoChannelIdHeadphonesRight][1] = NULL; + names[SoundIoChannelIdHeadphonesRight][2] = NULL; + names[SoundIoChannelIdClickTrack][0] = "Click Track"; + names[SoundIoChannelIdClickTrack][1] = NULL; + names[SoundIoChannelIdClickTrack][2] = NULL; + names[SoundIoChannelIdForeignLanguage][0] = "Foreign Language"; + names[SoundIoChannelIdForeignLanguage][1] = NULL; + names[SoundIoChannelIdForeignLanguage][2] = NULL; + names[SoundIoChannelIdHearingImpaired][0] = "Hearing Impaired"; + names[SoundIoChannelIdHearingImpaired][1] = NULL; + names[SoundIoChannelIdHearingImpaired][2] = NULL; + names[SoundIoChannelIdNarration][0] = "Narration"; + names[SoundIoChannelIdNarration][1] = NULL; + names[SoundIoChannelIdNarration][2] = NULL; + names[SoundIoChannelIdHaptic][0] = "Haptic"; + names[SoundIoChannelIdHaptic][1] = NULL; + names[SoundIoChannelIdHaptic][2] = NULL; + names[SoundIoChannelIdDialogCentricMix][0] = "Dialog Centric Mix"; + names[SoundIoChannelIdDialogCentricMix][1] = NULL; + names[SoundIoChannelIdDialogCentricMix][2] = NULL; + names[SoundIoChannelIdAux][0] = "Aux"; + names[SoundIoChannelIdAux][1] = NULL; + names[SoundIoChannelIdAux][2] = NULL; + names[SoundIoChannelIdAux0][0] = "Aux 0"; + names[SoundIoChannelIdAux0][1] = NULL; + names[SoundIoChannelIdAux0][2] = NULL; + names[SoundIoChannelIdAux1][0] = "Aux 1"; + names[SoundIoChannelIdAux1][1] = NULL; + names[SoundIoChannelIdAux1][2] = NULL; + names[SoundIoChannelIdAux2][0] = "Aux 2"; + names[SoundIoChannelIdAux2][1] = NULL; + names[SoundIoChannelIdAux2][2] = NULL; + names[SoundIoChannelIdAux3][0] = "Aux 3"; + names[SoundIoChannelIdAux3][1] = NULL; + names[SoundIoChannelIdAux3][2] = NULL; + names[SoundIoChannelIdAux4][0] = "Aux 4"; + names[SoundIoChannelIdAux4][1] = NULL; + names[SoundIoChannelIdAux4][2] = NULL; + names[SoundIoChannelIdAux5][0] = "Aux 5"; + names[SoundIoChannelIdAux5][1] = NULL; + names[SoundIoChannelIdAux5][2] = NULL; + names[SoundIoChannelIdAux6][0] = "Aux 6"; + names[SoundIoChannelIdAux6][1] = NULL; + names[SoundIoChannelIdAux6][2] = NULL; + names[SoundIoChannelIdAux7][0] = "Aux 7"; + names[SoundIoChannelIdAux7][1] = NULL; + names[SoundIoChannelIdAux7][2] = NULL; + names[SoundIoChannelIdAux8][0] = "Aux 8"; + names[SoundIoChannelIdAux8][1] = NULL; + names[SoundIoChannelIdAux8][2] = NULL; + names[SoundIoChannelIdAux9][0] = "Aux 9"; + names[SoundIoChannelIdAux9][1] = NULL; + names[SoundIoChannelIdAux9][2] = NULL; + names[SoundIoChannelIdAux10][0] = "Aux 10"; + names[SoundIoChannelIdAux10][1] = NULL; + names[SoundIoChannelIdAux10][2] = NULL; + names[SoundIoChannelIdAux11][0] = "Aux 11"; + names[SoundIoChannelIdAux11][1] = NULL; + names[SoundIoChannelIdAux11][2] = NULL; + names[SoundIoChannelIdAux12][0] = "Aux 12"; + names[SoundIoChannelIdAux12][1] = NULL; + names[SoundIoChannelIdAux12][2] = NULL; + names[SoundIoChannelIdAux13][0] = "Aux 13"; + names[SoundIoChannelIdAux13][1] = NULL; + names[SoundIoChannelIdAux13][2] = NULL; + names[SoundIoChannelIdAux14][0] = "Aux 14"; + names[SoundIoChannelIdAux14][1] = NULL; + names[SoundIoChannelIdAux14][2] = NULL; + names[SoundIoChannelIdAux15][0] = "Aux 15"; + names[SoundIoChannelIdAux15][1] = NULL; + names[SoundIoChannelIdAux15][2] = NULL; + return &names[0]; }; +static channel_names_t *channel_names = make_channel_names(); const char *soundio_get_channel_name(enum SoundIoChannelId id) { if (id >= ARRAY_LENGTH(channel_names)) diff --git a/src/soundio.c b/src/soundio.c index 5e12418..5b0c043 100644 --- a/src/soundio.c +++ b/src/soundio.c @@ -33,36 +33,29 @@ static const enum SoundIoBackend available_backends[] = { SoundIoBackendDummy, }; -static int (*backend_init_fns[])(struct SoundIoPrivate *) = { - [SoundIoBackendNone] = NULL, +typedef int (*backend_init_t)(struct SoundIoPrivate *); +static backend_init_t *make_backend_init_fns() +{ + static backend_init_t fns[6] = { 0 }; #ifdef SOUNDIO_HAVE_JACK - [SoundIoBackendJack] = soundio_jack_init, -#else - [SoundIoBackendJack] = NULL, + fns[SoundIoBackendJack] = soundio_jack_init; #endif #ifdef SOUNDIO_HAVE_PULSEAUDIO - [SoundIoBackendPulseAudio] = soundio_pulseaudio_init, -#else - [SoundIoBackendPulseAudio] = NULL, + fns[SoundIoBackendPulseAudio] = soundio_pulseaudio_init; #endif #ifdef SOUNDIO_HAVE_ALSA - [SoundIoBackendAlsa] = soundio_alsa_init, -#else - [SoundIoBackendAlsa] = NULL, + fns[SoundIoBackendAlsa] = soundio_alsa_init; #endif #ifdef SOUNDIO_HAVE_COREAUDIO - [SoundIoBackendCoreAudio] = soundio_coreaudio_init, -#else - [SoundIoBackendCoreAudio] = NULL, + fns[SoundIoBackendCoreAudio] = soundio_coreaudio_init; #endif #ifdef SOUNDIO_HAVE_WASAPI - [SoundIoBackendWasapi] = soundio_wasapi_init, -#else - [SoundIoBackendWasapi] = NULL, + fns[SoundIoBackendWasapi] = soundio_wasapi_init; #endif - [SoundIoBackendDummy] = soundio_dummy_init, -}; - + fns[SoundIoBackendDummy] = soundio_dummy_init; + return &fns[0]; +} +static backend_init_t *backend_init_fns = make_backend_init_fns(); SOUNDIO_MAKE_LIST_DEF(struct SoundIoDevice*, SoundIoListDevicePtr, SOUNDIO_LIST_NOT_STATIC) SOUNDIO_MAKE_LIST_DEF(struct SoundIoSampleRateRange, SoundIoListSampleRateRange, SOUNDIO_LIST_NOT_STATIC)