diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 5a68c9ca255d88a13f77f50e2f346ccfda643ad7..07f892264b1535111c388f9a2242c0ccb8c28cdf 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -427,6 +427,7 @@ call_t * sflphone_new_call() void sflphone_keypad( guint keyval, gchar * key) { + dbus_play_dtmf(key); call_t * c = call_get_selected(); if(c) { @@ -434,6 +435,7 @@ sflphone_keypad( guint keyval, gchar * key) switch(c->state) { case CALL_STATE_DIALING: // Currently dialing => edit number + //dbus_play_dtmf(key); process_dialing(c, keyval, key); break; case CALL_STATE_CURRENT: diff --git a/src/audio/audiolayer.cpp b/src/audio/audiolayer.cpp index 289f5d379f792fb9f324bb94c54ede71e508caeb..d4f73eef525623f26fc3765fb7bb151e0d04a30e 100644 --- a/src/audio/audiolayer.cpp +++ b/src/audio/audiolayer.cpp @@ -177,10 +177,11 @@ AudioLayer::isStreamActive (void) int -AudioLayer::playSamples(void* buffer, int toCopy) +AudioLayer::playSamples(void* buffer, int toCopy, bool isTalking) { //ost::MutexLock lock( _mutex ); - _talk = true; + if( isTalking ) + _talk = true; if ( _PlaybackHandle ){ write( adjustVolume( buffer , toCopy , SFL_PCM_PLAYBACK ) , toCopy ); } @@ -254,7 +255,7 @@ AudioLayer::toggleEchoTesting() { void AudioLayer::playTones( void ) { - int frames = 1024 ; + int frames = _periodSize ; int maxBytes = frames * sizeof(SFLDataFormat) ; SFLDataFormat* out = (SFLDataFormat*)malloc(maxBytes * sizeof(SFLDataFormat)); if( _talk ) {} @@ -364,13 +365,10 @@ AudioLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) //if( err = snd_pcm_hw_params_set_buffer_size_near( _PlaybackHandle, hwParams, &buffer_size_out ) < 0) _debugAlsa(" Cannot set buffer size (%s)\n", snd_strerror(err)); if( err = snd_pcm_hw_params_set_buffer_time_near( _PlaybackHandle, hwParams, &buffer_time , &dir) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); if( err = snd_pcm_hw_params_set_period_time_near( _PlaybackHandle, hwParams, &period_time , &dir) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_period_size( hwParams, &period_size_out , &dir) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); + if( err = snd_pcm_hw_params_get_period_size( hwParams, &_periodSize , &dir) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); if( err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_out ) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); if( err = snd_pcm_hw_params( _PlaybackHandle, hwParams ) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); - unsigned int hz; - snd_pcm_hw_params_get_rate( hwParams , &hz , &dir ); - _debugAlsa("Rate = %d\n" , hz); snd_pcm_hw_params_free( hwParams ); diff --git a/src/audio/audiolayer.h b/src/audio/audiolayer.h index bcb54c88bc3a66e722a077b47aa382fd5c65b63b..aea67b96445165b6b2dd8ef86dd37e4f5163c63d 100644 --- a/src/audio/audiolayer.h +++ b/src/audio/audiolayer.h @@ -111,7 +111,7 @@ class AudioLayer { * @params toCopy The number of samples, in bytes * @return int The number of bytes played */ - int playSamples(void* buffer, int toCopy); + int playSamples(void* buffer, int toCopy, bool isTalking); /* * Send a chunk of data to the hardware buffer to start the playback @@ -287,6 +287,7 @@ class AudioLayer { */ snd_pcm_t* _PlaybackHandle; snd_pcm_t* _CaptureHandle; + snd_pcm_uframes_t _periodSize; /* * Handle on asynchronous event diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 76800e7667cec3f2f35eb7f455b074949d1d1492..01f4729704b3095ac603758289e2f466b42ff9da 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -379,7 +379,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) #endif - audiolayer->playSamples(toAudioLayer, nbSample * sizeof(SFLDataFormat)); + audiolayer->playSamples(toAudioLayer, nbSample * sizeof(SFLDataFormat), true); // Notify (with a beep) an incoming call when there is already a call countTime += time->getSecond(); if (Manager::instance().incomingCallWaiting() > 0) { diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp index 04240e30e28693fe4dc03f4a6ded85b1b0f49d55..9ea3415fc7032cfc84c684d2e710bb44bf5eda12 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -823,7 +823,7 @@ IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call) toAudioLayer = _receiveDataDecoded; // int to int #endif } - audiolayer->playSamples(toAudioLayer, nbSample * sizeof(SFLDataFormat)); + audiolayer->playSamples(toAudioLayer, nbSample * sizeof(SFLDataFormat), true); } else { _debug("IAX: incoming audio, but no sound card open"); } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 3e6943cfdfd28b032f0c2b89e8f4777026ce2e19..17d38782c30d8d20b52aa241fdd0c77f657ff5a6 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -501,8 +501,8 @@ ManagerImpl::sendDtmf(const CallID& id, char code) { AccountID accountid = getAccountFromCall( id ); if (accountid == AccountNULL) { - _debug("Send DTMF: call doesn't exists\n"); - //playDtmf(code); + //_debug("Send DTMF: call doesn't exists\n"); + playDtmf(code, false); return false; } @@ -510,7 +510,7 @@ ManagerImpl::sendDtmf(const CallID& id, char code) bool returnValue = false; switch (sendType) { case 0: // SIP INFO - playDtmf(code); + playDtmf(code , true); returnValue = getAccountLink(accountid)->carryingDTMFdigits(id, code); break; @@ -526,7 +526,7 @@ ManagerImpl::sendDtmf(const CallID& id, char code) //THREAD=Main | VoIPLink bool -ManagerImpl::playDtmf(char code) +ManagerImpl::playDtmf(char code, bool isTalking) { // HERE are the variable: // - boolean variable to play or not (config) @@ -566,7 +566,7 @@ ManagerImpl::playDtmf(char code) // Put buffer to urgentRingBuffer // put the size in bytes... // so size * 1 channel (mono) * sizeof (bytes for the data) - audiolayer->playSamples(_buf, size * sizeof(SFLDataFormat)); + audiolayer->playSamples(_buf, size * sizeof(SFLDataFormat), isTalking); //audiolayer->putUrgent(_buf, size * sizeof(SFLDataFormat)); // We activate the stream if it's not active yet. @@ -974,7 +974,7 @@ ManagerImpl::notificationIncomingCall(void) { unsigned int nbSampling = tone.getSize(); SFLDataFormat buf[nbSampling]; tone.getNext(buf, tone.getSize()); - audiolayer->playSamples(buf, sizeof(SFLDataFormat)*nbSampling); + audiolayer->playSamples(buf, sizeof(SFLDataFormat)*nbSampling, true); } } @@ -2164,11 +2164,11 @@ ManagerImpl::setSwitch(const std::string& switchName, std::string& message) { } message = _("Change with success"); - playDtmf('9'); + playDtmf('9', true); //getAudioDriver()->sleep(300); // in milliseconds - playDtmf('1'); + playDtmf('1', true); //getAudioDriver()->sleep(300); // in milliseconds - playDtmf('1'); + playDtmf('1', true); return true; } } else if ( switchName == "echo" ) { diff --git a/src/managerimpl.h b/src/managerimpl.h index 6d01ab20e78e0cdf8e3c0558652e5c57c1d02520..57fbdf18b3fdb40a0a6655a1472f658dc7ff90b4 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -174,7 +174,7 @@ public: * @param code: pressed key. */ bool sendDtmf(const CallID& id, char code); - bool playDtmf(char code); + bool playDtmf(char code, bool isTalking); bool playTone (); void stopTone(bool stopAudio/*=true*/); diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 091be923ea9d078bcc53c529a0fca65fb8972911..e61224cb931cfb2bccaa7309245b1e15ac5a679b 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -1692,7 +1692,7 @@ SIPVoIPLink::handleDtmfRelay(eXosip_event_t* event) { if (!signal.empty()) { if (Manager::instance().isCurrentCall(call->getCallId())) { - Manager::instance().playDtmf(signal[0]); + Manager::instance().playDtmf(signal[0], true); returnValue = true; } }