added some initial JACK code

This commit is contained in:
Volker Fischer 2009-03-08 08:10:10 +00:00
parent d3c76269d2
commit 2f8d8fbd7e
2 changed files with 75 additions and 3 deletions

View File

@ -12,6 +12,59 @@
#include "sound.h"
#ifdef WITH_SOUND
# if USE_JACK
CSound::CSound ( void (*fpNewCallback) ( CVector<short>& 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<short>& psData )
{
}
bool CSound::Write ( CVector<short>& psData )
{
}
// JACK callbacks --------------------------------------------------------------
int CSound::process ( jack_nframes_t nframes, void* arg )
{
CSound* pSound = reinterpret_cast<CSound*> ( 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

View File

@ -49,9 +49,28 @@
/* Classes ********************************************************************/
#if WITH_SOUND
# if USE_JACK
class CSound : public CSoundBase
{
public:
CSound ( void (*fpNewCallback) ( CVector<short>& 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<short>& psData );
virtual bool Write ( CVector<short>& psData );
protected:
// callback
static int process ( jack_nframes_t nframes, void* arg );
jack_client_t* pJackClient;
};
# else
class CSound : public CSoundBase
{