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
99c14e26
Commit
99c14e26
authored
11 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #28679: audio: don't create a new scratch buffer every time we resample
parent
f388aade
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/audio/samplerateconverter.cpp
+5
-4
5 additions, 4 deletions
daemon/src/audio/samplerateconverter.cpp
daemon/src/audio/samplerateconverter.h
+1
-0
1 addition, 0 deletions
daemon/src/audio/samplerateconverter.h
with
6 additions
and
4 deletions
daemon/src/audio/samplerateconverter.cpp
+
5
−
4
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
);
}
This diff is collapsed.
Click to expand it.
daemon/src/audio/samplerateconverter.h
+
1
−
0
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
...
...
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