From 12889fbea57bc25a0811fa65327af909b4fd8b6c Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 5 Jul 2015 12:00:54 +0000 Subject: [PATCH] fixed a buffer overrun problem in the Mac audio interface if the sound card has a lot of input and output channels --- mac/sound.cpp | 13 +++++++------ src/global.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mac/sound.cpp b/mac/sound.cpp index 82818d96..f4aa3167 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -180,14 +180,14 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* ar lNumDevs++; // next device - // add detected devices (also check for maximum allowed sound cards!) + // add detected devices // // we add combined entries for input and output for each device so that we // do not need two combo boxes in the GUI for input and output (therefore - // all possible combinations are required) - for ( UInt32 i = 0; ( i < deviceCount ) && ( i < MAX_NUMBER_SOUND_CARDS - 1 ); i++ ) + // all possible combinations are required which can be a large number) + for ( UInt32 i = 0; i < deviceCount; i++ ) { - for ( UInt32 j = 0; ( j < deviceCount ) && ( j < MAX_NUMBER_SOUND_CARDS - 1 ); j++ ) + for ( UInt32 j = 0; j < deviceCount; j++ ) { // get device infos for both current devices QString strDeviceName_i; @@ -207,8 +207,9 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* ar bIsInput_j, bIsOutput_j ); - // check if i device is input and j device is output - if ( bIsInput_i && bIsOutput_j ) + // check if i device is input and j device is output and that we are + // in range + if ( bIsInput_i && bIsOutput_j && ( lNumDevs < MAX_NUMBER_SOUND_CARDS ) ) { strDriverNames[lNumDevs] = "in: " + strDeviceName_i + "/out: " + diff --git a/src/global.h b/src/global.h index 99e73d34..b2785c77 100755 --- a/src/global.h +++ b/src/global.h @@ -149,7 +149,7 @@ LED bar: lbr // maximum number of recognized sound cards installed in the system, // definition for "no device" -#define MAX_NUMBER_SOUND_CARDS 30 +#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS) #define INVALID_SNC_CARD_DEVICE -1 // define the maximum number of audio channel for input/output we can store