Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
7531c4df
Commit
7531c4df
authored
11 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
revert bug in pulseaudio
parent
bb88a719
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
daemon/src/audio/pulseaudio/pulselayer.h
+1
-1
1 addition, 1 deletion
daemon/src/audio/pulseaudio/pulselayer.h
daemon/src/managerimpl.cpp
+53
-61
53 additions, 61 deletions
daemon/src/managerimpl.cpp
daemon/src/managerimpl.h
+5
-5
5 additions, 5 deletions
daemon/src/managerimpl.h
with
59 additions
and
67 deletions
daemon/src/audio/pulseaudio/pulselayer.h
+
1
−
1
View file @
7531c4df
...
@@ -48,7 +48,7 @@ class AudioStream;
...
@@ -48,7 +48,7 @@ class AudioStream;
/**
/**
* Convenience structure to hold PulseAudio device propreties such as supported channel number etc.
* Convenience structure to hold PulseAudio device propreties such as supported channel number etc.
*/
*/
typedef
struct
{
typedef
struct
PaDeviceInfos
{
uint32_t
index
;
uint32_t
index
;
std
::
string
name
;
std
::
string
name
;
pa_sample_spec
sample_spec
;
pa_sample_spec
sample_spec
;
...
...
This diff is collapsed.
Click to expand it.
daemon/src/managerimpl.cpp
+
53
−
61
View file @
7531c4df
...
@@ -78,14 +78,13 @@
...
@@ -78,14 +78,13 @@
#endif
#endif
#include
"conference.h"
#include
"conference.h"
#include
"scoped_lock.h"
#include
<cerrno>
#include
<cerrno>
#include
<algorithm>
#include
<algorithm>
#include
<ctime>
#include
<ctime>
#include
<cstdlib>
#include
<cstdlib>
#include
<iostream>
#include
<iostream>
#include
<
tr1/
functional>
#include
<functional>
#include
<iterator>
#include
<iterator>
#include
<fstream>
#include
<fstream>
#include
<sstream>
#include
<sstream>
...
@@ -102,21 +101,12 @@ ManagerImpl::ManagerImpl() :
...
@@ -102,21 +101,12 @@ ManagerImpl::ManagerImpl() :
waitingCalls_
(),
waitingCallsMutex_
(),
path_
(),
waitingCalls_
(),
waitingCallsMutex_
(),
path_
(),
IPToIPMap_
(),
mainBuffer_
(),
conferenceMap_
(),
history_
(),
finished_
(
false
)
IPToIPMap_
(),
mainBuffer_
(),
conferenceMap_
(),
history_
(),
finished_
(
false
)
{
{
pthread_mutex_init
(
&
currentCallMutex_
,
NULL
);
pthread_mutex_init
(
&
toneMutex_
,
NULL
);
pthread_mutex_init
(
&
audioLayerMutex_
,
NULL
);
pthread_mutex_init
(
&
waitingCallsMutex_
,
NULL
);
// initialize random generator for call id
// initialize random generator for call id
srand
(
time
(
NULL
));
srand
(
time
(
NULL
));
}
}
ManagerImpl
::~
ManagerImpl
()
ManagerImpl
::~
ManagerImpl
()
{
{
// destroy in reverse order of initialization
pthread_mutex_destroy
(
&
waitingCallsMutex_
);
pthread_mutex_destroy
(
&
audioLayerMutex_
);
pthread_mutex_destroy
(
&
toneMutex_
);
pthread_mutex_destroy
(
&
currentCallMutex_
);
}
}
namespace
{
namespace
{
...
@@ -207,10 +197,10 @@ void ManagerImpl::init(const std::string &config_file)
...
@@ -207,10 +197,10 @@ void ManagerImpl::init(const std::string &config_file)
initAudioDriver
();
initAudioDriver
();
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
audiodriver_
)
{
if
(
audiodriver_
)
{
{
{
s
fl
::
ScopedLock
toneLock
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
toneLock
(
toneMutex_
);
telephoneTone_
.
reset
(
new
TelephoneTone
(
preferences
.
getZoneToneChoice
(),
audiodriver_
->
getSampleRate
()));
telephoneTone_
.
reset
(
new
TelephoneTone
(
preferences
.
getZoneToneChoice
(),
audiodriver_
->
getSampleRate
()));
}
}
dtmfKey_
.
reset
(
new
DTMF
(
getMainBuffer
().
getInternalSamplingRate
()));
dtmfKey_
.
reset
(
new
DTMF
(
getMainBuffer
().
getInternalSamplingRate
()));
...
@@ -260,7 +250,7 @@ void ManagerImpl::finish()
...
@@ -260,7 +250,7 @@ void ManagerImpl::finish()
#endif
#endif
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
delete
audiodriver_
;
delete
audiodriver_
;
audiodriver_
=
NULL
;
audiodriver_
=
NULL
;
...
@@ -292,7 +282,7 @@ void ManagerImpl::unsetCurrentCall()
...
@@ -292,7 +282,7 @@ void ManagerImpl::unsetCurrentCall()
void
ManagerImpl
::
switchCall
(
const
std
::
string
&
id
)
void
ManagerImpl
::
switchCall
(
const
std
::
string
&
id
)
{
{
s
fl
::
ScopedLock
m
(
currentCallMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
currentCallMutex_
);
DEBUG
(
"----- Switch current call id to %s -----"
,
id
.
c_str
());
DEBUG
(
"----- Switch current call id to %s -----"
,
id
.
c_str
());
currentCallId_
=
id
;
currentCallId_
=
id
;
}
}
...
@@ -447,7 +437,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
...
@@ -447,7 +437,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
void
ManagerImpl
::
checkAudio
()
void
ManagerImpl
::
checkAudio
()
{
{
if
(
getCallList
().
empty
())
{
if
(
getCallList
().
empty
())
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
audiodriver_
)
if
(
audiodriver_
)
audiodriver_
->
stopStream
();
audiodriver_
->
stopStream
();
}
}
...
@@ -699,7 +689,7 @@ bool ManagerImpl::refuseCall(const std::string& id)
...
@@ -699,7 +689,7 @@ bool ManagerImpl::refuseCall(const std::string& id)
stopTone
();
stopTone
();
if
(
getCallList
().
size
()
<=
1
)
{
if
(
getCallList
().
size
()
<=
1
)
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
->
stopStream
();
audiodriver_
->
stopStream
();
}
}
...
@@ -961,7 +951,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
...
@@ -961,7 +951,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
}
}
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
ConferenceMap
::
const_iterator
iter
=
conferenceMap_
.
find
(
conference_id
);
ConferenceMap
::
const_iterator
iter
=
conferenceMap_
.
find
(
conference_id
);
...
@@ -1106,7 +1096,7 @@ ManagerImpl::joinParticipant(const std::string& callId1, const std::string& call
...
@@ -1106,7 +1096,7 @@ ManagerImpl::joinParticipant(const std::string& callId1, const std::string& call
// set recording sampling rate
// set recording sampling rate
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
audiodriver_
)
if
(
audiodriver_
)
conf
->
setRecordingSmplRate
(
audiodriver_
->
getSampleRate
());
conf
->
setRecordingSmplRate
(
audiodriver_
->
getSampleRate
());
}
}
...
@@ -1157,7 +1147,7 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string >
...
@@ -1157,7 +1147,7 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string >
client_
.
getCallManager
()
->
conferenceCreated
(
conf
->
getConfID
());
client_
.
getCallManager
()
->
conferenceCreated
(
conf
->
getConfID
());
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
audiodriver_
)
if
(
audiodriver_
)
conf
->
setRecordingSmplRate
(
audiodriver_
->
getSampleRate
());
conf
->
setRecordingSmplRate
(
audiodriver_
->
getSampleRate
());
...
@@ -1351,7 +1341,7 @@ void ManagerImpl::addStream(const std::string& call_id)
...
@@ -1351,7 +1341,7 @@ void ManagerImpl::addStream(const std::string& call_id)
// bind to main
// bind to main
getMainBuffer
().
bindCallID
(
call_id
,
MainBuffer
::
DEFAULT_ID
);
getMainBuffer
().
bindCallID
(
call_id
,
MainBuffer
::
DEFAULT_ID
);
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
->
flushUrgent
();
audiodriver_
->
flushUrgent
();
audiodriver_
->
flushMain
();
audiodriver_
->
flushMain
();
}
}
...
@@ -1432,7 +1422,7 @@ void ManagerImpl::playDtmf(char code)
...
@@ -1432,7 +1422,7 @@ void ManagerImpl::playDtmf(char code)
return
;
return
;
}
}
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
// numbers of int = length in milliseconds / 1000 (number of seconds)
// numbers of int = length in milliseconds / 1000 (number of seconds)
// = number of seconds * SAMPLING_RATE by SECONDS
// = number of seconds * SAMPLING_RATE by SECONDS
...
@@ -1473,19 +1463,19 @@ void ManagerImpl::playDtmf(char code)
...
@@ -1473,19 +1463,19 @@ void ManagerImpl::playDtmf(char code)
// Multi-thread
// Multi-thread
bool
ManagerImpl
::
incomingCallsWaiting
()
bool
ManagerImpl
::
incomingCallsWaiting
()
{
{
s
fl
::
ScopedLock
m
(
waitingCallsMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
waitingCallsMutex_
);
return
not
waitingCalls_
.
empty
();
return
not
waitingCalls_
.
empty
();
}
}
void
ManagerImpl
::
addWaitingCall
(
const
std
::
string
&
id
)
void
ManagerImpl
::
addWaitingCall
(
const
std
::
string
&
id
)
{
{
s
fl
::
ScopedLock
m
(
waitingCallsMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
waitingCallsMutex_
);
waitingCalls_
.
insert
(
id
);
waitingCalls_
.
insert
(
id
);
}
}
void
ManagerImpl
::
removeWaitingCall
(
const
std
::
string
&
id
)
void
ManagerImpl
::
removeWaitingCall
(
const
std
::
string
&
id
)
{
{
s
fl
::
ScopedLock
m
(
waitingCallsMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
waitingCallsMutex_
);
waitingCalls_
.
erase
(
id
);
waitingCalls_
.
erase
(
id
);
}
}
...
@@ -1651,7 +1641,7 @@ void ManagerImpl::peerAnsweredCall(const std::string& id)
...
@@ -1651,7 +1641,7 @@ void ManagerImpl::peerAnsweredCall(const std::string& id)
addStream
(
id
);
addStream
(
id
);
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
->
flushMain
();
audiodriver_
->
flushMain
();
audiodriver_
->
flushUrgent
();
audiodriver_
->
flushUrgent
();
}
}
...
@@ -1765,7 +1755,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId)
...
@@ -1765,7 +1755,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId)
return
;
return
;
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
audiodriver_
==
NULL
)
{
if
(
audiodriver_
==
NULL
)
{
ERROR
(
"Audio layer not initialized"
);
ERROR
(
"Audio layer not initialized"
);
...
@@ -1777,7 +1767,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId)
...
@@ -1777,7 +1767,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId)
}
}
{
{
s
fl
::
ScopedLock
lock
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
toneMutex_
);
if
(
telephoneTone_
.
get
()
!=
0
)
if
(
telephoneTone_
.
get
()
!=
0
)
telephoneTone_
->
setCurrentTone
(
toneId
);
telephoneTone_
->
setCurrentTone
(
toneId
);
}
}
...
@@ -1791,7 +1781,7 @@ void ManagerImpl::stopTone()
...
@@ -1791,7 +1781,7 @@ void ManagerImpl::stopTone()
if
(
not
voipPreferences
.
getPlayTones
())
if
(
not
voipPreferences
.
getPlayTones
())
return
;
return
;
s
fl
::
ScopedLock
lock
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
toneMutex_
);
if
(
telephoneTone_
.
get
()
!=
NULL
)
if
(
telephoneTone_
.
get
()
!=
NULL
)
telephoneTone_
->
setCurrentTone
(
Tone
::
TONE_NULL
);
telephoneTone_
->
setCurrentTone
(
Tone
::
TONE_NULL
);
...
@@ -1874,7 +1864,7 @@ void ManagerImpl::playRingtone(const std::string& accountID)
...
@@ -1874,7 +1864,7 @@ void ManagerImpl::playRingtone(const std::string& accountID)
int
audioLayerSmplr
=
8000
;
int
audioLayerSmplr
=
8000
;
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
!
audiodriver_
)
{
if
(
!
audiodriver_
)
{
ERROR
(
"no audio layer in ringtone"
);
ERROR
(
"no audio layer in ringtone"
);
...
@@ -1885,7 +1875,7 @@ void ManagerImpl::playRingtone(const std::string& accountID)
...
@@ -1885,7 +1875,7 @@ void ManagerImpl::playRingtone(const std::string& accountID)
}
}
{
{
s
fl
::
ScopedLock
m
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
toneMutex_
);
if
(
audiofile_
.
get
())
{
if
(
audiofile_
.
get
())
{
client_
.
getCallManager
()
->
recordPlaybackStopped
(
audiofile_
->
getFilePath
());
client_
.
getCallManager
()
->
recordPlaybackStopped
(
audiofile_
->
getFilePath
());
...
@@ -1895,14 +1885,14 @@ void ManagerImpl::playRingtone(const std::string& accountID)
...
@@ -1895,14 +1885,14 @@ void ManagerImpl::playRingtone(const std::string& accountID)
updateAudioFile
(
ringchoice
,
audioLayerSmplr
);
updateAudioFile
(
ringchoice
,
audioLayerSmplr
);
}
// leave mutex
}
// leave mutex
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
// start audio if not started AND flush all buffers (main and urgent)
// start audio if not started AND flush all buffers (main and urgent)
audiodriver_
->
startStream
();
audiodriver_
->
startStream
();
}
}
AudioLoop
*
ManagerImpl
::
getTelephoneTone
()
AudioLoop
*
ManagerImpl
::
getTelephoneTone
()
{
{
s
fl
::
ScopedLock
m
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
toneMutex_
);
if
(
telephoneTone_
.
get
())
if
(
telephoneTone_
.
get
())
return
telephoneTone_
->
getCurrentTone
();
return
telephoneTone_
->
getCurrentTone
();
else
else
...
@@ -1912,7 +1902,7 @@ AudioLoop* ManagerImpl::getTelephoneTone()
...
@@ -1912,7 +1902,7 @@ AudioLoop* ManagerImpl::getTelephoneTone()
AudioLoop
*
AudioLoop
*
ManagerImpl
::
getTelephoneFile
()
ManagerImpl
::
getTelephoneFile
()
{
{
s
fl
::
ScopedLock
m
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
toneMutex_
);
return
audiofile_
.
get
();
return
audiofile_
.
get
();
}
}
...
@@ -1979,7 +1969,7 @@ ManagerImpl::getCurrentVideoCodecName(const std::string& ID)
...
@@ -1979,7 +1969,7 @@ ManagerImpl::getCurrentVideoCodecName(const std::string& ID)
*/
*/
void
ManagerImpl
::
setAudioPlugin
(
const
std
::
string
&
audioPlugin
)
void
ManagerImpl
::
setAudioPlugin
(
const
std
::
string
&
audioPlugin
)
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audioPreference
.
setAlsaPlugin
(
audioPlugin
);
audioPreference
.
setAlsaPlugin
(
audioPlugin
);
...
@@ -1998,7 +1988,7 @@ void ManagerImpl::setAudioPlugin(const std::string& audioPlugin)
...
@@ -1998,7 +1988,7 @@ void ManagerImpl::setAudioPlugin(const std::string& audioPlugin)
*/
*/
void
ManagerImpl
::
setAudioDevice
(
int
index
,
AudioLayer
::
PCMType
type
)
void
ManagerImpl
::
setAudioDevice
(
int
index
,
AudioLayer
::
PCMType
type
)
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
!
audiodriver_
)
{
if
(
!
audiodriver_
)
{
ERROR
(
"Audio driver not initialized"
);
ERROR
(
"Audio driver not initialized"
);
...
@@ -2021,7 +2011,7 @@ void ManagerImpl::setAudioDevice(int index, AudioLayer::PCMType type)
...
@@ -2021,7 +2011,7 @@ void ManagerImpl::setAudioDevice(int index, AudioLayer::PCMType type)
*/
*/
std
::
vector
<
std
::
string
>
ManagerImpl
::
getAudioOutputDeviceList
()
std
::
vector
<
std
::
string
>
ManagerImpl
::
getAudioOutputDeviceList
()
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
return
audiodriver_
->
getPlaybackDeviceList
();
return
audiodriver_
->
getPlaybackDeviceList
();
}
}
...
@@ -2031,7 +2021,7 @@ std::vector<std::string> ManagerImpl::getAudioOutputDeviceList()
...
@@ -2031,7 +2021,7 @@ std::vector<std::string> ManagerImpl::getAudioOutputDeviceList()
*/
*/
std
::
vector
<
std
::
string
>
ManagerImpl
::
getAudioInputDeviceList
()
std
::
vector
<
std
::
string
>
ManagerImpl
::
getAudioInputDeviceList
()
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
return
audiodriver_
->
getCaptureDeviceList
();
return
audiodriver_
->
getCaptureDeviceList
();
}
}
...
@@ -2040,7 +2030,7 @@ std::vector<std::string> ManagerImpl::getAudioInputDeviceList()
...
@@ -2040,7 +2030,7 @@ std::vector<std::string> ManagerImpl::getAudioInputDeviceList()
*/
*/
std
::
vector
<
std
::
string
>
ManagerImpl
::
getCurrentAudioDevicesIndex
()
std
::
vector
<
std
::
string
>
ManagerImpl
::
getCurrentAudioDevicesIndex
()
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
std
::
vector
<
std
::
string
>
v
;
std
::
vector
<
std
::
string
>
v
;
...
@@ -2132,7 +2122,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
...
@@ -2132,7 +2122,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
int
sampleRate
;
int
sampleRate
;
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
!
audiodriver_
)
{
if
(
!
audiodriver_
)
{
ERROR
(
"No audio layer in start recorded file playback"
);
ERROR
(
"No audio layer in start recorded file playback"
);
...
@@ -2143,7 +2133,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
...
@@ -2143,7 +2133,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
}
}
{
{
s
fl
::
ScopedLock
m
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
toneMutex_
);
if
(
audiofile_
.
get
())
{
if
(
audiofile_
.
get
())
{
client_
.
getCallManager
()
->
recordPlaybackStopped
(
audiofile_
->
getFilePath
());
client_
.
getCallManager
()
->
recordPlaybackStopped
(
audiofile_
->
getFilePath
());
...
@@ -2155,15 +2145,17 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
...
@@ -2155,15 +2145,17 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
return
false
;
return
false
;
}
// release toneMutex
}
// release toneMutex
sfl
::
ScopedLock
lock
(
audioLayerMutex_
);
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
->
startStream
();
audiodriver_
->
startStream
();
}
return
true
;
return
true
;
}
}
void
ManagerImpl
::
recordingPlaybackSeek
(
const
double
value
)
void
ManagerImpl
::
recordingPlaybackSeek
(
const
double
value
)
{
{
s
fl
::
ScopedLock
m
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
toneMutex_
);
if
(
audiofile_
.
get
())
if
(
audiofile_
.
get
())
audiofile_
.
get
()
->
seek
(
value
);
audiofile_
.
get
()
->
seek
(
value
);
}
}
...
@@ -2174,12 +2166,12 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath)
...
@@ -2174,12 +2166,12 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath)
DEBUG
(
"Stop recorded file playback %s"
,
filepath
.
c_str
());
DEBUG
(
"Stop recorded file playback %s"
,
filepath
.
c_str
());
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
->
stopStream
();
audiodriver_
->
stopStream
();
}
}
{
{
s
fl
::
ScopedLock
m
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
m
(
toneMutex_
);
audiofile_
.
reset
();
audiofile_
.
reset
();
}
}
client_
.
getCallManager
()
->
recordPlaybackStopped
(
filepath
);
client_
.
getCallManager
()
->
recordPlaybackStopped
(
filepath
);
...
@@ -2200,7 +2192,7 @@ int ManagerImpl::getHistoryLimit() const
...
@@ -2200,7 +2192,7 @@ int ManagerImpl::getHistoryLimit() const
void
ManagerImpl
::
setAudioManager
(
const
std
::
string
&
api
)
void
ManagerImpl
::
setAudioManager
(
const
std
::
string
&
api
)
{
{
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
!
audiodriver_
)
if
(
!
audiodriver_
)
return
;
return
;
...
@@ -2226,7 +2218,7 @@ int ManagerImpl::getAudioDeviceIndex(const std::string &name)
...
@@ -2226,7 +2218,7 @@ int ManagerImpl::getAudioDeviceIndex(const std::string &name)
{
{
int
soundCardIndex
=
0
;
int
soundCardIndex
=
0
;
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
audiodriver_
==
NULL
)
{
if
(
audiodriver_
==
NULL
)
{
ERROR
(
"Audio layer not initialized"
);
ERROR
(
"Audio layer not initialized"
);
...
@@ -2267,13 +2259,13 @@ void ManagerImpl::setEchoCancelState(const std::string &state)
...
@@ -2267,13 +2259,13 @@ void ManagerImpl::setEchoCancelState(const std::string &state)
*/
*/
void
ManagerImpl
::
initAudioDriver
()
void
ManagerImpl
::
initAudioDriver
()
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
=
audioPreference
.
createAudioLayer
();
audiodriver_
=
audioPreference
.
createAudioLayer
();
}
}
void
ManagerImpl
::
switchAudioManager
()
void
ManagerImpl
::
switchAudioManager
()
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
bool
wasStarted
=
audiodriver_
->
isStarted
();
bool
wasStarted
=
audiodriver_
->
isStarted
();
delete
audiodriver_
;
delete
audiodriver_
;
...
@@ -2285,7 +2277,7 @@ void ManagerImpl::switchAudioManager()
...
@@ -2285,7 +2277,7 @@ void ManagerImpl::switchAudioManager()
void
ManagerImpl
::
audioSamplingRateChanged
(
int
samplerate
)
void
ManagerImpl
::
audioSamplingRateChanged
(
int
samplerate
)
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
if
(
!
audiodriver_
)
{
if
(
!
audiodriver_
)
{
DEBUG
(
"No Audio driver initialized"
);
DEBUG
(
"No Audio driver initialized"
);
...
@@ -2311,7 +2303,7 @@ void ManagerImpl::audioSamplingRateChanged(int samplerate)
...
@@ -2311,7 +2303,7 @@ void ManagerImpl::audioSamplingRateChanged(int samplerate)
unsigned
int
sampleRate
=
audiodriver_
->
getSampleRate
();
unsigned
int
sampleRate
=
audiodriver_
->
getSampleRate
();
{
{
s
fl
::
ScopedLock
toneLock
(
toneMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
toneLock
(
toneMutex_
);
telephoneTone_
.
reset
(
new
TelephoneTone
(
preferences
.
getZoneToneChoice
(),
sampleRate
));
telephoneTone_
.
reset
(
new
TelephoneTone
(
preferences
.
getZoneToneChoice
(),
sampleRate
));
}
}
dtmfKey_
.
reset
(
new
DTMF
(
sampleRate
));
dtmfKey_
.
reset
(
new
DTMF
(
sampleRate
));
...
@@ -2700,18 +2692,18 @@ int ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
...
@@ -2700,18 +2692,18 @@ int ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
}
}
#endif
#endif
using
std
::
tr1
::
placeholders
::
_1
;
using
std
::
placeholders
::
_1
;
#if HAVE_IAX
#if HAVE_IAX
std
::
for_each
(
seq
->
begin
(),
seq
->
end
(),
std
::
for_each
(
seq
->
begin
(),
seq
->
end
(),
std
::
tr1
::
bind
(
loadAccount
,
_1
,
std
::
bind
(
loadAccount
,
_1
,
std
::
tr1
::
ref
(
SIPVoIPLink
::
instance
()
->
getAccounts
()),
std
::
ref
(
SIPVoIPLink
::
instance
()
->
getAccounts
()),
std
::
tr1
::
ref
(
IAXVoIPLink
::
getAccounts
()),
std
::
ref
(
IAXVoIPLink
::
getAccounts
()),
std
::
tr1
::
ref
(
errorCount
)));
std
::
ref
(
errorCount
)));
#else
#else
std
::
for_each
(
seq
->
begin
(),
seq
->
end
(),
std
::
for_each
(
seq
->
begin
(),
seq
->
end
(),
std
::
tr1
::
bind
(
loadAccount
,
_1
,
std
::
bind
(
loadAccount
,
_1
,
std
::
tr1
::
ref
(
SIPVoIPLink
::
instance
()
->
getAccounts
()),
std
::
ref
(
SIPVoIPLink
::
instance
()
->
getAccounts
()),
std
::
tr1
::
ref
(
errorCount
)));
std
::
ref
(
errorCount
)));
#endif
#endif
return
errorCount
;
return
errorCount
;
...
@@ -2917,7 +2909,7 @@ void ManagerImpl::clearHistory()
...
@@ -2917,7 +2909,7 @@ void ManagerImpl::clearHistory()
void
ManagerImpl
::
startAudioDriverStream
()
void
ManagerImpl
::
startAudioDriverStream
()
{
{
s
fl
::
ScopedLock
lock
(
audioLayerMutex_
);
s
td
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
audiodriver_
->
startStream
();
audiodriver_
->
startStream
();
}
}
...
...
This diff is collapsed.
Click to expand it.
daemon/src/managerimpl.h
+
5
−
5
View file @
7531c4df
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#include
<set>
#include
<set>
#include
<map>
#include
<map>
#include
<memory>
#include
<memory>
#include
<
pthread.h
>
#include
<
mutex
>
#include
"client/client.h"
#include
"client/client.h"
...
@@ -843,7 +843,7 @@ class ManagerImpl {
...
@@ -843,7 +843,7 @@ class ManagerImpl {
std
::
string
currentCallId_
;
std
::
string
currentCallId_
;
/** Protected current call access */
/** Protected current call access */
pthread_
mutex
_t
currentCallMutex_
;
std
::
mutex
currentCallMutex_
;
/** Audio layer */
/** Audio layer */
AudioLayer
*
audiodriver_
;
AudioLayer
*
audiodriver_
;
...
@@ -854,7 +854,7 @@ class ManagerImpl {
...
@@ -854,7 +854,7 @@ class ManagerImpl {
/////////////////////
/////////////////////
// Protected by Mutex
// Protected by Mutex
/////////////////////
/////////////////////
pthread_
mutex
_t
toneMutex_
;
std
::
mutex
toneMutex_
;
std
::
unique_ptr
<
TelephoneTone
>
telephoneTone_
;
std
::
unique_ptr
<
TelephoneTone
>
telephoneTone_
;
std
::
unique_ptr
<
AudioFile
>
audiofile_
;
std
::
unique_ptr
<
AudioFile
>
audiofile_
;
...
@@ -866,7 +866,7 @@ class ManagerImpl {
...
@@ -866,7 +866,7 @@ class ManagerImpl {
/**
/**
* Mutex used to protect audio layer
* Mutex used to protect audio layer
*/
*/
pthread_
mutex
_t
audioLayerMutex_
;
std
::
mutex
audioLayerMutex_
;
/**
/**
* Waiting Call Vectors
* Waiting Call Vectors
...
@@ -876,7 +876,7 @@ class ManagerImpl {
...
@@ -876,7 +876,7 @@ class ManagerImpl {
/**
/**
* Protect waiting call list, access by many voip/audio threads
* Protect waiting call list, access by many voip/audio threads
*/
*/
pthread_
mutex
_t
waitingCallsMutex_
;
std
::
mutex
waitingCallsMutex_
;
/**
/**
* Add incoming callid to the waiting list
* Add incoming callid to the waiting list
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment