Commit ff705de0 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2360] Moved MainBuffer from AudioLayer to ManagerImpl

As the mainbuffer was deleted when switching audio device,
the application crashed

Now in ManagerImpl, we can switch audio device during a call
parent a8b867f1
......@@ -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;
......
......@@ -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)
......
......@@ -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:
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment