Commit 45e8bd3e authored by llea's avatar llea
Browse files

Fix configuration init.

Fix volume control
parent 2d8ae978
Laurielle LEA (15 July 2005) version 0.4
- Fix configuration init
Jerome OUFELLA (13 July 2005) version 0.4
- Fix tone.
......
......@@ -247,11 +247,10 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
void
AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers,
int16* data_for_speakers_tmp, int spkrVolume)
int16* data_for_speakers_tmp, int spkrVolume, int& countTime)
{
int expandedSize;
int k;
int countTime = 0;
const AppDataUnit* adu = NULL;
// Get audio data stream
......@@ -288,9 +287,10 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers,
// Notify (with a bip) an incoming call when there is already a call
countTime += time->getSecond();
if (Manager::instance().getNumberOfCalls() > 0 and Manager::instance().getbRingtone()) {
if (Manager::instance().getNumberOfCalls() > 0
and Manager::instance().getbRingtone()) {
countTime = countTime % 2000;
if (countTime < 10 and countTime > 0) {
if (countTime < 100 and countTime > 0) {
Manager::instance().notificationIncomingCall();
}
}
......@@ -310,6 +310,7 @@ AudioRtpRTX::run (void) {
int timestamp;
int16 *data_for_speakers = NULL;
int16 *data_for_speakers_tmp = NULL;
int countTime = 0;
data_from_mic = new int16[SIZEDATA];
data_from_mic_tmp = new int16[SIZEDATA];
......@@ -350,7 +351,7 @@ AudioRtpRTX::run (void) {
// Recv session
////////////////////////////
receiveSessionForSpkr(data_for_speakers, data_for_speakers_tmp,
spkrVolume);
spkrVolume, countTime);
// Let's wait for the next transmit cycle
Thread::sleep(TimerPort::getTimer());
......
......@@ -55,7 +55,7 @@ private:
void initAudioRtpSession (void);
void sendSessionFromMic (unsigned char*, int16*, int16*, int, int);
void receiveSessionForSpkr (int16*, int16*, int);
void receiveSessionForSpkr (int16*, int16*, int, int&);
};
///////////////////////////////////////////////////////////////////////////////
......
......@@ -60,14 +60,15 @@ ToneThread::run (void) {
// How long do 'size' samples play ?
unsigned int play_time = (size * 1000) / SAMPLING_RATE;
// Create a new stereo buffer with the volume adjusted
spkrVolume = Manager::instance().getSpkrVolume();
for (int j = 0; j < size; j++) {
k = j*2;
buf_ctrl_vol[k] = buf_ctrl_vol[k+1] = buffer[j] * spkrVolume/100;
}
while (Manager::instance().getZonetone()) {
// Create a new stereo buffer with the volume adjusted
spkrVolume = Manager::instance().getSpkrVolume();
for (int j = 0; j < size; j++) {
k = j*2;
buf_ctrl_vol[k] = buf_ctrl_vol[k+1] = buffer[j] * spkrVolume/100;
}
// Push the tone to the audio FIFO
Manager::instance().getAudioDriver()->mainSndRingBuffer().Put(buf_ctrl_vol,
SAMPLES_SIZE(size));
......
......@@ -57,7 +57,7 @@ GuiFramework::cancelCall (short id)
int
GuiFramework::answerCall (short id)
{
if (Manager::instance().answerCall(id)) {
if (Manager::instance().answerCall(id) == 0) {
return 1;
} else {
return 0;
......@@ -87,7 +87,7 @@ GuiFramework::offHoldCall (short id)
int
GuiFramework::transferCall (short id, const string& to)
{
if (Manager::instance().transferCall(id, to) == 1) {
if (Manager::instance().transferCall(id, to) == 0) {
return 1;
} else {
return 0;
......
......@@ -773,7 +773,7 @@ QtGUIMainWindow::getPhoneLine (short id)
}
}
if (i == NUMBER_OF_LINES) {
_debug("Id is not attributed to a phoneline\n");
_debug("getPhoneLine(id): Id %d is not attributed to a phoneline\n", id);
return NULL;
}
return NULL;
......@@ -1028,7 +1028,7 @@ QtGUIMainWindow::qt_transferCall (short id)
{
int i;
const string to(_lcd->getTextBuffer().ascii());;
_debug("Transfer call %d to %s\n", id, to.data());
_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;
......@@ -1058,6 +1058,7 @@ QtGUIMainWindow::qt_refuseCall (short id)
displayStatus(HUNGUP_STATUS);
getPhoneLine(id)->setbRinging(false);
_TabIncomingCalls[id2line(id)] = -1;
setCurrentLine(-1);
return i;
}
......@@ -1146,13 +1147,12 @@ QtGUIMainWindow::dial (void)
if (line != -1) {
_TabIncomingCalls[line] = -1;
toggleLine(line);
//setPrevLine(line);
} else {
return;
}
} else if (getTransfer()){
// If call transfer
if(qt_transferCall (line2id(getCurrentLine()) != 1)) {
if(qt_transferCall (line2id(getCurrentLine())) != 1) {
Manager::instance().displayErrorText("Transfer failed !\n");
}
} else {
......@@ -1177,6 +1177,7 @@ QtGUIMainWindow::hangupLine (void)
int i;
int line = getCurrentLine();
int id = phLines[line]->getCallId();
_debug("id = %d et line = %d\n", id, line);
if (Manager::instance().getbCongestion()) {
// If congestion tone
......@@ -1188,6 +1189,14 @@ QtGUIMainWindow::hangupLine (void)
} else {
Manager::instance().displayErrorText("Hangup call failed !\n");
}
} else if ((i = isThereIncomingCall()) > 0){
// To refuse new incoming call
_debug("Refuse call %d\n", id);
if (qt_refuseCall(i)) {
changeLineStatePixmap(id2line(i), FREE);
} else {
Manager::instance().displayErrorText("Refused call failed !\n");
}
} else if (line >= 0 and id > 0 and getCall(id)->isProgressing()) {
// If I want to cancel a call before ringing.
if (qt_cancelCall(id)) {
......@@ -1207,14 +1216,6 @@ QtGUIMainWindow::hangupLine (void)
} else {
Manager::instance().displayErrorText("Hangup call failed !\n");
}
} else if ((i = isThereIncomingCall()) > 0){
// To refuse new incoming call
_debug("Refuse call %d\n", id);
if (qt_refuseCall(i)) {
changeLineStatePixmap(id2line(i), FREE);
} else {
Manager::instance().displayErrorText("Refused call failed !\n");
}
} else if (line >= 0) {
_debug("Just load free pixmap for the line %d\n", line);
changeLineStatePixmap(line, FREE);
......
......@@ -43,12 +43,13 @@ main (int argc, char **argv) {
#if defined(GUI_QT)
QApplication a(argc, argv);
Manager::instance().initConfigFile();
GUI = new QtGUIMainWindow (0, 0 ,
Qt::WDestructiveClose |
Qt::WStyle_Customize |
Qt::WStyle_NoBorder);
Manager::instance().setGui(GUI);
Manager::instance().init();
Manager::instance().setGui(GUI);
a.setMainWidget((QtGUIMainWindow*)GUI);
return a.exec();
......
......@@ -96,8 +96,6 @@ ManagerImpl::init (void)
// Set a sip voip link by default
_voIPLinkVector->push_back(new SipVoIPLink(DFT_VOIP_LINK));
initConfigFile();
_exist = createSettingsPath();
if (_exist == 0) {
_debug("Cannot create config file in your home directory\n");
}
......@@ -371,11 +369,7 @@ ManagerImpl::transferCall (short id, const string& to)
return -1;
call->setStatus(string(TRANSFER_STATUS));
call->setState(Transfered);
if (call->transfer(to) != 0) {
return -1;
} else {
return 1;
}
return call->transfer(to);
}
void
......@@ -410,7 +404,6 @@ ManagerImpl::refuseCall (short id)
call->setStatus(string(HUNGUP_STATUS));
call->setState(Refused);
ringtone(false);
delete call;
return call->refuse();
}
......@@ -547,6 +540,9 @@ ManagerImpl::peerHungupCall (short id)
if (getbRingback()) {
ringback(false);
}
if (getbRingtone()) {
ringtone(false);
}
_mutex.enterMutex();
_nCalls -= 1;
_mutex.leaveMutex();
......@@ -660,12 +656,15 @@ ManagerImpl::notificationIncomingCall (void) {
getAudioDriver()->urgentRingBuffer().Put(buf_ctrl_vol,
size * CHANNELS);
_debug("---- Notification call\n");
#if 0
getAudioDriver()->startStream();
getAudioDriver()->sleep(NOTIFICATION_LEN);
getAudioDriver()->stopStream();
#endif
delete[] buffer;
delete[] buf_ctrl_vol;
delete[] buffer;
}
void
......@@ -799,6 +798,8 @@ ManagerImpl::createSettingsPath (void) {
void
ManagerImpl::initConfigFile (void)
{
_exist = createSettingsPath();
fill_config_fields_int(SIGNALISATION, VOIP_LINK_ID, DFT_VOIP_LINK);
fill_config_fields_str(SIGNALISATION, FULL_NAME, EMPTY_FIELD);
fill_config_fields_str(SIGNALISATION, USER_PART, EMPTY_FIELD);
......
......@@ -212,6 +212,11 @@ public:
int deviceCount (void);
bool defaultDevice (int);
/*
* Init default values for the different fields
*/
void initConfigFile (void);
private:
/*
......@@ -229,10 +234,7 @@ private:
*/
int createSettingsPath (void);
/*
* Init default values for the different fields
*/
void initConfigFile (void);
void initAudioCodec(void);
void selectAudioDriver (void);
......
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