Jack improvements
This commit is contained in:
parent
433fc30623
commit
bdec88cfdf
2 changed files with 75 additions and 49 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
3.0.2
|
||||||
|
|
||||||
|
- fix for Jack Linux audio interface: ports are only once registered and
|
||||||
|
connect when the software is started up
|
||||||
|
|
||||||
3.0.1
|
3.0.1
|
||||||
|
|
||||||
- bug fix: buzzing occurred when audio stream was interrupted (e.g. in case
|
- bug fix: buzzing occurred when audio stream was interrupted (e.g. in case
|
||||||
|
|
|
@ -41,17 +41,6 @@ if ( jack_get_sample_rate ( pJackClient ) != SYSTEM_SAMPLE_RATE )
|
||||||
throw CGenErr ( "Jack server sample rate is different from "
|
throw CGenErr ( "Jack server sample rate is different from "
|
||||||
"required one" );
|
"required one" );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CSound::CloseJack()
|
|
||||||
{
|
|
||||||
// close client connection to jack server
|
|
||||||
jack_client_close ( pJackClient );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSound::Start()
|
|
||||||
{
|
|
||||||
const char** ports;
|
|
||||||
|
|
||||||
// create four ports (two for input, two for output -> stereo)
|
// create four ports (two for input, two for output -> stereo)
|
||||||
input_port_left = jack_port_register ( pJackClient, "input left",
|
input_port_left = jack_port_register ( pJackClient, "input left",
|
||||||
|
@ -66,6 +55,8 @@ void CSound::Start()
|
||||||
output_port_right = jack_port_register ( pJackClient, "output right",
|
output_port_right = jack_port_register ( pJackClient, "output right",
|
||||||
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
|
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
|
||||||
|
|
||||||
|
const char** ports;
|
||||||
|
|
||||||
// tell the JACK server that we are ready to roll
|
// tell the JACK server that we are ready to roll
|
||||||
if ( jack_activate ( pJackClient ) )
|
if ( jack_activate ( pJackClient ) )
|
||||||
{
|
{
|
||||||
|
@ -119,12 +110,9 @@ void CSound::Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
free ( ports );
|
free ( ports );
|
||||||
|
|
||||||
// call base class
|
|
||||||
CSoundBase::Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::Stop()
|
void CSound::CloseJack()
|
||||||
{
|
{
|
||||||
// deactivate client
|
// deactivate client
|
||||||
jack_deactivate ( pJackClient );
|
jack_deactivate ( pJackClient );
|
||||||
|
@ -135,6 +123,18 @@ void CSound::Stop()
|
||||||
jack_port_unregister ( pJackClient, output_port_left );
|
jack_port_unregister ( pJackClient, output_port_left );
|
||||||
jack_port_unregister ( pJackClient, output_port_right );
|
jack_port_unregister ( pJackClient, output_port_right );
|
||||||
|
|
||||||
|
// close client connection to jack server
|
||||||
|
jack_client_close ( pJackClient );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSound::Start()
|
||||||
|
{
|
||||||
|
// call base class
|
||||||
|
CSoundBase::Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSound::Stop()
|
||||||
|
{
|
||||||
// call base class
|
// call base class
|
||||||
CSoundBase::Stop();
|
CSoundBase::Stop();
|
||||||
}
|
}
|
||||||
|
@ -164,9 +164,11 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
|
||||||
// JACK callbacks --------------------------------------------------------------
|
// JACK callbacks --------------------------------------------------------------
|
||||||
int CSound::process ( jack_nframes_t nframes, void* arg )
|
int CSound::process ( jack_nframes_t nframes, void* arg )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
CSound* pSound = reinterpret_cast<CSound*> ( arg );
|
CSound* pSound = reinterpret_cast<CSound*> ( arg );
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ( pSound->IsRunning() )
|
||||||
|
{
|
||||||
// get input data pointer
|
// get input data pointer
|
||||||
jack_default_audio_sample_t* in_left =
|
jack_default_audio_sample_t* in_left =
|
||||||
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
||||||
|
@ -204,6 +206,25 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
|
||||||
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
|
||||||
|
{
|
||||||
|
// get output data pointer
|
||||||
|
jack_default_audio_sample_t* out_left =
|
||||||
|
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
||||||
|
pSound->output_port_left, nframes );
|
||||||
|
|
||||||
|
jack_default_audio_sample_t* out_right =
|
||||||
|
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
||||||
|
pSound->output_port_right, nframes );
|
||||||
|
|
||||||
|
// clear output data
|
||||||
|
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
|
||||||
|
{
|
||||||
|
out_left[i] = 0;
|
||||||
|
out_right[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0; // zero on success, non-zero on error
|
return 0; // zero on success, non-zero on error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue