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
1dfadf48
Commit
1dfadf48
authored
Nov 14, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/modplug: count frame position
Don't maintain the current time stamp in a floating point variable, because this is subject to rounding errors.
parent
f5b9e3c0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
modplug_plugin.c
src/decoder/modplug_plugin.c
+11
-13
No files found.
src/decoder/modplug_plugin.c
View file @
1dfadf48
...
...
@@ -94,10 +94,9 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
ModPlug_Settings
settings
;
GByteArray
*
bdatas
;
struct
audio_format
audio_format
;
float
total_time
=
0
.
0
;
int
ret
,
current
;
int
ret
;
char
audio_buffer
[
MODPLUG_FRAME_SIZE
];
float
sec_perbyte
;
unsigned
frame_size
,
current_frame
=
0
;
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
bdatas
=
mod_loadfile
(
decoder
,
is
);
...
...
@@ -126,29 +125,28 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
audio_format_init
(
&
audio_format
,
44100
,
16
,
2
);
assert
(
audio_format_valid
(
&
audio_format
));
sec_perbyte
=
1
.
0
/
((
audio_format
.
bits
*
audio_format
.
channels
/
8
.
0
)
*
(
float
)
audio_format
.
sample_rate
);
decoder_initialized
(
decoder
,
&
audio_format
,
is
->
seekable
,
ModPlug_GetLength
(
f
)
/
1000
.
0
);
total_time
=
0
;
frame_size
=
audio_format_frame_size
(
&
audio_format
)
;
do
{
ret
=
ModPlug_Read
(
f
,
audio_buffer
,
MODPLUG_FRAME_SIZE
);
if
(
ret
<=
0
)
break
;
total_time
+=
ret
*
sec_perbyt
e
;
current_frame
+=
(
unsigned
)
ret
/
frame_siz
e
;
cmd
=
decoder_data
(
decoder
,
NULL
,
audio_buffer
,
ret
,
total_time
,
0
,
NULL
);
(
float
)
current_frame
/
(
float
)
audio_format
.
sample_rate
,
0
,
NULL
);
if
(
cmd
==
DECODE_COMMAND_SEEK
)
{
total_time
=
decoder_seek_where
(
decoder
);
current
=
total_time
*
1000
;
ModPlug_Seek
(
f
,
current
);
float
where
=
decoder_seek_where
(
decoder
);
ModPlug_Seek
(
f
,
(
int
)(
where
*
1000
.
0
));
current_frame
=
(
unsigned
)(
where
*
audio_format
.
sample_rate
);
decoder_command_finished
(
decoder
);
}
...
...
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