diff --git a/CHANGES b/CHANGES index ca20a29e0754f1a110f1bb8c563a8e506e49f7b8..ef612b9d0e60208a4b4dd80a7b9f99f7042ab628 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,5 @@ -SFLphone (0.3) / 2005-02-10 - * ALSA driver support added (not yet operationnal) +SFLphone (0.3) / 2005-04-05 + * ALSA driver support added * GSM audio codec support added * Rings support (just ulaw format) added * Notification incoming call added diff --git a/src/Makefile b/src/Makefile index f503ba35fa1e56e2fa23b822edba7b9c385ae163..05ab754cf0504308b74567b2b583bd4141a9657d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -66,8 +66,8 @@ OBJS = \ volumecontrol.o volumecontrol.moc.o \ stun.o udp.o -start: check prereq all -#start: check all +#start: check prereq all +start: check all check: ifeq ($(CONFIGURE_CONF),../configure.conf) diff --git a/src/audiobuffer.cpp b/src/audiobuffer.cpp index 821cbb055819884bd89f540f0bd68eda17b8ce23..c85a0d59dac28dab6c7be4a4605d85440d501fc9 100644 --- a/src/audiobuffer.cpp +++ b/src/audiobuffer.cpp @@ -52,6 +52,7 @@ void AudioBuffer::resize (size_t newsize) void AudioBuffer::setData (short *buf, int vol) { short *databuf = (short*)data; + for (int i = 0; i < (int)size; i++) { databuf[i] = buf[i]*vol/100; } diff --git a/src/audiocodec.cpp b/src/audiocodec.cpp index c7bcdcb09bf35e4bb2a8143bfb7e4a49cb70d897..ce8682c95211c84c1ae6e3154c53f14fdc8e9bb5 100644 --- a/src/audiocodec.cpp +++ b/src/audiocodec.cpp @@ -26,12 +26,6 @@ #include <string> -#define swab16(x) \ - ((unsigned short)( \ - (((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \ - (((unsigned short)(x) & (unsigned short)0xff00U) >> 8) )) - - using namespace std; @@ -138,40 +132,7 @@ AudioCodec::codecEncode (int pt, unsigned char *dst, short *src, unsigned int si break; case PAYLOAD_CODEC_GSM: -#if 0 - { - gsm_frame gsmdata; // dst - int iii; - - bzero (gsmdata, sizeof(gsm_frame)); - - printf ("Before gsm_encode: "); - for (iii = 0; iii < 33; iii++) { - unsigned char *ptr = gsmdata; - printf ("%02X ", ptr[iii]); - } - gsm_signal sample[160]; - for (iii = 0; iii < 160; iii++) { - unsigned short dat; - dat = (unsigned short) src[iii]; - //dat = (unsigned short) sample[iii]; - //sample[iii] = (short) swab16(dat); - sample[iii] = src[iii]; - } - gsm_encode(encode_gsmhandle, sample, gsmdata); - printf ("\nAfter gsm_encode: "); - for (iii = 0; iii < 33; iii++) { - unsigned char *ptr = gsmdata; - printf ("%02X ", ptr[iii]); - dst[iii] = ptr[iii]; - } - printf ("\n------\n"); - } -#endif -#if 1 gsm_encode(encode_gsmhandle, (gsm_signal*)src, (gsm_byte*)dst); - -#endif return 33; break; @@ -208,28 +169,4 @@ AudioCodec::gsmDestroy (void) { gsm_destroy(encode_gsmhandle); } -int -AudioCodec::getSizeByPayload (int pt){ - switch (pt) { - case PAYLOAD_CODEC_ULAW: - case PAYLOAD_CODEC_ALAW: - return 320; - break; - - case PAYLOAD_CODEC_GSM: - return 320; - break; - - case PAYLOAD_CODEC_ILBC: - // TODO - break; - case PAYLOAD_CODEC_SPEEX: - // TODO - break; - - default: - break; - } - return 0; -} diff --git a/src/audiocodec.h b/src/audiocodec.h index 8630be6062db6a44e39652fbdb573c3da27fdb3e..9d927752d1c674f39a0e8b18b736fdb4763f38cd 100644 --- a/src/audiocodec.h +++ b/src/audiocodec.h @@ -56,7 +56,6 @@ public: static int codecEncode (int, unsigned char *, short *, unsigned int); static void gsmCreate (void); static void gsmDestroy (void); - static int getSizeByPayload(int); }; #endif // __CODEC_AUDIO_H__ diff --git a/src/audiodriversalsa.cpp b/src/audiodriversalsa.cpp index b3d20ffb0b487e988b19c2d97c6be8f01510c0bf..799641a8f48a5a7a221cc1aa58e39b08114dd153 100644 --- a/src/audiodriversalsa.cpp +++ b/src/audiodriversalsa.cpp @@ -43,9 +43,16 @@ AudioDriversALSA::AudioDriversALSA(DeviceMode mode) : AudioDrivers () { AudioDriversALSA::~AudioDriversALSA (void) { /* Close the audio handle */ - if (audio_hdl != NULL) snd_pcm_close (audio_hdl); + this->closeDevice(); } +void +AudioDriversALSA::closeDevice (void) { + if (audio_hdl != NULL) { + snd_pcm_close (audio_hdl); + audio_hdl = (snd_pcm_t *) NULL; + } +} int AudioDriversALSA::initDevice (DeviceMode mode) { @@ -57,16 +64,17 @@ AudioDriversALSA::initDevice (DeviceMode mode) { } // Open the audio device - // Flags : blocking (else have to OR omode with SND_PCM_NONBLOCK). switch (mode) { case ReadOnly: /* Only read sound from the device */ - err = snd_pcm_open (&audio_hdl, ALSA_DEVICE,SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK); + err = snd_pcm_open (&audio_hdl, ALSA_DEVICE,SND_PCM_STREAM_CAPTURE, + SND_PCM_NONBLOCK); break; case WriteOnly: /* Only write sound to the device */ - err = snd_pcm_open (&audio_hdl, ALSA_DEVICE,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK); + err = snd_pcm_open (&audio_hdl, ALSA_DEVICE,SND_PCM_STREAM_PLAYBACK, + SND_PCM_NONBLOCK); break; default: break; @@ -132,7 +140,7 @@ AudioDriversALSA::initDevice (DeviceMode mode) { printf ("Cannot set channel count (%s)\n", snd_strerror (err)); return -1; } - + // Apply previously setup parameters err = snd_pcm_hw_params (audio_hdl, hw_params); if (err < 0) { @@ -142,6 +150,7 @@ AudioDriversALSA::initDevice (DeviceMode mode) { // Free temp variable used for configuration. snd_pcm_hw_params_free (hw_params); + //////////////////////////////////////////////////////////////////////////// // END DEVICE SETUP //////////////////////////////////////////////////////////////////////////// @@ -157,75 +166,24 @@ AudioDriversALSA::writeBuffer (void) { printf ("ALSA: writeBuffer(): Device Not Open\n"); return -1; } - -#if 1 + int rc; size_t count = audio_buf.getSize()/2; short* buf = (short *)audio_buf.getData(); while (count > 0) { rc = snd_pcm_writei(audio_hdl, buf, count); + snd_pcm_wait(audio_hdl, 1); if (rc == -EPIPE) { snd_pcm_prepare(audio_hdl); } else if (rc == -EAGAIN) { continue; } else if (rc < 0) { - printf ("ALSA: write(): %s\n", strerror(errno)); break; } - printf("rc = %d\n",rc); buf += rc; count -= rc; } return rc; -#endif -} - -unsigned int -AudioDriversALSA::readableBytes (void) { - audio_buf_info info; -#if 0 - struct timeval timeout; - fd_set read_fds; - - if (devstate != DeviceOpened) { - return 0; - } - timeout.tv_sec = 0; - timeout.tv_usec = 0; - FD_ZERO (&read_fds); - FD_SET (audio_fd, &read_fds); - if (select (audio_fd + 1, &read_fds, NULL, NULL, &timeout) == -1) { - return 0; - } - if (!FD_ISSET ( audio_fd, &read_fds)) { - return 0; - } - if (ioctl (audio_fd, SNDCTL_DSP_GETISPACE, &info) == -1) { - printf ("ERROR: readableBytes %s\n", strerror(errno)); - return 0; - } -#endif - return info.bytes; -} - - -int -AudioDriversALSA::readBuffer (int bytes) { -/* if (devstate != DeviceOpened) { - printf ("Device Not Open\n"); - return false; - } - - audio_buf.resize (bytes); - size_t count = bytes; - - void *buf; - buf = audio_buf.getData (); - size_t rc = read (audio_fd, buf, count); - if (rc != count) { - printf ("warning: asked microphone for %d got %d\n", count, rc); - }*/ - return true; } int @@ -234,34 +192,37 @@ AudioDriversALSA::readBuffer (void *ptr, int bytes) { printf ("ALSA: readBuffer(): Device Not Open\n"); return -1; } - -#if 1 - ssize_t count = bytes/2; + + ssize_t count = bytes; ssize_t rc; - do { rc = snd_pcm_readi(audio_hdl, (short*)ptr, count); } while (rc == -EAGAIN); - if (rc == -EBADFD) printf ("Read: PCM is not in the right state\n"); - if (rc == -ESTRPIPE) printf ("Read: a suspend event occurred\n"); if (rc == -EPIPE) { - printf ("Read: -EPIPE %d\n", rc); snd_pcm_prepare(audio_hdl); + bzero(ptr, bytes); + rc = 320; } - if (rc > 0 && rc != count) { - printf("Read: warning: asked microphone for %d frames but got %d\n", - count, rc); - } - + if (rc != 320) + rc = rc * 2; return rc; -#endif } int AudioDriversALSA::resetDevice (void) { -/* printf ("ALSA: Resetting device.\n"); - snd_pcm_drop(audio_hdl); - snd_pcm_drain(audio_hdl);*/ + int err; + + printf("Resetting...\n"); + if ((err = snd_pcm_drop(audio_hdl)) < 0) { + printf ("ALSA: drop() error: %s\n", snd_strerror (err)); + return -1; + } + + if ((err = snd_pcm_prepare(audio_hdl)) < 0) { + printf ("ALSA: prepare() error: %s\n", snd_strerror (err)); + return -1; + } + return 0; } diff --git a/src/audiodriversalsa.h b/src/audiodriversalsa.h index fe515a4501edbcd35fd00def95640798c0f94bfd..8e31369a8eb4fc4cda9a6c6e262074f6e3d02a68 100644 --- a/src/audiodriversalsa.h +++ b/src/audiodriversalsa.h @@ -45,15 +45,11 @@ public: int initDevice (DeviceMode); int resetDevice (void); int writeBuffer (void); - int readBuffer (int); int readBuffer (void *, int); - unsigned int readableBytes(void); - int audio_fd; - - private: snd_pcm_t *audio_hdl; + void closeDevice (void); }; #endif // _AUDIO_DRIVERS_ALSA_H_ diff --git a/src/audiortp.cpp b/src/audiortp.cpp index 78843cbc4b86b30fe22f1214fd1f15d046602af6..c5742779a6109ff6cadf2245214425668c8e9156 100644 --- a/src/audiortp.cpp +++ b/src/audiortp.cpp @@ -93,9 +93,7 @@ AudioRtp::closeRtpSession (SipCall *ca) { ca->enable_audio = -1; if (RTXThread != NULL) { - // Wait for them...and delete. - //RTXThread->join(); - qDebug("DELETED"); + qDebug("RTXThread DELETED"); delete RTXThread; RTXThread = NULL; } @@ -262,7 +260,6 @@ AudioRtpRTX::run (void) { //////////////////////////// // Send session //////////////////////////// - //int size = AudioCodec::getSizeByPayload(ca->payload); int size = 320; if (!manager->mute) { #ifdef ALSA @@ -283,9 +280,9 @@ AudioRtpRTX::run (void) { if (!manager->useAlsa) i = audioDevice->readBuffer (data_mute, size); } - //qDebug("read i = %d", i); // TODO : return an error because no sound if (i < 0) { + qDebug("audiortp.cpp: No sound"); break; } for (int j = 0; j < i; j++) @@ -303,7 +300,6 @@ AudioRtpRTX::run (void) { } else { session->putData(timestamp, data_to_send, compSize); } - //timestamp += compSize; timestamp += 160; //////////////////////////// diff --git a/src/configurationpanelui.cpp b/src/configurationpanelui.cpp index 36b2275e28eafbfd33aebfd57b61f75c3287a72d..d2a26a5e00c5810f14326631515585a7de5036eb 100644 --- a/src/configurationpanelui.cpp +++ b/src/configurationpanelui.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'configurationpanel.ui' ** -** Created: Thu Mar 31 11:43:54 2005 +** Created: Thu Mar 31 12:04:22 2005 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/configurationpanelui.h b/src/configurationpanelui.h index ac84e4e6e419ce3e0480a2b8998ebe7af5e54896..62b1fdd94fe014058fed413d13b6258914d819fd 100644 --- a/src/configurationpanelui.h +++ b/src/configurationpanelui.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'configurationpanel.ui' ** -** Created: Thu Mar 31 11:43:54 2005 +** Created: Thu Mar 31 12:04:22 2005 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/manager.cpp b/src/manager.cpp index 5bf59e70022bf4ac2a48f15abd66f3ceeb39ecb4..4dd80c15c46ffb95b176cc77d0c5846654c7ff6d 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -199,6 +199,7 @@ Manager::ring (bool var) { if (this->b_ringing != var) { this->b_ringing = var; } + tonezone = ringing(); if (sip->getNumberPendingCalls() == 1) diff --git a/src/phonebookui.cpp b/src/phonebookui.cpp index d422f74191a92beee406926b0fa72b7d0d6b7ff3..db2ed159d2112e37c1c3add7c2038bf77f1a5630 100644 --- a/src/phonebookui.cpp +++ b/src/phonebookui.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'phonebook.ui' ** -** Created: Thu Mar 31 11:43:53 2005 +** Created: Thu Mar 31 12:04:22 2005 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/phonebookui.h b/src/phonebookui.h index fb46428726efb64b6b89cbe16aa6785ba79372e7..dd24d47aa911f01d3e109f841deab9929b28a64f 100644 --- a/src/phonebookui.h +++ b/src/phonebookui.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'phonebook.ui' ** -** Created: Thu Mar 31 11:43:53 2005 +** Created: Thu Mar 31 12:04:22 2005 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/qtGUImainwindow.cpp b/src/qtGUImainwindow.cpp index 05e0e6d1f4f00f54e21449d1250ae9c5c79e6f3a..8fdbf856ad929607243b7f84b82b8d90cad23037 100644 --- a/src/qtGUImainwindow.cpp +++ b/src/qtGUImainwindow.cpp @@ -1132,8 +1132,10 @@ QtGUIMainWindow::pressedKeySlot (int id) { callmanager->audiodriver->audio_buf.resize(SAMPLING_RATE); callmanager->audiodriver->audio_buf.setData( buf, callmanager->getSpkrVolume()); + pulselen = Config::get("Signalisations", "DTMF.pulseLength", 250); callmanager->audiodriver->audio_buf.resize(pulselen * (OCTETS/1000)); +// callmanager->audiodriver->resetDevice(); a = callmanager->audiodriver->writeBuffer(); if (a == 1) { pressedKeySlot(id); diff --git a/src/sip.cpp b/src/sip.cpp index f889e0894ba644d2601c2cf13678acd6e6a604b2..8be9fe0ebe99f5a2d1d7ff29f71927fe67ba067d 100644 --- a/src/sip.cpp +++ b/src/sip.cpp @@ -908,8 +908,7 @@ SIP::getEvent (void) { // The remote peer closed the phone call(we received BYE). case EXOSIP_CALL_CLOSED: - qDebug("<- (%i %i) BYE from: %s", event->cid, event->did, - event->remote_uri); + qDebug("<- (%i %i) BYE", event->cid, event->did); call[theline]->usehold = false; theline = findLineNumber(event); diff --git a/src/tonegenerator.cpp b/src/tonegenerator.cpp index 7940d6989e8965aebde329d6cd2d6960db379841..694a02ec659630c31561e67cbc4955fae08da806 100644 --- a/src/tonegenerator.cpp +++ b/src/tonegenerator.cpp @@ -241,6 +241,7 @@ ToneGenerator::toneHandle (int idr) { } if (!manager->tonezone) { + manager->audiodriver->resetDevice(); if (tonethread != NULL) { delete tonethread; tonethread = NULL; @@ -292,6 +293,7 @@ ToneGenerator::playRing (const char *fileName) { tonethread->start(); } if (!manager->tonezone) { + manager->audiodriver->resetDevice(); if (tonethread != NULL) { delete tonethread; tonethread = NULL; diff --git a/src/url_inputui.cpp b/src/url_inputui.cpp index 3429fdc619a4e244708fcec1aee529a6878c3f26..3209c47159ced20933bc45ba6510cf00ceb4a693 100644 --- a/src/url_inputui.cpp +++ b/src/url_inputui.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'url_input.ui' ** -** Created: Thu Mar 31 11:43:53 2005 +** Created: Thu Mar 31 12:04:22 2005 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/url_inputui.h b/src/url_inputui.h index 0edaff121481381649e958004ac29652ad521d80..ec7a3698f6172c02f5dc6d8e92cfa791742144f8 100644 --- a/src/url_inputui.h +++ b/src/url_inputui.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'url_input.ui' ** -** Created: Thu Mar 31 11:43:53 2005 +** Created: Thu Mar 31 12:04:22 2005 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost!