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,13 +212,16 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->input_port_right, nframes ); pSound->input_port_right, nframes );
// copy input data // copy input data
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ ) if ( in_left != 0 && in_right != 0 )
{ {
pSound->vecsTmpAudioSndCrdStereo[2 * i] = for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
(short) ( in_left[i] * _MAXSHORT ); {
pSound->vecsTmpAudioSndCrdStereo[2 * i] =
(short) ( in_left[i] * _MAXSHORT );
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] =
(short) ( in_right[i] * _MAXSHORT ); (short) ( in_right[i] * _MAXSHORT );
}
} }
// call processing callback function // call processing callback function
@ -234,13 +237,16 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->output_port_right, nframes ); pSound->output_port_right, nframes );
// copy output data // copy output data
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ ) if ( out_left != 0 && out_right != 0 )
{ {
out_left[i] = (jack_default_audio_sample_t) for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; {
out_left[i] = (jack_default_audio_sample_t)
pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT;
out_right[i] = (jack_default_audio_sample_t) out_right[i] = (jack_default_audio_sample_t)
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT;
}
} }
} }
else else
@ -255,11 +261,14 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
pSound->output_port_right, nframes ); pSound->output_port_right, nframes );
// clear output data // clear output data
memset ( out_left, if ( out_left != 0 && out_right != 0 )
0, sizeof ( jack_default_audio_sample_t ) * nframes ); {
memset ( out_left,
0, sizeof ( jack_default_audio_sample_t ) * nframes );
memset ( out_right, memset ( out_right,
0, sizeof ( jack_default_audio_sample_t ) * nframes ); 0, sizeof ( jack_default_audio_sample_t ) * nframes );
}
} }
return 0; // zero on success, non-zero on error return 0; // zero on success, non-zero on error