Commit 194dae11 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

Switching from ALSA to PULSEAUDIO during a call

parent a4c1a0c8
......@@ -194,9 +194,9 @@ void AlsaLayer::stopCaptureStream (void)
if(_CaptureHandle){
err = snd_pcm_drop (_CaptureHandle);
_debug("AlsaLayer::stopCaptureStream snd_pcm_drop returned vaue : %i\n",err);
stop_capture ();
_debug("Wroking here !!!!!!!!!!!!!!!\n");
}
}
......
......@@ -66,6 +66,7 @@ AudioStream::stream_state_callback( pa_stream* s, void* user_data UNUSED )
case PA_STREAM_READY:
_debug("Stream successfully created, connected to %s\n", pa_stream_get_device_name( s ));
pa_stream_cork( s, 0, NULL, NULL);
break;
case PA_STREAM_UNCONNECTED:
_debug("Stream unconnected\n");
......
......@@ -140,12 +140,12 @@ void PulseLayer::createStreams( pa_context* c )
playback = new AudioStream(c, PLAYBACK_STREAM, PLAYBACK_STREAM_NAME, _manager->getSpkrVolume());
pa_stream_set_write_callback( playback->pulseStream(), audioCallback, this);
//pa_stream_set_overflow_callback( playback->pulseStream() , overflow , this);
// pa_stream_set_overflow_callback( playback->pulseStream() , overflow , this);
// pa_stream_set_suspended_callback( playback->pulseStream(), stream_suspended_callback, this);
record = new AudioStream(c, CAPTURE_STREAM, CAPTURE_STREAM_NAME , _manager->getMicVolume());
pa_stream_set_read_callback( record->pulseStream() , audioCallback, this);
//pa_stream_set_underflow_callback( record->pulseStream() , underflow , this);
// pa_stream_set_underflow_callback( record->pulseStream() , underflow , this);
// pa_stream_set_suspended_callback(record->pulseStream(), stream_suspended_callback, this);
......@@ -173,6 +173,8 @@ bool PulseLayer::openDevice(int indexIn UNUSED, int indexOut UNUSED, int sampleR
assert(context);
connectPulseAudioServer();
startStream();
_debug("Connection Done!! \n");
return true;
......@@ -254,8 +256,6 @@ void PulseLayer::stream_suspended_callback(pa_stream *s, void *userdata UNUSED )
void PulseLayer::processData( void )
{
_debug("PulseLayer::processData() \n");
// Handle the mic
// We check if the stream is ready
if( (record->pulseStream()) && (pa_stream_get_state( record->pulseStream()) == PA_STREAM_READY))
......
......@@ -74,6 +74,8 @@ IAXVoIPLink::~IAXVoIPLink()
audiolayer = NULL;
delete converter;
delete [] micData; micData = NULL;
delete [] micDataConverted; micDataConverted = NULL;
delete [] micDataEncoded; micDataEncoded = NULL;
......
......@@ -124,7 +124,7 @@ ManagerImpl::init()
AudioLayer *audiolayer = getAudioDriver();
if (audiolayer!=0) {
if (audiolayer != 0) {
unsigned int sampleRate = audiolayer->getSampleRate();
_debugInit("Load Telephone Tone");
......@@ -134,6 +134,9 @@ ManagerImpl::init()
_debugInit("Loading DTMF key");
_dtmfKey = new DTMF(sampleRate);
}
if (audiolayer == 0)
audiolayer->stopStream();
}
void ManagerImpl::terminate()
......@@ -190,6 +193,9 @@ ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const
{
_debug("ManagerImpl::outgoingCall() method \n");
stopTone(false);
playTone();
if (!accountExists(accountid)) {
_debug("! Manager Error: Outgoing Call: account doesn't exist\n");
return false;
......@@ -313,7 +319,7 @@ ManagerImpl::cancelCall (const CallID& id)
bool
ManagerImpl::onHoldCall(const CallID& id)
{
_debug("*************** ON HOLD ***********************************\n");
stopTone(true);
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
......@@ -336,7 +342,7 @@ ManagerImpl::onHoldCall(const CallID& id)
bool
ManagerImpl::offHoldCall(const CallID& id)
{
_debug("*************** OFF HOLD ***********************************\n");
stopTone(false);
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
......@@ -1592,6 +1598,8 @@ void ManagerImpl::setAudioManager( const int32_t& api )
{
int manager;
_debug(" ManagerImpl::setAudioManager :: %i \n",api);
manager = api;
if( manager == PULSEAUDIO )
{
......@@ -1705,8 +1713,8 @@ ManagerImpl::initAudioDriver(void)
if (error == -1) {
_debug("Init audio driver: %i\n", error);
}
}
}
}
/**
......@@ -1756,6 +1764,7 @@ ManagerImpl::selectAudioDriver (void)
/* Notify the error if there is one */
if( _audiodriver -> getErrorMessage() != -1 )
notifyErrClient( _audiodriver -> getErrorMessage());
}
void ManagerImpl::switchAudioManager (void)
......@@ -1796,6 +1805,16 @@ void ManagerImpl::switchAudioManager (void)
_audiodriver->openDevice( numCardIn , numCardOut, samplerate, framesize, SFL_PCM_BOTH, alsaPlugin );
if( _audiodriver -> getErrorMessage() != -1 )
notifyErrClient( _audiodriver -> getErrorMessage());
_debug("Current device: %i \n", type);
_debug("has current call: %i \n", hasCurrentCall());
// need to stop audio streams if there is currently no call
if( (type != PULSEAUDIO) && (!hasCurrentCall())) {
_debug("There is currently a call!!\n");
_audiodriver->stopStream();
}
}
/**
......
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