try to fix issue reported in https://sourceforge.net/p/llcon/discussion/software/thread/7c443f2ed9/#eeab
This commit is contained in:
parent
c8c0b17fc7
commit
21318f993d
2 changed files with 27 additions and 21 deletions
|
@ -19,6 +19,7 @@ TODO issue with Mac audio interface: https://sourceforge.net/p/llcon/discussion/
|
||||||
|
|
||||||
TODO let the user select all possible sound card buffer sizes, this should solve Ticket #53
|
TODO let the user select all possible sound card buffer sizes, this should solve Ticket #53
|
||||||
|
|
||||||
|
|
||||||
TODO auto jitter buffer performance not good at 64 samples frame size -> to be checked again
|
TODO auto jitter buffer performance not good at 64 samples frame size -> to be checked again
|
||||||
|
|
||||||
TODO for different frame sizes (64/128) the start value of 6 for the jitter buffer might be too low
|
TODO for different frame sizes (64/128) the start value of 6 for the jitter buffer might be too low
|
||||||
|
|
|
@ -277,6 +277,9 @@ int CSound::CountChannels ( AudioDeviceID devID,
|
||||||
{
|
{
|
||||||
for ( UInt32 i = 0; i < buflist->mNumberBuffers; ++i )
|
for ( UInt32 i = 0; i < buflist->mNumberBuffers; ++i )
|
||||||
{
|
{
|
||||||
|
// The correct value mNumberChannels for an AudioBuffer can be derived from the mChannelsPerFrame
|
||||||
|
// and the interleaved flag. For non interleaved formats, mNumberChannels is always 1.
|
||||||
|
// For interleaved formats, mNumberChannels is equal to mChannelsPerFrame.
|
||||||
result += buflist->mBuffers[i].mNumberChannels;
|
result += buflist->mBuffers[i].mNumberChannels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -812,28 +815,11 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice,
|
||||||
|
|
||||||
if ( inDevice == pSound->CurrentAudioInputDeviceID )
|
if ( inDevice == pSound->CurrentAudioInputDeviceID )
|
||||||
{
|
{
|
||||||
// we should have a matching number of buffers to channels
|
// check size (float32 has four bytes)
|
||||||
if ( inInputData->mNumberBuffers == (UInt32) iNumInChan &&
|
if ( inInputData->mBuffers[0].mDataByteSize ==
|
||||||
inInputData->mBuffers[0].mDataByteSize == static_cast<UInt32> ( iCoreAudioBufferSizeMono * 4 ) )
|
static_cast<UInt32> ( iCoreAudioBufferSizeMono * iNumInChan * 4 ) )
|
||||||
{
|
{
|
||||||
// One buffer per channel mode
|
// one buffer with all the channels in interleaved format:
|
||||||
AudioBuffer left = inInputData->mBuffers[iSelInputLeftChannel];
|
|
||||||
Float32* pLeftData = static_cast<Float32*> ( left.mData );
|
|
||||||
AudioBuffer right = inInputData->mBuffers[iSelInputRightChannel];
|
|
||||||
Float32* pRightData = static_cast<Float32*> ( right.mData );
|
|
||||||
|
|
||||||
// copy input data
|
|
||||||
for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ )
|
|
||||||
{
|
|
||||||
// left
|
|
||||||
pSound->vecsTmpAudioSndCrdStereo[2 * i] = (short) ( pLeftData[i] * _MAXSHORT );
|
|
||||||
|
|
||||||
// right
|
|
||||||
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = (short) ( pRightData[i] * _MAXSHORT );
|
|
||||||
}
|
|
||||||
} else if ( inInputData->mBuffers[0].mDataByteSize == static_cast<UInt32> ( iCoreAudioBufferSizeMono * iNumInChan * 4 ) )
|
|
||||||
{
|
|
||||||
// One buffer with all the channels in
|
|
||||||
// get a pointer to the input data of the correct type
|
// get a pointer to the input data of the correct type
|
||||||
Float32* pInData = static_cast<Float32*> ( inInputData->mBuffers[0].mData );
|
Float32* pInData = static_cast<Float32*> ( inInputData->mBuffers[0].mData );
|
||||||
|
|
||||||
|
@ -864,6 +850,25 @@ if ( iNumInChan == 4 )
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( inInputData->mNumberBuffers == (UInt32) iNumInChan && // we should have a matching number of buffers to channels
|
||||||
|
inInputData->mBuffers[0].mDataByteSize == static_cast<UInt32> ( iCoreAudioBufferSizeMono * 4 ) )
|
||||||
|
{
|
||||||
|
// one buffer per channel mode:
|
||||||
|
AudioBuffer left = inInputData->mBuffers[iSelInputLeftChannel];
|
||||||
|
Float32* pLeftData = static_cast<Float32*> ( left.mData );
|
||||||
|
AudioBuffer right = inInputData->mBuffers[iSelInputRightChannel];
|
||||||
|
Float32* pRightData = static_cast<Float32*> ( right.mData );
|
||||||
|
|
||||||
|
// copy input data
|
||||||
|
for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ )
|
||||||
|
{
|
||||||
|
// left
|
||||||
|
pSound->vecsTmpAudioSndCrdStereo[2 * i] = (short) ( pLeftData[i] * _MAXSHORT );
|
||||||
|
|
||||||
|
// right
|
||||||
|
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = (short) ( pRightData[i] * _MAXSHORT );
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// incompatible sizes, clear work buffer
|
// incompatible sizes, clear work buffer
|
||||||
|
|
Loading…
Reference in a new issue