diff --git a/linux/sound.cpp b/linux/sound.cpp index 80ec1ff0..04f7d4b0 100755 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -12,6 +12,59 @@ #include "sound.h" #ifdef WITH_SOUND +# if USE_JACK +CSound::CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), + void* arg ) : + CSoundBase ( false, fpNewCallback, arg ) +{ + jack_status_t JackStatus; + + // try to become a client of the JACK server + pJackClient = jack_client_open ( "llcon", JackNullOption, &JackStatus ); + if ( pJackClient == NULL ) + { + throw CGenErr ( "Jack server not running" ); + } + + // tell the JACK server to call "process()" whenever + // there is work to be done + jack_set_process_callback ( pJackClient, process, this ); +} + + + +int CSound::Init ( const int iNewPrefMonoBufferSize ) +{ + +// TEST +return iNewPrefMonoBufferSize; + +} + +bool CSound::Read ( CVector& psData ) +{ + + +} + +bool CSound::Write ( CVector& psData ) +{ + + + +} + +// JACK callbacks -------------------------------------------------------------- +int CSound::process ( jack_nframes_t nframes, void* arg ) +{ + CSound* pSound = reinterpret_cast ( arg ); + + + return 0; // zero on success, non-zero on error +} + + +# else // Wave in ********************************************************************* void CSound::InitRecording() { @@ -366,5 +419,5 @@ void CSound::Close() phandle = NULL; } - -#endif /* WITH_SOUND */ +# endif // USE_JACK +#endif // WITH_SOUND diff --git a/linux/sound.h b/linux/sound.h index d2ccb4ee..e29369fb 100755 --- a/linux/sound.h +++ b/linux/sound.h @@ -49,9 +49,28 @@ /* Classes ********************************************************************/ #if WITH_SOUND # if USE_JACK +class CSound : public CSoundBase +{ +public: + CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), void* arg ); + virtual ~CSound() {} -// TODO, see http://jackit.sourceforge.net/cgi-bin/lxr/http/source/example-clients/simple_client.c + // not implemented yet, always return one device and default string + int GetNumDev() { return 1; } + std::string GetDeviceName ( const int iDiD ) { return "wave mapper"; } + int SetDev ( const int iNewDev ) {} // dummy + int GetDev() { return 0; } + virtual int Init ( const int iNewPrefMonoBufferSize ); + virtual bool Read ( CVector& psData ); + virtual bool Write ( CVector& psData ); + +protected: + // callback + static int process ( jack_nframes_t nframes, void* arg ); + + jack_client_t* pJackClient; +}; # else class CSound : public CSoundBase {