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
22a9e866
Commit
22a9e866
authored
Jun 16, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/mad: make enums strictly-typed
parent
97e6ea57
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
48 deletions
+48
-48
MadDecoderPlugin.cxx
src/decoder/plugins/MadDecoderPlugin.cxx
+48
-48
No files found.
src/decoder/plugins/MadDecoderPlugin.cxx
View file @
22a9e866
...
...
@@ -49,17 +49,17 @@
static
constexpr
unsigned
long
FRAMES_CUSHION
=
2000
;
enum
mp3_a
ction
{
DECODE_SKIP
=
-
3
,
DECODE_BREAK
=
-
2
,
DECODE_CONT
=
-
1
,
DECODE_OK
=
0
enum
class
MadDecoderA
ction
{
SKIP
,
BREAK
,
CONT
,
OK
};
enum
mutef
rame
{
MUTEFRAME_
NONE
,
MUTEFRAME_
SKIP
,
MUTEFRAME_
SEEK
enum
class
MadDecoderMuteF
rame
{
NONE
,
SKIP
,
SEEK
};
/* the number of samples of silence the decoder inserts at start */
...
...
@@ -129,7 +129,7 @@ struct MadDecoder {
SignedSongTime
total_time
;
SongTime
elapsed_time
;
SongTime
seek_time
;
enum
muteframe
mute_frame
=
MUTEFRAME_
NONE
;
MadDecoderMuteFrame
mute_frame
=
MadDecoderMuteFrame
::
NONE
;
long
*
frame_offsets
=
nullptr
;
mad_timer_t
*
times
=
nullptr
;
unsigned
long
highest_frame
=
0
;
...
...
@@ -153,8 +153,8 @@ struct MadDecoder {
bool
Seek
(
long
offset
);
bool
FillBuffer
();
void
ParseId3
(
size_t
tagsize
,
Tag
*
tag
);
enum
mp3_a
ction
DecodeNextFrameHeader
(
Tag
*
tag
);
enum
mp3_a
ction
DecodeNextFrame
();
MadDecoderA
ction
DecodeNextFrameHeader
(
Tag
*
tag
);
MadDecoderA
ction
DecodeNextFrame
();
gcc_pure
offset_type
ThisFrameOffset
()
const
noexcept
;
...
...
@@ -364,26 +364,26 @@ id3_tag_query(const void *p0, size_t length)
}
#endif
/* !ENABLE_ID3TAG */
static
enum
mp3_a
ction
static
MadDecoderA
ction
RecoverFrameError
(
struct
mad_stream
&
stream
)
{
if
(
MAD_RECOVERABLE
(
stream
.
error
))
return
DECODE_
SKIP
;
return
MadDecoderAction
::
SKIP
;
else
if
(
stream
.
error
==
MAD_ERROR_BUFLEN
)
return
DECODE_
CONT
;
return
MadDecoderAction
::
CONT
;
FormatWarning
(
mad_domain
,
"unrecoverable frame level error: %s"
,
mad_stream_errorstr
(
&
stream
));
return
DECODE_
BREAK
;
return
MadDecoderAction
::
BREAK
;
}
enum
mp3_a
ction
MadDecoderA
ction
MadDecoder
::
DecodeNextFrameHeader
(
Tag
*
tag
)
{
if
((
stream
.
buffer
==
nullptr
||
stream
.
error
==
MAD_ERROR_BUFLEN
)
&&
!
FillBuffer
())
return
DECODE_
BREAK
;
return
MadDecoderAction
::
BREAK
;
if
(
mad_header_decode
(
&
frame
.
header
,
&
stream
))
{
if
(
stream
.
error
==
MAD_ERROR_LOSTSYNC
&&
stream
.
this_frame
)
{
...
...
@@ -393,7 +393,7 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag)
if
(
tagsize
>
0
)
{
ParseId3
((
size_t
)
tagsize
,
tag
);
return
DECODE_
CONT
;
return
MadDecoderAction
::
CONT
;
}
}
...
...
@@ -404,24 +404,24 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag)
if
(
layer
==
(
mad_layer
)
0
)
{
if
(
new_layer
!=
MAD_LAYER_II
&&
new_layer
!=
MAD_LAYER_III
)
{
/* Only layer 2 and 3 have been tested to work */
return
DECODE_
SKIP
;
return
MadDecoderAction
::
SKIP
;
}
layer
=
new_layer
;
}
else
if
(
new_layer
!=
layer
)
{
/* Don't decode frames with a different layer than the first */
return
DECODE_
SKIP
;
return
MadDecoderAction
::
SKIP
;
}
return
DECODE_
OK
;
return
MadDecoderAction
::
OK
;
}
enum
mp3_a
ction
MadDecoderA
ction
MadDecoder
::
DecodeNextFrame
()
{
if
((
stream
.
buffer
==
nullptr
||
stream
.
error
==
MAD_ERROR_BUFLEN
)
&&
!
FillBuffer
())
return
DECODE_
BREAK
;
return
MadDecoderAction
::
BREAK
;
if
(
mad_frame_decode
(
&
frame
,
&
stream
))
{
if
(
stream
.
error
==
MAD_ERROR_LOSTSYNC
)
{
...
...
@@ -430,14 +430,14 @@ MadDecoder::DecodeNextFrame()
stream
.
this_frame
);
if
(
tagsize
>
0
)
{
mad_stream_skip
(
&
stream
,
tagsize
);
return
DECODE_
CONT
;
return
MadDecoderAction
::
CONT
;
}
}
return
RecoverFrameError
(
stream
);
}
return
DECODE_
OK
;
return
MadDecoderAction
::
OK
;
}
/* xing stuff stolen from alsaplayer, and heavily modified by jat */
...
...
@@ -699,20 +699,20 @@ MadDecoder::DecodeFirstFrame(Tag *tag)
struct
xing
xing
;
while
(
true
)
{
enum
mp3_a
ction
ret
;
MadDecoderA
ction
ret
;
do
{
ret
=
DecodeNextFrameHeader
(
tag
);
}
while
(
ret
==
DECODE_
CONT
);
if
(
ret
==
DECODE_
BREAK
)
}
while
(
ret
==
MadDecoderAction
::
CONT
);
if
(
ret
==
MadDecoderAction
::
BREAK
)
return
false
;
if
(
ret
==
DECODE_
SKIP
)
continue
;
if
(
ret
==
MadDecoderAction
::
SKIP
)
continue
;
do
{
ret
=
DecodeNextFrame
();
}
while
(
ret
==
DECODE_
CONT
);
if
(
ret
==
DECODE_
BREAK
)
}
while
(
ret
==
MadDecoderAction
::
CONT
);
if
(
ret
==
MadDecoderAction
::
BREAK
)
return
false
;
if
(
ret
==
DECODE_
OK
)
break
;
if
(
ret
==
MadDecoderAction
::
OK
)
break
;
}
struct
mad_bitptr
ptr
=
stream
.
anc_ptr
;
...
...
@@ -724,7 +724,7 @@ MadDecoder::DecodeFirstFrame(Tag *tag)
* if an xing tag exists, use that!
*/
if
(
parse_xing
(
&
xing
,
&
ptr
,
&
bitlen
))
{
mute_frame
=
M
UTEFRAME_
SKIP
;
mute_frame
=
M
adDecoderMuteFrame
::
SKIP
;
if
((
xing
.
flags
&
XING_FRAMES
)
&&
xing
.
frames
)
{
mad_timer_t
duration
=
frame
.
header
.
duration
;
...
...
@@ -906,14 +906,14 @@ MadDecoder::Read()
switch
(
mute_frame
)
{
DecoderCommand
cmd
;
case
M
UTEFRAME_
SKIP
:
mute_frame
=
M
UTEFRAME_
NONE
;
case
M
adDecoderMuteFrame
:
:
SKIP
:
mute_frame
=
M
adDecoderMuteFrame
::
NONE
;
break
;
case
M
UTEFRAME_
SEEK
:
case
M
adDecoderMuteFrame
:
:
SEEK
:
if
(
elapsed_time
>=
seek_time
)
mute_frame
=
M
UTEFRAME_
NONE
;
mute_frame
=
M
adDecoderMuteFrame
::
NONE
;
break
;
case
M
UTEFRAME_
NONE
:
case
M
adDecoderMuteFrame
:
:
NONE
:
cmd
=
SyncAndSend
();
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
assert
(
input_stream
.
IsSeekable
());
...
...
@@ -928,7 +928,7 @@ MadDecoder::Read()
client
->
SeekError
();
}
else
{
seek_time
=
t
;
mute_frame
=
M
UTEFRAME_
SEEK
;
mute_frame
=
M
adDecoderMuteFrame
::
SEEK
;
client
->
CommandFinished
();
}
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
...
...
@@ -936,7 +936,7 @@ MadDecoder::Read()
}
while
(
true
)
{
enum
mp3_a
ction
ret
;
MadDecoderA
ction
ret
;
do
{
Tag
tag
;
...
...
@@ -945,21 +945,21 @@ MadDecoder::Read()
if
(
!
tag
.
IsEmpty
())
client
->
SubmitTag
(
input_stream
,
std
::
move
(
tag
));
}
while
(
ret
==
DECODE_
CONT
);
if
(
ret
==
DECODE_
BREAK
)
}
while
(
ret
==
MadDecoderAction
::
CONT
);
if
(
ret
==
MadDecoderAction
::
BREAK
)
return
false
;
const
bool
skip
=
ret
==
DECODE_
SKIP
;
const
bool
skip
=
ret
==
MadDecoderAction
::
SKIP
;
if
(
mute_frame
==
M
UTEFRAME_
NONE
)
{
if
(
mute_frame
==
M
adDecoderMuteFrame
::
NONE
)
{
do
{
ret
=
DecodeNextFrame
();
}
while
(
ret
==
DECODE_
CONT
);
if
(
ret
==
DECODE_
BREAK
)
}
while
(
ret
==
MadDecoderAction
::
CONT
);
if
(
ret
==
MadDecoderAction
::
BREAK
)
return
false
;
}
if
(
!
skip
&&
ret
==
DECODE_
OK
)
if
(
!
skip
&&
ret
==
MadDecoderAction
::
OK
)
return
true
;
}
}
...
...
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