Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3057d19c
Commit
3057d19c
authored
Oct 08, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_resample_lsr: move common code to lsr_process()
parent
8dd83a2c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
32 deletions
+17
-32
pcm_resample_libsamplerate.c
src/pcm_resample_libsamplerate.c
+17
-32
No files found.
src/pcm_resample_libsamplerate.c
View file @
3057d19c
...
...
@@ -142,6 +142,21 @@ pcm_resample_set(struct pcm_resample_state *state,
return
true
;
}
static
bool
lsr_process
(
struct
pcm_resample_state
*
state
,
GError
**
error_r
)
{
if
(
state
->
error
==
0
)
state
->
error
=
src_process
(
state
->
state
,
&
state
->
data
);
if
(
state
->
error
)
{
g_set_error
(
error_r
,
libsamplerate_quark
(),
state
->
error
,
"libsamplerate has failed: %s"
,
src_strerror
(
state
->
error
));
return
false
;
}
return
true
;
}
const
int16_t
*
pcm_resample_lsr_16
(
struct
pcm_resample_state
*
state
,
uint8_t
channels
,
...
...
@@ -154,7 +169,6 @@ pcm_resample_lsr_16(struct pcm_resample_state *state,
SRC_DATA
*
data
=
&
state
->
data
;
size_t
data_in_size
;
size_t
data_out_size
;
int
error
;
int16_t
*
dest_buffer
;
assert
((
src_size
%
(
sizeof
(
*
src_buffer
)
*
channels
))
==
0
);
...
...
@@ -164,14 +178,6 @@ pcm_resample_lsr_16(struct pcm_resample_state *state,
if
(
!
success
)
return
NULL
;
/* there was an error previously, and nothing has changed */
if
(
state
->
error
)
{
g_set_error
(
error_r
,
libsamplerate_quark
(),
state
->
error
,
"libsamplerate has failed: %s"
,
src_strerror
(
state
->
error
));
return
NULL
;
}
data
->
input_frames
=
src_size
/
sizeof
(
*
src_buffer
)
/
channels
;
data_in_size
=
data
->
input_frames
*
sizeof
(
float
)
*
channels
;
data
->
data_in
=
pcm_buffer_get
(
&
state
->
in
,
data_in_size
);
...
...
@@ -183,14 +189,8 @@ pcm_resample_lsr_16(struct pcm_resample_state *state,
src_short_to_float_array
(
src_buffer
,
data
->
data_in
,
data
->
input_frames
*
channels
);
error
=
src_process
(
state
->
state
,
data
);
if
(
error
)
{
g_set_error
(
error_r
,
libsamplerate_quark
(),
error
,
"libsamplerate has failed: %s"
,
src_strerror
(
error
));
state
->
error
=
error
;
if
(
!
lsr_process
(
state
,
error_r
))
return
NULL
;
}
*
dest_size_r
=
data
->
output_frames_gen
*
sizeof
(
*
dest_buffer
)
*
channels
;
...
...
@@ -233,7 +233,6 @@ pcm_resample_lsr_32(struct pcm_resample_state *state,
SRC_DATA
*
data
=
&
state
->
data
;
size_t
data_in_size
;
size_t
data_out_size
;
int
error
;
int32_t
*
dest_buffer
;
assert
((
src_size
%
(
sizeof
(
*
src_buffer
)
*
channels
))
==
0
);
...
...
@@ -243,14 +242,6 @@ pcm_resample_lsr_32(struct pcm_resample_state *state,
if
(
!
success
)
return
NULL
;
/* there was an error previously, and nothing has changed */
if
(
state
->
error
)
{
g_set_error
(
error_r
,
libsamplerate_quark
(),
state
->
error
,
"libsamplerate has failed: %s"
,
src_strerror
(
state
->
error
));
return
NULL
;
}
data
->
input_frames
=
src_size
/
sizeof
(
*
src_buffer
)
/
channels
;
data_in_size
=
data
->
input_frames
*
sizeof
(
float
)
*
channels
;
data
->
data_in
=
pcm_buffer_get
(
&
state
->
in
,
data_in_size
);
...
...
@@ -262,14 +253,8 @@ pcm_resample_lsr_32(struct pcm_resample_state *state,
src_int_to_float_array
(
src_buffer
,
data
->
data_in
,
data
->
input_frames
*
channels
);
error
=
src_process
(
state
->
state
,
data
);
if
(
error
)
{
g_set_error
(
error_r
,
libsamplerate_quark
(),
error
,
"libsamplerate has failed: %s"
,
src_strerror
(
error
));
state
->
error
=
error
;
if
(
!
lsr_process
(
state
,
error_r
))
return
NULL
;
}
*
dest_size_r
=
data
->
output_frames_gen
*
sizeof
(
*
dest_buffer
)
*
channels
;
...
...
Write
Preview
Markdown
is supported
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