preparation for buffer size change callback for audio interfaces, small fix in server GUI
This commit is contained in:
parent
70c1510c60
commit
caad05ddaa
6 changed files with 43 additions and 26 deletions
|
@ -13,9 +13,9 @@
|
|||
|
||||
#ifdef WITH_SOUND
|
||||
# if USE_JACK
|
||||
CSound::CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ),
|
||||
void* arg ) :
|
||||
CSoundBase ( true, fpNewCallback, arg )
|
||||
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* pParg ),
|
||||
void* pParg ) :
|
||||
CSoundBase ( true, fpNewProcessCallback, pParg )
|
||||
{
|
||||
jack_status_t JackStatus;
|
||||
|
||||
|
@ -30,6 +30,9 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ),
|
|||
// there is work to be done
|
||||
jack_set_process_callback ( pJackClient, process, this );
|
||||
|
||||
// register a "buffer size changed" callback function
|
||||
jack_set_buffer_size_callback ( pJackClient, bufferSizeCallback, this );
|
||||
|
||||
// TEST check sample rate, if not correct, just fire error
|
||||
if ( jack_get_sample_rate ( pJackClient ) != SND_CRD_SAMPLE_RATE )
|
||||
{
|
||||
|
@ -147,12 +150,14 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
|
|||
int i;
|
||||
CSound* pSound = reinterpret_cast<CSound*> ( arg );
|
||||
|
||||
// get input data
|
||||
// get input data pointer
|
||||
jack_default_audio_sample_t* in_left =
|
||||
(jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->input_port_left, nframes );
|
||||
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
||||
pSound->input_port_left, nframes );
|
||||
|
||||
jack_default_audio_sample_t* in_right =
|
||||
(jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->input_port_right, nframes );
|
||||
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
||||
pSound->input_port_right, nframes );
|
||||
|
||||
// copy input data
|
||||
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
|
||||
|
@ -162,14 +167,16 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
|
|||
}
|
||||
|
||||
// call processing callback function
|
||||
pSound->Callback ( pSound->vecsTmpAudioSndCrdStereo );
|
||||
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
|
||||
|
||||
// put output data
|
||||
// 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*) 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 );
|
||||
(jack_default_audio_sample_t*) jack_port_get_buffer (
|
||||
pSound->output_port_right, nframes );
|
||||
|
||||
// copy output data
|
||||
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
|
||||
|
@ -183,6 +190,15 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
|
|||
|
||||
return 0; // zero on success, non-zero on error
|
||||
}
|
||||
|
||||
int CSound::bufferSizeCallback ( jack_nframes_t nframes, void *arg )
|
||||
{
|
||||
CSound* pSound = reinterpret_cast<CSound*> ( arg );
|
||||
|
||||
// TODO actual implementation
|
||||
|
||||
return 0; // zero on success, non-zero on error
|
||||
}
|
||||
# else
|
||||
// Wave in *********************************************************************
|
||||
void CSound::InitRecording()
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
class CSound : public CSoundBase
|
||||
{
|
||||
public:
|
||||
CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg );
|
||||
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ), void* arg );
|
||||
virtual ~CSound() {}
|
||||
|
||||
virtual int Init ( const int iNewPrefMonoBufferSize );
|
||||
|
@ -77,16 +77,17 @@ public:
|
|||
jack_port_t* output_port_right;
|
||||
|
||||
protected:
|
||||
// callback
|
||||
// callbacks
|
||||
static int process ( jack_nframes_t nframes, void* arg );
|
||||
static int bufferSizeCallback ( jack_nframes_t nframes, void *arg );
|
||||
jack_client_t* pJackClient;
|
||||
};
|
||||
# else
|
||||
class CSound : public CSoundBase
|
||||
{
|
||||
public:
|
||||
CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
|
||||
CSoundBase ( false, fpNewCallback, arg ), rhandle ( NULL ),
|
||||
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* pParg ), void* pParg ) :
|
||||
CSoundBase ( false, fpNewProcessCallback, pParg ), rhandle ( NULL ),
|
||||
phandle ( NULL ), iCurPeriodSizeIn ( NUM_PERIOD_BLOCKS_IN ),
|
||||
iCurPeriodSizeOut ( NUM_PERIOD_BLOCKS_OUT ), bChangParamIn ( true ),
|
||||
bChangParamOut ( true ) {}
|
||||
|
@ -139,8 +140,8 @@ protected:
|
|||
class CSound : public CSoundBase
|
||||
{
|
||||
public:
|
||||
CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
|
||||
CSoundBase ( false, fpNewCallback, arg ) {}
|
||||
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* pParg ), void* pParg ) :
|
||||
CSoundBase ( false, fpNewProcessCallback, pParg ) {}
|
||||
virtual ~CSound() { Close(); }
|
||||
|
||||
// not used
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
<item>
|
||||
<widget class="QPushButton" name="buttonOk" >
|
||||
<property name="text" >
|
||||
<string>&OK</string>
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<bool>true</bool>
|
||||
|
|
|
@ -95,7 +95,7 @@ void CSoundBase::run()
|
|||
}
|
||||
|
||||
// process audio data
|
||||
(*fpCallback) ( vecsAudioSndCrdStereo, pCallbackArg );
|
||||
(*fpProcessCallback) ( vecsAudioSndCrdStereo, pProcessCallbackArg );
|
||||
|
||||
// play the new block
|
||||
if ( Write ( vecsAudioSndCrdStereo ) )
|
||||
|
|
|
@ -35,9 +35,9 @@ class CSoundBase : public QThread
|
|||
{
|
||||
public:
|
||||
CSoundBase ( const bool bNewIsCallbackAudioInterface,
|
||||
void (*fpNewCallback) ( CVector<short>& psData, void* arg ),
|
||||
void* arg ) : fpCallback ( fpNewCallback ), pCallbackArg ( arg ),
|
||||
bRun ( false ),
|
||||
void (*fpNewProcessCallback) ( CVector<short>& psData, void* pParg ),
|
||||
void* pParg ) : fpProcessCallback ( fpNewProcessCallback ),
|
||||
pProcessCallbackArg ( pParg ), bRun ( false ),
|
||||
bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ) {}
|
||||
virtual ~CSoundBase() {}
|
||||
|
||||
|
@ -50,13 +50,13 @@ public:
|
|||
|
||||
protected:
|
||||
// function pointer to callback function
|
||||
void (*fpCallback) ( CVector<short>& psData, void* arg );
|
||||
void* pCallbackArg;
|
||||
void (*fpProcessCallback) ( CVector<short>& psData, void* arg );
|
||||
void* pProcessCallbackArg;
|
||||
|
||||
// callback function call for derived classes
|
||||
void Callback ( CVector<short>& psData )
|
||||
void ProcessCallback ( CVector<short>& psData )
|
||||
{
|
||||
(*fpCallback) ( psData, pCallbackArg );
|
||||
(*fpProcessCallback) ( psData, pProcessCallbackArg );
|
||||
}
|
||||
|
||||
// these functions should be overwritten by derived class for
|
||||
|
|
|
@ -489,7 +489,7 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
|
|||
}
|
||||
|
||||
// call processing callback function
|
||||
pSound->Callback ( vecsTmpAudioSndCrdStereo );
|
||||
pSound->ProcessCallback ( vecsTmpAudioSndCrdStereo );
|
||||
|
||||
// perform the processing for input and output
|
||||
for ( int i = 0; i < 2 * NUM_IN_OUT_CHANNELS; i++ ) // stereo
|
||||
|
|
Loading…
Reference in a new issue