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
c5d05ac0
Commit
c5d05ac0
authored
Sep 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderCommand: convert to strictly-typed enum
parent
939003c1
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
219 additions
and
223 deletions
+219
-223
DecoderAPI.cxx
src/DecoderAPI.cxx
+25
-25
DecoderAPI.hxx
src/DecoderAPI.hxx
+7
-7
DecoderCommand.hxx
src/DecoderCommand.hxx
+7
-5
DecoderControl.cxx
src/DecoderControl.cxx
+7
-7
DecoderControl.hxx
src/DecoderControl.hxx
+8
-8
DecoderInternal.cxx
src/DecoderInternal.cxx
+6
-6
DecoderThread.cxx
src/DecoderThread.cxx
+12
-12
AdPlugDecoderPlugin.cxx
src/decoder/AdPlugDecoderPlugin.cxx
+2
-2
AudiofileDecoderPlugin.cxx
src/decoder/AudiofileDecoderPlugin.cxx
+4
-4
DsdiffDecoderPlugin.cxx
src/decoder/DsdiffDecoderPlugin.cxx
+5
-6
DsfDecoderPlugin.cxx
src/decoder/DsfDecoderPlugin.cxx
+5
-6
FaadDecoderPlugin.cxx
src/decoder/FaadDecoderPlugin.cxx
+3
-3
FfmpegDecoderPlugin.cxx
src/decoder/FfmpegDecoderPlugin.cxx
+6
-7
FlacCommon.cxx
src/decoder/FlacCommon.cxx
+7
-8
FlacDecoderPlugin.cxx
src/decoder/FlacDecoderPlugin.cxx
+4
-4
FlacInput.cxx
src/decoder/FlacInput.cxx
+4
-4
FluidsynthDecoderPlugin.cxx
src/decoder/FluidsynthDecoderPlugin.cxx
+2
-2
GmeDecoderPlugin.cxx
src/decoder/GmeDecoderPlugin.cxx
+3
-3
MadDecoderPlugin.cxx
src/decoder/MadDecoderPlugin.cxx
+20
-20
MikmodDecoderPlugin.cxx
src/decoder/MikmodDecoderPlugin.cxx
+3
-2
ModplugDecoderPlugin.cxx
src/decoder/ModplugDecoderPlugin.cxx
+3
-3
MpcdecDecoderPlugin.cxx
src/decoder/MpcdecDecoderPlugin.cxx
+4
-4
Mpg123DecoderPlugin.cxx
src/decoder/Mpg123DecoderPlugin.cxx
+4
-4
OpusDecoderPlugin.cxx
src/decoder/OpusDecoderPlugin.cxx
+27
-28
PcmDecoderPlugin.cxx
src/decoder/PcmDecoderPlugin.cxx
+4
-5
SndfileDecoderPlugin.cxx
src/decoder/SndfileDecoderPlugin.cxx
+4
-4
VorbisDecoderPlugin.cxx
src/decoder/VorbisDecoderPlugin.cxx
+5
-6
WavpackDecoderPlugin.cxx
src/decoder/WavpackDecoderPlugin.cxx
+3
-3
WildmidiDecoderPlugin.cxx
src/decoder/WildmidiDecoderPlugin.cxx
+4
-4
sidplay_decoder_plugin.cxx
src/decoder/sidplay_decoder_plugin.cxx
+3
-3
dump_playlist.cxx
test/dump_playlist.cxx
+6
-6
read_tags.cxx
test/read_tags.cxx
+6
-6
run_decoder.cxx
test/run_decoder.cxx
+6
-6
No files found.
src/DecoderAPI.cxx
View file @
c5d05ac0
...
@@ -106,7 +106,7 @@ decoder_prepare_initial_seek(struct decoder *decoder)
...
@@ -106,7 +106,7 @@ decoder_prepare_initial_seek(struct decoder *decoder)
return
false
;
return
false
;
}
}
if
(
dc
->
command
==
D
ECODE_COMMAND_
NONE
)
{
if
(
dc
->
command
==
D
ecoderCommand
::
NONE
)
{
/* begin initial seek */
/* begin initial seek */
decoder
->
initial_seek_pending
=
false
;
decoder
->
initial_seek_pending
=
false
;
...
@@ -129,19 +129,19 @@ decoder_prepare_initial_seek(struct decoder *decoder)
...
@@ -129,19 +129,19 @@ decoder_prepare_initial_seek(struct decoder *decoder)
* track.
* track.
*/
*/
gcc_pure
gcc_pure
static
enum
decoder_c
ommand
static
DecoderC
ommand
decoder_get_virtual_command
(
struct
decoder
*
decoder
)
decoder_get_virtual_command
(
struct
decoder
*
decoder
)
{
{
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
assert
(
dc
->
pipe
!=
NULL
);
assert
(
dc
->
pipe
!=
NULL
);
if
(
decoder_prepare_initial_seek
(
decoder
))
if
(
decoder_prepare_initial_seek
(
decoder
))
return
D
ECODE_COMMAND_
SEEK
;
return
D
ecoderCommand
::
SEEK
;
return
dc
->
command
;
return
dc
->
command
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_get_command
(
struct
decoder
*
decoder
)
decoder_get_command
(
struct
decoder
*
decoder
)
{
{
return
decoder_get_virtual_command
(
decoder
);
return
decoder_get_virtual_command
(
decoder
);
...
@@ -154,9 +154,9 @@ decoder_command_finished(struct decoder *decoder)
...
@@ -154,9 +154,9 @@ decoder_command_finished(struct decoder *decoder)
dc
->
Lock
();
dc
->
Lock
();
assert
(
dc
->
command
!=
D
ECODE_COMMAND_
NONE
||
assert
(
dc
->
command
!=
D
ecoderCommand
::
NONE
||
decoder
->
initial_seek_running
);
decoder
->
initial_seek_running
);
assert
(
dc
->
command
!=
D
ECODE_COMMAND_
SEEK
||
assert
(
dc
->
command
!=
D
ecoderCommand
::
SEEK
||
decoder
->
initial_seek_running
||
decoder
->
initial_seek_running
||
dc
->
seek_error
||
decoder
->
seeking
);
dc
->
seek_error
||
decoder
->
seeking
);
assert
(
dc
->
pipe
!=
NULL
);
assert
(
dc
->
pipe
!=
NULL
);
...
@@ -187,7 +187,7 @@ decoder_command_finished(struct decoder *decoder)
...
@@ -187,7 +187,7 @@ decoder_command_finished(struct decoder *decoder)
decoder
->
timestamp
=
dc
->
seek_where
;
decoder
->
timestamp
=
dc
->
seek_where
;
}
}
dc
->
command
=
D
ECODE_COMMAND_
NONE
;
dc
->
command
=
D
ecoderCommand
::
NONE
;
dc
->
client_cond
.
signal
();
dc
->
client_cond
.
signal
();
dc
->
Unlock
();
dc
->
Unlock
();
}
}
...
@@ -201,7 +201,7 @@ double decoder_seek_where(gcc_unused struct decoder * decoder)
...
@@ -201,7 +201,7 @@ double decoder_seek_where(gcc_unused struct decoder * decoder)
if
(
decoder
->
initial_seek_running
)
if
(
decoder
->
initial_seek_running
)
return
dc
->
start_ms
/
1000.
;
return
dc
->
start_ms
/
1000.
;
assert
(
dc
->
command
==
D
ECODE_COMMAND_
SEEK
);
assert
(
dc
->
command
==
D
ecoderCommand
::
SEEK
);
decoder
->
seeking
=
true
;
decoder
->
seeking
=
true
;
...
@@ -221,7 +221,7 @@ void decoder_seek_error(struct decoder * decoder)
...
@@ -221,7 +221,7 @@ void decoder_seek_error(struct decoder * decoder)
return
;
return
;
}
}
assert
(
dc
->
command
==
D
ECODE_COMMAND_
SEEK
);
assert
(
dc
->
command
==
D
ecoderCommand
::
SEEK
);
dc
->
seek_error
=
true
;
dc
->
seek_error
=
true
;
decoder
->
seeking
=
false
;
decoder
->
seeking
=
false
;
...
@@ -241,12 +241,12 @@ decoder_check_cancel_read(const struct decoder *decoder)
...
@@ -241,12 +241,12 @@ decoder_check_cancel_read(const struct decoder *decoder)
return
false
;
return
false
;
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
if
(
dc
->
command
==
D
ECODE_COMMAND_
NONE
)
if
(
dc
->
command
==
D
ecoderCommand
::
NONE
)
return
false
;
return
false
;
/* ignore the SEEK command during initialization, the plugin
/* ignore the SEEK command during initialization, the plugin
should handle that after it has initialized successfully */
should handle that after it has initialized successfully */
if
(
dc
->
command
==
D
ECODE_COMMAND_
SEEK
&&
if
(
dc
->
command
==
D
ecoderCommand
::
SEEK
&&
(
dc
->
state
==
DECODE_STATE_START
||
decoder
->
seeking
))
(
dc
->
state
==
DECODE_STATE_START
||
decoder
->
seeking
))
return
false
;
return
false
;
...
@@ -308,7 +308,7 @@ decoder_timestamp(struct decoder *decoder, double t)
...
@@ -308,7 +308,7 @@ decoder_timestamp(struct decoder *decoder, double t)
* Sends a #tag as-is to the music pipe. Flushes the current chunk
* Sends a #tag as-is to the music pipe. Flushes the current chunk
* (decoder.chunk) if there is one.
* (decoder.chunk) if there is one.
*/
*/
static
enum
decoder_c
ommand
static
DecoderC
ommand
do_send_tag
(
struct
decoder
*
decoder
,
const
Tag
&
tag
)
do_send_tag
(
struct
decoder
*
decoder
,
const
Tag
&
tag
)
{
{
struct
music_chunk
*
chunk
;
struct
music_chunk
*
chunk
;
...
@@ -324,12 +324,12 @@ do_send_tag(struct decoder *decoder, const Tag &tag)
...
@@ -324,12 +324,12 @@ do_send_tag(struct decoder *decoder, const Tag &tag)
chunk
=
decoder_get_chunk
(
decoder
);
chunk
=
decoder_get_chunk
(
decoder
);
if
(
chunk
==
NULL
)
{
if
(
chunk
==
NULL
)
{
assert
(
decoder
->
dc
->
command
!=
D
ECODE_COMMAND_
NONE
);
assert
(
decoder
->
dc
->
command
!=
D
ecoderCommand
::
NONE
);
return
decoder
->
dc
->
command
;
return
decoder
->
dc
->
command
;
}
}
chunk
->
tag
=
new
Tag
(
tag
);
chunk
->
tag
=
new
Tag
(
tag
);
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
static
bool
static
bool
...
@@ -355,14 +355,14 @@ update_stream_tag(struct decoder *decoder, struct input_stream *is)
...
@@ -355,14 +355,14 @@ update_stream_tag(struct decoder *decoder, struct input_stream *is)
return
true
;
return
true
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_data
(
struct
decoder
*
decoder
,
decoder_data
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
struct
input_stream
*
is
,
const
void
*
data
,
size_t
length
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
uint16_t
kbit_rate
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
struct
decoder_control
*
dc
=
decoder
->
dc
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
assert
(
dc
->
state
==
DECODE_STATE_DECODE
);
assert
(
dc
->
state
==
DECODE_STATE_DECODE
);
assert
(
dc
->
pipe
!=
NULL
);
assert
(
dc
->
pipe
!=
NULL
);
...
@@ -372,7 +372,7 @@ decoder_data(struct decoder *decoder,
...
@@ -372,7 +372,7 @@ decoder_data(struct decoder *decoder,
cmd
=
decoder_get_virtual_command
(
decoder
);
cmd
=
decoder_get_virtual_command
(
decoder
);
dc
->
Unlock
();
dc
->
Unlock
();
if
(
cmd
==
D
ECODE_COMMAND_STOP
||
cmd
==
DECODE_COMMAND_
SEEK
||
if
(
cmd
==
D
ecoderCommand
::
STOP
||
cmd
==
DecoderCommand
::
SEEK
||
length
==
0
)
length
==
0
)
return
cmd
;
return
cmd
;
...
@@ -389,7 +389,7 @@ decoder_data(struct decoder *decoder,
...
@@ -389,7 +389,7 @@ decoder_data(struct decoder *decoder,
/* send only the stream tag */
/* send only the stream tag */
cmd
=
do_send_tag
(
decoder
,
*
decoder
->
stream_tag
);
cmd
=
do_send_tag
(
decoder
,
*
decoder
->
stream_tag
);
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
return
cmd
;
return
cmd
;
}
}
...
@@ -405,7 +405,7 @@ decoder_data(struct decoder *decoder,
...
@@ -405,7 +405,7 @@ decoder_data(struct decoder *decoder,
playback, since we have no better way to
playback, since we have no better way to
bail out */
bail out */
g_warning
(
"%s"
,
error
.
GetMessage
());
g_warning
(
"%s"
,
error
.
GetMessage
());
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
}
}
}
}
...
@@ -416,7 +416,7 @@ decoder_data(struct decoder *decoder,
...
@@ -416,7 +416,7 @@ decoder_data(struct decoder *decoder,
chunk
=
decoder_get_chunk
(
decoder
);
chunk
=
decoder_get_chunk
(
decoder
);
if
(
chunk
==
NULL
)
{
if
(
chunk
==
NULL
)
{
assert
(
dc
->
command
!=
D
ECODE_COMMAND_
NONE
);
assert
(
dc
->
command
!=
D
ecoderCommand
::
NONE
);
return
dc
->
command
;
return
dc
->
command
;
}
}
...
@@ -459,18 +459,18 @@ decoder_data(struct decoder *decoder,
...
@@ -459,18 +459,18 @@ decoder_data(struct decoder *decoder,
decoder
->
timestamp
>=
dc
->
end_ms
/
1000.0
)
decoder
->
timestamp
>=
dc
->
end_ms
/
1000.0
)
/* the end of this range has been reached:
/* the end of this range has been reached:
stop decoding */
stop decoding */
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
}
}
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
Tag
&&
tag
)
Tag
&&
tag
)
{
{
gcc_unused
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
gcc_unused
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
assert
(
dc
->
state
==
DECODE_STATE_DECODE
);
assert
(
dc
->
state
==
DECODE_STATE_DECODE
);
assert
(
dc
->
pipe
!=
NULL
);
assert
(
dc
->
pipe
!=
NULL
);
...
@@ -490,7 +490,7 @@ decoder_tag(gcc_unused struct decoder *decoder, struct input_stream *is,
...
@@ -490,7 +490,7 @@ decoder_tag(gcc_unused struct decoder *decoder, struct input_stream *is,
/* during initial seek, no music chunk must be created
/* during initial seek, no music chunk must be created
until seeking is finished; skip the rest of the
until seeking is finished; skip the rest of the
function here */
function here */
return
D
ECODE_COMMAND_
SEEK
;
return
D
ecoderCommand
::
SEEK
;
/* send tag to music pipe */
/* send tag to music pipe */
...
...
src/DecoderAPI.hxx
View file @
c5d05ac0
...
@@ -54,10 +54,10 @@ decoder_initialized(struct decoder *decoder,
...
@@ -54,10 +54,10 @@ decoder_initialized(struct decoder *decoder,
* Determines the pending decoder command.
* Determines the pending decoder command.
*
*
* @param decoder the decoder object
* @param decoder the decoder object
* @return the current command, or D
ECODE_COMMAND_
NONE if there is no
* @return the current command, or D
ecoderCommand::
NONE if there is no
* command pending
* command pending
*/
*/
enum
decoder_c
ommand
DecoderC
ommand
decoder_get_command
(
struct
decoder
*
decoder
);
decoder_get_command
(
struct
decoder
*
decoder
);
/**
/**
...
@@ -71,7 +71,7 @@ void
...
@@ -71,7 +71,7 @@ void
decoder_command_finished
(
struct
decoder
*
decoder
);
decoder_command_finished
(
struct
decoder
*
decoder
);
/**
/**
* Call this when you have received the D
ECODE_COMMAND_
SEEK command.
* Call this when you have received the D
ecoderCommand::
SEEK command.
*
*
* @param decoder the decoder object
* @param decoder the decoder object
* @return the destination position for the week
* @return the destination position for the week
...
@@ -120,10 +120,10 @@ decoder_timestamp(struct decoder *decoder, double t);
...
@@ -120,10 +120,10 @@ decoder_timestamp(struct decoder *decoder, double t);
* for the player
* for the player
* @param data the source buffer
* @param data the source buffer
* @param length the number of bytes in the buffer
* @param length the number of bytes in the buffer
* @return the current command, or D
ECODE_COMMAND_
NONE if there is no
* @return the current command, or D
ecoderCommand::
NONE if there is no
* command pending
* command pending
*/
*/
enum
decoder_c
ommand
DecoderC
ommand
decoder_data
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
decoder_data
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
const
void
*
data
,
size_t
length
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
);
uint16_t
kbit_rate
);
...
@@ -136,10 +136,10 @@ decoder_data(struct decoder *decoder, struct input_stream *is,
...
@@ -136,10 +136,10 @@ decoder_data(struct decoder *decoder, struct input_stream *is,
* @param is an input stream which is buffering while we are waiting
* @param is an input stream which is buffering while we are waiting
* for the player
* for the player
* @param tag the tag to send
* @param tag the tag to send
* @return the current command, or D
ECODE_COMMAND_
NONE if there is no
* @return the current command, or D
ecoderCommand::
NONE if there is no
* command pending
* command pending
*/
*/
enum
decoder_c
ommand
DecoderC
ommand
decoder_tag
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
Tag
&&
tag
);
decoder_tag
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
Tag
&&
tag
);
/**
/**
...
...
src/DecoderCommand.hxx
View file @
c5d05ac0
...
@@ -20,11 +20,13 @@
...
@@ -20,11 +20,13 @@
#ifndef MPD_DECODER_COMMAND_HXX
#ifndef MPD_DECODER_COMMAND_HXX
#define MPD_DECODER_COMMAND_HXX
#define MPD_DECODER_COMMAND_HXX
enum
decoder_command
{
#include <stdint.h>
DECODE_COMMAND_NONE
=
0
,
DECODE_COMMAND_START
,
enum
class
DecoderCommand
:
uint8_t
{
DECODE_COMMAND_STOP
,
NONE
=
0
,
DECODE_COMMAND_SEEK
START
,
STOP
,
SEEK
};
};
#endif
#endif
src/DecoderControl.cxx
View file @
c5d05ac0
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
decoder_control
::
decoder_control
()
decoder_control
::
decoder_control
()
:
thread
(
nullptr
),
:
thread
(
nullptr
),
state
(
DECODE_STATE_STOP
),
state
(
DECODE_STATE_STOP
),
command
(
D
ECODE_COMMAND_
NONE
),
command
(
D
ecoderCommand
::
NONE
),
song
(
nullptr
),
song
(
nullptr
),
replay_gain_db
(
0
),
replay_gain_prev_db
(
0
),
replay_gain_db
(
0
),
replay_gain_prev_db
(
0
),
mixramp_start
(
nullptr
),
mixramp_end
(
nullptr
),
mixramp_start
(
nullptr
),
mixramp_end
(
nullptr
),
...
@@ -84,7 +84,7 @@ decoder_control::Start(Song *_song,
...
@@ -84,7 +84,7 @@ decoder_control::Start(Song *_song,
buffer
=
&
_buffer
;
buffer
=
&
_buffer
;
pipe
=
&
_pipe
;
pipe
=
&
_pipe
;
LockSynchronousCommand
(
D
ECODE_COMMAND_
START
);
LockSynchronousCommand
(
D
ecoderCommand
::
START
);
}
}
void
void
...
@@ -92,15 +92,15 @@ decoder_control::Stop()
...
@@ -92,15 +92,15 @@ decoder_control::Stop()
{
{
Lock
();
Lock
();
if
(
command
!=
D
ECODE_COMMAND_
NONE
)
if
(
command
!=
D
ecoderCommand
::
NONE
)
/* Attempt to cancel the current command. If it's too
/* Attempt to cancel the current command. If it's too
late and the decoder thread is already executing
late and the decoder thread is already executing
the old command, we'll call STOP again in this
the old command, we'll call STOP again in this
function (see below). */
function (see below). */
SynchronousCommandLocked
(
D
ECODE_COMMAND_
STOP
);
SynchronousCommandLocked
(
D
ecoderCommand
::
STOP
);
if
(
state
!=
DECODE_STATE_STOP
&&
state
!=
DECODE_STATE_ERROR
)
if
(
state
!=
DECODE_STATE_STOP
&&
state
!=
DECODE_STATE_ERROR
)
SynchronousCommandLocked
(
D
ECODE_COMMAND_
STOP
);
SynchronousCommandLocked
(
D
ecoderCommand
::
STOP
);
Unlock
();
Unlock
();
}
}
...
@@ -117,7 +117,7 @@ decoder_control::Seek(double where)
...
@@ -117,7 +117,7 @@ decoder_control::Seek(double where)
seek_where
=
where
;
seek_where
=
where
;
seek_error
=
false
;
seek_error
=
false
;
SynchronousCommandLocked
(
D
ECODE_COMMAND_
SEEK
);
SynchronousCommandLocked
(
D
ecoderCommand
::
SEEK
);
return
!
seek_error
;
return
!
seek_error
;
}
}
...
@@ -128,7 +128,7 @@ decoder_control::Quit()
...
@@ -128,7 +128,7 @@ decoder_control::Quit()
assert
(
thread
!=
nullptr
);
assert
(
thread
!=
nullptr
);
quit
=
true
;
quit
=
true
;
LockAsynchronousCommand
(
D
ECODE_COMMAND_
STOP
);
LockAsynchronousCommand
(
D
ecoderCommand
::
STOP
);
g_thread_join
(
thread
);
g_thread_join
(
thread
);
thread
=
nullptr
;
thread
=
nullptr
;
...
...
src/DecoderControl.hxx
View file @
c5d05ac0
...
@@ -72,7 +72,7 @@ struct decoder_control {
...
@@ -72,7 +72,7 @@ struct decoder_control {
Cond
client_cond
;
Cond
client_cond
;
enum
decoder_state
state
;
enum
decoder_state
state
;
enum
decoder_c
ommand
command
;
DecoderC
ommand
command
;
/**
/**
* The error that occurred in the decoder thread. This
* The error that occurred in the decoder thread. This
...
@@ -95,7 +95,7 @@ struct decoder_control {
...
@@ -95,7 +95,7 @@ struct decoder_control {
/**
/**
* The song currently being decoded. This attribute is set by
* The song currently being decoded. This attribute is set by
* the player thread, when it sends the #D
ECODE_COMMAND_
START
* the player thread, when it sends the #D
ecoderCommand::
START
* command.
* command.
*
*
* This is a duplicate, and must be freed when this attribute
* This is a duplicate, and must be freed when this attribute
...
@@ -207,7 +207,7 @@ struct decoder_control {
...
@@ -207,7 +207,7 @@ struct decoder_control {
}
}
bool
HasFailed
()
const
{
bool
HasFailed
()
const
{
assert
(
command
==
D
ECODE_COMMAND_
NONE
);
assert
(
command
==
D
ecoderCommand
::
NONE
);
return
state
==
DECODE_STATE_ERROR
;
return
state
==
DECODE_STATE_ERROR
;
}
}
...
@@ -228,7 +228,7 @@ struct decoder_control {
...
@@ -228,7 +228,7 @@ struct decoder_control {
*/
*/
gcc_pure
gcc_pure
Error
GetError
()
const
{
Error
GetError
()
const
{
assert
(
command
==
D
ECODE_COMMAND_
NONE
);
assert
(
command
==
D
ecoderCommand
::
NONE
);
assert
(
state
!=
DECODE_STATE_ERROR
||
error
.
IsDefined
());
assert
(
state
!=
DECODE_STATE_ERROR
||
error
.
IsDefined
());
Error
result
;
Error
result
;
...
@@ -286,7 +286,7 @@ private:
...
@@ -286,7 +286,7 @@ private:
* object.
* object.
*/
*/
void
WaitCommandLocked
()
{
void
WaitCommandLocked
()
{
while
(
command
!=
D
ECODE_COMMAND_
NONE
)
while
(
command
!=
D
ecoderCommand
::
NONE
)
WaitForDecoder
();
WaitForDecoder
();
}
}
...
@@ -297,7 +297,7 @@ private:
...
@@ -297,7 +297,7 @@ private:
* To be called from the client thread. Caller must lock the
* To be called from the client thread. Caller must lock the
* object.
* object.
*/
*/
void
SynchronousCommandLocked
(
decoder_c
ommand
cmd
)
{
void
SynchronousCommandLocked
(
DecoderC
ommand
cmd
)
{
command
=
cmd
;
command
=
cmd
;
Signal
();
Signal
();
WaitCommandLocked
();
WaitCommandLocked
();
...
@@ -310,14 +310,14 @@ private:
...
@@ -310,14 +310,14 @@ private:
* To be called from the client thread. This method locks the
* To be called from the client thread. This method locks the
* object.
* object.
*/
*/
void
LockSynchronousCommand
(
decoder_c
ommand
cmd
)
{
void
LockSynchronousCommand
(
DecoderC
ommand
cmd
)
{
Lock
();
Lock
();
ClearError
();
ClearError
();
SynchronousCommandLocked
(
cmd
);
SynchronousCommandLocked
(
cmd
);
Unlock
();
Unlock
();
}
}
void
LockAsynchronousCommand
(
decoder_c
ommand
cmd
)
{
void
LockAsynchronousCommand
(
DecoderC
ommand
cmd
)
{
Lock
();
Lock
();
command
=
cmd
;
command
=
cmd
;
Signal
();
Signal
();
...
...
src/DecoderInternal.cxx
View file @
c5d05ac0
...
@@ -41,11 +41,11 @@ decoder::~decoder()
...
@@ -41,11 +41,11 @@ decoder::~decoder()
* All chunks are full of decoded data; wait for the player to free
* All chunks are full of decoded data; wait for the player to free
* one.
* one.
*/
*/
static
enum
decoder_c
ommand
static
DecoderC
ommand
need_chunks
(
struct
decoder_control
*
dc
,
bool
do_wait
)
need_chunks
(
struct
decoder_control
*
dc
,
bool
do_wait
)
{
{
if
(
dc
->
command
==
D
ECODE_COMMAND_
STOP
||
if
(
dc
->
command
==
D
ecoderCommand
::
STOP
||
dc
->
command
==
D
ECODE_COMMAND_
SEEK
)
dc
->
command
==
D
ecoderCommand
::
SEEK
)
return
dc
->
command
;
return
dc
->
command
;
if
(
do_wait
)
{
if
(
do_wait
)
{
...
@@ -55,14 +55,14 @@ need_chunks(struct decoder_control *dc, bool do_wait)
...
@@ -55,14 +55,14 @@ need_chunks(struct decoder_control *dc, bool do_wait)
return
dc
->
command
;
return
dc
->
command
;
}
}
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
struct
music_chunk
*
struct
music_chunk
*
decoder_get_chunk
(
struct
decoder
*
decoder
)
decoder_get_chunk
(
struct
decoder
*
decoder
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
struct
decoder_control
*
dc
=
decoder
->
dc
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
assert
(
decoder
!=
NULL
);
assert
(
decoder
!=
NULL
);
...
@@ -84,7 +84,7 @@ decoder_get_chunk(struct decoder *decoder)
...
@@ -84,7 +84,7 @@ decoder_get_chunk(struct decoder *decoder)
dc
->
Lock
();
dc
->
Lock
();
cmd
=
need_chunks
(
dc
,
true
);
cmd
=
need_chunks
(
dc
,
true
);
dc
->
Unlock
();
dc
->
Unlock
();
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
return
NULL
;
return
NULL
;
}
}
...
...
src/DecoderThread.cxx
View file @
c5d05ac0
...
@@ -52,9 +52,9 @@
...
@@ -52,9 +52,9 @@
static
void
static
void
decoder_command_finished_locked
(
struct
decoder_control
*
dc
)
decoder_command_finished_locked
(
struct
decoder_control
*
dc
)
{
{
assert
(
dc
->
command
!=
D
ECODE_COMMAND_
NONE
);
assert
(
dc
->
command
!=
D
ecoderCommand
::
NONE
);
dc
->
command
=
D
ECODE_COMMAND_
NONE
;
dc
->
command
=
D
ecoderCommand
::
NONE
;
dc
->
client_cond
.
signal
();
dc
->
client_cond
.
signal
();
}
}
...
@@ -67,7 +67,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
...
@@ -67,7 +67,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
*
*
* Unlock the decoder before calling this function.
* Unlock the decoder before calling this function.
*
*
* @return an input_stream on success or if #D
ECODE_COMMAND_
STOP is
* @return an input_stream on success or if #D
ecoderCommand::
STOP is
* received, NULL on error
* received, NULL on error
*/
*/
static
struct
input_stream
*
static
struct
input_stream
*
...
@@ -90,7 +90,7 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
...
@@ -90,7 +90,7 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
is
->
Update
();
is
->
Update
();
while
(
!
is
->
ready
&&
while
(
!
is
->
ready
&&
dc
->
command
!=
D
ECODE_COMMAND_
STOP
)
{
dc
->
command
!=
D
ecoderCommand
::
STOP
)
{
dc
->
Wait
();
dc
->
Wait
();
is
->
Update
();
is
->
Update
();
...
@@ -124,7 +124,7 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
...
@@ -124,7 +124,7 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
g_debug
(
"probing plugin %s"
,
plugin
->
name
);
g_debug
(
"probing plugin %s"
,
plugin
->
name
);
if
(
decoder
->
dc
->
command
==
D
ECODE_COMMAND_
STOP
)
if
(
decoder
->
dc
->
command
==
D
ecoderCommand
::
STOP
)
return
true
;
return
true
;
/* rewind the stream, so each plugin gets a fresh start */
/* rewind the stream, so each plugin gets a fresh start */
...
@@ -157,7 +157,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
...
@@ -157,7 +157,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
g_debug
(
"probing plugin %s"
,
plugin
->
name
);
g_debug
(
"probing plugin %s"
,
plugin
->
name
);
if
(
decoder
->
dc
->
command
==
D
ECODE_COMMAND_
STOP
)
if
(
decoder
->
dc
->
command
==
D
ecoderCommand
::
STOP
)
return
true
;
return
true
;
decoder
->
dc
->
Unlock
();
decoder
->
dc
->
Unlock
();
...
@@ -286,7 +286,7 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
...
@@ -286,7 +286,7 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
GSList
*
tried
=
NULL
;
GSList
*
tried
=
NULL
;
success
=
dc
->
command
==
D
ECODE_COMMAND_
STOP
||
success
=
dc
->
command
==
D
ecoderCommand
::
STOP
||
/* first we try mime types: */
/* first we try mime types: */
decoder_run_stream_mime_type
(
decoder
,
input_stream
,
&
tried
)
||
decoder_run_stream_mime_type
(
decoder
,
input_stream
,
&
tried
)
||
/* if that fails, try suffix matching the URL: */
/* if that fails, try suffix matching the URL: */
...
@@ -455,7 +455,7 @@ decoder_task(gpointer arg)
...
@@ -455,7 +455,7 @@ decoder_task(gpointer arg)
dc
->
state
==
DECODE_STATE_ERROR
);
dc
->
state
==
DECODE_STATE_ERROR
);
switch
(
dc
->
command
)
{
switch
(
dc
->
command
)
{
case
D
ECODE_COMMAND_
START
:
case
D
ecoderCommand
:
:
START
:
dc
->
MixRampStart
(
nullptr
);
dc
->
MixRampStart
(
nullptr
);
dc
->
MixRampPrevEnd
(
dc
->
mixramp_end
);
dc
->
MixRampPrevEnd
(
dc
->
mixramp_end
);
dc
->
mixramp_end
=
NULL
;
/* Don't free, it's copied above. */
dc
->
mixramp_end
=
NULL
;
/* Don't free, it's copied above. */
...
@@ -464,19 +464,19 @@ decoder_task(gpointer arg)
...
@@ -464,19 +464,19 @@ decoder_task(gpointer arg)
/* fall through */
/* fall through */
case
D
ECODE_COMMAND_
SEEK
:
case
D
ecoderCommand
:
:
SEEK
:
decoder_run
(
dc
);
decoder_run
(
dc
);
break
;
break
;
case
D
ECODE_COMMAND_
STOP
:
case
D
ecoderCommand
:
:
STOP
:
decoder_command_finished_locked
(
dc
);
decoder_command_finished_locked
(
dc
);
break
;
break
;
case
D
ECODE_COMMAND_
NONE
:
case
D
ecoderCommand
:
:
NONE
:
dc
->
Wait
();
dc
->
Wait
();
break
;
break
;
}
}
}
while
(
dc
->
command
!=
D
ECODE_COMMAND_
NONE
||
!
dc
->
quit
);
}
while
(
dc
->
command
!=
D
ecoderCommand
::
NONE
||
!
dc
->
quit
);
dc
->
Unlock
();
dc
->
Unlock
();
...
...
src/decoder/AdPlugDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -68,7 +68,7 @@ adplug_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -68,7 +68,7 @@ adplug_file_decode(struct decoder *decoder, const char *path_fs)
int16_t
buffer
[
2048
];
int16_t
buffer
[
2048
];
const
unsigned
frames_per_buffer
=
G_N_ELEMENTS
(
buffer
)
/
2
;
const
unsigned
frames_per_buffer
=
G_N_ELEMENTS
(
buffer
)
/
2
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
do
{
do
{
if
(
!
player
->
update
())
if
(
!
player
->
update
())
...
@@ -78,7 +78,7 @@ adplug_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -78,7 +78,7 @@ adplug_file_decode(struct decoder *decoder, const char *path_fs)
cmd
=
decoder_data
(
decoder
,
NULL
,
cmd
=
decoder_data
(
decoder
,
NULL
,
buffer
,
sizeof
(
buffer
),
buffer
,
sizeof
(
buffer
),
0
);
0
);
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
delete
player
;
delete
player
;
}
}
...
...
src/decoder/AudiofileDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -166,7 +166,6 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -166,7 +166,6 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
uint16_t
bit_rate
;
uint16_t
bit_rate
;
int
ret
;
int
ret
;
char
chunk
[
CHUNK_SIZE
];
char
chunk
[
CHUNK_SIZE
];
enum
decoder_command
cmd
;
if
(
!
is
->
IsSeekable
())
{
if
(
!
is
->
IsSeekable
())
{
g_warning
(
"not seekable"
);
g_warning
(
"not seekable"
);
...
@@ -202,6 +201,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -202,6 +201,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_initialized
(
decoder
,
audio_format
,
true
,
total_time
);
decoder_initialized
(
decoder
,
audio_format
,
true
,
total_time
);
DecoderCommand
cmd
;
do
{
do
{
ret
=
afReadFrames
(
af_fp
,
AF_DEFAULT_TRACK
,
chunk
,
ret
=
afReadFrames
(
af_fp
,
AF_DEFAULT_TRACK
,
chunk
,
CHUNK_SIZE
/
fs
);
CHUNK_SIZE
/
fs
);
...
@@ -212,15 +212,15 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -212,15 +212,15 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
chunk
,
ret
*
fs
,
chunk
,
ret
*
fs
,
bit_rate
);
bit_rate
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
AFframecount
frame
=
decoder_seek_where
(
decoder
)
*
AFframecount
frame
=
decoder_seek_where
(
decoder
)
*
audio_format
.
sample_rate
;
audio_format
.
sample_rate
;
afSeekFrame
(
af_fp
,
AF_DEFAULT_TRACK
,
frame
);
afSeekFrame
(
af_fp
,
AF_DEFAULT_TRACK
,
frame
);
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
cmd
=
D
ECODE_COMMAND_
NONE
;
cmd
=
D
ecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
afCloseFile
(
af_fp
);
afCloseFile
(
af_fp
);
}
}
...
...
src/decoder/DsdiffDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -403,17 +403,16 @@ dsdiff_decode_chunk(struct decoder *decoder, struct input_stream *is,
...
@@ -403,17 +403,16 @@ dsdiff_decode_chunk(struct decoder *decoder, struct input_stream *is,
if
(
lsbitfirst
)
if
(
lsbitfirst
)
bit_reverse_buffer
(
buffer
,
buffer
+
nbytes
);
bit_reverse_buffer
(
buffer
,
buffer
+
nbytes
);
enum
decoder_command
cmd
=
const
auto
cmd
=
decoder_data
(
decoder
,
is
,
buffer
,
nbytes
,
0
);
decoder_data
(
decoder
,
is
,
buffer
,
nbytes
,
0
);
switch
(
cmd
)
{
switch
(
cmd
)
{
case
D
ECODE_COMMAND_
NONE
:
case
D
ecoderCommand
:
:
NONE
:
break
;
break
;
case
D
ECODE_COMMAND_
START
:
case
D
ecoderCommand
:
:
START
:
case
D
ECODE_COMMAND_
STOP
:
case
D
ecoderCommand
:
:
STOP
:
return
false
;
return
false
;
case
D
ECODE_COMMAND_
SEEK
:
case
D
ecoderCommand
:
:
SEEK
:
/* Not implemented yet */
/* Not implemented yet */
decoder_seek_error
(
decoder
);
decoder_seek_error
(
decoder
);
...
...
src/decoder/DsfDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -258,17 +258,16 @@ dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
...
@@ -258,17 +258,16 @@ dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
dsf_to_pcm_order
(
buffer
,
dsf_scratch_buffer
,
nbytes
);
dsf_to_pcm_order
(
buffer
,
dsf_scratch_buffer
,
nbytes
);
enum
decoder_command
cmd
=
const
auto
cmd
=
decoder_data
(
decoder
,
is
,
buffer
,
nbytes
,
0
);
decoder_data
(
decoder
,
is
,
buffer
,
nbytes
,
0
);
switch
(
cmd
)
{
switch
(
cmd
)
{
case
D
ECODE_COMMAND_
NONE
:
case
D
ecoderCommand
:
:
NONE
:
break
;
break
;
case
D
ECODE_COMMAND_
START
:
case
D
ecoderCommand
:
:
START
:
case
D
ECODE_COMMAND_
STOP
:
case
D
ecoderCommand
:
:
STOP
:
return
false
;
return
false
;
case
D
ECODE_COMMAND_
SEEK
:
case
D
ecoderCommand
:
:
SEEK
:
/* not implemented yet */
/* not implemented yet */
decoder_seek_error
(
decoder
);
decoder_seek_error
(
decoder
);
...
...
src/decoder/FaadDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -368,7 +368,6 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -368,7 +368,6 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
bool
ret
;
bool
ret
;
uint16_t
bit_rate
=
0
;
uint16_t
bit_rate
=
0
;
DecoderBuffer
*
buffer
;
DecoderBuffer
*
buffer
;
enum
decoder_command
cmd
;
buffer
=
decoder_buffer_new
(
mpd_decoder
,
is
,
buffer
=
decoder_buffer_new
(
mpd_decoder
,
is
,
FAAD_MIN_STREAMSIZE
*
AAC_MAX_CHANNELS
);
FAAD_MIN_STREAMSIZE
*
AAC_MAX_CHANNELS
);
...
@@ -386,7 +385,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -386,7 +385,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
NeAACDecSetConfiguration
(
decoder
,
config
);
NeAACDecSetConfiguration
(
decoder
,
config
);
while
(
!
decoder_buffer_is_full
(
buffer
)
&&
!
is
->
LockIsEOF
()
&&
while
(
!
decoder_buffer_is_full
(
buffer
)
&&
!
is
->
LockIsEOF
()
&&
decoder_get_command
(
mpd_decoder
)
==
D
ECODE_COMMAND_
NONE
)
{
decoder_get_command
(
mpd_decoder
)
==
D
ecoderCommand
::
NONE
)
{
adts_find_frame
(
buffer
);
adts_find_frame
(
buffer
);
decoder_buffer_fill
(
buffer
);
decoder_buffer_fill
(
buffer
);
}
}
...
@@ -407,6 +406,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -407,6 +406,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
/* the decoder loop */
/* the decoder loop */
DecoderCommand
cmd
;
do
{
do
{
size_t
frame_size
;
size_t
frame_size
;
const
void
*
decoded
;
const
void
*
decoded
;
...
@@ -457,7 +457,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -457,7 +457,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
cmd
=
decoder_data
(
mpd_decoder
,
is
,
decoded
,
cmd
=
decoder_data
(
mpd_decoder
,
is
,
decoded
,
(
size_t
)
frame_info
.
samples
*
2
,
(
size_t
)
frame_info
.
samples
*
2
,
bit_rate
);
bit_rate
);
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
/* cleanup */
/* cleanup */
...
...
src/decoder/FfmpegDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -253,7 +253,7 @@ copy_interleave_frame(const AVCodecContext *codec_context,
...
@@ -253,7 +253,7 @@ copy_interleave_frame(const AVCodecContext *codec_context,
return
data_size
;
return
data_size
;
}
}
static
enum
decoder_c
ommand
static
DecoderC
ommand
ffmpeg_send_packet
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
ffmpeg_send_packet
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
const
AVPacket
*
packet
,
const
AVPacket
*
packet
,
AVCodecContext
*
codec_context
,
AVCodecContext
*
codec_context
,
...
@@ -269,9 +269,8 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
...
@@ -269,9 +269,8 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
uint8_t
*
output_buffer
;
uint8_t
*
output_buffer
;
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
while
(
packet2
.
size
>
0
&&
while
(
packet2
.
size
>
0
&&
cmd
==
DecoderCommand
::
NONE
)
{
cmd
==
DECODE_COMMAND_NONE
)
{
int
audio_size
=
0
;
int
audio_size
=
0
;
int
got_frame
=
0
;
int
got_frame
=
0
;
int
len
=
avcodec_decode_audio4
(
codec_context
,
int
len
=
avcodec_decode_audio4
(
codec_context
,
...
@@ -470,7 +469,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
...
@@ -470,7 +469,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
uint8_t
*
interleaved_buffer
=
NULL
;
uint8_t
*
interleaved_buffer
=
NULL
;
int
interleaved_buffer_size
=
0
;
int
interleaved_buffer_size
=
0
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
do
{
do
{
AVPacket
packet
;
AVPacket
packet
;
if
(
av_read_frame
(
format_context
,
&
packet
)
<
0
)
if
(
av_read_frame
(
format_context
,
&
packet
)
<
0
)
...
@@ -488,7 +487,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
...
@@ -488,7 +487,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
av_free_packet
(
&
packet
);
av_free_packet
(
&
packet
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
int64_t
where
=
int64_t
where
=
time_to_ffmpeg
(
decoder_seek_where
(
decoder
),
time_to_ffmpeg
(
decoder_seek_where
(
decoder
),
av_stream
->
time_base
);
av_stream
->
time_base
);
...
@@ -501,7 +500,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
...
@@ -501,7 +500,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
}
}
}
}
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
avcodec_free_frame
(
&
frame
);
avcodec_free_frame
(
&
frame
);
...
...
src/decoder/FlacCommon.cxx
View file @
c5d05ac0
...
@@ -158,7 +158,6 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
...
@@ -158,7 +158,6 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
const
FLAC__int32
*
const
buf
[],
const
FLAC__int32
*
const
buf
[],
FLAC__uint64
nbytes
)
FLAC__uint64
nbytes
)
{
{
enum
decoder_command
cmd
;
void
*
buffer
;
void
*
buffer
;
unsigned
bit_rate
;
unsigned
bit_rate
;
...
@@ -178,19 +177,19 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
...
@@ -178,19 +177,19 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
else
else
bit_rate
=
0
;
bit_rate
=
0
;
cmd
=
decoder_data
(
data
->
decoder
,
data
->
input_stream
,
auto
cmd
=
decoder_data
(
data
->
decoder
,
data
->
input_stream
,
buffer
,
buffer_size
,
buffer
,
buffer_size
,
bit_rate
);
bit_rate
);
data
->
next_frame
+=
frame
->
header
.
blocksize
;
data
->
next_frame
+=
frame
->
header
.
blocksize
;
switch
(
cmd
)
{
switch
(
cmd
)
{
case
D
ECODE_COMMAND_
NONE
:
case
D
ecoderCommand
:
:
NONE
:
case
D
ECODE_COMMAND_
START
:
case
D
ecoderCommand
:
:
START
:
break
;
break
;
case
D
ECODE_COMMAND_
STOP
:
case
D
ecoderCommand
:
:
STOP
:
return
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
;
return
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
;
case
D
ECODE_COMMAND_
SEEK
:
case
D
ecoderCommand
:
:
SEEK
:
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE
;
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE
;
}
}
...
...
src/decoder/FlacDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -168,11 +168,11 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
...
@@ -168,11 +168,11 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
FLAC__uint64
t_start
,
FLAC__uint64
t_end
)
FLAC__uint64
t_start
,
FLAC__uint64
t_end
)
{
{
struct
decoder
*
decoder
=
data
->
decoder
;
struct
decoder
*
decoder
=
data
->
decoder
;
enum
decoder_command
cmd
;
data
->
first_frame
=
t_start
;
data
->
first_frame
=
t_start
;
while
(
true
)
{
while
(
true
)
{
DecoderCommand
cmd
;
if
(
!
data
->
tag
.
IsEmpty
())
{
if
(
!
data
->
tag
.
IsEmpty
())
{
cmd
=
decoder_tag
(
data
->
decoder
,
data
->
input_stream
,
cmd
=
decoder_tag
(
data
->
decoder
,
data
->
input_stream
,
std
::
move
(
data
->
tag
));
std
::
move
(
data
->
tag
));
...
@@ -180,7 +180,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
...
@@ -180,7 +180,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
}
else
}
else
cmd
=
decoder_get_command
(
decoder
);
cmd
=
decoder_get_command
(
decoder
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
FLAC__uint64
seek_sample
=
t_start
+
FLAC__uint64
seek_sample
=
t_start
+
decoder_seek_where
(
decoder
)
*
decoder_seek_where
(
decoder
)
*
data
->
audio_format
.
sample_rate
;
data
->
audio_format
.
sample_rate
;
...
@@ -192,7 +192,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
...
@@ -192,7 +192,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
}
else
}
else
decoder_seek_error
(
decoder
);
decoder_seek_error
(
decoder
);
}
else
if
(
cmd
==
D
ECODE_COMMAND_
STOP
||
}
else
if
(
cmd
==
D
ecoderCommand
::
STOP
||
FLAC__stream_decoder_get_state
(
flac_dec
)
==
FLAC__STREAM_DECODER_END_OF_STREAM
)
FLAC__stream_decoder_get_state
(
flac_dec
)
==
FLAC__STREAM_DECODER_END_OF_STREAM
)
break
;
break
;
...
@@ -201,7 +201,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
...
@@ -201,7 +201,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
break
;
break
;
if
(
!
FLAC__stream_decoder_process_single
(
flac_dec
)
&&
if
(
!
FLAC__stream_decoder_process_single
(
flac_dec
)
&&
decoder_get_command
(
decoder
)
==
D
ECODE_COMMAND_
NONE
)
{
decoder_get_command
(
decoder
)
==
D
ecoderCommand
::
NONE
)
{
/* a failure that was not triggered by a
/* a failure that was not triggered by a
decoder command */
decoder command */
flacPrintErroredState
(
FLAC__stream_decoder_get_state
(
flac_dec
));
flacPrintErroredState
(
FLAC__stream_decoder_get_state
(
flac_dec
));
...
...
src/decoder/FlacInput.cxx
View file @
c5d05ac0
...
@@ -33,7 +33,7 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
...
@@ -33,7 +33,7 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
if
(
r
==
0
)
{
if
(
r
==
0
)
{
if
(
input_stream
->
LockIsEOF
()
||
if
(
input_stream
->
LockIsEOF
()
||
(
decoder
!=
nullptr
&&
(
decoder
!=
nullptr
&&
decoder_get_command
(
decoder
)
!=
D
ECODE_COMMAND_
NONE
))
decoder_get_command
(
decoder
)
!=
D
ecoderCommand
::
NONE
))
return
FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM
;
return
FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM
;
else
else
return
FLAC__STREAM_DECODER_READ_STATUS_ABORT
;
return
FLAC__STREAM_DECODER_READ_STATUS_ABORT
;
...
@@ -79,8 +79,8 @@ FLAC__bool
...
@@ -79,8 +79,8 @@ FLAC__bool
FlacInput
::
Eof
()
FlacInput
::
Eof
()
{
{
return
(
decoder
!=
nullptr
&&
return
(
decoder
!=
nullptr
&&
decoder_get_command
(
decoder
)
!=
D
ECODE_COMMAND_
NONE
&&
decoder_get_command
(
decoder
)
!=
D
ecoderCommand
::
NONE
&&
decoder_get_command
(
decoder
)
!=
D
ECODE_COMMAND_
SEEK
)
||
decoder_get_command
(
decoder
)
!=
D
ecoderCommand
::
SEEK
)
||
input_stream
->
LockIsEOF
();
input_stream
->
LockIsEOF
();
}
}
...
@@ -88,7 +88,7 @@ void
...
@@ -88,7 +88,7 @@ void
FlacInput
::
Error
(
FLAC__StreamDecoderErrorStatus
status
)
FlacInput
::
Error
(
FLAC__StreamDecoderErrorStatus
status
)
{
{
if
(
decoder
==
nullptr
||
if
(
decoder
==
nullptr
||
decoder_get_command
(
decoder
)
!=
D
ECODE_COMMAND_
STOP
)
decoder_get_command
(
decoder
)
!=
D
ecoderCommand
::
STOP
)
g_warning
(
"%s"
,
FLAC__StreamDecoderErrorStatusString
[
status
]);
g_warning
(
"%s"
,
FLAC__StreamDecoderErrorStatusString
[
status
]);
}
}
...
...
src/decoder/FluidsynthDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -102,7 +102,6 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -102,7 +102,6 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
fluid_synth_t
*
synth
;
fluid_synth_t
*
synth
;
fluid_player_t
*
player
;
fluid_player_t
*
player
;
int
ret
;
int
ret
;
enum
decoder_command
cmd
;
/* set up fluid settings */
/* set up fluid settings */
...
@@ -167,6 +166,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -167,6 +166,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
const
AudioFormat
audio_format
(
sample_rate
,
SampleFormat
::
S16
,
2
);
const
AudioFormat
audio_format
(
sample_rate
,
SampleFormat
::
S16
,
2
);
decoder_initialized
(
decoder
,
audio_format
,
false
,
-
1
);
decoder_initialized
(
decoder
,
audio_format
,
false
,
-
1
);
DecoderCommand
cmd
;
while
(
fluid_player_get_status
(
player
)
==
FLUID_PLAYER_PLAYING
)
{
while
(
fluid_player_get_status
(
player
)
==
FLUID_PLAYER_PLAYING
)
{
int16_t
buffer
[
2048
];
int16_t
buffer
[
2048
];
const
unsigned
max_frames
=
G_N_ELEMENTS
(
buffer
)
/
2
;
const
unsigned
max_frames
=
G_N_ELEMENTS
(
buffer
)
/
2
;
...
@@ -182,7 +182,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -182,7 +182,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
sizeof
(
buffer
),
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
sizeof
(
buffer
),
0
);
0
);
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
break
;
break
;
}
}
...
...
src/decoder/GmeDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -174,7 +174,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -174,7 +174,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
gme_set_fade
(
emu
,
ti
->
length
);
gme_set_fade
(
emu
,
ti
->
length
);
/* play */
/* play */
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
do
{
do
{
short
buf
[
GME_BUFFER_SAMPLES
];
short
buf
[
GME_BUFFER_SAMPLES
];
gme_err
=
gme_play
(
emu
,
GME_BUFFER_SAMPLES
,
buf
);
gme_err
=
gme_play
(
emu
,
GME_BUFFER_SAMPLES
,
buf
);
...
@@ -184,7 +184,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -184,7 +184,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
}
}
cmd
=
decoder_data
(
decoder
,
nullptr
,
buf
,
sizeof
(
buf
),
0
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
buf
,
sizeof
(
buf
),
0
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
float
where
=
decoder_seek_where
(
decoder
);
float
where
=
decoder_seek_where
(
decoder
);
gme_err
=
gme_seek
(
emu
,
int
(
where
*
1000
));
gme_err
=
gme_seek
(
emu
,
int
(
where
*
1000
));
if
(
gme_err
!=
nullptr
)
if
(
gme_err
!=
nullptr
)
...
@@ -194,7 +194,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -194,7 +194,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
if
(
gme_track_ended
(
emu
))
if
(
gme_track_ended
(
emu
))
break
;
break
;
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
gme_free_info
(
ti
);
gme_free_info
(
ti
);
gme_delete
(
emu
);
gme_delete
(
emu
);
...
...
src/decoder/MadDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -171,13 +171,13 @@ struct MadDecoder {
...
@@ -171,13 +171,13 @@ struct MadDecoder {
/**
/**
* Sends the synthesized current frame via decoder_data().
* Sends the synthesized current frame via decoder_data().
*/
*/
enum
decoder_c
ommand
SendPCM
(
unsigned
i
,
unsigned
pcm_length
);
DecoderC
ommand
SendPCM
(
unsigned
i
,
unsigned
pcm_length
);
/**
/**
* Synthesize the current frame and send it via
* Synthesize the current frame and send it via
* decoder_data().
* decoder_data().
*/
*/
enum
decoder_c
ommand
SyncAndSend
();
DecoderC
ommand
SyncAndSend
();
bool
Read
();
bool
Read
();
};
};
...
@@ -953,7 +953,7 @@ MadDecoder::UpdateTimerNextFrame()
...
@@ -953,7 +953,7 @@ MadDecoder::UpdateTimerNextFrame()
elapsed_time
=
mad_timer_count
(
timer
,
MAD_UNITS_MILLISECONDS
)
/
1000.0
;
elapsed_time
=
mad_timer_count
(
timer
,
MAD_UNITS_MILLISECONDS
)
/
1000.0
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
MadDecoder
::
SendPCM
(
unsigned
i
,
unsigned
pcm_length
)
MadDecoder
::
SendPCM
(
unsigned
i
,
unsigned
pcm_length
)
{
{
unsigned
max_samples
;
unsigned
max_samples
;
...
@@ -963,7 +963,6 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
...
@@ -963,7 +963,6 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
MAD_NCHANNELS
(
&
frame
.
header
);
MAD_NCHANNELS
(
&
frame
.
header
);
while
(
i
<
pcm_length
)
{
while
(
i
<
pcm_length
)
{
enum
decoder_command
cmd
;
unsigned
int
num_samples
=
pcm_length
-
i
;
unsigned
int
num_samples
=
pcm_length
-
i
;
if
(
num_samples
>
max_samples
)
if
(
num_samples
>
max_samples
)
num_samples
=
max_samples
;
num_samples
=
max_samples
;
...
@@ -975,17 +974,17 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
...
@@ -975,17 +974,17 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
MAD_NCHANNELS
(
&
frame
.
header
));
MAD_NCHANNELS
(
&
frame
.
header
));
num_samples
*=
MAD_NCHANNELS
(
&
frame
.
header
);
num_samples
*=
MAD_NCHANNELS
(
&
frame
.
header
);
cmd
=
decoder_data
(
decoder
,
input_stream
,
output_buffer
,
auto
cmd
=
decoder_data
(
decoder
,
input_stream
,
output_buffer
,
sizeof
(
output_buffer
[
0
])
*
num_samples
,
sizeof
(
output_buffer
[
0
])
*
num_samples
,
bit_rate
/
1000
);
bit_rate
/
1000
);
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
return
cmd
;
return
cmd
;
}
}
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
inline
enum
decoder_c
ommand
inline
DecoderC
ommand
MadDecoder
::
SyncAndSend
()
MadDecoder
::
SyncAndSend
()
{
{
mad_synth_frame
(
&
synth
,
&
frame
);
mad_synth_frame
(
&
synth
,
&
frame
);
...
@@ -1001,12 +1000,12 @@ MadDecoder::SyncAndSend()
...
@@ -1001,12 +1000,12 @@ MadDecoder::SyncAndSend()
if
(
drop_start_frames
>
0
)
{
if
(
drop_start_frames
>
0
)
{
drop_start_frames
--
;
drop_start_frames
--
;
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
else
if
((
drop_end_frames
>
0
)
&&
}
else
if
((
drop_end_frames
>
0
)
&&
(
current_frame
==
(
max_frames
+
1
-
drop_end_frames
)))
{
(
current_frame
==
(
max_frames
+
1
-
drop_end_frames
)))
{
/* stop decoding, effectively dropping all remaining
/* stop decoding, effectively dropping all remaining
frames */
frames */
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
}
}
unsigned
i
=
0
;
unsigned
i
=
0
;
...
@@ -1024,28 +1023,29 @@ MadDecoder::SyncAndSend()
...
@@ -1024,28 +1023,29 @@ MadDecoder::SyncAndSend()
pcm_length
-=
drop_end_samples
;
pcm_length
-=
drop_end_samples
;
}
}
enum
decoder_command
cmd
=
SendPCM
(
i
,
pcm_length
);
auto
cmd
=
SendPCM
(
i
,
pcm_length
);
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
return
cmd
;
return
cmd
;
if
(
drop_end_samples
&&
if
(
drop_end_samples
&&
(
current_frame
==
max_frames
-
drop_end_frames
))
(
current_frame
==
max_frames
-
drop_end_frames
))
/* stop decoding, effectively dropping
/* stop decoding, effectively dropping
* all remaining samples */
* all remaining samples */
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
inline
bool
inline
bool
MadDecoder
::
Read
()
MadDecoder
::
Read
()
{
{
enum
mp3_action
ret
;
enum
mp3_action
ret
;
enum
decoder_command
cmd
;
UpdateTimerNextFrame
();
UpdateTimerNextFrame
();
switch
(
mute_frame
)
{
switch
(
mute_frame
)
{
DecoderCommand
cmd
;
case
MUTEFRAME_SKIP
:
case
MUTEFRAME_SKIP
:
mute_frame
=
MUTEFRAME_NONE
;
mute_frame
=
MUTEFRAME_NONE
;
break
;
break
;
...
@@ -1055,7 +1055,7 @@ MadDecoder::Read()
...
@@ -1055,7 +1055,7 @@ MadDecoder::Read()
break
;
break
;
case
MUTEFRAME_NONE
:
case
MUTEFRAME_NONE
:
cmd
=
SyncAndSend
();
cmd
=
SyncAndSend
();
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
unsigned
long
j
;
unsigned
long
j
;
assert
(
input_stream
->
IsSeekable
());
assert
(
input_stream
->
IsSeekable
());
...
@@ -1072,7 +1072,7 @@ MadDecoder::Read()
...
@@ -1072,7 +1072,7 @@ MadDecoder::Read()
mute_frame
=
MUTEFRAME_SEEK
;
mute_frame
=
MUTEFRAME_SEEK
;
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
}
}
}
else
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
}
else
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
return
false
;
return
false
;
}
}
...
@@ -1119,7 +1119,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
...
@@ -1119,7 +1119,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
if
(
!
data
.
DecodeFirstFrame
(
&
tag
))
{
if
(
!
data
.
DecodeFirstFrame
(
&
tag
))
{
delete
tag
;
delete
tag
;
if
(
decoder_get_command
(
decoder
)
==
D
ECODE_COMMAND_
NONE
)
if
(
decoder_get_command
(
decoder
)
==
D
ecoderCommand
::
NONE
)
g_warning
g_warning
(
"Input does not appear to be a mp3 bit stream.
\n
"
);
(
"Input does not appear to be a mp3 bit stream.
\n
"
);
return
;
return
;
...
...
src/decoder/MikmodDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -148,7 +148,6 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -148,7 +148,6 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
MODULE
*
handle
;
MODULE
*
handle
;
int
ret
;
int
ret
;
SBYTE
buffer
[
MIKMOD_FRAME_SIZE
];
SBYTE
buffer
[
MIKMOD_FRAME_SIZE
];
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
path2
=
g_strdup
(
path_fs
);
path2
=
g_strdup
(
path_fs
);
handle
=
Player_Load
(
path2
,
128
,
0
);
handle
=
Player_Load
(
path2
,
128
,
0
);
...
@@ -168,7 +167,9 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -168,7 +167,9 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
decoder_initialized
(
decoder
,
audio_format
,
false
,
0
);
decoder_initialized
(
decoder
,
audio_format
,
false
,
0
);
Player_Start
(
handle
);
Player_Start
(
handle
);
while
(
cmd
==
DECODE_COMMAND_NONE
&&
Player_Active
())
{
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
while
(
cmd
==
DecoderCommand
::
NONE
&&
Player_Active
())
{
ret
=
VC_WriteBytes
(
buffer
,
sizeof
(
buffer
));
ret
=
VC_WriteBytes
(
buffer
,
sizeof
(
buffer
));
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
ret
,
0
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
ret
,
0
);
}
}
...
...
src/decoder/ModplugDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -99,7 +99,6 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -99,7 +99,6 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
GByteArray
*
bdatas
;
GByteArray
*
bdatas
;
int
ret
;
int
ret
;
char
audio_buffer
[
MODPLUG_FRAME_SIZE
];
char
audio_buffer
[
MODPLUG_FRAME_SIZE
];
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
bdatas
=
mod_loadfile
(
decoder
,
is
);
bdatas
=
mod_loadfile
(
decoder
,
is
);
...
@@ -131,6 +130,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -131,6 +130,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
is
->
IsSeekable
(),
is
->
IsSeekable
(),
ModPlug_GetLength
(
f
)
/
1000.0
);
ModPlug_GetLength
(
f
)
/
1000.0
);
DecoderCommand
cmd
;
do
{
do
{
ret
=
ModPlug_Read
(
f
,
audio_buffer
,
MODPLUG_FRAME_SIZE
);
ret
=
ModPlug_Read
(
f
,
audio_buffer
,
MODPLUG_FRAME_SIZE
);
if
(
ret
<=
0
)
if
(
ret
<=
0
)
...
@@ -140,7 +140,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -140,7 +140,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
audio_buffer
,
ret
,
audio_buffer
,
ret
,
0
);
0
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
float
where
=
decoder_seek_where
(
decoder
);
float
where
=
decoder_seek_where
(
decoder
);
ModPlug_Seek
(
f
,
(
int
)(
where
*
1000.0
));
ModPlug_Seek
(
f
,
(
int
)(
where
*
1000.0
));
...
@@ -148,7 +148,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -148,7 +148,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
}
}
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
ModPlug_Unload
(
f
);
ModPlug_Unload
(
f
);
}
}
...
...
src/decoder/MpcdecDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -147,7 +147,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -147,7 +147,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
mpc_demux
*
demux
=
mpc_demux_init
(
&
reader
);
mpc_demux
*
demux
=
mpc_demux_init
(
&
reader
);
if
(
demux
==
nullptr
)
{
if
(
demux
==
nullptr
)
{
if
(
decoder_get_command
(
mpd_decoder
)
!=
D
ECODE_COMMAND_
STOP
)
if
(
decoder_get_command
(
mpd_decoder
)
!=
D
ecoderCommand
::
STOP
)
g_warning
(
"Not a valid musepack stream"
);
g_warning
(
"Not a valid musepack stream"
);
return
;
return
;
}
}
...
@@ -178,9 +178,9 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -178,9 +178,9 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
is
->
IsSeekable
(),
is
->
IsSeekable
(),
mpc_streaminfo_get_length
(
&
info
));
mpc_streaminfo_get_length
(
&
info
));
enum
decoder_command
cmd
=
DECODE_COMMAND_
NONE
;
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
do
{
do
{
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
mpc_int64_t
where
=
decoder_seek_where
(
mpd_decoder
)
*
mpc_int64_t
where
=
decoder_seek_where
(
mpd_decoder
)
*
audio_format
.
sample_rate
;
audio_format
.
sample_rate
;
bool
success
;
bool
success
;
...
@@ -218,7 +218,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -218,7 +218,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
cmd
=
decoder_data
(
mpd_decoder
,
is
,
cmd
=
decoder_data
(
mpd_decoder
,
is
,
chunk
,
ret
*
sizeof
(
chunk
[
0
]),
chunk
,
ret
*
sizeof
(
chunk
[
0
]),
bit_rate
);
bit_rate
);
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
mpc_demux_exit
(
demux
);
mpc_demux_exit
(
demux
);
}
}
...
...
src/decoder/Mpg123DecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -106,7 +106,6 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -106,7 +106,6 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
mpg123_handle
*
handle
;
mpg123_handle
*
handle
;
int
error
;
int
error
;
off_t
num_samples
;
off_t
num_samples
;
enum
decoder_command
cmd
;
struct
mpg123_frameinfo
info
;
struct
mpg123_frameinfo
info
;
/* open the file */
/* open the file */
...
@@ -149,6 +148,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -149,6 +148,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
/* the decoder main loop */
/* the decoder main loop */
DecoderCommand
cmd
;
do
{
do
{
unsigned
char
buffer
[
8192
];
unsigned
char
buffer
[
8192
];
size_t
nbytes
;
size_t
nbytes
;
...
@@ -175,7 +175,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -175,7 +175,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
nbytes
,
info
.
bitrate
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
nbytes
,
info
.
bitrate
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
off_t
c
=
decoder_seek_where
(
decoder
)
*
audio_format
.
sample_rate
;
off_t
c
=
decoder_seek_where
(
decoder
)
*
audio_format
.
sample_rate
;
c
=
mpg123_seek
(
handle
,
c
,
SEEK_SET
);
c
=
mpg123_seek
(
handle
,
c
,
SEEK_SET
);
if
(
c
<
0
)
if
(
c
<
0
)
...
@@ -185,9 +185,9 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -185,9 +185,9 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
decoder_timestamp
(
decoder
,
c
/
(
double
)
audio_format
.
sample_rate
);
decoder_timestamp
(
decoder
,
c
/
(
double
)
audio_format
.
sample_rate
);
}
}
cmd
=
D
ECODE_COMMAND_
NONE
;
cmd
=
D
ecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
/* cleanup */
/* cleanup */
...
...
src/decoder/OpusDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -96,11 +96,11 @@ public:
...
@@ -96,11 +96,11 @@ public:
bool
ReadFirstPage
(
OggSyncState
&
oy
);
bool
ReadFirstPage
(
OggSyncState
&
oy
);
bool
ReadNextPage
(
OggSyncState
&
oy
);
bool
ReadNextPage
(
OggSyncState
&
oy
);
enum
decoder_c
ommand
HandlePackets
();
DecoderC
ommand
HandlePackets
();
enum
decoder_c
ommand
HandlePacket
(
const
ogg_packet
&
packet
);
DecoderC
ommand
HandlePacket
(
const
ogg_packet
&
packet
);
enum
decoder_c
ommand
HandleBOS
(
const
ogg_packet
&
packet
);
DecoderC
ommand
HandleBOS
(
const
ogg_packet
&
packet
);
enum
decoder_c
ommand
HandleTags
(
const
ogg_packet
&
packet
);
DecoderC
ommand
HandleTags
(
const
ogg_packet
&
packet
);
enum
decoder_c
ommand
HandleAudio
(
const
ogg_packet
&
packet
);
DecoderC
ommand
HandleAudio
(
const
ogg_packet
&
packet
);
};
};
MPDOpusDecoder
::~
MPDOpusDecoder
()
MPDOpusDecoder
::~
MPDOpusDecoder
()
...
@@ -143,29 +143,29 @@ MPDOpusDecoder::ReadNextPage(OggSyncState &oy)
...
@@ -143,29 +143,29 @@ MPDOpusDecoder::ReadNextPage(OggSyncState &oy)
return
true
;
return
true
;
}
}
inline
enum
decoder_c
ommand
inline
DecoderC
ommand
MPDOpusDecoder
::
HandlePackets
()
MPDOpusDecoder
::
HandlePackets
()
{
{
ogg_packet
packet
;
ogg_packet
packet
;
while
(
ogg_stream_packetout
(
&
os
,
&
packet
)
==
1
)
{
while
(
ogg_stream_packetout
(
&
os
,
&
packet
)
==
1
)
{
enum
decoder_command
cmd
=
HandlePacket
(
packet
);
auto
cmd
=
HandlePacket
(
packet
);
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
return
cmd
;
return
cmd
;
}
}
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
inline
enum
decoder_c
ommand
inline
DecoderC
ommand
MPDOpusDecoder
::
HandlePacket
(
const
ogg_packet
&
packet
)
MPDOpusDecoder
::
HandlePacket
(
const
ogg_packet
&
packet
)
{
{
if
(
packet
.
e_o_s
)
if
(
packet
.
e_o_s
)
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
if
(
packet
.
b_o_s
)
if
(
packet
.
b_o_s
)
return
HandleBOS
(
packet
);
return
HandleBOS
(
packet
);
else
if
(
!
found_opus
)
else
if
(
!
found_opus
)
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
if
(
IsOpusTags
(
packet
))
if
(
IsOpusTags
(
packet
))
return
HandleTags
(
packet
);
return
HandleTags
(
packet
);
...
@@ -173,18 +173,18 @@ MPDOpusDecoder::HandlePacket(const ogg_packet &packet)
...
@@ -173,18 +173,18 @@ MPDOpusDecoder::HandlePacket(const ogg_packet &packet)
return
HandleAudio
(
packet
);
return
HandleAudio
(
packet
);
}
}
inline
enum
decoder_c
ommand
inline
DecoderC
ommand
MPDOpusDecoder
::
HandleBOS
(
const
ogg_packet
&
packet
)
MPDOpusDecoder
::
HandleBOS
(
const
ogg_packet
&
packet
)
{
{
assert
(
packet
.
b_o_s
);
assert
(
packet
.
b_o_s
);
if
(
found_opus
||
!
IsOpusHead
(
packet
))
if
(
found_opus
||
!
IsOpusHead
(
packet
))
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
unsigned
channels
;
unsigned
channels
;
if
(
!
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
)
||
if
(
!
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
)
||
!
audio_valid_channel_count
(
channels
))
!
audio_valid_channel_count
(
channels
))
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
assert
(
opus_decoder
==
nullptr
);
assert
(
opus_decoder
==
nullptr
);
assert
(
output_buffer
==
nullptr
);
assert
(
output_buffer
==
nullptr
);
...
@@ -201,7 +201,7 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
...
@@ -201,7 +201,7 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
if
(
opus_decoder
==
nullptr
)
{
if
(
opus_decoder
==
nullptr
)
{
g_warning
(
"libopus error: %s"
,
g_warning
(
"libopus error: %s"
,
opus_strerror
(
opus_error
));
opus_strerror
(
opus_error
));
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
}
}
const
AudioFormat
audio_format
(
opus_sample_rate
,
const
AudioFormat
audio_format
(
opus_sample_rate
,
...
@@ -220,12 +220,12 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
...
@@ -220,12 +220,12 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
return
decoder_get_command
(
decoder
);
return
decoder_get_command
(
decoder
);
}
}
inline
enum
decoder_c
ommand
inline
DecoderC
ommand
MPDOpusDecoder
::
HandleTags
(
const
ogg_packet
&
packet
)
MPDOpusDecoder
::
HandleTags
(
const
ogg_packet
&
packet
)
{
{
TagBuilder
tag_builder
;
TagBuilder
tag_builder
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
if
(
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
if
(
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
&
add_tag_handler
,
&
tag_builder
)
&&
&
add_tag_handler
,
&
tag_builder
)
&&
!
tag_builder
.
IsEmpty
())
{
!
tag_builder
.
IsEmpty
())
{
...
@@ -238,7 +238,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
...
@@ -238,7 +238,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
return
cmd
;
return
cmd
;
}
}
inline
enum
decoder_c
ommand
inline
DecoderC
ommand
MPDOpusDecoder
::
HandleAudio
(
const
ogg_packet
&
packet
)
MPDOpusDecoder
::
HandleAudio
(
const
ogg_packet
&
packet
)
{
{
assert
(
opus_decoder
!=
nullptr
);
assert
(
opus_decoder
!=
nullptr
);
...
@@ -250,20 +250,19 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
...
@@ -250,20 +250,19 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
0
);
0
);
if
(
nframes
<
0
)
{
if
(
nframes
<
0
)
{
g_warning
(
"%s"
,
opus_strerror
(
nframes
));
g_warning
(
"%s"
,
opus_strerror
(
nframes
));
return
D
ECODE_COMMAND_
STOP
;
return
D
ecoderCommand
::
STOP
;
}
}
if
(
nframes
>
0
)
{
if
(
nframes
>
0
)
{
const
size_t
nbytes
=
nframes
*
frame_size
;
const
size_t
nbytes
=
nframes
*
frame_size
;
enum
decoder_command
cmd
=
auto
cmd
=
decoder_data
(
decoder
,
input_stream
,
decoder_data
(
decoder
,
input_stream
,
output_buffer
,
nbytes
,
output_buffer
,
nbytes
,
0
);
0
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DECODE_COMMAND_NONE
)
return
cmd
;
return
cmd
;
}
}
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
static
void
static
void
...
@@ -284,8 +283,8 @@ mpd_opus_stream_decode(struct decoder *decoder,
...
@@ -284,8 +283,8 @@ mpd_opus_stream_decode(struct decoder *decoder,
return
;
return
;
while
(
true
)
{
while
(
true
)
{
enum
decoder_command
cmd
=
d
.
HandlePackets
();
auto
cmd
=
d
.
HandlePackets
();
if
(
cmd
!=
D
ECODE_COMMAND_
NONE
)
if
(
cmd
!=
D
ecoderCommand
::
NONE
)
break
;
break
;
if
(
!
d
.
ReadNextPage
(
oy
))
if
(
!
d
.
ReadNextPage
(
oy
))
...
...
src/decoder/PcmDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -48,8 +48,6 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -48,8 +48,6 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
const
bool
reverse_endian
=
mime
!=
nullptr
&&
const
bool
reverse_endian
=
mime
!=
nullptr
&&
strcmp
(
mime
,
"audio/x-mpd-cdda-pcm-reverse"
)
==
0
;
strcmp
(
mime
,
"audio/x-mpd-cdda-pcm-reverse"
)
==
0
;
enum
decoder_command
cmd
;
const
double
time_to_size
=
audio_format
.
GetTimeToSize
();
const
double
time_to_size
=
audio_format
.
GetTimeToSize
();
float
total_time
=
-
1
;
float
total_time
=
-
1
;
...
@@ -60,6 +58,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -60,6 +58,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_initialized
(
decoder
,
audio_format
,
decoder_initialized
(
decoder
,
audio_format
,
is
->
IsSeekable
(),
total_time
);
is
->
IsSeekable
(),
total_time
);
DecoderCommand
cmd
;
do
{
do
{
char
buffer
[
4096
];
char
buffer
[
4096
];
...
@@ -79,7 +78,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -79,7 +78,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
?
decoder_data
(
decoder
,
is
,
?
decoder_data
(
decoder
,
is
,
buffer
,
nbytes
,
0
)
buffer
,
nbytes
,
0
)
:
decoder_get_command
(
decoder
);
:
decoder_get_command
(
decoder
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
goffset
offset
=
(
goffset
)(
time_to_size
*
goffset
offset
=
(
goffset
)(
time_to_size
*
decoder_seek_where
(
decoder
));
decoder_seek_where
(
decoder
));
...
@@ -91,9 +90,9 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -91,9 +90,9 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_seek_error
(
decoder
);
decoder_seek_error
(
decoder
);
}
}
cmd
=
D
ECODE_COMMAND_
NONE
;
cmd
=
D
ecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
}
}
static
const
char
*
const
pcm_mime_types
[]
=
{
static
const
char
*
const
pcm_mime_types
[]
=
{
...
...
src/decoder/SndfileDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -119,7 +119,6 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -119,7 +119,6 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
size_t
frame_size
;
size_t
frame_size
;
sf_count_t
read_frames
,
num_frames
;
sf_count_t
read_frames
,
num_frames
;
int
buffer
[
4096
];
int
buffer
[
4096
];
enum
decoder_command
cmd
;
info
.
format
=
0
;
info
.
format
=
0
;
...
@@ -147,6 +146,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -147,6 +146,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
frame_size
=
audio_format
.
GetFrameSize
();
frame_size
=
audio_format
.
GetFrameSize
();
read_frames
=
sizeof
(
buffer
)
/
frame_size
;
read_frames
=
sizeof
(
buffer
)
/
frame_size
;
DecoderCommand
cmd
;
do
{
do
{
num_frames
=
sf_readf_int
(
sf
,
buffer
,
read_frames
);
num_frames
=
sf_readf_int
(
sf
,
buffer
,
read_frames
);
if
(
num_frames
<=
0
)
if
(
num_frames
<=
0
)
...
@@ -155,7 +155,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -155,7 +155,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
cmd
=
decoder_data
(
decoder
,
is
,
cmd
=
decoder_data
(
decoder
,
is
,
buffer
,
num_frames
*
frame_size
,
buffer
,
num_frames
*
frame_size
,
0
);
0
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
sf_count_t
c
=
sf_count_t
c
=
time_to_frame
(
decoder_seek_where
(
decoder
),
time_to_frame
(
decoder_seek_where
(
decoder
),
&
audio_format
);
&
audio_format
);
...
@@ -164,9 +164,9 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
...
@@ -164,9 +164,9 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_seek_error
(
decoder
);
decoder_seek_error
(
decoder
);
else
else
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
cmd
=
D
ECODE_COMMAND_
NONE
;
cmd
=
D
ecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
sf_close
(
sf
);
sf_close
(
sf
);
}
}
...
...
src/decoder/VorbisDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -83,7 +83,7 @@ static int ogg_seek_cb(void *data, ogg_int64_t offset, int whence)
...
@@ -83,7 +83,7 @@ static int ogg_seek_cb(void *data, ogg_int64_t offset, int whence)
Error
error
;
Error
error
;
return
vis
->
seekable
&&
return
vis
->
seekable
&&
(
!
vis
->
decoder
||
decoder_get_command
(
vis
->
decoder
)
!=
D
ECODE_COMMAND_
STOP
)
&&
(
!
vis
->
decoder
||
decoder_get_command
(
vis
->
decoder
)
!=
D
ecoderCommand
::
STOP
)
&&
vis
->
input_stream
->
LockSeek
(
offset
,
whence
,
error
)
vis
->
input_stream
->
LockSeek
(
offset
,
whence
,
error
)
?
0
:
-
1
;
?
0
:
-
1
;
}
}
...
@@ -143,7 +143,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
...
@@ -143,7 +143,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
int
ret
=
ov_open_callbacks
(
vis
,
vf
,
NULL
,
0
,
vorbis_is_callbacks
);
int
ret
=
ov_open_callbacks
(
vis
,
vf
,
NULL
,
0
,
vorbis_is_callbacks
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
decoder
==
NULL
||
if
(
decoder
==
NULL
||
decoder_get_command
(
decoder
)
==
D
ECODE_COMMAND_
NONE
)
decoder_get_command
(
decoder
)
==
D
ecoderCommand
::
NONE
)
g_warning
(
"Failed to open Ogg Vorbis stream: %s"
,
g_warning
(
"Failed to open Ogg Vorbis stream: %s"
,
vorbis_strerror
(
ret
));
vorbis_strerror
(
ret
));
return
false
;
return
false
;
...
@@ -221,8 +221,6 @@ vorbis_stream_decode(struct decoder *decoder,
...
@@ -221,8 +221,6 @@ vorbis_stream_decode(struct decoder *decoder,
decoder_initialized
(
decoder
,
audio_format
,
vis
.
seekable
,
total_time
);
decoder_initialized
(
decoder
,
audio_format
,
vis
.
seekable
,
total_time
);
enum
decoder_command
cmd
=
decoder_get_command
(
decoder
);
#ifdef HAVE_TREMOR
#ifdef HAVE_TREMOR
char
buffer
[
4096
];
char
buffer
[
4096
];
#else
#else
...
@@ -235,8 +233,9 @@ vorbis_stream_decode(struct decoder *decoder,
...
@@ -235,8 +233,9 @@ vorbis_stream_decode(struct decoder *decoder,
int
prev_section
=
-
1
;
int
prev_section
=
-
1
;
unsigned
kbit_rate
=
0
;
unsigned
kbit_rate
=
0
;
DecoderCommand
cmd
=
decoder_get_command
(
decoder
);
do
{
do
{
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
double
seek_where
=
decoder_seek_where
(
decoder
);
double
seek_where
=
decoder_seek_where
(
decoder
);
if
(
0
==
ov_time_seek_page
(
&
vf
,
seek_where
))
{
if
(
0
==
ov_time_seek_page
(
&
vf
,
seek_where
))
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
...
@@ -302,7 +301,7 @@ vorbis_stream_decode(struct decoder *decoder,
...
@@ -302,7 +301,7 @@ vorbis_stream_decode(struct decoder *decoder,
cmd
=
decoder_data
(
decoder
,
input_stream
,
cmd
=
decoder_data
(
decoder
,
input_stream
,
buffer
,
nbytes
,
buffer
,
nbytes
,
kbit_rate
);
kbit_rate
);
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
ov_clear
(
&
vf
);
ov_clear
(
&
vf
);
}
}
...
...
src/decoder/WavpackDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -177,9 +177,9 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
...
@@ -177,9 +177,9 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
decoder_initialized
(
decoder
,
audio_format
,
can_seek
,
total_time
);
decoder_initialized
(
decoder
,
audio_format
,
can_seek
,
total_time
);
enum
decoder_c
ommand
cmd
=
decoder_get_command
(
decoder
);
DecoderC
ommand
cmd
=
decoder_get_command
(
decoder
);
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
)
{
while
(
cmd
!=
D
ecoderCommand
::
STOP
)
{
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
if
(
can_seek
)
{
if
(
can_seek
)
{
unsigned
where
=
decoder_seek_where
(
decoder
)
*
unsigned
where
=
decoder_seek_where
(
decoder
)
*
audio_format
.
sample_rate
;
audio_format
.
sample_rate
;
...
...
src/decoder/WildmidiDecoderPlugin.cxx
View file @
c5d05ac0
...
@@ -72,7 +72,6 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -72,7 +72,6 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
};
};
midi
*
wm
;
midi
*
wm
;
const
struct
_WM_Info
*
info
;
const
struct
_WM_Info
*
info
;
enum
decoder_command
cmd
;
wm
=
WildMidi_Open
(
path_fs
);
wm
=
WildMidi_Open
(
path_fs
);
if
(
wm
==
nullptr
)
if
(
wm
==
nullptr
)
...
@@ -87,6 +86,7 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -87,6 +86,7 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
decoder_initialized
(
decoder
,
audio_format
,
true
,
decoder_initialized
(
decoder
,
audio_format
,
true
,
info
->
approx_total_samples
/
WILDMIDI_SAMPLE_RATE
);
info
->
approx_total_samples
/
WILDMIDI_SAMPLE_RATE
);
DecoderCommand
cmd
;
do
{
do
{
char
buffer
[
4096
];
char
buffer
[
4096
];
int
len
;
int
len
;
...
@@ -101,7 +101,7 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -101,7 +101,7 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
len
,
0
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
len
,
0
);
if
(
cmd
==
D
ECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
D
ecoderCommand
::
SEEK
)
{
unsigned
long
seek_where
=
WILDMIDI_SAMPLE_RATE
*
unsigned
long
seek_where
=
WILDMIDI_SAMPLE_RATE
*
decoder_seek_where
(
decoder
);
decoder_seek_where
(
decoder
);
...
@@ -111,10 +111,10 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -111,10 +111,10 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
WildMidi_FastSeek
(
wm
,
&
seek_where
);
WildMidi_FastSeek
(
wm
,
&
seek_where
);
#endif
#endif
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
cmd
=
D
ECODE_COMMAND_
NONE
;
cmd
=
D
ecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
D
ECODE_COMMAND_
NONE
);
}
while
(
cmd
==
D
ecoderCommand
::
NONE
);
WildMidi_Close
(
wm
);
WildMidi_Close
(
wm
);
}
}
...
...
src/decoder/sidplay_decoder_plugin.cxx
View file @
c5d05ac0
...
@@ -290,7 +290,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -290,7 +290,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
const
unsigned
timebase
=
player
.
timebase
();
const
unsigned
timebase
=
player
.
timebase
();
song_len
*=
timebase
;
song_len
*=
timebase
;
enum
decoder_c
ommand
cmd
;
DecoderC
ommand
cmd
;
do
{
do
{
char
buffer
[
4096
];
char
buffer
[
4096
];
size_t
nbytes
;
size_t
nbytes
;
...
@@ -303,7 +303,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -303,7 +303,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
cmd
=
decoder_data
(
decoder
,
NULL
,
buffer
,
nbytes
,
0
);
cmd
=
decoder_data
(
decoder
,
NULL
,
buffer
,
nbytes
,
0
);
if
(
cmd
==
DECODE_COMMAND_
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
unsigned
data_time
=
player
.
time
();
unsigned
data_time
=
player
.
time
();
unsigned
target_time
=
(
unsigned
)
unsigned
target_time
=
(
unsigned
)
(
decoder_seek_where
(
decoder
)
*
timebase
);
(
decoder_seek_where
(
decoder
)
*
timebase
);
...
@@ -328,7 +328,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
...
@@ -328,7 +328,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
if
(
song_len
>
0
&&
player
.
time
()
>=
(
unsigned
)
song_len
)
if
(
song_len
>
0
&&
player
.
time
()
>=
(
unsigned
)
song_len
)
break
;
break
;
}
while
(
cmd
!=
D
ECODE_COMMAND_
STOP
);
}
while
(
cmd
!=
D
ecoderCommand
::
STOP
);
}
}
static
bool
static
bool
...
...
test/dump_playlist.cxx
View file @
c5d05ac0
...
@@ -59,10 +59,10 @@ decoder_initialized(gcc_unused struct decoder *decoder,
...
@@ -59,10 +59,10 @@ decoder_initialized(gcc_unused struct decoder *decoder,
{
{
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_get_command
(
gcc_unused
struct
decoder
*
decoder
)
decoder_get_command
(
gcc_unused
struct
decoder
*
decoder
)
{
{
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
void
void
...
@@ -96,22 +96,22 @@ decoder_timestamp(gcc_unused struct decoder *decoder,
...
@@ -96,22 +96,22 @@ decoder_timestamp(gcc_unused struct decoder *decoder,
{
{
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_data
(
gcc_unused
struct
decoder
*
decoder
,
decoder_data
(
gcc_unused
struct
decoder
*
decoder
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
struct
input_stream
*
is
,
const
void
*
data
,
size_t
datalen
,
const
void
*
data
,
size_t
datalen
,
gcc_unused
uint16_t
kbit_rate
)
gcc_unused
uint16_t
kbit_rate
)
{
{
gcc_unused
ssize_t
nbytes
=
write
(
1
,
data
,
datalen
);
gcc_unused
ssize_t
nbytes
=
write
(
1
,
data
,
datalen
);
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
Tag
&&
tag
)
gcc_unused
Tag
&&
tag
)
{
{
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
void
void
...
...
test/read_tags.cxx
View file @
c5d05ac0
...
@@ -47,10 +47,10 @@ decoder_initialized(gcc_unused struct decoder *decoder,
...
@@ -47,10 +47,10 @@ decoder_initialized(gcc_unused struct decoder *decoder,
{
{
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_get_command
(
gcc_unused
struct
decoder
*
decoder
)
decoder_get_command
(
gcc_unused
struct
decoder
*
decoder
)
{
{
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
void
decoder_command_finished
(
gcc_unused
struct
decoder
*
decoder
)
void
decoder_command_finished
(
gcc_unused
struct
decoder
*
decoder
)
...
@@ -81,22 +81,22 @@ decoder_timestamp(gcc_unused struct decoder *decoder,
...
@@ -81,22 +81,22 @@ decoder_timestamp(gcc_unused struct decoder *decoder,
{
{
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_data
(
gcc_unused
struct
decoder
*
decoder
,
decoder_data
(
gcc_unused
struct
decoder
*
decoder
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
struct
input_stream
*
is
,
const
void
*
data
,
size_t
datalen
,
const
void
*
data
,
size_t
datalen
,
gcc_unused
uint16_t
bit_rate
)
gcc_unused
uint16_t
bit_rate
)
{
{
gcc_unused
ssize_t
nbytes
=
write
(
1
,
data
,
datalen
);
gcc_unused
ssize_t
nbytes
=
write
(
1
,
data
,
datalen
);
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
Tag
&&
tag
)
gcc_unused
Tag
&&
tag
)
{
{
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
void
void
...
...
test/run_decoder.cxx
View file @
c5d05ac0
...
@@ -68,10 +68,10 @@ decoder_initialized(struct decoder *decoder,
...
@@ -68,10 +68,10 @@ decoder_initialized(struct decoder *decoder,
decoder
->
initialized
=
true
;
decoder
->
initialized
=
true
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_get_command
(
gcc_unused
struct
decoder
*
decoder
)
decoder_get_command
(
gcc_unused
struct
decoder
*
decoder
)
{
{
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
void
decoder_command_finished
(
gcc_unused
struct
decoder
*
decoder
)
void
decoder_command_finished
(
gcc_unused
struct
decoder
*
decoder
)
...
@@ -101,22 +101,22 @@ decoder_timestamp(gcc_unused struct decoder *decoder,
...
@@ -101,22 +101,22 @@ decoder_timestamp(gcc_unused struct decoder *decoder,
{
{
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_data
(
gcc_unused
struct
decoder
*
decoder
,
decoder_data
(
gcc_unused
struct
decoder
*
decoder
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
struct
input_stream
*
is
,
const
void
*
data
,
size_t
datalen
,
const
void
*
data
,
size_t
datalen
,
gcc_unused
uint16_t
kbit_rate
)
gcc_unused
uint16_t
kbit_rate
)
{
{
gcc_unused
ssize_t
nbytes
=
write
(
1
,
data
,
datalen
);
gcc_unused
ssize_t
nbytes
=
write
(
1
,
data
,
datalen
);
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
enum
decoder_c
ommand
DecoderC
ommand
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
struct
input_stream
*
is
,
gcc_unused
Tag
&&
tag
)
gcc_unused
Tag
&&
tag
)
{
{
return
D
ECODE_COMMAND_
NONE
;
return
D
ecoderCommand
::
NONE
;
}
}
void
void
...
...
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