diff --git a/src/audio/codecDescriptor.cpp b/src/audio/codecDescriptor.cpp index 7773aef4afe66ba1ba50a2b66f0287d4551317c6..d45d2edc1b06e3857b43cda974ffd140851a917f 100644 --- a/src/audio/codecDescriptor.cpp +++ b/src/audio/codecDescriptor.cpp @@ -277,10 +277,6 @@ CodecDescriptor::seemsValid( std::string lib) return false; -#ifdef HAVE_SPEEX - printf("cadvfsdgvssbsdfbdgfffffffffffffffffffffffffffffffffffffffff\n"); -#endif - #ifdef HAVE_SPEEX // Nothing special #else diff --git a/src/audio/pulselayer.cpp b/src/audio/pulselayer.cpp index a2da80d467f095d9cfbd318e81349f05292ab8a2..3a1ec8167a6dead4212e760ba4c59c22941fe245 100644 --- a/src/audio/pulselayer.cpp +++ b/src/audio/pulselayer.cpp @@ -325,15 +325,17 @@ void PulseLayer::writeToSpeaker( void ) normalAvail = _mainSndRingBuffer.AvailForGet(); toGet = (normalAvail < (int)(framesPerBuffer * sizeof(SFLDataFormat))) ? normalAvail : framesPerBuffer * sizeof(SFLDataFormat); if (toGet) { - _mainSndRingBuffer.Get(out, toGet, 100); - _mainSndRingBuffer.Discard(toGet); + _mainSndRingBuffer.Get(out, toGet, 100); + _mainSndRingBuffer.Discard(toGet); } else { - bzero(out, framesPerBuffer * sizeof(SFLDataFormat)); + bzero(out, framesPerBuffer * sizeof(SFLDataFormat)); } pa_stream_write( playback->pulseStream() , out , toGet , pa_xfree, 0 , PA_SEEK_RELATIVE); } } + + //if(out) pa_xfree(out); } void PulseLayer::readFromMic( void ) diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp index ff235d41b03b98baf350c1a93da67e65fb547f53..730eada2a63587c04bd62bb15a24a780f0f2b829 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -263,8 +263,6 @@ IAXVoIPLink::sendAudioFromMic(void) // available bytes inside ringbuffer availBytesFromMic = audiolayer->canGetMic(); - _debug("max bytes=%i - avail = %i\n", maxBytesToGet, availBytesFromMic); - if (availBytesFromMic < maxBytesToGet) { // We need packets full! return; @@ -752,7 +750,7 @@ IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call) IAXVoIPLink::iaxHandleRegReply(iax_event* event) { - int voicemail; + int new_voicemails; std::string account_id; if (event->etype == IAX_EVENT_REGREJ) { @@ -770,11 +768,11 @@ IAXVoIPLink::iaxHandleRegReply(iax_event* event) // Looking for the voicemail information //if( event->ies != 0 ) - voicemail = event->ies.msgcount; - _debug("iax voicemail number notification: %i\n", voicemail); + new_voicemails = processIAXMsgCount(event->ies.msgcount); + _debug("iax voicemail number notification: %i\n", new_voicemails); // Notify the client if new voicemail waiting for the current account - account_id = getAccountID(); - Manager::instance().startVoiceMessageNotification(account_id.c_str(), voicemail); + account_id = getAccountID(); + Manager::instance().startVoiceMessageNotification(account_id.c_str(), new_voicemails); iax_destroy(_regSession); _mutexIAX.leaveMutex(); @@ -787,6 +785,28 @@ IAXVoIPLink::iaxHandleRegReply(iax_event* event) } } +int IAXVoIPLink::processIAXMsgCount( int msgcount ) +{ + + // IAX sends the message count under a specific format: + // 1 + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // | 0x18 | 0x02 | + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // | Old messages | New messages | + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + // For now we just need the new messages informations. + // Thus: + // 0 <= msgcount <= 255 => msgcount new messages, 0 old messages + // msgcount >= 256 => msgcount/256 old messages , msgcount%256 new messages (RULES) + + return msgcount%256; + +} + + void IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event) { diff --git a/src/iaxvoiplink.h b/src/iaxvoiplink.h index 569ac88298964b0462cb4e4ef5945b3dd72cffdb..f01ce54dad66c8cca18513b9facb03ecf6df173c 100644 --- a/src/iaxvoiplink.h +++ b/src/iaxvoiplink.h @@ -191,6 +191,17 @@ class IAXVoIPLink : public VoIPLink void updateAudiolayer( void ); private: + + /* + * Decode the message count IAX send. + * Returns only the new messages number + * + * @param msgcount The value sent by IAX in the REGACK message + * @return int The number of new messages waiting for the current registered user + */ + int processIAXMsgCount( int msgcount ); + + /** * Get IAX Call from an id * @param id CallId