Skip to content

Commit

Permalink
AudioQueueCaptureSession + stereo support
Browse files Browse the repository at this point in the history
  • Loading branch information
YuAo committed Dec 2, 2020
1 parent 0299c6d commit ab8b95a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/VideoIO/AudioQueueCaptureSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,15 @@ public class AudioQueueCaptureSession {
}

var acl = AudioChannelLayout()
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono
switch recordFormat.mChannelsPerFrame {
case 2:
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo
case 1:
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono
default:
print("[AudioQueueCaptureSession] Unsupported ChannelsPerFrame: \(recordFormat.mChannelsPerFrame), fallback to kAudioChannelLayoutTag_Mono.")
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono
}
if CMAudioFormatDescriptionCreate(allocator: nil, asbd: &recordFormat, layoutSize: MemoryLayout.size(ofValue: acl), layout: &acl, magicCookieSize: 0, magicCookie: nil, extensions: nil, formatDescriptionOut: &self.audioFormatDescription) != 0 {
AudioQueueDispose(audioQueue, true)
throw Error.cannotCreateAudioFormatDescription
Expand Down

0 comments on commit ab8b95a

Please sign in to comment.