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
107321e3
Commit
107321e3
authored
Jul 10, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/audiofile: implement scan_stream() instead of scan_file()
parent
1d214b4a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
22 deletions
+23
-22
NEWS
NEWS
+1
-0
AudiofileDecoderPlugin.cxx
src/decoder/plugins/AudiofileDecoderPlugin.cxx
+22
-22
No files found.
NEWS
View file @
107321e3
...
...
@@ -30,6 +30,7 @@ ver 0.19 (not yet released)
- volume: improved software volume dithering
* decoder:
- vorbis, flac, opus: honor DESCRIPTION= tag in Xiph-based files as a comment to the song
- audiofile: support scanning remote files
* encoder:
- shine: new encoder plugin
* threads:
...
...
src/decoder/plugins/AudiofileDecoderPlugin.cxx
View file @
107321e3
...
...
@@ -63,19 +63,6 @@ audiofile_get_duration(AFfilehandle fh)
return
frame_count
/
rate
;
}
gcc_pure
static
int
audiofile_get_duration
(
Path
path_fs
)
{
AFfilehandle
af_fp
=
afOpenFile
(
path_fs
.
c_str
(),
"r"
,
nullptr
);
if
(
af_fp
==
AF_NULL_FILEHANDLE
)
{
return
-
1
;
}
int
total_time
=
int
(
audiofile_get_duration
(
af_fp
));
afCloseFile
(
af_fp
);
return
total_time
;
}
static
ssize_t
audiofile_file_read
(
AFvirtualfile
*
vfile
,
void
*
data
,
size_t
length
)
{
...
...
@@ -250,18 +237,31 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
afCloseFile
(
af_fp
);
}
gcc_pure
static
int
audiofile_get_duration
(
InputStream
&
is
)
{
if
(
!
is
.
IsSeekable
())
return
-
1
;
AudioFileInputStream
afis
{
nullptr
,
is
};
AFvirtualfile
*
vf
=
setup_virtual_fops
(
afis
);
AFfilehandle
fh
=
afOpenVirtualFile
(
vf
,
"r"
,
nullptr
);
if
(
fh
==
AF_NULL_FILEHANDLE
)
return
-
1
;
int
duration
=
int
(
audiofile_get_duration
(
fh
));
afCloseFile
(
fh
);
return
duration
;
}
static
bool
audiofile_scan_
file
(
Path
path_f
s
,
audiofile_scan_
stream
(
InputStream
&
i
s
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
int
total_time
=
audiofile_get_duration
(
path_fs
);
if
(
total_time
<
0
)
{
FormatWarning
(
audiofile_domain
,
"Failed to get total song time from: %s"
,
path_fs
.
c_str
());
int
total_time
=
audiofile_get_duration
(
is
);
if
(
total_time
<
0
)
return
false
;
}
tag_handler_invoke_duration
(
handler
,
handler_ctx
,
total_time
);
return
true
;
...
...
@@ -283,8 +283,8 @@ const struct DecoderPlugin audiofile_decoder_plugin = {
nullptr
,
audiofile_stream_decode
,
nullptr
,
audiofile_scan_file
,
nullptr
,
audiofile_scan_stream
,
nullptr
,
audiofile_suffixes
,
audiofile_mime_types
,
...
...
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