Skip to content

Commit 4dd585f

Browse files
committed
coreaudio: convert MPEG channel layout to WAVE channel layout
1 parent 81e5714 commit 4dd585f

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/audio/coreaudio/SDL_coreaudio.m

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -769,21 +769,35 @@ static bool PrepareAudioQueue(SDL_AudioDevice *device)
769769
// L R C LFE Cs Ls Rs
770770
layout.mChannelLayoutTag = kAudioChannelLayoutTag_WAVE_6_1;
771771
} else {
772-
// FIXME: We need to manually swizzle channels into a supported layout
773772
// L R C LFE Ls Rs Cs
774-
//layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_6_1_A;
775-
return SDL_SetError("Unsupported audio channels");
773+
layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_6_1_A;
774+
775+
// Convert from SDL channel layout to kAudioChannelLayoutTag_MPEG_6_1_A
776+
static const int swizzle_map[7] = {
777+
0, 1, 2, 3, 6, 4, 5
778+
};
779+
device->chmap = SDL_ChannelMapDup(swizzle_map, SDL_arraysize(swizzle_map));
780+
if (!device->chmap) {
781+
return false;
782+
}
776783
}
777784
break;
778785
case 8:
779786
if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
780787
// L R C LFE Rls Rrs Ls Rs
781788
layout.mChannelLayoutTag = kAudioChannelLayoutTag_WAVE_7_1;
782789
} else {
783-
// FIXME: We need to manually swizzle channels into a supported layout
784790
// L R C LFE Ls Rs Rls Rrs
785-
//layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_7_1_C;
786-
return SDL_SetError("Unsupported audio channels");
791+
layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_7_1_C;
792+
793+
// Convert from SDL channel layout to kAudioChannelLayoutTag_MPEG_7_1_C
794+
static const int swizzle_map[8] = {
795+
0, 1, 2, 3, 6, 7, 4, 5
796+
};
797+
device->chmap = SDL_ChannelMapDup(swizzle_map, SDL_arraysize(swizzle_map));
798+
if (!device->chmap) {
799+
return false;
800+
}
787801
}
788802
break;
789803
default:

0 commit comments

Comments
 (0)