Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
fc906287
Commit
fc906287
authored
Aug 29, 2011
by
Rafaël Carré
Browse files
* #6629 : correct AudioLayer::notifyincomingCall()
move some code from managerimpl code
parent
aa07e16e
Changes
4
Hide whitespace changes
Inline
Side-by-side
daemon/src/audio/audiolayer.cpp
View file @
fc906287
...
...
@@ -29,11 +29,11 @@
* as that of the covered work.
*/
#include
<ctime>
#include
"audiolayer.h"
#include
"audioprocessing.h"
#include
"audio/dcblocker.h"
#include
"manager.h"
#include
<cc++/numbers.h>
AudioLayer
::
AudioLayer
(
ManagerImpl
*
manager
,
int
type
)
:
layerType_
(
type
)
...
...
@@ -54,14 +54,12 @@ AudioLayer::AudioLayer (ManagerImpl* manager , int type)
,
dcblocker_
(
0
)
,
audiofilter_
(
0
)
,
noiseSuppressState_
(
false
)
,
countNotificationTime_
(
0
)
,
time_
(
new
ost
::
Time
)
,
lastNotificationTime_
(
0
)
{}
AudioLayer
::~
AudioLayer
()
{
delete
time_
;
delete
audiofilter_
;
delete
dcblocker_
;
}
...
...
@@ -85,17 +83,33 @@ void AudioLayer::putUrgent (void* buffer, int toCopy)
urgentRingBuffer_
.
Put
(
buffer
,
toCopy
);
}
// Notify (with a beep) an incoming call when there is already a call in progress
void
AudioLayer
::
notifyincomingCall
()
{
// Notify (with a beep) an incoming call when there is already a call
if
(
Manager
::
instance
().
incomingCallWaiting
())
{
countNotificationTime_
+=
time_
->
getSecond
();
int
countTimeModulo
=
countNotificationTime_
%
5000
;
if
(
!
Manager
::
instance
().
incomingCallWaiting
())
return
;
if
((
countTimeModulo
-
countNotificationTime_
)
<
0
)
Manager
::
instance
().
notificationIncomingCall
();
time_t
now
=
time
(
NULL
);
countNotificationTime_
=
countTimeModulo
;
}
// Notify maximum once every 5 seconds
if
(
difftime
(
now
,
lastNotificationTime_
)
<
5
)
return
;
lastNotificationTime_
=
now
;
// Enable notification only if more than one call
if
(
!
Manager
::
instance
().
hasCurrentCall
())
return
;
Tone
tone
(
"440/160"
,
getSampleRate
());
unsigned
int
nbSample
=
tone
.
getSize
();
SFLDataFormat
buf
[
nbSample
];
tone
.
getNext
(
buf
,
nbSample
);
/* Put the data in the urgent ring buffer */
Manager
::
instance
().
audioLayerMutexLock
();
flushUrgent
();
putUrgent
(
buf
,
sizeof
buf
);
Manager
::
instance
().
audioLayerMutexUnlock
();
}
daemon/src/audio/audiolayer.h
View file @
fc906287
...
...
@@ -35,6 +35,7 @@
#define _AUDIO_LAYER_H
#include
<cc++/thread.h>
// for ost::Mutex
#include
<sys/time.h>
#include
"ringbuffer.h"
...
...
@@ -334,15 +335,11 @@ class AudioLayer
bool
noiseSuppressState_
;
private:
/**
* Time counter used to trigger incoming call notification
*/
int
countNotificationTime_
;
/**
* Used to get formated system time in order to compute incoming call notification
* Time of the last incoming call notification
*/
ost
::
Time
*
t
ime_
;
time_t
lastNotificationT
ime_
;
};
#endif // _AUDIO_LAYER_H_
daemon/src/managerimpl.cpp
View file @
fc906287
...
...
@@ -1470,7 +1470,7 @@ bool ManagerImpl::playDtmf (char code)
// Multi-thread
bool
ManagerImpl
::
incomingCallWaiting
()
{
return
(
_nbIncomingWaitingCall
>
0
)
?
true
:
false
;
return
_nbIncomingWaitingCall
>
0
;
}
void
ManagerImpl
::
addWaitingCall
(
const
std
::
string
&
id
)
...
...
@@ -1977,34 +1977,6 @@ ManagerImpl::getTelephoneFile ()
return
_audiofile
;
}
void
ManagerImpl
::
notificationIncomingCall
(
void
)
{
audioLayerMutexLock
();
if
(
_audiodriver
==
NULL
)
{
_error
(
"Manager: Error: Audio layer not initialized"
);
audioLayerMutexUnlock
();
return
;
}
_debug
(
"ManagerImpl: Notification incoming call"
);
// Enable notification only if more than one call
if
(
hasCurrentCall
())
{
std
::
ostringstream
frequency
;
frequency
<<
"440/"
<<
160
;
Tone
tone
(
frequency
.
str
(),
_audiodriver
->
getSampleRate
());
unsigned
int
nbSample
=
tone
.
getSize
();
SFLDataFormat
buf
[
nbSample
];
tone
.
getNext
(
buf
,
nbSample
);
/* Put the data in the urgent ring buffer */
_audiodriver
->
flushUrgent
();
_audiodriver
->
putUrgent
(
buf
,
sizeof
(
SFLDataFormat
)
*
nbSample
);
}
audioLayerMutexUnlock
();
}
///////////////////////////////////////////////////////////////////////////////
// Private functions
///////////////////////////////////////////////////////////////////////////////
...
...
daemon/src/managerimpl.h
View file @
fc906287
...
...
@@ -878,11 +878,6 @@ class ManagerImpl
*/
bool
incomingCallWaiting
(
void
);
/**
* Notification of incoming call when you are already busy
*/
void
notificationIncomingCall
(
void
);
/*
* Inline functions to manage speaker volume control
* Read by main thread and AudioLayer thread
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment