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

Fixes error when looking for devices with more than 2 channels #290

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 16 additions & 6 deletions EZAudio/EZAudioDevice.m
Expand Up @@ -395,22 +395,32 @@ + (NSInteger)channelCountForScope:(AudioObjectPropertyScope)scope
address.mScope = scope;
address.mElement = kAudioObjectPropertyElementMaster;
address.mSelector = kAudioDevicePropertyStreamConfiguration;

AudioBufferList streamConfiguration;
UInt32 propSize = sizeof(streamConfiguration);

UInt32 propSize;

[EZAudioUtilities checkResult:AudioObjectGetPropertyDataSize(deviceID,
&address,
0,
NULL,
&propSize)
operation:"Failed to get frame size size"];

AudioBufferList * streamConfiguration = (AudioBufferList *)malloc(propSize);
[EZAudioUtilities checkResult:AudioObjectGetPropertyData(deviceID,
&address,
0,
NULL,
&propSize,
&streamConfiguration)
streamConfiguration)
operation:"Failed to get frame size"];

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

free(streamConfiguration);

return channelCount;
}
Expand Down
2 changes: 1 addition & 1 deletion EZAudio/EZAudioOSX.h
Expand Up @@ -23,4 +23,4 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <EZAudioOSX/EZAudio.h>
#import <EZAudio/EZAudio.h>
2 changes: 1 addition & 1 deletion EZAudio/EZAudioiOS.h
Expand Up @@ -23,4 +23,4 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <EZAudioiOS/EZAudio.h>
#import <EZAudio/EZAudio.h>