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
d39d2874
Commit
d39d2874
authored
Aug 03, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/mad: move code to methods RunDecoder(), RunScan()
parent
a0a74951
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
21 deletions
+37
-21
MadDecoderPlugin.cxx
src/decoder/plugins/MadDecoderPlugin.cxx
+37
-21
No files found.
src/decoder/plugins/MadDecoderPlugin.cxx
View file @
d39d2874
...
...
@@ -139,6 +139,9 @@ struct MadDecoder {
MadDecoder
(
DecoderClient
*
client
,
InputStream
&
input_stream
)
noexcept
;
~
MadDecoder
()
noexcept
;
void
RunDecoder
()
noexcept
;
bool
RunScan
(
TagHandler
&
handler
)
noexcept
;
bool
Seek
(
long
offset
)
noexcept
;
bool
FillBuffer
()
noexcept
;
void
ParseId3
(
size_t
tagsize
,
Tag
*
tag
)
noexcept
;
...
...
@@ -953,53 +956,66 @@ MadDecoder::Read() noexcept
}
}
static
void
mad_decode
(
DecoderClient
&
client
,
InputStream
&
input_stream
)
inline
void
MadDecoder
::
RunDecoder
()
noexcept
{
MadDecoder
data
(
&
client
,
input_stream
);
assert
(
client
!=
nullptr
);
Tag
tag
;
if
(
!
data
.
DecodeFirstFrame
(
&
tag
))
{
if
(
client
.
GetCommand
()
==
DecoderCommand
::
NONE
)
if
(
!
DecodeFirstFrame
(
&
tag
))
{
if
(
client
->
GetCommand
()
==
DecoderCommand
::
NONE
)
LogError
(
mad_domain
,
"input does not appear to be a mp3 bit stream"
);
return
;
}
data
.
AllocateBuffers
();
AllocateBuffers
();
client
.
Ready
(
CheckAudioFormat
(
data
.
frame
.
header
.
samplerate
,
SampleFormat
::
S24_P32
,
MAD_NCHANNELS
(
&
data
.
frame
.
header
)),
input_stream
.
IsSeekable
(),
data
.
total_time
);
client
->
Ready
(
CheckAudioFormat
(
frame
.
header
.
samplerate
,
SampleFormat
::
S24_P32
,
MAD_NCHANNELS
(
&
frame
.
header
)),
input_stream
.
IsSeekable
(),
total_time
);
if
(
!
tag
.
IsEmpty
())
client
.
SubmitTag
(
input_stream
,
std
::
move
(
tag
));
client
->
SubmitTag
(
input_stream
,
std
::
move
(
tag
));
while
(
data
.
Read
())
{}
while
(
Read
())
{}
}
static
bool
mad_decode
r_scan_stream
(
InputStream
&
is
,
TagHandler
&
handler
)
noexcept
static
void
mad_decode
(
DecoderClient
&
client
,
InputStream
&
input_stream
)
{
MadDecoder
data
(
nullptr
,
is
);
if
(
!
data
.
DecodeFirstFrame
(
nullptr
))
MadDecoder
data
(
&
client
,
input_stream
);
data
.
RunDecoder
();
}
inline
bool
MadDecoder
::
RunScan
(
TagHandler
&
handler
)
noexcept
{
if
(
!
DecodeFirstFrame
(
nullptr
))
return
false
;
if
(
!
data
.
total_time
.
IsNegative
())
handler
.
OnDuration
(
SongTime
(
data
.
total_time
));
if
(
!
total_time
.
IsNegative
())
handler
.
OnDuration
(
SongTime
(
total_time
));
try
{
handler
.
OnAudioFormat
(
CheckAudioFormat
(
data
.
frame
.
header
.
samplerate
,
handler
.
OnAudioFormat
(
CheckAudioFormat
(
frame
.
header
.
samplerate
,
SampleFormat
::
S24_P32
,
MAD_NCHANNELS
(
&
data
.
frame
.
header
)));
MAD_NCHANNELS
(
&
frame
.
header
)));
}
catch
(...)
{
}
return
true
;
}
static
bool
mad_decoder_scan_stream
(
InputStream
&
is
,
TagHandler
&
handler
)
noexcept
{
MadDecoder
data
(
nullptr
,
is
);
return
data
.
RunScan
(
handler
);
}
static
const
char
*
const
mad_suffixes
[]
=
{
"mp3"
,
"mp2"
,
nullptr
};
static
const
char
*
const
mad_mime_types
[]
=
{
"audio/mpeg"
,
nullptr
};
...
...
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