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
99c14e26
Commit
99c14e26
authored
Aug 20, 2013
by
Tristan Matthews
Browse files
* #28679: audio: don't create a new scratch buffer every time we resample
parent
f388aade
Changes
2
Hide whitespace changes
Inline
Side-by-side
daemon/src/audio/samplerateconverter.cpp
View file @
99c14e26
...
...
@@ -32,7 +32,7 @@
#include
"sfl_types.h"
SamplerateConverter
::
SamplerateConverter
(
int
freq
,
size_t
channels
/* = 1 */
)
:
floatBufferIn_
(),
floatBufferOut_
(),
samples_
(
0
),
channels_
(
channels
),
maxFreq_
(
freq
),
src_state_
(
0
)
floatBufferOut_
(),
scratchBuffer_
(),
samples_
(
0
),
channels_
(
channels
),
maxFreq_
(
freq
),
src_state_
(
0
)
{
int
err
;
src_state_
=
src_new
(
SRC_LINEAR
,
channels_
,
&
err
);
...
...
@@ -41,6 +41,7 @@ SamplerateConverter::SamplerateConverter(int freq, size_t channels /* = 1 */) :
floatBufferIn_
.
resize
(
samples_
);
floatBufferOut_
.
resize
(
samples_
);
scratchBuffer_
.
resize
(
samples_
);
}
SamplerateConverter
::~
SamplerateConverter
()
...
...
@@ -86,6 +87,7 @@ void SamplerateConverter::resample(const AudioBuffer &dataIn, AudioBuffer &dataO
samples_
=
std
::
max
(
inSamples
,
outSamples
);
floatBufferIn_
.
resize
(
inSamples
);
floatBufferOut_
.
resize
(
outSamples
);
scratchBuffer_
.
resize
(
outSamples
);
SRC_DATA
src_data
;
src_data
.
data_in
=
floatBufferIn_
.
data
();
...
...
@@ -102,7 +104,6 @@ void SamplerateConverter::resample(const AudioBuffer &dataIn, AudioBuffer &dataO
/*
TODO: one-shot deinterleave and float-to-short conversion
*/
std
::
vector
<
SFLAudioSample
>
scratch_buff
(
outSamples
);
src_float_to_short_array
(
floatBufferOut_
.
data
(),
scratch_buff
.
data
(),
outSamples
);
dataOut
.
deinterleave
(
scratch_buff
.
data
(),
src_data
.
output_frames
,
nbChans
);
src_float_to_short_array
(
floatBufferOut_
.
data
(),
scratchBuffer_
.
data
(),
outSamples
);
dataOut
.
deinterleave
(
scratchBuffer_
.
data
(),
src_data
.
output_frames
,
nbChans
);
}
daemon/src/audio/samplerateconverter.h
View file @
99c14e26
...
...
@@ -78,6 +78,7 @@ class SamplerateConverter {
/* temporary buffers */
std
::
vector
<
float
>
floatBufferIn_
;
std
::
vector
<
float
>
floatBufferOut_
;
std
::
vector
<
SFLAudioSample
>
scratchBuffer_
;
size_t
samples_
;
// size in samples of temporary buffers
size_t
channels_
;
// number of channels configured
...
...
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