From d27fab999903131a38d02344fc52969eaf883355 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Thu, 12 Mar 2009 11:56:15 +0000 Subject: [PATCH] some more work on sound interface --- linux/Makefile.am | 4 ++++ linux/sound.cpp | 12 +++++++++++- linux/sound.h | 1 + src/soundbase.h | 9 +++++++++ windows/MocQT.bat | 1 + windows/llcon.vcproj | 6 +++++- windows/sound.cpp | 8 ++------ 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/linux/Makefile.am b/linux/Makefile.am index 89a267a9..f5800bf1 100755 --- a/linux/Makefile.am +++ b/linux/Makefile.am @@ -52,6 +52,7 @@ llcon_SOURCES = ../src/buffer.cpp \ # these need to be generated before the rest can be compiled BUILT_SOURCES=moc/moc_server.cpp \ + moc/moc_soundbase.cpp \ moc/moc_client.cpp \ moc/moc_protocol.cpp \ moc/moc_channel.cpp \ @@ -78,6 +79,9 @@ nodist_llcon_SOURCES=$(BUILT_SOURCES) dist-hook: mkdir $(distdir)/moc +moc/moc_soundbase.cpp: ../src/soundbase.h + $(QT_MOC) ../src/soundbase.h -o moc/moc_soundbase.cpp + moc/moc_server.cpp: ../src/server.h $(QT_MOC) ../src/server.h -o moc/moc_server.cpp diff --git a/linux/sound.cpp b/linux/sound.cpp index 1261bd9f..8a01ef50 100755 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -34,6 +34,9 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* pP // register a "buffer size changed" callback function jack_set_buffer_size_callback ( pJackClient, bufferSizeCallback, this ); + // register shutdown callback function + jack_on_shutdown ( pJackClient, shutdownCallback, this ); + // TEST check sample rate, if not correct, just fire error if ( jack_get_sample_rate ( pJackClient ) != SND_CRD_SAMPLE_RATE ) { @@ -199,10 +202,17 @@ int CSound::bufferSizeCallback ( jack_nframes_t nframes, void *arg ) { CSound* pSound = reinterpret_cast ( arg ); -// TODO actual implementation + pSound->EmitReinitRequestSignal(); return 0; // zero on success, non-zero on error } + +void CSound::shutdownCallback ( void *arg ) +{ + // without a Jack server, our software makes no sense to run, throw + // error message + throw CGenErr ( "Jack server was shut down" ); +} # else // Wave in ********************************************************************* void CSound::InitRecording() diff --git a/linux/sound.h b/linux/sound.h index 973a3210..57ed9155 100755 --- a/linux/sound.h +++ b/linux/sound.h @@ -80,6 +80,7 @@ protected: // callbacks static int process ( jack_nframes_t nframes, void* arg ); static int bufferSizeCallback ( jack_nframes_t nframes, void *arg ); + static void shutdownCallback ( void *arg ); jack_client_t* pJackClient; }; # else diff --git a/src/soundbase.h b/src/soundbase.h index 5c8128fc..6f4414f5 100755 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -33,6 +33,8 @@ /* Classes ********************************************************************/ class CSoundBase : public QThread { + Q_OBJECT + public: CSoundBase ( const bool bNewIsCallbackAudioInterface, void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), @@ -48,6 +50,10 @@ public: virtual void OpenDriverSetup() {} + // TODO this should be protected but since it is used + // in a callback function it has to be public -> better solution + void EmitReinitRequestSignal() { emit ReinitRequest(); } + protected: // function pointer to callback function void (*fpProcessCallback) ( CVector& psData, void* arg ); @@ -69,6 +75,9 @@ protected: bool bIsCallbackAudioInterface; CVector vecsAudioSndCrdStereo; + +signals: + void ReinitRequest(); }; #endif /* !defined ( SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_ ) */ diff --git a/windows/MocQT.bat b/windows/MocQT.bat index 37ebee90..8a3f0fb2 100755 --- a/windows/MocQT.bat +++ b/windows/MocQT.bat @@ -38,6 +38,7 @@ rem .h -------------- %qtdir%\bin\moc.exe ..\src\socket.h -o moc\moc_socket.cpp %qtdir%\bin\moc.exe ..\src\protocol.h -o moc\moc_protocol.cpp %qtdir%\bin\moc.exe ..\src\channel.h -o moc\moc_channel.cpp +%qtdir%\bin\moc.exe ..\src\soundbase.h -o moc\moc_soundbase.cpp rem .ui ------------- diff --git a/windows/llcon.vcproj b/windows/llcon.vcproj index 3d8de999..81d0eae0 100755 --- a/windows/llcon.vcproj +++ b/windows/llcon.vcproj @@ -1,7 +1,7 @@ + + diff --git a/windows/sound.cpp b/windows/sound.cpp index 714d6a33..a20b5c27 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -558,12 +558,8 @@ long CSound::asioMessages ( long selector, long value, void* message, double* op // both messages might be send if the buffer size changes case kAsioBufferSizeChange: case kAsioResetRequest: - -// TODO reinit sound interface and check for new buffer size -// requires changes in client class, too - - - ret = 0;//1L; // 1L if request is accepted or 0 otherwise + pSound->EmitReinitRequestSignal(); + ret = 1L; // 1L if request is accepted or 0 otherwise break; } return ret;