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

Fixed for more than 1 stream #338

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
26 changes: 19 additions & 7 deletions EZAudio/EZAudioDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,34 @@ + (NSInteger)channelCountForScope:(AudioObjectPropertyScope)scope
address.mElement = kAudioObjectPropertyElementMaster;
address.mSelector = kAudioDevicePropertyStreamConfiguration;

AudioBufferList streamConfiguration;
UInt32 propSize = sizeof(streamConfiguration);
UInt32 dataSize = 0;
[EZAudioUtilities checkResult:AudioObjectGetPropertyDataSize(deviceID,
&address,
0,
NULL,
&dataSize)
operation:"Failed to get buffer size"];

AudioBufferList *bufferList = (AudioBufferList *)(malloc(dataSize));

[EZAudioUtilities checkResult:AudioObjectGetPropertyData(deviceID,
&address,
0,
NULL,
&propSize,
&streamConfiguration)
operation:"Failed to get frame size"];
&dataSize,
bufferList)
operation:"Failed to get buffer list"];

UInt32 numBuffers = bufferList->mNumberBuffers;

NSInteger channelCount = 0;
for (NSInteger i = 0; i < streamConfiguration.mNumberBuffers; i++)
for (NSInteger i = 0; i < numBuffers; i++)
{
channelCount += streamConfiguration.mBuffers[i].mNumberChannels;
channelCount += bufferList->mBuffers[i].mNumberChannels;
}

free(bufferList), bufferList = NULL;

return channelCount;
}

Expand Down