diff --git a/sflphone-common/src/audio/audiolayer.cpp b/sflphone-common/src/audio/audiolayer.cpp index 8966eb6aba086a30183d9dfa048ec3d42f5350f8..0dcace767bab39182c745c4f3ac37ca000bc9fd7 100644 --- a/sflphone-common/src/audio/audiolayer.cpp +++ b/sflphone-common/src/audio/audiolayer.cpp @@ -24,7 +24,7 @@ void AudioLayer::flushMain (void) ost::MutexLock guard (_mutex); // should pass call id - _mainBuffer.flushAllBuffers(); + getMainBuffer()->flushAllBuffers(); } void AudioLayer::flushUrgent (void) @@ -36,7 +36,7 @@ void AudioLayer::flushUrgent (void) void AudioLayer::flushMic (void) { ost::MutexLock guard (_mutex); - _mainBuffer.flushDefault(); + getMainBuffer()->flushDefault(); } int AudioLayer::putUrgent (void* buffer, int toCopy) @@ -60,13 +60,13 @@ int AudioLayer::putMain (void *buffer, int toCopy, CallID call_id) int a; ost::MutexLock guard (_mutex); - a = _mainBuffer.availForPut(call_id); + a = getMainBuffer()->availForPut(call_id); if (a >= toCopy) { - return _mainBuffer.putData (buffer, toCopy, _defaultVolume, call_id); + return getMainBuffer()->putData (buffer, toCopy, _defaultVolume, call_id); } else { _debug ("Chopping sound, Ouch! RingBuffer full ?\n"); - return _mainBuffer.putData (buffer, a, _defaultVolume, call_id); + return getMainBuffer()->putData (buffer, a, _defaultVolume, call_id); } return 0; diff --git a/sflphone-common/src/audio/audiolayer.h b/sflphone-common/src/audio/audiolayer.h index b995a87af96c772f589aec895e0e78995de703d5..2e3dbee8e2e9eb484ea13f16dadfb3b0c1086653 100644 --- a/sflphone-common/src/audio/audiolayer.h +++ b/sflphone-common/src/audio/audiolayer.h @@ -208,12 +208,12 @@ class AudioLayer { * * @return MainBuffer* a pointer to the MainBuffer instance */ - MainBuffer* getMainBuffer( void ) { return &_mainBuffer; } + MainBuffer* getMainBuffer( void ) { return _mainBuffer; } /** * Set the mainbuffer once the audiolayer is created */ - // void setMainBuffer( MainBuffer* mainbuffer ) { _mainBuffer = mainbuffer; } + void setMainBuffer( MainBuffer* mainbuffer ) { _mainBuffer = mainbuffer; } /** * Default volume for incoming RTP and Urgent sounds. @@ -261,7 +261,7 @@ class AudioLayer { * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. * */ - MainBuffer _mainBuffer; + MainBuffer* _mainBuffer; /** * A pointer to the recordable instance (may be a call or a conference) diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 51599a04d99dcea79989aea5fb74e419cc8f4bb4..274bd21820e1ee60229a0e78ef8af9e6de7e37c4 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -3072,12 +3072,15 @@ ManagerImpl::initAudioDriver (void) if (getConfigInt (PREFERENCES , CONFIG_AUDIO) == ALSA) { _audiodriver = new AlsaLayer (this); + _audiodriver->setMainBuffer(&_mainBuffer); } else if (getConfigInt (PREFERENCES , CONFIG_AUDIO) == PULSEAUDIO) { if (app_is_running ("pulseaudio") == 0) { _audiodriver = new PulseLayer (this); + _audiodriver->setMainBuffer(&_mainBuffer); } else { _audiodriver = new AlsaLayer (this); setConfig (PREFERENCES, CONFIG_AUDIO, ALSA); + _audiodriver->setMainBuffer(&_mainBuffer); } } else _debug ("Error - Audio API unknown\n"); @@ -3176,7 +3179,7 @@ void ManagerImpl::switchAudioManager (void) _debug ("Deleting current layer... \n"); - //_audiodriver->closeLayer(); + // _audiodriver->closeLayer(); delete _audiodriver; _audiodriver = NULL; @@ -3186,11 +3189,13 @@ void ManagerImpl::switchAudioManager (void) case ALSA: _debug ("Creating Pulseaudio layer...\n"); _audiodriver = new PulseLayer (this); + _audiodriver->setMainBuffer(&_mainBuffer); break; case PULSEAUDIO: _debug ("Creating ALSA layer...\n"); _audiodriver = new AlsaLayer (this); + _audiodriver->setMainBuffer(&_mainBuffer); break; default: diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 19904a204ca692ef02e3dedf4a7254214d6ab123..9689044a087e78186e9150744e70c96b063430b9 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -43,6 +43,8 @@ #include "audio/sound/dtmf.h" // DTMF class contained by value here #include "audio/codecs/codecDescriptor.h" // CodecDescriptor class contained by value here +#include "audio/mainbuffer.h" + class AudioLayer; class GuiFramework; class TelephoneTone; @@ -1191,6 +1193,17 @@ class ManagerImpl { * Unload the account (delete them) */ void unloadAccountMap(); + + + /** + * Instance of the MainBuffer for the whole application + * + * In order to send signal to other parts of the application, one must pass through the mainbuffer. + * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. + * + */ + MainBuffer _mainBuffer; + public: @@ -1252,6 +1265,8 @@ class ManagerImpl { // ConferenceMap _conferencemap; + + private: // Copy Constructor