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
84523fae
Commit
84523fae
authored
Mar 02, 2011
by
Alexandre Savard
Browse files
[#5249] Fix audio samplerate update algorithm for g722
parent
b9f8a89d
Changes
5
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/audio/audiortp/AudioRtpRecordHandler.cpp
View file @
84523fae
...
...
@@ -158,7 +158,8 @@ void AudioRtpRecordHandler::updateRtpMedia (AudioCodec *audioCodec)
_audioRtpRecord
.
audioCodecMutex
.
leave
();
Manager
::
instance
().
getMainBuffer
()
->
setInternalSamplingRate
(
_audioRtpRecord
.
_codecSampleRate
);
// Manager::instance().getMainBuffer()->setInternalSamplingRate (_audioRtpRecord._codecSampleRate);
Manager
::
instance
().
audioSamplingRateChanged
(
_audioRtpRecord
.
_codecSampleRate
);
if
(
lastSamplingRate
!=
_audioRtpRecord
.
_codecSampleRate
)
updateNoiseSuppress
();
...
...
@@ -173,7 +174,8 @@ void AudioRtpRecordHandler::initBuffers()
int
codecSampleRate
=
_audioRtpRecord
.
_codecSampleRate
;
// Set sampling rate, main buffer choose the highest one
Manager
::
instance
().
getMainBuffer
()
->
setInternalSamplingRate
(
codecSampleRate
);
// Manager::instance().getMainBuffer()->setInternalSamplingRate (codecSampleRate);
Manager
::
instance
().
audioSamplingRateChanged
(
codecSampleRate
);
// initialize SampleRate converter using AudioLayer's sampling rate
// (internal buffers initialized with maximal sampling rate and frame size)
...
...
sflphone-common/src/audio/codecs/g722.cpp
View file @
84523fae
...
...
@@ -103,10 +103,20 @@ class G722 : public AudioCodec
// Enable 8khz mode, encode using lower subband only
encode_s
->
eight_k
=
FALSE
;
// Never set packed TRUE when using 64 kbps
encode_s
->
packed
=
FALSE
;
memset
(
encode_s
->
band
,
0
,
sizeof
(
decode_s
->
band
)
*
2
);
encode_s
->
band
[
0
].
det
=
32
;
encode_s
->
band
[
1
].
det
=
8
;
memset
(
encode_s
->
x
,
0
,
sizeof
(
int
)
*
24
);
decode_s
->
in_buffer
=
0
;
decode_s
->
in_bits
=
0
;
decode_s
->
out_buffer
=
0
;
decode_s
->
out_bits
=
0
;
}
void
g722_decode_init
(
void
)
{
...
...
@@ -121,14 +131,23 @@ class G722 : public AudioCodec
// Never set packed TRUE when using 64 kbps
decode_s
->
packed
=
FALSE
;
memset
(
decode_s
->
band
,
0
,
sizeof
(
decode_s
->
band
)
*
2
);
decode_s
->
band
[
0
].
det
=
32
;
decode_s
->
band
[
1
].
det
=
8
;
decode_s
->
in_bits
=
0
;
memset
(
decode_s
->
x
,
0
,
sizeof
(
int
)
*
24
);
decode_s
->
in_buffer
=
0
;
decode_s
->
in_bits
=
0
;
decode_s
->
out_buffer
=
0
;
decode_s
->
out_bits
=
0
;
}
int16_t
saturate
(
int32_t
amp
)
{
int16_t
amp16
;
int16_t
amp16
=
0
;
/* Hopefully this is optimised for the common case - not clipping */
amp16
=
(
int16_t
)
amp
;
...
...
sflphone-common/src/audio/mainbuffer.cpp
View file @
84523fae
...
...
@@ -57,11 +57,11 @@ void MainBuffer::setInternalSamplingRate (int sr)
// This call takes the mutex
flushAllBuffers
();
ost
::
MutexLock
guard
(
_mutex
);
//
ost::MutexLock guard (_mutex);
_internalSamplingRate
=
sr
;
Manager
::
instance
().
audioSamplingRateChanged
();
//
Manager::instance().audioSamplingRateChanged(
sr
);
}
}
...
...
sflphone-common/src/managerimpl.cpp
View file @
84523fae
...
...
@@ -3038,10 +3038,10 @@ void ManagerImpl::switchAudioManager (void)
// }
}
void
ManagerImpl
::
audioSamplingRateChanged
(
void
)
void
ManagerImpl
::
audioSamplingRateChanged
(
int
samplerate
)
{
int
type
,
s
amplerate
,
framesize
,
numCardIn
,
numCardOut
,
numCardRing
;
int
type
,
currentS
amplerate
,
framesize
,
numCardIn
,
numCardOut
,
numCardRing
;
std
::
string
alsaPlugin
;
_debug
(
"Manager: Audio sampling rate changed"
);
...
...
@@ -3049,9 +3049,14 @@ void ManagerImpl::audioSamplingRateChanged (void)
if
(
!
_audiodriver
)
return
;
// Only modify internal sampling rate if new sampling rate is higher
currentSamplerate
=
_mainBuffer
.
getInternalSamplingRate
();
if
(
currentSamplerate
<=
samplerate
)
return
;
type
=
_audiodriver
->
getLayerType
();
samplerate
=
_mainBuffer
.
getInternalSamplingRate
();
//
samplerate = _mainBuffer.getInternalSamplingRate();
framesize
=
audioPreference
.
getFramesize
();
_debug
(
"Manager: new samplerate: %d, new framesize %d"
,
samplerate
,
framesize
);
...
...
@@ -3101,6 +3106,8 @@ void ManagerImpl::audioSamplingRateChanged (void)
_debug
(
"Manager: Current device: %d "
,
type
);
_mainBuffer
.
setInternalSamplingRate
(
samplerate
);
if
(
_audiodriver
)
{
unsigned
int
sampleRate
=
_audiodriver
->
getSampleRate
();
...
...
sflphone-common/src/managerimpl.h
View file @
84523fae
...
...
@@ -851,7 +851,11 @@ class ManagerImpl
void
switchAudioManager
(
void
);
void
audioSamplingRateChanged
(
void
);
/**
* Set the internal audio sampling rate change. Should close the audio layer and
* reopen stream at different rate,
*/
void
audioSamplingRateChanged
(
int
);
/**
* Get the desktop mail notification level
...
...
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