introduced some safety checks for the buffer pointers

This commit is contained in:
Volker Fischer 2015-02-15 16:53:17 +00:00
parent 4de2d7ac44
commit 070fb4a6a4

View File

@ -212,6 +212,8 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->input_port_right, nframes );
// copy input data
if ( in_left != 0 && in_right != 0 )
{
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
{
pSound->vecsTmpAudioSndCrdStereo[2 * i] =
@ -220,6 +222,7 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] =
(short) ( in_right[i] * _MAXSHORT );
}
}
// call processing callback function
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
@ -234,6 +237,8 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->output_port_right, nframes );
// copy output data
if ( out_left != 0 && out_right != 0 )
{
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
{
out_left[i] = (jack_default_audio_sample_t)
@ -243,6 +248,7 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT;
}
}
}
else
{
// get output data pointer
@ -255,12 +261,15 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->output_port_right, nframes );
// clear output data
if ( out_left != 0 && out_right != 0 )
{
memset ( out_left,
0, sizeof ( jack_default_audio_sample_t ) * nframes );
memset ( out_right,
0, sizeof ( jack_default_audio_sample_t ) * nframes );
}
}
return 0; // zero on success, non-zero on error
}