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
e0532ae0
Commit
e0532ae0
authored
Oct 29, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mp3: moved code to mp3_send_pcm()
Break the large function mp3_read() into smaller pieces.
parent
a6ad0e40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
29 deletions
+48
-29
mp3_plugin.c
src/decoder/mp3_plugin.c
+48
-29
No files found.
src/decoder/mp3_plugin.c
View file @
e0532ae0
...
...
@@ -871,14 +871,56 @@ mp3_update_timer_next_frame(struct mp3_data *data)
mad_timer_count
(
data
->
timer
,
MAD_UNITS_MILLISECONDS
)
/
1000
.
0
;
}
/**
* Sends the synthesized current frame via decoder_data().
*/
static
enum
decoder_command
mp3_send_pcm
(
struct
mp3_data
*
data
,
unsigned
i
,
unsigned
pcm_length
,
ReplayGainInfo
*
replay_gain_info
)
{
unsigned
max_samples
;
max_samples
=
sizeof
(
data
->
output_buffer
)
/
sizeof
(
data
->
output_buffer
[
0
])
/
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
);
while
(
i
<
pcm_length
)
{
enum
decoder_command
cmd
;
unsigned
int
num_samples
=
pcm_length
-
i
;
if
(
num_samples
>
max_samples
)
num_samples
=
max_samples
;
i
+=
num_samples
;
mad_fixed_to_24_buffer
(
data
->
output_buffer
,
&
data
->
synth
,
i
-
num_samples
,
i
,
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
));
num_samples
*=
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
);
cmd
=
decoder_data
(
data
->
decoder
,
data
->
input_stream
,
data
->
input_stream
->
seekable
,
data
->
output_buffer
,
sizeof
(
data
->
output_buffer
[
0
])
*
num_samples
,
data
->
elapsed_time
,
data
->
bit_rate
/
1000
,
replay_gain_info
);
if
(
cmd
==
DECODE_COMMAND_STOP
)
return
cmd
;
}
return
DECODE_COMMAND_NONE
;
}
static
enum
mp3_action
mp3_read
(
struct
mp3_data
*
data
,
ReplayGainInfo
**
replay_gain_info_r
)
{
struct
decoder
*
decoder
=
data
->
decoder
;
unsigned
int
pcm_length
,
max_samples
;
unsigned
int
pcm_length
;
unsigned
int
i
;
int
ret
;
int
skip
;
enum
decoder_command
cmd
;
mp3_update_timer_next_frame
(
data
);
...
...
@@ -943,34 +985,11 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
pcm_length
-=
data
->
drop_end_samples
;
}
max_samples
=
sizeof
(
data
->
output_buffer
)
/
sizeof
(
data
->
output_buffer
[
0
])
/
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
);
while
(
i
<
pcm_length
)
{
enum
decoder_command
cmd
;
unsigned
int
num_samples
=
pcm_length
-
i
;
if
(
num_samples
>
max_samples
)
num_samples
=
max_samples
;
i
+=
num_samples
;
mad_fixed_to_24_buffer
(
data
->
output_buffer
,
&
data
->
synth
,
i
-
num_samples
,
i
,
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
));
num_samples
*=
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
);
cmd
=
decoder_data
(
decoder
,
data
->
input_stream
,
data
->
input_stream
->
seekable
,
data
->
output_buffer
,
sizeof
(
data
->
output_buffer
[
0
])
*
num_samples
,
data
->
elapsed_time
,
data
->
bit_rate
/
1000
,
(
replay_gain_info_r
!=
NULL
)
?
*
replay_gain_info_r
:
NULL
);
if
(
cmd
==
DECODE_COMMAND_STOP
)
return
DECODE_BREAK
;
}
cmd
=
mp3_send_pcm
(
data
,
i
,
pcm_length
,
replay_gain_info_r
!=
NULL
?
*
replay_gain_info_r
:
NULL
);
if
(
cmd
==
DECODE_COMMAND_STOP
)
return
DECODE_BREAK
;
if
(
data
->
drop_end_samples
&&
(
data
->
current_frame
==
data
->
max_frames
-
data
->
drop_end_frames
))
...
...
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