some preparations for new JACK audio interface

This commit is contained in:
Volker Fischer 2009-03-07 22:56:46 +00:00
parent 0308768ecb
commit 3bf3ab832d
5 changed files with 56 additions and 61 deletions

View File

@ -20,20 +20,29 @@ AC_CHECK_PROGS(RPMBUILD, rpmbuild, rpm)
dnl Configuration Arguments dnl Configuration Arguments
AC_ARG_ENABLE( sound,[ --enable-sound generic sound support], enable_sound=$enableval, enable_sound=yes) AC_ARG_ENABLE( sound,[ --enable-sound generic sound support], enable_sound=$enableval, enable_sound=yes)
AC_ARG_ENABLE( alsa,[ --enable-alsa use ALSA interface], enable_alsa=$enableval, enable_alsa=yes)
dnl AC_ARG_WITH( qt4dir,[ --with-qtdir=path to QT],QT4DIR=$withval)
AC_CHECK_HEADER(sys/asoundlib.h, , enable_sound=no) if test "$enable_alsa" = "yes"; then
AC_CHECK_LIB(asound, snd_pcm_open, , enable_sound=no) dnl checks for ALSA audio
AC_CHECK_HEADER(sys/asoundlib.h, , enable_sound=no)
AC_CHECK_LIB(asound, snd_pcm_open, , enable_sound=no)
else
dnl checks for JACK audio
AC_CHECK_HEADER([jack/jack.h], have_jack=yes, have_jack=no, [
])
dnl AM_CONDITIONAL(USE_JACK,test "$have_jack" = yes)
if test "$have_jack" = yes; then
JACK_LIB="-ljack"
AC_DEFINE(USE_JACK, 1,[Define to enable JACK input module])
fi
fi
if test "$enable_sound" = "yes"; then if test "$enable_sound" = "yes"; then
AC_DEFINE(WITH_SOUND, 1, [Define if you want to use sound]) AC_DEFINE(WITH_SOUND, 1, [Define if you want to use sound])
fi fi
if test "$enable_client" = "yes"; then
AC_DEFINE(APPL_TYPE_CLIENT, 1, [Define if you want to use client])
fi
dnl Checks for header files. dnl Checks for header files.
@ -78,12 +87,9 @@ fi
QT_LIBS="$QT_LIB" QT_LIBS="$QT_LIB"
QT_LDADD="-L$QTDIR/lib $QT_LIBS" QT_LDADD="-L$QTDIR/lib $QT_LIBS"
LDFLAGS="$QT_LDADD $LDFLAGS" JACK_LIBS="$JACK_LIB"
JACK_LDADD="$JACK_LIBS"
dnl FOO=`echo $QT_LIBS | sed -e 's/-L/-Wl,-rpath,/' | sed -e 's/-L.*//'` LDFLAGS="$QT_LDADD $JACK_LDADD $LDFLAGS"
dnl LDFLAGS="$LDFLAGS $FOO"
dnl LDFLAGS="-L/usr/lib $QT_LIBS $LDFLAGS"
AC_MSG_NOTICE([Set LDFLAGS... $LDFLAGS]) AC_MSG_NOTICE([Set LDFLAGS... $LDFLAGS])
@ -94,27 +100,5 @@ AC_SUBST(QT_MOC)
AC_SUBST(QT_RCC) AC_SUBST(QT_RCC)
AC_SUBST(QT_UIC) AC_SUBST(QT_UIC)
dnl old QT2/QT3 code:
dnl if test "no$QTDIR" = "no"; then
dnl AC_MSG_ERROR( "*** Please set QTDIR ***" )
dnl fi
dnl
dnl saved_ldflags="$LDFLAGS"
dnl LDFLAGS="$LDFLAGS -L$QTDIR/lib"
dnl
dnl AC_HAVE_LIBRARY(qt-mt,,exit 1)
dnl
dnl AC_PATH_PROG(MOC, moc,, "$QTDIR/bin")
dnl if test -z "$MOC"; then
dnl AC_MSG_ERROR("No moc found in $QTDIR/bin");
dnl fi
dnl AC_PATH_PROG(UIC, uic,, "$QTDIR/bin")
dnl if test -z "$UIC"; then
dnl AC_MSG_ERROR("No uic found in $QTDIR/bin");
dnl fi
dnl AC_SUBST(QTDIR)
AC_CONFIG_FILES(Makefile linux/Makefile) AC_CONFIG_FILES(Makefile linux/Makefile)
AC_OUTPUT AC_OUTPUT

View File

@ -25,9 +25,13 @@
#include "global.h" #include "global.h"
#if WITH_SOUND #if WITH_SOUND
# define ALSA_PCM_NEW_HW_PARAMS_API # if USE_JACK
# define ALSA_PCM_NEW_SW_PARAMS_API # include <jack/jack.h>
# include <alsa/asoundlib.h> # else
# define ALSA_PCM_NEW_HW_PARAMS_API
# define ALSA_PCM_NEW_SW_PARAMS_API
# include <alsa/asoundlib.h>
# endif
#endif #endif
@ -43,18 +47,20 @@
/* Classes ********************************************************************/ /* Classes ********************************************************************/
#if WITH_SOUND
# if USE_JACK
// TODO, see http://jackit.sourceforge.net/cgi-bin/lxr/http/source/example-clients/simple_client.c
# else
class CSound : public CSoundBase class CSound : public CSoundBase
{ {
public: public:
CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) : CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
#if WITH_SOUND CSoundBase ( false, fpNewCallback, arg ), rhandle ( NULL ),
CSoundBase ( false, fpNewCallback, arg ), rhandle ( NULL ), phandle ( NULL ), iCurPeriodSizeIn ( NUM_PERIOD_BLOCKS_IN ),
phandle ( NULL ), iCurPeriodSizeIn ( NUM_PERIOD_BLOCKS_IN ), iCurPeriodSizeOut ( NUM_PERIOD_BLOCKS_OUT ), bChangParamIn ( true ),
iCurPeriodSizeOut ( NUM_PERIOD_BLOCKS_OUT ), bChangParamIn ( true ), bChangParamOut ( true ) {}
bChangParamOut ( true ) {}
#else
CSoundBase ( false, fpNewCallback, arg ) {}
#endif
virtual ~CSound() { Close(); } virtual ~CSound() { Close(); }
// not implemented yet, always return one device and default string // not implemented yet, always return one device and default string
@ -63,7 +69,6 @@ public:
int SetDev ( const int iNewDev ) {} // dummy int SetDev ( const int iNewDev ) {} // dummy
int GetDev() { return 0; } int GetDev() { return 0; }
#if WITH_SOUND
virtual int Init ( const int iNewPrefMonoBufferSize ) virtual int Init ( const int iNewPrefMonoBufferSize )
{ {
// init base class // init base class
@ -80,9 +85,9 @@ public:
} }
virtual bool Read ( CVector<short>& psData ); virtual bool Read ( CVector<short>& psData );
virtual bool Write ( CVector<short>& psData ); virtual bool Write ( CVector<short>& psData );
virtual void Close();
protected: protected:
void Close();
void InitRecording(); void InitRecording();
void InitPlayback(); void InitPlayback();
@ -98,13 +103,28 @@ protected:
int iCurPeriodSizeIn; int iCurPeriodSizeIn;
bool bChangParamOut; bool bChangParamOut;
int iCurPeriodSizeOut; int iCurPeriodSizeOut;
};
# endif // USE_JACK
#else #else
// no sound -> dummy class definition
class CSound : public CSoundBase
{
public:
CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
CSoundBase ( false, fpNewCallback, arg ) {}
virtual ~CSound() { Close(); }
// not used
int GetNumDev() { return 1; }
std::string GetDeviceName ( const int iDiD ) { return "wave mapper"; }
int SetDev ( const int iNewDev ) {} // dummy
int GetDev() { return 0; }
// dummy definitions // dummy definitions
virtual int Init ( const int iNewPrefMonoBufferSize ) { CSoundBase::Init ( iNewPrefMonoBufferSize ); } virtual int Init ( const int iNewPrefMonoBufferSize ) { CSoundBase::Init ( iNewPrefMonoBufferSize ); }
virtual bool Read ( CVector<short>& psData ) { printf ( "no sound!" ); return false; } virtual bool Read ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
virtual bool Write ( CVector<short>& psData ) { printf ( "no sound!" ); return false; } virtual bool Write ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
virtual void Close() {}
#endif
}; };
#endif // WITH_SOUND
#endif // !defined(_SOUND_H__9518A621345F78_3634567_8C0D_EEBF182CF549__INCLUDED_) #endif // !defined(_SOUND_H__9518A621345F78_3634567_8C0D_EEBF182CF549__INCLUDED_)

View File

@ -45,7 +45,6 @@ public:
virtual void Start(); virtual void Start();
virtual void Stop(); virtual void Stop();
bool IsRunning() const { return bRun; } bool IsRunning() const { return bRun; }
virtual void Close() = 0;
virtual void OpenDriverSetup() {} virtual void OpenDriverSetup() {}

View File

@ -360,13 +360,6 @@ void CSound::Stop()
CSoundBase::Stop(); CSoundBase::Stop();
} }
void CSound::Close()
{
// TODO
}
CSound::CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) : CSound::CSound ( void (*fpNewCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
CSoundBase ( true, fpNewCallback, arg ) CSoundBase ( true, fpNewCallback, arg )
{ {
@ -564,7 +557,7 @@ long CSound::asioMessages ( long selector, long value, void* message, double* op
// requires changes in client class, too // requires changes in client class, too
ret = 1L; // 1L if request is accepted or 0 otherwise ret = 0;//1L; // 1L if request is accepted or 0 otherwise
break; break;
} }
return ret; return ret;

View File

@ -62,7 +62,6 @@ public:
virtual int Init ( const int iNewPrefMonoBufferSize ); virtual int Init ( const int iNewPrefMonoBufferSize );
virtual void Start(); virtual void Start();
virtual void Stop(); virtual void Stop();
virtual void Close();
virtual void OpenDriverSetup() { ASIOControlPanel(); } virtual void OpenDriverSetup() { ASIOControlPanel(); }