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
c1a999c4
Commit
c1a999c4
authored
Nov 10, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/flac: don't use float to calculate song duration
Simple (up-rounding) integer division is good enough. We're casting the result back to an integer anyway.
parent
e51d9fc6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
_flac_common.h
src/decoder/_flac_common.h
+7
-0
flac_plugin.c
src/decoder/flac_plugin.c
+2
-5
oggflac_plugin.c
src/decoder/oggflac_plugin.c
+1
-3
No files found.
src/decoder/_flac_common.h
View file @
c1a999c4
...
...
@@ -159,6 +159,13 @@ struct flac_data {
struct
tag
*
tag
;
};
static
inline
unsigned
flac_duration
(
const
FLAC__StreamMetadata_StreamInfo
*
stream_info
)
{
return
(
stream_info
->
total_samples
+
stream_info
->
sample_rate
-
1
)
/
stream_info
->
sample_rate
;
}
/* initializes a given FlacData struct */
void
flac_data_init
(
struct
flac_data
*
data
,
struct
decoder
*
decoder
,
...
...
src/decoder/flac_plugin.c
View file @
c1a999c4
...
...
@@ -272,8 +272,7 @@ flac_tag_load(const char *file, const char *char_tnum)
flac_vorbis_comments_to_tag
(
tag
,
char_tnum
,
&
block
->
data
.
vorbis_comment
);
}
else
if
(
block
->
type
==
FLAC__METADATA_TYPE_STREAMINFO
)
{
tag
->
time
=
((
float
)
block
->
data
.
stream_info
.
total_samples
)
/
block
->
data
.
stream_info
.
sample_rate
+
0
.
5
;
tag
->
time
=
flac_duration
(
&
block
->
data
.
stream_info
);
}
FLAC__metadata_object_delete
(
block
);
}
while
(
FLAC__metadata_simple_iterator_next
(
it
));
...
...
@@ -853,9 +852,7 @@ oggflac_tag_dup(const char *file)
flac_vorbis_comments_to_tag
(
ret
,
NULL
,
&
block
->
data
.
vorbis_comment
);
}
else
if
(
block
->
type
==
FLAC__METADATA_TYPE_STREAMINFO
)
{
ret
->
time
=
((
float
)
block
->
data
.
stream_info
.
total_samples
)
/
block
->
data
.
stream_info
.
sample_rate
+
0
.
5
;
ret
->
time
=
flac_duration
(
&
block
->
data
.
stream_info
);
}
}
while
(
FLAC__metadata_iterator_next
(
it
));
FLAC__metadata_iterator_delete
(
it
);
...
...
src/decoder/oggflac_plugin.c
View file @
c1a999c4
...
...
@@ -172,9 +172,7 @@ static void of_metadata_dup_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecode
switch
(
block
->
type
)
{
case
FLAC__METADATA_TYPE_STREAMINFO
:
data
->
tag
->
time
=
((
float
)
block
->
data
.
stream_info
.
total_samples
)
/
block
->
data
.
stream_info
.
sample_rate
+
0
.
5
;
data
->
tag
->
time
=
flac_duration
(
&
block
->
data
.
stream_info
);
return
;
case
FLAC__METADATA_TYPE_VORBIS_COMMENT
:
flac_vorbis_comments_to_tag
(
data
->
tag
,
NULL
,
...
...
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