From 2eda0872011551d1510935e74c2ebedc398df26f Mon Sep 17 00:00:00 2001
From: llea <llea>
Date: Mon, 18 Jul 2005 21:06:00 +0000
Subject: [PATCH] Fix incoming call notification. Fix transfer if no busy line.

---
 ChangeLog                      |  4 ++++
 src/audio/audiolayer.cpp       |  1 +
 src/audio/audiortp.cpp         |  2 +-
 src/gui/qt/qtGUImainwindow.cpp | 18 ++++++++++++------
 src/managerimpl.cpp            | 13 +++----------
 5 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d6f7f4496a..17c8a63c84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Laurielle LEA (18 July 2005) version 0.4
+- Fix incoming call sound notification
+- Fix transfer if no busy line
+
 Laurielle LEA (15 July 2005) version 0.4
 - Fix configuration init
 
diff --git a/src/audio/audiolayer.cpp b/src/audio/audiolayer.cpp
index 9fdf1278f4..dbf1c5e796 100644
--- a/src/audio/audiolayer.cpp
+++ b/src/audio/audiolayer.cpp
@@ -150,6 +150,7 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer,
 		
 		// Consume the regular one as well (same amount of bytes)
 		_mainSndRingBuffer.Discard(SAMPLES_SIZE(toGet));
+		
 	}  
 	else {
 	// If nothing urgent, play the regular sound samples
diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp
index a88d8e6b50..6b78e0509b 100644
--- a/src/audio/audiortp.cpp
+++ b/src/audio/audiortp.cpp
@@ -289,7 +289,7 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers,
 	countTime += time->getSecond();
 	if (Manager::instance().getNumberOfCalls() > 0 
 			and Manager::instance().getbRingtone()) {
-		countTime = countTime % 2000;
+		countTime = countTime % 4000;
 		if (countTime < 100 and countTime > 0) {
 			Manager::instance().notificationIncomingCall();
 		}
diff --git a/src/gui/qt/qtGUImainwindow.cpp b/src/gui/qt/qtGUImainwindow.cpp
index ef1e8e3627..9ddfd5ee55 100644
--- a/src/gui/qt/qtGUImainwindow.cpp
+++ b/src/gui/qt/qtGUImainwindow.cpp
@@ -1027,11 +1027,15 @@ int
 QtGUIMainWindow::qt_transferCall (short id)
 {
 	int i;
-	const string to(_lcd->getTextBuffer().ascii());;
-	_debug("qt_transferCall: Transfer call %d to %s\n", id, to.data());
-	i = transferCall(id, to);
-	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));
-	return i;	
+	if (id != -1) {
+		const string to(_lcd->getTextBuffer().ascii());;
+		_debug("qt_transferCall: Transfer call %d to %s\n", id, to.data());
+		i = transferCall(id, to);
+		getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));
+		return i;	
+	} else {
+		return 0;
+	}
 }	
 	
 void 
@@ -1177,6 +1181,7 @@ QtGUIMainWindow::hangupLine (void)
 	int i;
 	int line = getCurrentLine();
 	int id = phLines[line]->getCallId();
+	setTransfer(false);
 	_debug("id = %d et line = %d\n", id, line);
 
 	if (Manager::instance().getbCongestion()) {
@@ -1320,7 +1325,8 @@ QtGUIMainWindow::button_msg (void) {
 // This number is validated by ok-button or typing Enter
 void
 QtGUIMainWindow::button_transfer (void) {
-	if (getCurrentLine() != -1) {
+	int line_num = getCurrentLine();
+    if (line_num != -1 and phLines[line_num]->isBusy()) {
 		setTransfer(true);
 		onHoldCall(line2id(getCurrentLine()));
 		displayStatus(TRANSFER_STATUS);
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 085d345932..99a2bbcc73 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -640,13 +640,13 @@ void
 ManagerImpl::notificationIncomingCall (void) {
     int16* buf_ctrl_vol;
     int16* buffer = new int16[SAMPLING_RATE];
-	int size = SAMPLING_RATE/2;
+	int size = SAMPLES_SIZE(FRAME_PER_BUFFER);//SAMPLING_RATE/2;
 	int k, spkrVolume;
                                                                                 
     _tone->generateSin(440, 0, buffer);
            
 	// Control volume
-	buf_ctrl_vol = new int16[size];
+	buf_ctrl_vol = new int16[size*CHANNELS];
 	spkrVolume = getSpkrVolume();
 	for (int j = 0; j < size; j++) {
 		k = j*2;
@@ -654,15 +654,8 @@ ManagerImpl::notificationIncomingCall (void) {
 	}
 	
 	getAudioDriver()->urgentRingBuffer().Put(buf_ctrl_vol, 
-			size * CHANNELS);
+			SAMPLES_SIZE(FRAME_PER_BUFFER));
 
-	_debug("---- Notification call\n");
-#if 0
-	getAudioDriver()->startStream();
-	getAudioDriver()->sleep(NOTIFICATION_LEN);
-	getAudioDriver()->stopStream();
-#endif
-	
     delete[] buf_ctrl_vol;
     delete[] buffer;
 }
-- 
GitLab