Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
d29d8d20
Commit
d29d8d20
authored
May 06, 2011
by
Alexandre Savard
Browse files
[#5730] Fix start audio session after changing sampling rate
parent
e654fe16
Changes
6
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/audio/alsa/alsalayer.cpp
View file @
d29d8d20
...
...
@@ -196,6 +196,7 @@ AlsaLayer::startStream (void)
}
}
_isStarted
=
true
;
}
void
...
...
@@ -203,6 +204,8 @@ AlsaLayer::stopStream (void)
{
_debug
(
"Audio: Stop stream"
);
_isStarted
=
false
;
try
{
/* Stop the audio thread first */
if
(
_audioThread
)
{
...
...
sflphone-common/src/audio/audiolayer.h
View file @
d29d8d20
...
...
@@ -72,6 +72,7 @@ class AudioLayer
AudioLayer
(
ManagerImpl
*
manager
,
int
type
)
:
_defaultVolume
(
100
)
,
_layerType
(
type
)
,
_isStarted
(
false
)
,
_manager
(
manager
)
,
_urgentRingBuffer
(
SIZEBUF
,
default_id
)
,
_indexIn
(
0
)
...
...
@@ -126,6 +127,8 @@ class AudioLayer
*/
virtual
void
stopStream
(
void
)
=
0
;
bool
isStarted
(
void
)
{
return
_isStarted
;
}
/**
* Send a chunk of data to the hardware buffer to start the playback
* Copy data in the urgent buffer.
...
...
@@ -296,6 +299,11 @@ class AudioLayer
* Drop the pending frames and close the playback device
*/
virtual
void
closePlaybackStream
(
void
)
=
0
;
/**
* Wether or not the audio layer stream is started
*/
bool
_isStarted
;
/** Augment coupling, reduce indirect access */
ManagerImpl
*
_manager
;
...
...
sflphone-common/src/audio/audiortp/AudioRtpSession.cpp
View file @
d29d8d20
...
...
@@ -306,7 +306,6 @@ void AudioRtpSession::receiveSpeakerData ()
spkrDataIn
=
(
unsigned
char
*
)
adu
->
getData
();
// data in char
size
=
adu
->
getSize
();
// size in char
// DTMF over RTP, size must be over 4 in order to process it as voice data
if
(
size
>
4
)
{
processDataDecode
(
spkrDataIn
,
size
);
...
...
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
View file @
d29d8d20
...
...
@@ -243,8 +243,6 @@ PulseLayer::PulseLayer (ManagerImpl* manager)
{
_urgentRingBuffer
.
createReadPointer
();
is_started
=
false
;
AudioLayer
::
_noisesuppressstate
=
true
;
byteCounter
=
0
;
...
...
@@ -272,16 +270,14 @@ PulseLayer::~PulseLayer (void)
void
PulseLayer
::
openLayer
(
void
)
{
if
(
!
is_started
)
{
_info
(
"Audio: Open Pulseaudio layer"
);
if
(
_isStarted
)
return
;
connect
Pulse
A
udio
Serv
er
(
);
_info
(
"Audio: Open
Pulse
a
udio
lay
er
"
);
is_started
=
true
;
}
connectPulseAudioServer
();
_isStarted
=
true
;
}
bool
...
...
@@ -289,6 +285,8 @@ PulseLayer::closeLayer (void)
{
_info
(
"Audio: Close Pulseaudio layer"
);
_isStarted
=
false
;
disconnectAudioStream
();
if
(
m
)
{
...
...
sflphone-common/src/audio/pulseaudio/pulselayer.h
View file @
d29d8d20
...
...
@@ -285,8 +285,6 @@ class PulseLayer : public AudioLayer
/** Sample rate converter object */
SamplerateConverter
*
_converter
;
bool
is_started
;
int
spkrVolume
;
int
micVolume
;
...
...
sflphone-common/src/managerimpl.cpp
View file @
d29d8d20
...
...
@@ -3070,9 +3070,12 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
int
type
,
currentSamplerate
,
framesize
,
numCardIn
,
numCardOut
,
numCardRing
;
std
::
string
alsaPlugin
;
bool
wasActive
;
_debug
(
"Manager: Audio Sampling rate changed"
);
if
(
!
_audiodriver
)
{
_debug
(
"Manager: No Audio driver
set
"
);
_debug
(
"Manager: No Audio driver
initialized
"
);
return
;
}
...
...
@@ -3099,12 +3102,9 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
_debug
(
"Manager: Deleting current layer..."
);
// ost::MutexLock lock (*getAudioLayerMutex());
// getAudioLayerMutex()->enter();
wasActive
=
_audiodriver
->
isStarted
();
// _audiodriver->closeLayer();
delete
_audiodriver
;
_audiodriver
=
NULL
;
switch
(
type
)
{
...
...
@@ -3126,35 +3126,48 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
break
;
}
if
(
_audiodriver
==
NULL
)
{
_debug
(
"Manager: Error: Audio driver could not be initialized"
);
}
_audiodriver
->
setErrorMessage
(
-
1
);
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
samplerate
,
framesize
,
SFL_PCM_BOTH
,
alsaPlugin
);
if
(
_audiodriver
->
getErrorMessage
()
!=
-
1
)
if
(
_audiodriver
->
getErrorMessage
()
!=
-
1
)
{
notifyErrClient
(
_audiodriver
->
getErrorMessage
());
}
_debug
(
"Manager: Current device: %d "
,
type
);
_mainBuffer
.
setInternalSamplingRate
(
samplerate
);
if
(
_audiodriver
)
{
unsigned
int
sampleRate
=
_audiodriver
->
getSampleRate
();
unsigned
int
sampleRate
=
_audiodriver
->
getSampleRate
();
delete
_telephoneTone
;
delete
_telephoneTone
;
_telephoneTone
=
NULL
;
_debugInit
(
"Manager: Load telephone tone"
);
std
::
string
country
=
preferences
.
getZoneToneChoice
();
_telephoneTone
=
new
TelephoneTone
(
country
,
sampleRate
);
_debugInit
(
"Manager: Load telephone tone"
);
std
::
string
country
=
preferences
.
getZoneToneChoice
();
_telephoneTone
=
new
TelephoneTone
(
country
,
sampleRate
);
if
(
_telephoneTone
==
NULL
)
{
_debug
(
"Manager: Error: Telephone tone is NULL"
);
}
delete
_dtmfKey
;
_dtmfKey
=
NULL
;
delete
_dtmfKey
;
_debugInit
(
"Manager: Loading DTMF key with sample rate %d"
,
sampleRate
);
_dtmfKey
=
new
DTMF
(
sampleRate
);
_debugInit
(
"Manager: Loading DTMF key with sample rate %d"
,
sampleRate
);
_d
tmfKey
=
new
DTMF
(
sampleRate
);
if
(
_dtmfKey
==
NULL
)
{
_d
ebug
(
"Manager: Error: DtmfKey is NULL"
);
}
if
(
hasCurrentCall
())
{
// Restart audio layer if it was active
if
(
wasActive
)
{
_audiodriver
->
startStream
();
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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