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
fd77acc2
Commit
fd77acc2
authored
Nov 18, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/Client: new interface which wraps struct Decoder
Prepare for a Decoder API redesign based on an abstract class with virtual methods.
parent
595d1942
Show whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
460 additions
and
407 deletions
+460
-407
Makefile.am
Makefile.am
+1
-0
Client.hxx
src/decoder/Client.hxx
+31
-0
DecoderAPI.cxx
src/decoder/DecoderAPI.cxx
+45
-22
DecoderAPI.hxx
src/decoder/DecoderAPI.hxx
+20
-18
DecoderBuffer.cxx
src/decoder/DecoderBuffer.cxx
+2
-2
DecoderBuffer.hxx
src/decoder/DecoderBuffer.hxx
+5
-5
DecoderInternal.hxx
src/decoder/DecoderInternal.hxx
+2
-1
DecoderPlugin.hxx
src/decoder/DecoderPlugin.hxx
+7
-12
Reader.cxx
src/decoder/Reader.cxx
+1
-1
Reader.hxx
src/decoder/Reader.hxx
+6
-6
AdPlugDecoderPlugin.cxx
src/decoder/plugins/AdPlugDecoderPlugin.cxx
+3
-3
AudiofileDecoderPlugin.cxx
src/decoder/plugins/AudiofileDecoderPlugin.cxx
+8
-8
DsdLib.cxx
src/decoder/plugins/DsdLib.cxx
+4
-4
DsdLib.hxx
src/decoder/plugins/DsdLib.hxx
+3
-3
DsdiffDecoderPlugin.cxx
src/decoder/plugins/DsdiffDecoderPlugin.cxx
+41
-41
DsfDecoderPlugin.cxx
src/decoder/plugins/DsfDecoderPlugin.cxx
+17
-17
FaadDecoderPlugin.cxx
src/decoder/plugins/FaadDecoderPlugin.cxx
+6
-6
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+32
-32
FfmpegIo.cxx
src/decoder/plugins/FfmpegIo.cxx
+1
-1
FfmpegIo.hxx
src/decoder/plugins/FfmpegIo.hxx
+4
-4
FlacCommon.cxx
src/decoder/plugins/FlacCommon.cxx
+4
-4
FlacCommon.hxx
src/decoder/plugins/FlacCommon.hxx
+2
-2
FlacDecoderPlugin.cxx
src/decoder/plugins/FlacDecoderPlugin.cxx
+14
-14
FlacInput.cxx
src/decoder/plugins/FlacInput.cxx
+8
-8
FlacInput.hxx
src/decoder/plugins/FlacInput.hxx
+6
-6
FluidsynthDecoderPlugin.cxx
src/decoder/plugins/FluidsynthDecoderPlugin.cxx
+3
-3
GmeDecoderPlugin.cxx
src/decoder/plugins/GmeDecoderPlugin.cxx
+6
-6
MadDecoderPlugin.cxx
src/decoder/plugins/MadDecoderPlugin.cxx
+24
-24
MikmodDecoderPlugin.cxx
src/decoder/plugins/MikmodDecoderPlugin.cxx
+3
-3
ModplugDecoderPlugin.cxx
src/decoder/plugins/ModplugDecoderPlugin.cxx
+10
-10
MpcdecDecoderPlugin.cxx
src/decoder/plugins/MpcdecDecoderPlugin.cxx
+13
-13
Mpg123DecoderPlugin.cxx
src/decoder/plugins/Mpg123DecoderPlugin.cxx
+18
-18
OggCodec.cxx
src/decoder/plugins/OggCodec.cxx
+2
-2
OggCodec.hxx
src/decoder/plugins/OggCodec.hxx
+2
-2
OggDecoder.cxx
src/decoder/plugins/OggDecoder.cxx
+1
-1
OggDecoder.hxx
src/decoder/plugins/OggDecoder.hxx
+2
-2
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+12
-12
PcmDecoderPlugin.cxx
src/decoder/plugins/PcmDecoderPlugin.cxx
+10
-10
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+6
-6
SndfileDecoderPlugin.cxx
src/decoder/plugins/SndfileDecoderPlugin.cxx
+9
-9
VorbisDecoderPlugin.cxx
src/decoder/plugins/VorbisDecoderPlugin.cxx
+14
-14
WavpackDecoderPlugin.cxx
src/decoder/plugins/WavpackDecoderPlugin.cxx
+22
-22
WildmidiDecoderPlugin.cxx
src/decoder/plugins/WildmidiDecoderPlugin.cxx
+7
-7
FakeDecoderAPI.cxx
test/FakeDecoderAPI.cxx
+19
-17
FakeDecoderAPI.hxx
test/FakeDecoderAPI.hxx
+3
-5
run_decoder.cxx
test/run_decoder.cxx
+1
-1
No files found.
Makefile.am
View file @
fd77acc2
...
@@ -100,6 +100,7 @@ libmpd_a_SOURCES = \
...
@@ -100,6 +100,7 @@ libmpd_a_SOURCES = \
src/decoder/DecoderCommand.hxx
\
src/decoder/DecoderCommand.hxx
\
src/decoder/DecoderControl.cxx src/decoder/DecoderControl.hxx
\
src/decoder/DecoderControl.cxx src/decoder/DecoderControl.hxx
\
src/decoder/DecoderAPI.cxx src/decoder/DecoderAPI.hxx
\
src/decoder/DecoderAPI.cxx src/decoder/DecoderAPI.hxx
\
src/decoder/Client.hxx
\
src/decoder/DecoderPlugin.hxx
\
src/decoder/DecoderPlugin.hxx
\
src/decoder/DecoderInternal.cxx src/decoder/DecoderInternal.hxx
\
src/decoder/DecoderInternal.cxx src/decoder/DecoderInternal.hxx
\
src/decoder/DecoderPrint.cxx src/decoder/DecoderPrint.hxx
\
src/decoder/DecoderPrint.cxx src/decoder/DecoderPrint.hxx
\
...
...
src/decoder/Client.hxx
0 → 100644
View file @
fd77acc2
/*
* Copyright 2003-2016 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DECODER_CLIENT_HXX
#define MPD_DECODER_CLIENT_HXX
#include "check.h"
/**
* An interface between the decoder plugin and the MPD core.
*/
class
DecoderClient
{
};
#endif
src/decoder/DecoderAPI.cxx
View file @
fd77acc2
...
@@ -38,10 +38,11 @@
...
@@ -38,10 +38,11 @@
#include <math.h>
#include <math.h>
void
void
decoder_initialized
(
Decoder
&
decoder
,
decoder_initialized
(
Decoder
Client
&
client
,
const
AudioFormat
audio_format
,
const
AudioFormat
audio_format
,
bool
seekable
,
SignedSongTime
duration
)
bool
seekable
,
SignedSongTime
duration
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
DecoderControl
&
dc
=
decoder
.
dc
;
DecoderControl
&
dc
=
decoder
.
dc
;
struct
audio_format_string
af_string
;
struct
audio_format_string
af_string
;
...
@@ -91,8 +92,9 @@ decoder_initialized(Decoder &decoder,
...
@@ -91,8 +92,9 @@ decoder_initialized(Decoder &decoder,
*/
*/
gcc_pure
gcc_pure
static
bool
static
bool
decoder_prepare_initial_seek
(
Decoder
&
decoder
)
decoder_prepare_initial_seek
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
const
DecoderControl
&
dc
=
decoder
.
dc
;
const
DecoderControl
&
dc
=
decoder
.
dc
;
assert
(
dc
.
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
...
@@ -138,8 +140,10 @@ decoder_prepare_initial_seek(Decoder &decoder)
...
@@ -138,8 +140,10 @@ decoder_prepare_initial_seek(Decoder &decoder)
*/
*/
gcc_pure
gcc_pure
static
DecoderCommand
static
DecoderCommand
decoder_get_virtual_command
(
Decoder
&
decoder
)
decoder_get_virtual_command
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
if
(
decoder
.
error
)
if
(
decoder
.
error
)
/* an error has occurred: stop the decoder plugin */
/* an error has occurred: stop the decoder plugin */
return
DecoderCommand
::
STOP
;
return
DecoderCommand
::
STOP
;
...
@@ -155,21 +159,24 @@ decoder_get_virtual_command(Decoder &decoder)
...
@@ -155,21 +159,24 @@ decoder_get_virtual_command(Decoder &decoder)
gcc_pure
gcc_pure
static
DecoderCommand
static
DecoderCommand
decoder_lock_get_virtual_command
(
Decoder
&
decoder
)
decoder_lock_get_virtual_command
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
const
ScopeLock
protect
(
decoder
.
dc
.
mutex
);
const
ScopeLock
protect
(
decoder
.
dc
.
mutex
);
return
decoder_get_virtual_command
(
decoder
);
return
decoder_get_virtual_command
(
decoder
);
}
}
DecoderCommand
DecoderCommand
decoder_get_command
(
Decoder
&
decoder
)
decoder_get_command
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
return
decoder_lock_get_virtual_command
(
decoder
);
return
decoder_lock_get_virtual_command
(
decoder
);
}
}
void
void
decoder_command_finished
(
Decoder
&
decoder
)
decoder_command_finished
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
DecoderControl
&
dc
=
decoder
.
dc
;
DecoderControl
&
dc
=
decoder
.
dc
;
const
ScopeLock
protect
(
dc
.
mutex
);
const
ScopeLock
protect
(
dc
.
mutex
);
...
@@ -211,8 +218,9 @@ decoder_command_finished(Decoder &decoder)
...
@@ -211,8 +218,9 @@ decoder_command_finished(Decoder &decoder)
}
}
SongTime
SongTime
decoder_seek_time
(
Decoder
&
decoder
)
decoder_seek_time
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
const
DecoderControl
&
dc
=
decoder
.
dc
;
const
DecoderControl
&
dc
=
decoder
.
dc
;
assert
(
dc
.
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
...
@@ -228,15 +236,18 @@ decoder_seek_time(Decoder &decoder)
...
@@ -228,15 +236,18 @@ decoder_seek_time(Decoder &decoder)
}
}
uint64_t
uint64_t
decoder_seek_where_frame
(
Decoder
&
decoder
)
decoder_seek_where_frame
(
Decoder
Client
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
const
DecoderControl
&
dc
=
decoder
.
dc
;
const
DecoderControl
&
dc
=
decoder
.
dc
;
return
decoder_seek_time
(
decoder
).
ToScale
<
uint64_t
>
(
dc
.
in_audio_format
.
sample_rate
);
return
decoder_seek_time
(
decoder
).
ToScale
<
uint64_t
>
(
dc
.
in_audio_format
.
sample_rate
);
}
}
void
decoder_seek_error
(
Decoder
&
decoder
)
void
decoder_seek_error
(
DecoderClient
&
client
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
DecoderControl
&
dc
=
decoder
.
dc
;
DecoderControl
&
dc
=
decoder
.
dc
;
assert
(
dc
.
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
...
@@ -257,8 +268,10 @@ void decoder_seek_error(Decoder & decoder)
...
@@ -257,8 +268,10 @@ void decoder_seek_error(Decoder & decoder)
}
}
InputStreamPtr
InputStreamPtr
decoder_open_uri
(
Decoder
&
decoder
,
const
char
*
uri
)
decoder_open_uri
(
Decoder
Client
&
client
,
const
char
*
uri
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
assert
(
decoder
.
dc
.
state
==
DecoderState
::
START
||
assert
(
decoder
.
dc
.
state
==
DecoderState
::
START
||
decoder
.
dc
.
state
==
DecoderState
::
DECODE
);
decoder
.
dc
.
state
==
DecoderState
::
DECODE
);
...
@@ -311,11 +324,12 @@ decoder_check_cancel_read(const Decoder *decoder)
...
@@ -311,11 +324,12 @@ decoder_check_cancel_read(const Decoder *decoder)
}
}
size_t
size_t
decoder_read
(
Decoder
*
decoder
,
decoder_read
(
Decoder
Client
*
client
,
InputStream
&
is
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
void
*
buffer
,
size_t
length
)
try
{
try
{
/* XXX don't allow decoder==nullptr */
/* XXX don't allow decoder==nullptr */
auto
*
decoder
=
(
Decoder
*
)
client
;
assert
(
decoder
==
nullptr
||
assert
(
decoder
==
nullptr
||
decoder
->
dc
.
state
==
DecoderState
::
START
||
decoder
->
dc
.
state
==
DecoderState
::
START
||
...
@@ -342,6 +356,7 @@ try {
...
@@ -342,6 +356,7 @@ try {
return
nbytes
;
return
nbytes
;
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
auto
*
decoder
=
(
Decoder
*
)
client
;
if
(
decoder
!=
nullptr
)
if
(
decoder
!=
nullptr
)
decoder
->
error
=
std
::
current_exception
();
decoder
->
error
=
std
::
current_exception
();
else
else
...
@@ -350,13 +365,13 @@ try {
...
@@ -350,13 +365,13 @@ try {
}
}
bool
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
decoder_read_full
(
Decoder
Client
*
client
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
void
*
_buffer
,
size_t
size
)
{
{
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size
);
size_t
nbytes
=
decoder_read
(
client
,
is
,
buffer
,
size
);
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
return
false
;
return
false
;
...
@@ -368,11 +383,11 @@ decoder_read_full(Decoder *decoder, InputStream &is,
...
@@ -368,11 +383,11 @@ decoder_read_full(Decoder *decoder, InputStream &is,
}
}
bool
bool
decoder_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
)
decoder_skip
(
Decoder
Client
*
client
,
InputStream
&
is
,
size_t
size
)
{
{
while
(
size
>
0
)
{
while
(
size
>
0
)
{
char
buffer
[
1024
];
char
buffer
[
1024
];
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size_t
nbytes
=
decoder_read
(
client
,
is
,
buffer
,
std
::
min
(
sizeof
(
buffer
),
size
));
std
::
min
(
sizeof
(
buffer
),
size
));
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
return
false
;
return
false
;
...
@@ -384,10 +399,11 @@ decoder_skip(Decoder *decoder, InputStream &is, size_t size)
...
@@ -384,10 +399,11 @@ decoder_skip(Decoder *decoder, InputStream &is, size_t size)
}
}
void
void
decoder_timestamp
(
Decoder
&
decoder
,
double
t
)
decoder_timestamp
(
Decoder
Client
&
client
,
double
t
)
{
{
assert
(
t
>=
0
);
assert
(
t
>=
0
);
auto
&
decoder
=
(
Decoder
&
)
client
;
decoder
.
timestamp
=
t
;
decoder
.
timestamp
=
t
;
}
}
...
@@ -396,8 +412,9 @@ decoder_timestamp(Decoder &decoder, double t)
...
@@ -396,8 +412,9 @@ decoder_timestamp(Decoder &decoder, double t)
* (decoder.chunk) if there is one.
* (decoder.chunk) if there is one.
*/
*/
static
DecoderCommand
static
DecoderCommand
do_send_tag
(
Decoder
&
decoder
,
const
Tag
&
tag
)
do_send_tag
(
Decoder
Client
&
client
,
const
Tag
&
tag
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
MusicChunk
*
chunk
;
MusicChunk
*
chunk
;
if
(
decoder
.
current_chunk
!=
nullptr
)
{
if
(
decoder
.
current_chunk
!=
nullptr
)
{
...
@@ -419,8 +436,9 @@ do_send_tag(Decoder &decoder, const Tag &tag)
...
@@ -419,8 +436,9 @@ do_send_tag(Decoder &decoder, const Tag &tag)
}
}
static
bool
static
bool
update_stream_tag
(
Decoder
&
decoder
,
InputStream
*
is
)
update_stream_tag
(
Decoder
Client
&
client
,
InputStream
*
is
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
Tag
*
tag
;
Tag
*
tag
;
tag
=
is
!=
nullptr
tag
=
is
!=
nullptr
...
@@ -445,11 +463,12 @@ update_stream_tag(Decoder &decoder, InputStream *is)
...
@@ -445,11 +463,12 @@ update_stream_tag(Decoder &decoder, InputStream *is)
}
}
DecoderCommand
DecoderCommand
decoder_data
(
Decoder
&
decoder
,
decoder_data
(
Decoder
Client
&
client
,
InputStream
*
is
,
InputStream
*
is
,
const
void
*
data
,
size_t
length
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
uint16_t
kbit_rate
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
DecoderControl
&
dc
=
decoder
.
dc
;
DecoderControl
&
dc
=
decoder
.
dc
;
assert
(
dc
.
state
==
DecoderState
::
DECODE
);
assert
(
dc
.
state
==
DecoderState
::
DECODE
);
...
@@ -552,9 +571,10 @@ decoder_data(Decoder &decoder,
...
@@ -552,9 +571,10 @@ decoder_data(Decoder &decoder,
}
}
DecoderCommand
DecoderCommand
decoder_tag
(
Decoder
&
decoder
,
InputStream
*
is
,
decoder_tag
(
Decoder
Client
&
client
,
InputStream
*
is
,
Tag
&&
tag
)
Tag
&&
tag
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
gcc_unused
const
DecoderControl
&
dc
=
decoder
.
dc
;
gcc_unused
const
DecoderControl
&
dc
=
decoder
.
dc
;
DecoderCommand
cmd
;
DecoderCommand
cmd
;
...
@@ -596,9 +616,11 @@ decoder_tag(Decoder &decoder, InputStream *is,
...
@@ -596,9 +616,11 @@ decoder_tag(Decoder &decoder, InputStream *is,
}
}
void
void
decoder_replay_gain
(
Decoder
&
decoder
,
decoder_replay_gain
(
Decoder
Client
&
client
,
const
ReplayGainInfo
*
replay_gain_info
)
const
ReplayGainInfo
*
replay_gain_info
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
if
(
replay_gain_info
!=
nullptr
)
{
if
(
replay_gain_info
!=
nullptr
)
{
static
unsigned
serial
;
static
unsigned
serial
;
if
(
++
serial
==
0
)
if
(
++
serial
==
0
)
...
@@ -631,8 +653,9 @@ decoder_replay_gain(Decoder &decoder,
...
@@ -631,8 +653,9 @@ decoder_replay_gain(Decoder &decoder,
}
}
void
void
decoder_mixramp
(
Decoder
&
decoder
,
MixRampInfo
&&
mix_ramp
)
decoder_mixramp
(
Decoder
Client
&
client
,
MixRampInfo
&&
mix_ramp
)
{
{
auto
&
decoder
=
(
Decoder
&
)
client
;
DecoderControl
&
dc
=
decoder
.
dc
;
DecoderControl
&
dc
=
decoder
.
dc
;
dc
.
SetMixRamp
(
std
::
move
(
mix_ramp
));
dc
.
SetMixRamp
(
std
::
move
(
mix_ramp
));
...
...
src/decoder/DecoderAPI.hxx
View file @
fd77acc2
...
@@ -44,6 +44,8 @@
...
@@ -44,6 +44,8 @@
#include <stdint.h>
#include <stdint.h>
class
DecoderClient
;
/**
/**
* Throw an instance of this class to stop decoding the current song
* Throw an instance of this class to stop decoding the current song
* (successfully). It can be used to jump out of all of a decoder's
* (successfully). It can be used to jump out of all of a decoder's
...
@@ -63,7 +65,7 @@ class StopDecoder {};
...
@@ -63,7 +65,7 @@ class StopDecoder {};
* unknown
* unknown
*/
*/
void
void
decoder_initialized
(
Decoder
&
decoder
,
decoder_initialized
(
Decoder
Client
&
decoder
,
AudioFormat
audio_format
,
AudioFormat
audio_format
,
bool
seekable
,
SignedSongTime
duration
);
bool
seekable
,
SignedSongTime
duration
);
...
@@ -76,7 +78,7 @@ decoder_initialized(Decoder &decoder,
...
@@ -76,7 +78,7 @@ decoder_initialized(Decoder &decoder,
*/
*/
gcc_pure
gcc_pure
DecoderCommand
DecoderCommand
decoder_get_command
(
Decoder
&
decoder
);
decoder_get_command
(
Decoder
Client
&
decoder
);
/**
/**
* Called by the decoder when it has performed the requested command
* Called by the decoder when it has performed the requested command
...
@@ -86,7 +88,7 @@ decoder_get_command(Decoder &decoder);
...
@@ -86,7 +88,7 @@ decoder_get_command(Decoder &decoder);
* @param decoder the decoder object
* @param decoder the decoder object
*/
*/
void
void
decoder_command_finished
(
Decoder
&
decoder
);
decoder_command_finished
(
Decoder
Client
&
decoder
);
/**
/**
* Call this when you have received the DecoderCommand::SEEK command.
* Call this when you have received the DecoderCommand::SEEK command.
...
@@ -96,7 +98,7 @@ decoder_command_finished(Decoder &decoder);
...
@@ -96,7 +98,7 @@ decoder_command_finished(Decoder &decoder);
*/
*/
gcc_pure
gcc_pure
SongTime
SongTime
decoder_seek_time
(
Decoder
&
decoder
);
decoder_seek_time
(
Decoder
Client
&
decoder
);
/**
/**
* Call this when you have received the DecoderCommand::SEEK command.
* Call this when you have received the DecoderCommand::SEEK command.
...
@@ -106,7 +108,7 @@ decoder_seek_time(Decoder &decoder);
...
@@ -106,7 +108,7 @@ decoder_seek_time(Decoder &decoder);
*/
*/
gcc_pure
gcc_pure
uint64_t
uint64_t
decoder_seek_where_frame
(
Decoder
&
decoder
);
decoder_seek_where_frame
(
Decoder
Client
&
decoder
);
/**
/**
* Call this instead of decoder_command_finished() when seeking has
* Call this instead of decoder_command_finished() when seeking has
...
@@ -115,7 +117,7 @@ decoder_seek_where_frame(Decoder &decoder);
...
@@ -115,7 +117,7 @@ decoder_seek_where_frame(Decoder &decoder);
* @param decoder the decoder object
* @param decoder the decoder object
*/
*/
void
void
decoder_seek_error
(
Decoder
&
decoder
);
decoder_seek_error
(
Decoder
Client
&
decoder
);
/**
/**
* Open a new #InputStream and wait until it's ready.
* Open a new #InputStream and wait until it's ready.
...
@@ -125,7 +127,7 @@ decoder_seek_error(Decoder &decoder);
...
@@ -125,7 +127,7 @@ decoder_seek_error(Decoder &decoder);
* Throws std::runtime_error on error.
* Throws std::runtime_error on error.
*/
*/
InputStreamPtr
InputStreamPtr
decoder_open_uri
(
Decoder
&
decoder
,
const
char
*
uri
);
decoder_open_uri
(
Decoder
Client
&
decoder
,
const
char
*
uri
);
/**
/**
* Blocking read from the input stream.
* Blocking read from the input stream.
...
@@ -138,11 +140,11 @@ decoder_open_uri(Decoder &decoder, const char *uri);
...
@@ -138,11 +140,11 @@ decoder_open_uri(Decoder &decoder, const char *uri);
* occurs: end of file; error; command (like SEEK or STOP).
* occurs: end of file; error; command (like SEEK or STOP).
*/
*/
size_t
size_t
decoder_read
(
Decoder
*
decoder
,
InputStream
&
is
,
decoder_read
(
Decoder
Client
*
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
);
void
*
buffer
,
size_t
length
);
static
inline
size_t
static
inline
size_t
decoder_read
(
Decoder
&
decoder
,
InputStream
&
is
,
decoder_read
(
Decoder
Client
&
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
void
*
buffer
,
size_t
length
)
{
{
return
decoder_read
(
&
decoder
,
is
,
buffer
,
length
);
return
decoder_read
(
&
decoder
,
is
,
buffer
,
length
);
...
@@ -156,7 +158,7 @@ decoder_read(Decoder &decoder, InputStream &is,
...
@@ -156,7 +158,7 @@ decoder_read(Decoder &decoder, InputStream &is,
* data
* data
*/
*/
bool
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
decoder_read_full
(
Decoder
Client
*
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
size
);
void
*
buffer
,
size_t
size
);
/**
/**
...
@@ -165,7 +167,7 @@ decoder_read_full(Decoder *decoder, InputStream &is,
...
@@ -165,7 +167,7 @@ decoder_read_full(Decoder *decoder, InputStream &is,
* @return true on success, false on error or command
* @return true on success, false on error or command
*/
*/
bool
bool
decoder_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
);
decoder_skip
(
Decoder
Client
*
decoder
,
InputStream
&
is
,
size_t
size
);
/**
/**
* Sets the time stamp for the next data chunk [seconds]. The MPD
* Sets the time stamp for the next data chunk [seconds]. The MPD
...
@@ -174,7 +176,7 @@ decoder_skip(Decoder *decoder, InputStream &is, size_t size);
...
@@ -174,7 +176,7 @@ decoder_skip(Decoder *decoder, InputStream &is, size_t size);
* on the buffer size won't work.
* on the buffer size won't work.
*/
*/
void
void
decoder_timestamp
(
Decoder
&
decoder
,
double
t
);
decoder_timestamp
(
Decoder
Client
&
decoder
,
double
t
);
/**
/**
* This function is called by the decoder plugin when it has
* This function is called by the decoder plugin when it has
...
@@ -189,12 +191,12 @@ decoder_timestamp(Decoder &decoder, double t);
...
@@ -189,12 +191,12 @@ decoder_timestamp(Decoder &decoder, double t);
* command pending
* command pending
*/
*/
DecoderCommand
DecoderCommand
decoder_data
(
Decoder
&
decoder
,
InputStream
*
is
,
decoder_data
(
Decoder
Client
&
decoder
,
InputStream
*
is
,
const
void
*
data
,
size_t
length
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
);
uint16_t
kbit_rate
);
static
inline
DecoderCommand
static
inline
DecoderCommand
decoder_data
(
Decoder
&
decoder
,
InputStream
&
is
,
decoder_data
(
Decoder
Client
&
decoder
,
InputStream
&
is
,
const
void
*
data
,
size_t
length
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
uint16_t
kbit_rate
)
{
{
...
@@ -212,10 +214,10 @@ decoder_data(Decoder &decoder, InputStream &is,
...
@@ -212,10 +214,10 @@ decoder_data(Decoder &decoder, InputStream &is,
* command pending
* command pending
*/
*/
DecoderCommand
DecoderCommand
decoder_tag
(
Decoder
&
decoder
,
InputStream
*
is
,
Tag
&&
tag
);
decoder_tag
(
Decoder
Client
&
decoder
,
InputStream
*
is
,
Tag
&&
tag
);
static
inline
DecoderCommand
static
inline
DecoderCommand
decoder_tag
(
Decoder
&
decoder
,
InputStream
&
is
,
Tag
&&
tag
)
decoder_tag
(
Decoder
Client
&
decoder
,
InputStream
&
is
,
Tag
&&
tag
)
{
{
return
decoder_tag
(
decoder
,
&
is
,
std
::
move
(
tag
));
return
decoder_tag
(
decoder
,
&
is
,
std
::
move
(
tag
));
}
}
...
@@ -227,13 +229,13 @@ decoder_tag(Decoder &decoder, InputStream &is, Tag &&tag)
...
@@ -227,13 +229,13 @@ decoder_tag(Decoder &decoder, InputStream &is, Tag &&tag)
* to invalidate the previous replay gain values
* to invalidate the previous replay gain values
*/
*/
void
void
decoder_replay_gain
(
Decoder
&
decoder
,
decoder_replay_gain
(
Decoder
Client
&
decoder
,
const
ReplayGainInfo
*
replay_gain_info
);
const
ReplayGainInfo
*
replay_gain_info
);
/**
/**
* Store MixRamp tags.
* Store MixRamp tags.
*/
*/
void
void
decoder_mixramp
(
Decoder
&
decoder
,
MixRampInfo
&&
mix_ramp
);
decoder_mixramp
(
Decoder
Client
&
decoder
,
MixRampInfo
&&
mix_ramp
);
#endif
#endif
src/decoder/DecoderBuffer.cxx
View file @
fd77acc2
...
@@ -29,7 +29,7 @@ DecoderBuffer::Fill()
...
@@ -29,7 +29,7 @@ DecoderBuffer::Fill()
/* buffer is full */
/* buffer is full */
return
false
;
return
false
;
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
size_t
nbytes
=
decoder_read
(
client
,
is
,
w
.
data
,
w
.
size
);
w
.
data
,
w
.
size
);
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
/* end of file, I/O error or decoder command
/* end of file, I/O error or decoder command
...
@@ -65,5 +65,5 @@ DecoderBuffer::Skip(size_t nbytes)
...
@@ -65,5 +65,5 @@ DecoderBuffer::Skip(size_t nbytes)
buffer
.
Clear
();
buffer
.
Clear
();
nbytes
-=
r
.
size
;
nbytes
-=
r
.
size
;
return
decoder_skip
(
decoder
,
is
,
nbytes
);
return
decoder_skip
(
client
,
is
,
nbytes
);
}
}
src/decoder/DecoderBuffer.hxx
View file @
fd77acc2
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include <stddef.h>
#include <stddef.h>
#include <stdint.h>
#include <stdint.h>
struct
Decoder
;
class
DecoderClient
;
class
InputStream
;
class
InputStream
;
/**
/**
...
@@ -36,7 +36,7 @@ class InputStream;
...
@@ -36,7 +36,7 @@ class InputStream;
* read it. It will automatically handle shifting the buffer.
* read it. It will automatically handle shifting the buffer.
*/
*/
class
DecoderBuffer
{
class
DecoderBuffer
{
Decoder
*
const
decoder
;
Decoder
Client
*
const
client
;
InputStream
&
is
;
InputStream
&
is
;
DynamicFifoBuffer
<
uint8_t
>
buffer
;
DynamicFifoBuffer
<
uint8_t
>
buffer
;
...
@@ -45,14 +45,14 @@ public:
...
@@ -45,14 +45,14 @@ public:
/**
/**
* Creates a new buffer.
* Creates a new buffer.
*
*
* @param _
decoder the decoder objec
t, used for decoder_read(),
* @param _
client the decoder clien
t, used for decoder_read(),
* may be nullptr
* may be nullptr
* @param _is the input stream object where we should read from
* @param _is the input stream object where we should read from
* @param _size the maximum size of the buffer
* @param _size the maximum size of the buffer
*/
*/
DecoderBuffer
(
Decoder
*
_decoder
,
InputStream
&
_is
,
DecoderBuffer
(
Decoder
Client
*
_client
,
InputStream
&
_is
,
size_t
_size
)
size_t
_size
)
:
decoder
(
_decoder
),
is
(
_is
),
buffer
(
_size
)
{}
:
client
(
_client
),
is
(
_is
),
buffer
(
_size
)
{}
const
InputStream
&
GetStream
()
const
{
const
InputStream
&
GetStream
()
const
{
return
is
;
return
is
;
...
...
src/decoder/DecoderInternal.hxx
View file @
fd77acc2
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#ifndef MPD_DECODER_INTERNAL_HXX
#ifndef MPD_DECODER_INTERNAL_HXX
#define MPD_DECODER_INTERNAL_HXX
#define MPD_DECODER_INTERNAL_HXX
#include "Client.hxx"
#include "ReplayGainInfo.hxx"
#include "ReplayGainInfo.hxx"
#include <exception>
#include <exception>
...
@@ -29,7 +30,7 @@ struct MusicChunk;
...
@@ -29,7 +30,7 @@ struct MusicChunk;
struct
DecoderControl
;
struct
DecoderControl
;
struct
Tag
;
struct
Tag
;
struct
Decoder
{
struct
Decoder
final
:
DecoderClient
{
DecoderControl
&
dc
;
DecoderControl
&
dc
;
/**
/**
...
...
src/decoder/DecoderPlugin.hxx
View file @
fd77acc2
...
@@ -27,12 +27,7 @@ class InputStream;
...
@@ -27,12 +27,7 @@ class InputStream;
struct
TagHandler
;
struct
TagHandler
;
class
Path
;
class
Path
;
template
<
typename
T
>
class
AllocatedString
;
template
<
typename
T
>
class
AllocatedString
;
class
DecoderClient
;
/**
* Opaque handle which the decoder plugin passes to the functions in
* this header.
*/
struct
Decoder
;
struct
DecoderPlugin
{
struct
DecoderPlugin
{
const
char
*
name
;
const
char
*
name
;
...
@@ -60,14 +55,14 @@ struct DecoderPlugin {
...
@@ -60,14 +55,14 @@ struct DecoderPlugin {
* possible, it is recommended to implement this method,
* possible, it is recommended to implement this method,
* because it is more versatile.
* because it is more versatile.
*/
*/
void
(
*
stream_decode
)(
Decoder
&
decoder
,
InputStream
&
is
);
void
(
*
stream_decode
)(
Decoder
Client
&
client
,
InputStream
&
is
);
/**
/**
* Decode a local file.
* Decode a local file.
*
*
* Either implement this method or stream_decode().
* Either implement this method or stream_decode().
*/
*/
void
(
*
file_decode
)(
Decoder
&
decoder
,
Path
path_fs
);
void
(
*
file_decode
)(
Decoder
Client
&
client
,
Path
path_fs
);
/**
/**
* Scan metadata of a file.
* Scan metadata of a file.
...
@@ -127,16 +122,16 @@ struct DecoderPlugin {
...
@@ -127,16 +122,16 @@ struct DecoderPlugin {
/**
/**
* Decode a stream.
* Decode a stream.
*/
*/
void
StreamDecode
(
Decoder
&
decoder
,
InputStream
&
is
)
const
{
void
StreamDecode
(
Decoder
Client
&
client
,
InputStream
&
is
)
const
{
stream_decode
(
decoder
,
is
);
stream_decode
(
client
,
is
);
}
}
/**
/**
* Decode a file.
* Decode a file.
*/
*/
template
<
typename
P
>
template
<
typename
P
>
void
FileDecode
(
Decoder
&
decoder
,
P
path_fs
)
const
{
void
FileDecode
(
Decoder
Client
&
client
,
P
path_fs
)
const
{
file_decode
(
decoder
,
path_fs
);
file_decode
(
client
,
path_fs
);
}
}
/**
/**
...
...
src/decoder/Reader.cxx
View file @
fd77acc2
...
@@ -24,5 +24,5 @@
...
@@ -24,5 +24,5 @@
size_t
size_t
DecoderReader
::
Read
(
void
*
data
,
size_t
size
)
DecoderReader
::
Read
(
void
*
data
,
size_t
size
)
{
{
return
decoder_read
(
&
decoder
,
is
,
data
,
size
);
return
decoder_read
(
client
,
is
,
data
,
size
);
}
}
src/decoder/Reader.hxx
View file @
fd77acc2
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "fs/io/Reader.hxx"
#include "fs/io/Reader.hxx"
#include "Compiler.h"
#include "Compiler.h"
struct
Decoder
;
class
DecoderClient
;
class
InputStream
;
class
InputStream
;
/**
/**
...
@@ -32,15 +32,15 @@ class InputStream;
...
@@ -32,15 +32,15 @@ class InputStream;
* interface.
* interface.
*/
*/
class
DecoderReader
final
:
public
Reader
{
class
DecoderReader
final
:
public
Reader
{
Decoder
&
decoder
;
Decoder
Client
&
client
;
InputStream
&
is
;
InputStream
&
is
;
public
:
public
:
DecoderReader
(
Decoder
&
_decoder
,
InputStream
&
_is
)
DecoderReader
(
Decoder
Client
&
_client
,
InputStream
&
_is
)
:
decoder
(
_decoder
),
is
(
_is
)
{}
:
client
(
_client
),
is
(
_is
)
{}
Decoder
&
GetDecoder
()
{
Decoder
Client
&
GetClient
()
{
return
decoder
;
return
client
;
}
}
InputStream
&
GetInputStream
()
{
InputStream
&
GetInputStream
()
{
...
...
src/decoder/plugins/AdPlugDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -49,7 +49,7 @@ adplug_init(const ConfigBlock &block)
...
@@ -49,7 +49,7 @@ adplug_init(const ConfigBlock &block)
}
}
static
void
static
void
adplug_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
adplug_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
CEmuopl
opl
(
sample_rate
,
true
,
true
);
CEmuopl
opl
(
sample_rate
,
true
,
true
);
opl
.
init
();
opl
.
init
();
...
@@ -61,7 +61,7 @@ adplug_file_decode(Decoder &decoder, Path path_fs)
...
@@ -61,7 +61,7 @@ adplug_file_decode(Decoder &decoder, Path path_fs)
const
AudioFormat
audio_format
(
sample_rate
,
SampleFormat
::
S16
,
2
);
const
AudioFormat
audio_format
(
sample_rate
,
SampleFormat
::
S16
,
2
);
assert
(
audio_format
.
IsValid
());
assert
(
audio_format
.
IsValid
());
decoder_initialized
(
decoder
,
audio_format
,
false
,
decoder_initialized
(
client
,
audio_format
,
false
,
SongTime
::
FromMS
(
player
->
songlength
()));
SongTime
::
FromMS
(
player
->
songlength
()));
DecoderCommand
cmd
;
DecoderCommand
cmd
;
...
@@ -73,7 +73,7 @@ adplug_file_decode(Decoder &decoder, Path path_fs)
...
@@ -73,7 +73,7 @@ adplug_file_decode(Decoder &decoder, Path path_fs)
int16_t
buffer
[
2048
];
int16_t
buffer
[
2048
];
constexpr
unsigned
frames_per_buffer
=
ARRAY_SIZE
(
buffer
)
/
2
;
constexpr
unsigned
frames_per_buffer
=
ARRAY_SIZE
(
buffer
)
/
2
;
opl
.
update
(
buffer
,
frames_per_buffer
);
opl
.
update
(
buffer
,
frames_per_buffer
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
cmd
=
decoder_data
(
client
,
nullptr
,
buffer
,
sizeof
(
buffer
),
buffer
,
sizeof
(
buffer
),
0
);
0
);
}
while
(
cmd
==
DecoderCommand
::
NONE
);
}
while
(
cmd
==
DecoderCommand
::
NONE
);
...
...
src/decoder/plugins/AudiofileDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -51,14 +51,14 @@ audiofile_init(const ConfigBlock &)
...
@@ -51,14 +51,14 @@ audiofile_init(const ConfigBlock &)
}
}
struct
AudioFileInputStream
{
struct
AudioFileInputStream
{
Decoder
*
const
decoder
;
Decoder
Client
*
const
client
;
InputStream
&
is
;
InputStream
&
is
;
size_t
Read
(
void
*
buffer
,
size_t
size
)
{
size_t
Read
(
void
*
buffer
,
size_t
size
)
{
/* libaudiofile does not like partial reads at all,
/* libaudiofile does not like partial reads at all,
and will abort playback; therefore always force full
and will abort playback; therefore always force full
reads */
reads */
return
decoder_read_full
(
decoder
,
is
,
buffer
,
size
)
return
decoder_read_full
(
client
,
is
,
buffer
,
size
)
?
size
?
size
:
0
;
:
0
;
}
}
...
@@ -181,14 +181,14 @@ audiofile_setup_sample_format(AFfilehandle af_fp)
...
@@ -181,14 +181,14 @@ audiofile_setup_sample_format(AFfilehandle af_fp)
}
}
static
void
static
void
audiofile_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
audiofile_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
if
(
!
is
.
IsSeekable
()
||
!
is
.
KnownSize
())
{
if
(
!
is
.
IsSeekable
()
||
!
is
.
KnownSize
())
{
LogWarning
(
audiofile_domain
,
"not seekable"
);
LogWarning
(
audiofile_domain
,
"not seekable"
);
return
;
return
;
}
}
AudioFileInputStream
afis
{
&
decoder
,
is
};
AudioFileInputStream
afis
{
&
client
,
is
};
AFvirtualfile
*
const
vf
=
setup_virtual_fops
(
afis
);
AFvirtualfile
*
const
vf
=
setup_virtual_fops
(
afis
);
const
AFfilehandle
fh
=
afOpenVirtualFile
(
vf
,
"r"
,
nullptr
);
const
AFfilehandle
fh
=
afOpenVirtualFile
(
vf
,
"r"
,
nullptr
);
...
@@ -210,7 +210,7 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -210,7 +210,7 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
const
unsigned
frame_size
=
(
unsigned
)
const
unsigned
frame_size
=
(
unsigned
)
afGetVirtualFrameSize
(
fh
,
AF_DEFAULT_TRACK
,
true
);
afGetVirtualFrameSize
(
fh
,
AF_DEFAULT_TRACK
,
true
);
decoder_initialized
(
decoder
,
audio_format
,
true
,
total_time
);
decoder_initialized
(
client
,
audio_format
,
true
,
total_time
);
DecoderCommand
cmd
;
DecoderCommand
cmd
;
do
{
do
{
...
@@ -223,15 +223,15 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -223,15 +223,15 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
if
(
nframes
<=
0
)
if
(
nframes
<=
0
)
break
;
break
;
cmd
=
decoder_data
(
decoder
,
nullptr
,
cmd
=
decoder_data
(
client
,
nullptr
,
chunk
,
nframes
*
frame_size
,
chunk
,
nframes
*
frame_size
,
kbit_rate
);
kbit_rate
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
AFframecount
frame
=
decoder_seek_where_frame
(
decoder
);
AFframecount
frame
=
decoder_seek_where_frame
(
client
);
afSeekFrame
(
fh
,
AF_DEFAULT_TRACK
,
frame
);
afSeekFrame
(
fh
,
AF_DEFAULT_TRACK
,
frame
);
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
cmd
=
DecoderCommand
::
NONE
;
cmd
=
DecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
DecoderCommand
::
NONE
);
}
while
(
cmd
==
DecoderCommand
::
NONE
);
...
...
src/decoder/plugins/DsdLib.cxx
View file @
fd77acc2
...
@@ -51,7 +51,7 @@ DsdId::Equals(const char *s) const
...
@@ -51,7 +51,7 @@ DsdId::Equals(const char *s) const
* Skip the #InputStream to the specified offset.
* Skip the #InputStream to the specified offset.
*/
*/
bool
bool
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip_to
(
Decoder
Client
*
client
,
InputStream
&
is
,
offset_type
offset
)
offset_type
offset
)
{
{
if
(
is
.
IsSeekable
())
{
if
(
is
.
IsSeekable
())
{
...
@@ -65,14 +65,14 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is,
...
@@ -65,14 +65,14 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is,
if
(
is
.
GetOffset
()
>
offset
)
if
(
is
.
GetOffset
()
>
offset
)
return
false
;
return
false
;
return
dsdlib_skip
(
decoder
,
is
,
offset
-
is
.
GetOffset
());
return
dsdlib_skip
(
client
,
is
,
offset
-
is
.
GetOffset
());
}
}
/**
/**
* Skip some bytes from the #InputStream.
* Skip some bytes from the #InputStream.
*/
*/
bool
bool
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip
(
Decoder
Client
*
client
,
InputStream
&
is
,
offset_type
delta
)
offset_type
delta
)
{
{
if
(
delta
==
0
)
if
(
delta
==
0
)
...
@@ -91,7 +91,7 @@ dsdlib_skip(Decoder *decoder, InputStream &is,
...
@@ -91,7 +91,7 @@ dsdlib_skip(Decoder *decoder, InputStream &is,
expensive */
expensive */
return
false
;
return
false
;
return
decoder_skip
(
decoder
,
is
,
delta
);
return
decoder_skip
(
client
,
is
,
delta
);
}
}
bool
bool
...
...
src/decoder/plugins/DsdLib.hxx
View file @
fd77acc2
...
@@ -26,8 +26,8 @@
...
@@ -26,8 +26,8 @@
#include <stdint.h>
#include <stdint.h>
struct
Decoder
;
struct
TagHandler
;
struct
TagHandler
;
class
DecoderClient
;
class
InputStream
;
class
InputStream
;
struct
DsdId
{
struct
DsdId
{
...
@@ -60,11 +60,11 @@ public:
...
@@ -60,11 +60,11 @@ public:
};
};
bool
bool
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip_to
(
Decoder
Client
*
client
,
InputStream
&
is
,
offset_type
offset
);
offset_type
offset
);
bool
bool
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip
(
Decoder
Client
*
client
,
InputStream
&
is
,
offset_type
delta
);
offset_type
delta
);
/**
/**
...
...
src/decoder/plugins/DsdiffDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -78,21 +78,21 @@ dsdiff_init(const ConfigBlock &block)
...
@@ -78,21 +78,21 @@ dsdiff_init(const ConfigBlock &block)
}
}
static
bool
static
bool
dsdiff_read_id
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_id
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsdId
*
id
)
DsdId
*
id
)
{
{
return
decoder_read_full
(
decoder
,
is
,
id
,
sizeof
(
*
id
));
return
decoder_read_full
(
client
,
is
,
id
,
sizeof
(
*
id
));
}
}
static
bool
static
bool
dsdiff_read_chunk_header
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_chunk_header
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsdiffChunkHeader
*
header
)
DsdiffChunkHeader
*
header
)
{
{
return
decoder_read_full
(
decoder
,
is
,
header
,
sizeof
(
*
header
));
return
decoder_read_full
(
client
,
is
,
header
,
sizeof
(
*
header
));
}
}
static
bool
static
bool
dsdiff_read_payload
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_payload
(
Decoder
Client
*
client
,
InputStream
&
is
,
const
DsdiffChunkHeader
*
header
,
const
DsdiffChunkHeader
*
header
,
void
*
data
,
size_t
length
)
void
*
data
,
size_t
length
)
{
{
...
@@ -100,20 +100,20 @@ dsdiff_read_payload(Decoder *decoder, InputStream &is,
...
@@ -100,20 +100,20 @@ dsdiff_read_payload(Decoder *decoder, InputStream &is,
if
(
size
!=
(
uint64_t
)
length
)
if
(
size
!=
(
uint64_t
)
length
)
return
false
;
return
false
;
return
decoder_read_full
(
decoder
,
is
,
data
,
length
);
return
decoder_read_full
(
client
,
is
,
data
,
length
);
}
}
/**
/**
* Read and parse a "SND" chunk inside "PROP".
* Read and parse a "SND" chunk inside "PROP".
*/
*/
static
bool
static
bool
dsdiff_read_prop_snd
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_prop_snd
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
DsdiffMetaData
*
metadata
,
offset_type
end_offset
)
offset_type
end_offset
)
{
{
DsdiffChunkHeader
header
;
DsdiffChunkHeader
header
;
while
(
is
.
GetOffset
()
+
sizeof
(
header
)
<=
end_offset
)
{
while
(
is
.
GetOffset
()
+
sizeof
(
header
)
<=
end_offset
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
&
header
))
if
(
!
dsdiff_read_chunk_header
(
client
,
is
,
&
header
))
return
false
;
return
false
;
offset_type
chunk_end_offset
=
is
.
GetOffset
()
offset_type
chunk_end_offset
=
is
.
GetOffset
()
...
@@ -123,7 +123,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -123,7 +123,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
if
(
header
.
id
.
Equals
(
"FS "
))
{
if
(
header
.
id
.
Equals
(
"FS "
))
{
uint32_t
sample_rate
;
uint32_t
sample_rate
;
if
(
!
dsdiff_read_payload
(
decoder
,
is
,
&
header
,
if
(
!
dsdiff_read_payload
(
client
,
is
,
&
header
,
&
sample_rate
,
&
sample_rate
,
sizeof
(
sample_rate
)))
sizeof
(
sample_rate
)))
return
false
;
return
false
;
...
@@ -132,18 +132,18 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -132,18 +132,18 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
}
else
if
(
header
.
id
.
Equals
(
"CHNL"
))
{
}
else
if
(
header
.
id
.
Equals
(
"CHNL"
))
{
uint16_t
channels
;
uint16_t
channels
;
if
(
header
.
GetSize
()
<
sizeof
(
channels
)
||
if
(
header
.
GetSize
()
<
sizeof
(
channels
)
||
!
decoder_read_full
(
decoder
,
is
,
!
decoder_read_full
(
client
,
is
,
&
channels
,
sizeof
(
channels
))
||
&
channels
,
sizeof
(
channels
))
||
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
!
dsdlib_skip_to
(
client
,
is
,
chunk_end_offset
))
return
false
;
return
false
;
metadata
->
channels
=
FromBE16
(
channels
);
metadata
->
channels
=
FromBE16
(
channels
);
}
else
if
(
header
.
id
.
Equals
(
"CMPR"
))
{
}
else
if
(
header
.
id
.
Equals
(
"CMPR"
))
{
DsdId
type
;
DsdId
type
;
if
(
header
.
GetSize
()
<
sizeof
(
type
)
||
if
(
header
.
GetSize
()
<
sizeof
(
type
)
||
!
decoder_read_full
(
decoder
,
is
,
!
decoder_read_full
(
client
,
is
,
&
type
,
sizeof
(
type
))
||
&
type
,
sizeof
(
type
))
||
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
!
dsdlib_skip_to
(
client
,
is
,
chunk_end_offset
))
return
false
;
return
false
;
if
(
!
type
.
Equals
(
"DSD "
))
if
(
!
type
.
Equals
(
"DSD "
))
...
@@ -153,7 +153,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -153,7 +153,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
}
else
{
}
else
{
/* ignore unknown chunk */
/* ignore unknown chunk */
if
(
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
if
(
!
dsdlib_skip_to
(
client
,
is
,
chunk_end_offset
))
return
false
;
return
false
;
}
}
}
}
...
@@ -165,7 +165,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -165,7 +165,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
* Read and parse a "PROP" chunk.
* Read and parse a "PROP" chunk.
*/
*/
static
bool
static
bool
dsdiff_read_prop
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_prop
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
DsdiffMetaData
*
metadata
,
const
DsdiffChunkHeader
*
prop_header
)
const
DsdiffChunkHeader
*
prop_header
)
{
{
...
@@ -174,14 +174,14 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
...
@@ -174,14 +174,14 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
DsdId
prop_id
;
DsdId
prop_id
;
if
(
prop_size
<
sizeof
(
prop_id
)
||
if
(
prop_size
<
sizeof
(
prop_id
)
||
!
dsdiff_read_id
(
decoder
,
is
,
&
prop_id
))
!
dsdiff_read_id
(
client
,
is
,
&
prop_id
))
return
false
;
return
false
;
if
(
prop_id
.
Equals
(
"SND "
))
if
(
prop_id
.
Equals
(
"SND "
))
return
dsdiff_read_prop_snd
(
decoder
,
is
,
metadata
,
end_offset
);
return
dsdiff_read_prop_snd
(
client
,
is
,
metadata
,
end_offset
);
else
else
/* ignore unknown PROP chunk */
/* ignore unknown PROP chunk */
return
dsdlib_skip_to
(
decoder
,
is
,
end_offset
);
return
dsdlib_skip_to
(
client
,
is
,
end_offset
);
}
}
static
void
static
void
...
@@ -225,7 +225,7 @@ dsdiff_handle_native_tag(InputStream &is,
...
@@ -225,7 +225,7 @@ dsdiff_handle_native_tag(InputStream &is,
*/
*/
static
bool
static
bool
dsdiff_read_metadata_extra
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_metadata_extra
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
DsdiffMetaData
*
metadata
,
DsdiffChunkHeader
*
chunk_header
,
DsdiffChunkHeader
*
chunk_header
,
const
TagHandler
&
handler
,
const
TagHandler
&
handler
,
...
@@ -233,9 +233,9 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
...
@@ -233,9 +233,9 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
{
{
/* skip from DSD data to next chunk header */
/* skip from DSD data to next chunk header */
if
(
!
dsdlib_skip
(
decoder
,
is
,
metadata
->
chunk_size
))
if
(
!
dsdlib_skip
(
client
,
is
,
metadata
->
chunk_size
))
return
false
;
return
false
;
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
chunk_header
))
if
(
!
dsdiff_read_chunk_header
(
client
,
is
,
chunk_header
))
return
false
;
return
false
;
/** offset for artist tag */
/** offset for artist tag */
...
@@ -276,9 +276,9 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
...
@@ -276,9 +276,9 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
}
}
#endif
#endif
if
(
!
dsdlib_skip
(
decoder
,
is
,
chunk_size
))
if
(
!
dsdlib_skip
(
client
,
is
,
chunk_size
))
break
;
break
;
}
while
(
dsdiff_read_chunk_header
(
decoder
,
is
,
chunk_header
));
}
while
(
dsdiff_read_chunk_header
(
client
,
is
,
chunk_header
));
/* done processing chunk headers, process tags if any */
/* done processing chunk headers, process tags if any */
...
@@ -307,23 +307,23 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
...
@@ -307,23 +307,23 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
* "chunk_header" parameter.
* "chunk_header" parameter.
*/
*/
static
bool
static
bool
dsdiff_read_metadata
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_metadata
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
DsdiffMetaData
*
metadata
,
DsdiffChunkHeader
*
chunk_header
)
DsdiffChunkHeader
*
chunk_header
)
{
{
DsdiffHeader
header
;
DsdiffHeader
header
;
if
(
!
decoder_read_full
(
decoder
,
is
,
&
header
,
sizeof
(
header
))
||
if
(
!
decoder_read_full
(
client
,
is
,
&
header
,
sizeof
(
header
))
||
!
header
.
id
.
Equals
(
"FRM8"
)
||
!
header
.
id
.
Equals
(
"FRM8"
)
||
!
header
.
format
.
Equals
(
"DSD "
))
!
header
.
format
.
Equals
(
"DSD "
))
return
false
;
return
false
;
while
(
true
)
{
while
(
true
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
if
(
!
dsdiff_read_chunk_header
(
client
,
is
,
chunk_header
))
chunk_header
))
return
false
;
return
false
;
if
(
chunk_header
->
id
.
Equals
(
"PROP"
))
{
if
(
chunk_header
->
id
.
Equals
(
"PROP"
))
{
if
(
!
dsdiff_read_prop
(
decoder
,
is
,
metadata
,
if
(
!
dsdiff_read_prop
(
client
,
is
,
metadata
,
chunk_header
))
chunk_header
))
return
false
;
return
false
;
}
else
if
(
chunk_header
->
id
.
Equals
(
"DSD "
))
{
}
else
if
(
chunk_header
->
id
.
Equals
(
"DSD "
))
{
...
@@ -336,7 +336,7 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -336,7 +336,7 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
const
offset_type
chunk_end_offset
=
const
offset_type
chunk_end_offset
=
is
.
GetOffset
()
+
chunk_size
;
is
.
GetOffset
()
+
chunk_size
;
if
(
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
if
(
!
dsdlib_skip_to
(
client
,
is
,
chunk_end_offset
))
return
false
;
return
false
;
}
}
}
}
...
@@ -359,7 +359,7 @@ FrameToOffset(uint64_t frame, unsigned channels)
...
@@ -359,7 +359,7 @@ FrameToOffset(uint64_t frame, unsigned channels)
* Decode one "DSD" chunk.
* Decode one "DSD" chunk.
*/
*/
static
bool
static
bool
dsdiff_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
dsdiff_decode_chunk
(
Decoder
Client
&
client
,
InputStream
&
is
,
unsigned
channels
,
unsigned
sample_rate
,
unsigned
channels
,
unsigned
sample_rate
,
const
offset_type
total_bytes
)
const
offset_type
total_bytes
)
{
{
...
@@ -372,23 +372,23 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -372,23 +372,23 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
const
unsigned
buffer_frames
=
sizeof
(
buffer
)
/
frame_size
;
const
unsigned
buffer_frames
=
sizeof
(
buffer
)
/
frame_size
;
const
size_t
buffer_size
=
buffer_frames
*
frame_size
;
const
size_t
buffer_size
=
buffer_frames
*
frame_size
;
auto
cmd
=
decoder_get_command
(
decoder
);
auto
cmd
=
decoder_get_command
(
client
);
for
(
offset_type
remaining_bytes
=
total_bytes
;
for
(
offset_type
remaining_bytes
=
total_bytes
;
remaining_bytes
>=
frame_size
&&
cmd
!=
DecoderCommand
::
STOP
;)
{
remaining_bytes
>=
frame_size
&&
cmd
!=
DecoderCommand
::
STOP
;)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
uint64_t
frame
=
decoder_seek_where_frame
(
decoder
);
uint64_t
frame
=
decoder_seek_where_frame
(
client
);
offset_type
offset
=
FrameToOffset
(
frame
,
channels
);
offset_type
offset
=
FrameToOffset
(
frame
,
channels
);
if
(
offset
>=
total_bytes
)
{
if
(
offset
>=
total_bytes
)
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
break
;
break
;
}
}
if
(
dsdlib_skip_to
(
&
decoder
,
is
,
if
(
dsdlib_skip_to
(
&
client
,
is
,
start_offset
+
offset
))
{
start_offset
+
offset
))
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
remaining_bytes
=
total_bytes
-
offset
;
remaining_bytes
=
total_bytes
-
offset
;
}
else
}
else
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
}
/* see how much aligned data from the remaining chunk
/* see how much aligned data from the remaining chunk
...
@@ -399,7 +399,7 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -399,7 +399,7 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
now_size
=
now_frames
*
frame_size
;
now_size
=
now_frames
*
frame_size
;
}
}
if
(
!
decoder_read_full
(
&
decoder
,
is
,
buffer
,
now_size
))
if
(
!
decoder_read_full
(
&
client
,
is
,
buffer
,
now_size
))
return
false
;
return
false
;
const
size_t
nbytes
=
now_size
;
const
size_t
nbytes
=
now_size
;
...
@@ -408,7 +408,7 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -408,7 +408,7 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
if
(
lsbitfirst
)
if
(
lsbitfirst
)
bit_reverse_buffer
(
buffer
,
buffer
+
nbytes
);
bit_reverse_buffer
(
buffer
,
buffer
+
nbytes
);
cmd
=
decoder_data
(
decoder
,
is
,
buffer
,
nbytes
,
cmd
=
decoder_data
(
client
,
is
,
buffer
,
nbytes
,
sample_rate
/
1000
);
sample_rate
/
1000
);
}
}
...
@@ -416,13 +416,13 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -416,13 +416,13 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
}
}
static
void
static
void
dsdiff_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
dsdiff_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
DsdiffMetaData
metadata
;
DsdiffMetaData
metadata
;
DsdiffChunkHeader
chunk_header
;
DsdiffChunkHeader
chunk_header
;
/* check if it is is a proper DFF file */
/* check if it is is a proper DFF file */
if
(
!
dsdiff_read_metadata
(
&
decoder
,
is
,
&
metadata
,
&
chunk_header
))
if
(
!
dsdiff_read_metadata
(
&
client
,
is
,
&
metadata
,
&
chunk_header
))
return
;
return
;
auto
audio_format
=
CheckAudioFormat
(
metadata
.
sample_rate
/
8
,
auto
audio_format
=
CheckAudioFormat
(
metadata
.
sample_rate
/
8
,
...
@@ -437,12 +437,12 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -437,12 +437,12 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is)
audio_format
.
sample_rate
);
audio_format
.
sample_rate
);
/* success: file was recognized */
/* success: file was recognized */
decoder_initialized
(
decoder
,
audio_format
,
is
.
IsSeekable
(),
songtime
);
decoder_initialized
(
client
,
audio_format
,
is
.
IsSeekable
(),
songtime
);
/* every iteration of the following loop decodes one "DSD"
/* every iteration of the following loop decodes one "DSD"
chunk from a DFF file */
chunk from a DFF file */
dsdiff_decode_chunk
(
decoder
,
is
,
dsdiff_decode_chunk
(
client
,
is
,
metadata
.
channels
,
metadata
.
channels
,
metadata
.
sample_rate
,
metadata
.
sample_rate
,
chunk_size
);
chunk_size
);
...
...
src/decoder/plugins/DsfDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -98,11 +98,11 @@ struct DsfDataChunk {
...
@@ -98,11 +98,11 @@ struct DsfDataChunk {
* Read and parse all needed metadata chunks for DSF files.
* Read and parse all needed metadata chunks for DSF files.
*/
*/
static
bool
static
bool
dsf_read_metadata
(
Decoder
*
decoder
,
InputStream
&
is
,
dsf_read_metadata
(
Decoder
Client
*
client
,
InputStream
&
is
,
DsfMetaData
*
metadata
)
DsfMetaData
*
metadata
)
{
{
DsfHeader
dsf_header
;
DsfHeader
dsf_header
;
if
(
!
decoder_read_full
(
decoder
,
is
,
&
dsf_header
,
sizeof
(
dsf_header
))
||
if
(
!
decoder_read_full
(
client
,
is
,
&
dsf_header
,
sizeof
(
dsf_header
))
||
!
dsf_header
.
id
.
Equals
(
"DSD "
))
!
dsf_header
.
id
.
Equals
(
"DSD "
))
return
false
;
return
false
;
...
@@ -116,7 +116,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -116,7 +116,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
/* read the 'fmt ' chunk of the DSF file */
/* read the 'fmt ' chunk of the DSF file */
DsfFmtChunk
dsf_fmt_chunk
;
DsfFmtChunk
dsf_fmt_chunk
;
if
(
!
decoder_read_full
(
decoder
,
is
,
if
(
!
decoder_read_full
(
client
,
is
,
&
dsf_fmt_chunk
,
sizeof
(
dsf_fmt_chunk
))
||
&
dsf_fmt_chunk
,
sizeof
(
dsf_fmt_chunk
))
||
!
dsf_fmt_chunk
.
id
.
Equals
(
"fmt "
))
!
dsf_fmt_chunk
.
id
.
Equals
(
"fmt "
))
return
false
;
return
false
;
...
@@ -144,7 +144,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -144,7 +144,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
/* read the 'data' chunk of the DSF file */
/* read the 'data' chunk of the DSF file */
DsfDataChunk
data_chunk
;
DsfDataChunk
data_chunk
;
if
(
!
decoder_read_full
(
decoder
,
is
,
&
data_chunk
,
sizeof
(
data_chunk
))
||
if
(
!
decoder_read_full
(
client
,
is
,
&
data_chunk
,
sizeof
(
data_chunk
))
||
!
data_chunk
.
id
.
Equals
(
"data"
))
!
data_chunk
.
id
.
Equals
(
"data"
))
return
false
;
return
false
;
...
@@ -251,7 +251,7 @@ FrameToBlock(uint64_t frame)
...
@@ -251,7 +251,7 @@ FrameToBlock(uint64_t frame)
* Decode one complete DSF 'data' chunk i.e. a complete song
* Decode one complete DSF 'data' chunk i.e. a complete song
*/
*/
static
bool
static
bool
dsf_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
dsf_decode_chunk
(
Decoder
Client
&
client
,
InputStream
&
is
,
unsigned
channels
,
unsigned
sample_rate
,
unsigned
channels
,
unsigned
sample_rate
,
offset_type
n_blocks
,
offset_type
n_blocks
,
bool
bitreverse
)
bool
bitreverse
)
...
@@ -259,28 +259,28 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -259,28 +259,28 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
const
size_t
block_size
=
channels
*
DSF_BLOCK_SIZE
;
const
size_t
block_size
=
channels
*
DSF_BLOCK_SIZE
;
const
offset_type
start_offset
=
is
.
GetOffset
();
const
offset_type
start_offset
=
is
.
GetOffset
();
auto
cmd
=
decoder_get_command
(
decoder
);
auto
cmd
=
decoder_get_command
(
client
);
for
(
offset_type
i
=
0
;
i
<
n_blocks
&&
cmd
!=
DecoderCommand
::
STOP
;)
{
for
(
offset_type
i
=
0
;
i
<
n_blocks
&&
cmd
!=
DecoderCommand
::
STOP
;)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
uint64_t
frame
=
decoder_seek_where_frame
(
decoder
);
uint64_t
frame
=
decoder_seek_where_frame
(
client
);
offset_type
block
=
FrameToBlock
(
frame
);
offset_type
block
=
FrameToBlock
(
frame
);
if
(
block
>=
n_blocks
)
{
if
(
block
>=
n_blocks
)
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
break
;
break
;
}
}
offset_type
offset
=
offset_type
offset
=
start_offset
+
block
*
block_size
;
start_offset
+
block
*
block_size
;
if
(
dsdlib_skip_to
(
&
decoder
,
is
,
offset
))
{
if
(
dsdlib_skip_to
(
&
client
,
is
,
offset
))
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
i
=
block
;
i
=
block
;
}
else
}
else
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
}
/* worst-case buffer size */
/* worst-case buffer size */
uint8_t
buffer
[
MAX_CHANNELS
*
DSF_BLOCK_SIZE
];
uint8_t
buffer
[
MAX_CHANNELS
*
DSF_BLOCK_SIZE
];
if
(
!
decoder_read_full
(
&
decoder
,
is
,
buffer
,
block_size
))
if
(
!
decoder_read_full
(
&
client
,
is
,
buffer
,
block_size
))
return
false
;
return
false
;
if
(
bitreverse
)
if
(
bitreverse
)
...
@@ -289,7 +289,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -289,7 +289,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
uint8_t
interleaved_buffer
[
MAX_CHANNELS
*
DSF_BLOCK_SIZE
];
uint8_t
interleaved_buffer
[
MAX_CHANNELS
*
DSF_BLOCK_SIZE
];
InterleaveDsfBlock
(
interleaved_buffer
,
buffer
,
channels
);
InterleaveDsfBlock
(
interleaved_buffer
,
buffer
,
channels
);
cmd
=
decoder_data
(
decoder
,
is
,
cmd
=
decoder_data
(
client
,
is
,
interleaved_buffer
,
block_size
,
interleaved_buffer
,
block_size
,
sample_rate
/
1000
);
sample_rate
/
1000
);
++
i
;
++
i
;
...
@@ -299,11 +299,11 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -299,11 +299,11 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
}
}
static
void
static
void
dsf_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
dsf_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
/* check if it is a proper DSF file */
/* check if it is a proper DSF file */
DsfMetaData
metadata
;
DsfMetaData
metadata
;
if
(
!
dsf_read_metadata
(
&
decoder
,
is
,
&
metadata
))
if
(
!
dsf_read_metadata
(
&
client
,
is
,
&
metadata
))
return
;
return
;
auto
audio_format
=
CheckAudioFormat
(
metadata
.
sample_rate
/
8
,
auto
audio_format
=
CheckAudioFormat
(
metadata
.
sample_rate
/
8
,
...
@@ -316,9 +316,9 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -316,9 +316,9 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
audio_format
.
sample_rate
);
audio_format
.
sample_rate
);
/* success: file was recognized */
/* success: file was recognized */
decoder_initialized
(
decoder
,
audio_format
,
is
.
IsSeekable
(),
songtime
);
decoder_initialized
(
client
,
audio_format
,
is
.
IsSeekable
(),
songtime
);
dsf_decode_chunk
(
decoder
,
is
,
metadata
.
channels
,
dsf_decode_chunk
(
client
,
is
,
metadata
.
channels
,
metadata
.
sample_rate
,
metadata
.
sample_rate
,
n_blocks
,
n_blocks
,
metadata
.
bitreverse
);
metadata
.
bitreverse
);
...
...
src/decoder/plugins/FaadDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -324,7 +324,7 @@ faad_get_file_time(InputStream &is)
...
@@ -324,7 +324,7 @@ faad_get_file_time(InputStream &is)
}
}
static
void
static
void
faad_stream_decode
(
Decoder
&
mpd_decoder
,
InputStream
&
is
,
faad_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
,
DecoderBuffer
&
buffer
,
const
NeAACDecHandle
decoder
)
DecoderBuffer
&
buffer
,
const
NeAACDecHandle
decoder
)
{
{
const
auto
total_time
=
faad_song_duration
(
buffer
,
is
);
const
auto
total_time
=
faad_song_duration
(
buffer
,
is
);
...
@@ -339,7 +339,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is,
...
@@ -339,7 +339,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is,
/* initialize the MPD core */
/* initialize the MPD core */
decoder_initialized
(
mpd_decoder
,
audio_format
,
false
,
total_time
);
decoder_initialized
(
client
,
audio_format
,
false
,
total_time
);
/* the decoder loop */
/* the decoder loop */
...
@@ -393,16 +393,16 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is,
...
@@ -393,16 +393,16 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is,
/* send PCM samples to MPD */
/* send PCM samples to MPD */
cmd
=
decoder_data
(
mpd_decoder
,
is
,
decoded
,
cmd
=
decoder_data
(
client
,
is
,
decoded
,
(
size_t
)
frame_info
.
samples
*
2
,
(
size_t
)
frame_info
.
samples
*
2
,
bit_rate
);
bit_rate
);
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
}
}
static
void
static
void
faad_stream_decode
(
Decoder
&
mpd_decoder
,
InputStream
&
is
)
faad_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
DecoderBuffer
buffer
(
&
mpd_decoder
,
is
,
DecoderBuffer
buffer
(
&
client
,
is
,
FAAD_MIN_STREAMSIZE
*
MAX_CHANNELS
);
FAAD_MIN_STREAMSIZE
*
MAX_CHANNELS
);
/* create the libfaad decoder */
/* create the libfaad decoder */
...
@@ -410,7 +410,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
...
@@ -410,7 +410,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
const
NeAACDecHandle
decoder
=
faad_decoder_new
();
const
NeAACDecHandle
decoder
=
faad_decoder_new
();
AtScopeExit
(
decoder
)
{
NeAACDecClose
(
decoder
);
};
AtScopeExit
(
decoder
)
{
NeAACDecClose
(
decoder
);
};
faad_stream_decode
(
mpd_decoder
,
is
,
buffer
,
decoder
);
faad_stream_decode
(
client
,
is
,
buffer
,
decoder
);
}
}
static
bool
static
bool
...
...
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -221,7 +221,7 @@ PtsToPcmFrame(uint64_t pts, const AVStream &stream,
...
@@ -221,7 +221,7 @@ PtsToPcmFrame(uint64_t pts, const AVStream &stream,
* Invoke decoder_data() with the contents of an #AVFrame.
* Invoke decoder_data() with the contents of an #AVFrame.
*/
*/
static
DecoderCommand
static
DecoderCommand
FfmpegSendFrame
(
Decoder
&
decoder
,
InputStream
&
is
,
FfmpegSendFrame
(
Decoder
Client
&
client
,
InputStream
&
is
,
AVCodecContext
&
codec_context
,
AVCodecContext
&
codec_context
,
const
AVFrame
&
frame
,
const
AVFrame
&
frame
,
size_t
&
skip_bytes
,
size_t
&
skip_bytes
,
...
@@ -250,7 +250,7 @@ FfmpegSendFrame(Decoder &decoder, InputStream &is,
...
@@ -250,7 +250,7 @@ FfmpegSendFrame(Decoder &decoder, InputStream &is,
skip_bytes
=
0
;
skip_bytes
=
0
;
}
}
return
decoder_data
(
decoder
,
is
,
return
decoder_data
(
client
,
is
,
output_buffer
.
data
,
output_buffer
.
size
,
output_buffer
.
data
,
output_buffer
.
size
,
codec_context
.
bit_rate
/
1000
);
codec_context
.
bit_rate
/
1000
);
}
}
...
@@ -258,7 +258,7 @@ FfmpegSendFrame(Decoder &decoder, InputStream &is,
...
@@ -258,7 +258,7 @@ FfmpegSendFrame(Decoder &decoder, InputStream &is,
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
static
DecoderCommand
static
DecoderCommand
FfmpegReceiveFrames
(
Decoder
&
decoder
,
InputStream
&
is
,
FfmpegReceiveFrames
(
Decoder
Client
&
client
,
InputStream
&
is
,
AVCodecContext
&
codec_context
,
AVCodecContext
&
codec_context
,
AVFrame
&
frame
,
AVFrame
&
frame
,
size_t
&
skip_bytes
,
size_t
&
skip_bytes
,
...
@@ -271,7 +271,7 @@ FfmpegReceiveFrames(Decoder &decoder, InputStream &is,
...
@@ -271,7 +271,7 @@ FfmpegReceiveFrames(Decoder &decoder, InputStream &is,
int
err
=
avcodec_receive_frame
(
&
codec_context
,
&
frame
);
int
err
=
avcodec_receive_frame
(
&
codec_context
,
&
frame
);
switch
(
err
)
{
switch
(
err
)
{
case
0
:
case
0
:
cmd
=
FfmpegSendFrame
(
decoder
,
is
,
codec_context
,
cmd
=
FfmpegSendFrame
(
client
,
is
,
codec_context
,
frame
,
skip_bytes
,
frame
,
skip_bytes
,
buffer
);
buffer
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
...
@@ -312,7 +312,7 @@ FfmpegReceiveFrames(Decoder &decoder, InputStream &is,
...
@@ -312,7 +312,7 @@ FfmpegReceiveFrames(Decoder &decoder, InputStream &is,
* desired time stamp has been reached
* desired time stamp has been reached
*/
*/
static
DecoderCommand
static
DecoderCommand
ffmpeg_send_packet
(
Decoder
&
decoder
,
InputStream
&
is
,
ffmpeg_send_packet
(
Decoder
Client
&
client
,
InputStream
&
is
,
AVPacket
&&
packet
,
AVPacket
&&
packet
,
AVCodecContext
&
codec_context
,
AVCodecContext
&
codec_context
,
const
AVStream
&
stream
,
const
AVStream
&
stream
,
...
@@ -330,7 +330,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
...
@@ -330,7 +330,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
if
(
cur_frame
<
min_frame
)
if
(
cur_frame
<
min_frame
)
skip_bytes
=
pcm_frame_size
*
(
min_frame
-
cur_frame
);
skip_bytes
=
pcm_frame_size
*
(
min_frame
-
cur_frame
);
}
else
}
else
decoder_timestamp
(
decoder
,
decoder_timestamp
(
client
,
FfmpegTimeToDouble
(
pts
,
FfmpegTimeToDouble
(
pts
,
stream
.
time_base
));
stream
.
time_base
));
}
}
...
@@ -358,7 +358,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
...
@@ -358,7 +358,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
return
DecoderCommand
::
NONE
;
return
DecoderCommand
::
NONE
;
}
}
auto
cmd
=
FfmpegReceiveFrames
(
decoder
,
is
,
codec_context
,
auto
cmd
=
FfmpegReceiveFrames
(
client
,
is
,
codec_context
,
frame
,
frame
,
skip_bytes
,
buffer
,
eof
);
skip_bytes
,
buffer
,
eof
);
...
@@ -383,7 +383,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
...
@@ -383,7 +383,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
if
(
!
got_frame
||
frame
.
nb_samples
<=
0
)
if
(
!
got_frame
||
frame
.
nb_samples
<=
0
)
continue
;
continue
;
cmd
=
FfmpegSendFrame
(
decoder
,
is
,
codec_context
,
cmd
=
FfmpegSendFrame
(
client
,
is
,
codec_context
,
frame
,
skip_bytes
,
frame
,
skip_bytes
,
buffer
);
buffer
);
}
}
...
@@ -393,7 +393,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
...
@@ -393,7 +393,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
}
}
static
DecoderCommand
static
DecoderCommand
ffmpeg_send_packet
(
Decoder
&
decoder
,
InputStream
&
is
,
ffmpeg_send_packet
(
Decoder
Client
&
client
,
InputStream
&
is
,
const
AVPacket
&
packet
,
const
AVPacket
&
packet
,
AVCodecContext
&
codec_context
,
AVCodecContext
&
codec_context
,
const
AVStream
&
stream
,
const
AVStream
&
stream
,
...
@@ -401,7 +401,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
...
@@ -401,7 +401,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
uint64_t
min_frame
,
size_t
pcm_frame_size
,
uint64_t
min_frame
,
size_t
pcm_frame_size
,
FfmpegBuffer
&
buffer
)
FfmpegBuffer
&
buffer
)
{
{
return
ffmpeg_send_packet
(
decoder
,
is
,
return
ffmpeg_send_packet
(
client
,
is
,
/* copy the AVPacket, because FFmpeg
/* copy the AVPacket, because FFmpeg
< 3.0 requires this */
< 3.0 requires this */
AVPacket
(
packet
),
AVPacket
(
packet
),
...
@@ -446,13 +446,13 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
...
@@ -446,13 +446,13 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
}
}
static
AVInputFormat
*
static
AVInputFormat
*
ffmpeg_probe
(
Decoder
*
decoder
,
InputStream
&
is
)
ffmpeg_probe
(
Decoder
Client
*
client
,
InputStream
&
is
)
{
{
constexpr
size_t
BUFFER_SIZE
=
16384
;
constexpr
size_t
BUFFER_SIZE
=
16384
;
constexpr
size_t
PADDING
=
16
;
constexpr
size_t
PADDING
=
16
;
unsigned
char
buffer
[
BUFFER_SIZE
];
unsigned
char
buffer
[
BUFFER_SIZE
];
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
BUFFER_SIZE
);
size_t
nbytes
=
decoder_read
(
client
,
is
,
buffer
,
BUFFER_SIZE
);
if
(
nbytes
<=
PADDING
)
if
(
nbytes
<=
PADDING
)
return
nullptr
;
return
nullptr
;
...
@@ -528,7 +528,7 @@ FfmpegParseMetaData(const AVFormatContext &format_context, int audio_stream,
...
@@ -528,7 +528,7 @@ FfmpegParseMetaData(const AVFormatContext &format_context, int audio_stream,
}
}
static
void
static
void
FfmpegParseMetaData
(
Decoder
&
decoder
,
FfmpegParseMetaData
(
Decoder
Client
&
client
,
const
AVFormatContext
&
format_context
,
int
audio_stream
)
const
AVFormatContext
&
format_context
,
int
audio_stream
)
{
{
ReplayGainInfo
rg
;
ReplayGainInfo
rg
;
...
@@ -540,10 +540,10 @@ FfmpegParseMetaData(Decoder &decoder,
...
@@ -540,10 +540,10 @@ FfmpegParseMetaData(Decoder &decoder,
FfmpegParseMetaData
(
format_context
,
audio_stream
,
rg
,
mr
);
FfmpegParseMetaData
(
format_context
,
audio_stream
,
rg
,
mr
);
if
(
rg
.
IsDefined
())
if
(
rg
.
IsDefined
())
decoder_replay_gain
(
decoder
,
&
rg
);
decoder_replay_gain
(
client
,
&
rg
);
if
(
mr
.
IsDefined
())
if
(
mr
.
IsDefined
())
decoder_mixramp
(
decoder
,
std
::
move
(
mr
));
decoder_mixramp
(
client
,
std
::
move
(
mr
));
}
}
static
void
static
void
...
@@ -579,7 +579,7 @@ FfmpegScanTag(const AVFormatContext &format_context, int audio_stream,
...
@@ -579,7 +579,7 @@ FfmpegScanTag(const AVFormatContext &format_context, int audio_stream,
* decoder_tag().
* decoder_tag().
*/
*/
static
void
static
void
FfmpegCheckTag
(
Decoder
&
decoder
,
InputStream
&
is
,
FfmpegCheckTag
(
Decoder
Client
&
client
,
InputStream
&
is
,
AVFormatContext
&
format_context
,
int
audio_stream
)
AVFormatContext
&
format_context
,
int
audio_stream
)
{
{
AVStream
&
stream
=
*
format_context
.
streams
[
audio_stream
];
AVStream
&
stream
=
*
format_context
.
streams
[
audio_stream
];
...
@@ -593,13 +593,13 @@ FfmpegCheckTag(Decoder &decoder, InputStream &is,
...
@@ -593,13 +593,13 @@ FfmpegCheckTag(Decoder &decoder, InputStream &is,
TagBuilder
tag
;
TagBuilder
tag
;
FfmpegScanTag
(
format_context
,
audio_stream
,
tag
);
FfmpegScanTag
(
format_context
,
audio_stream
,
tag
);
if
(
!
tag
.
IsEmpty
())
if
(
!
tag
.
IsEmpty
())
decoder_tag
(
decoder
,
is
,
tag
.
Commit
());
decoder_tag
(
client
,
is
,
tag
.
Commit
());
}
}
#endif
#endif
static
void
static
void
FfmpegDecode
(
Decoder
&
decoder
,
InputStream
&
input
,
FfmpegDecode
(
Decoder
Client
&
client
,
InputStream
&
input
,
AVFormatContext
&
format_context
)
AVFormatContext
&
format_context
)
{
{
const
int
find_result
=
const
int
find_result
=
...
@@ -689,10 +689,10 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
...
@@ -689,10 +689,10 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
const
SignedSongTime
total_time
=
const
SignedSongTime
total_time
=
FromFfmpegTimeChecked
(
av_stream
.
duration
,
av_stream
.
time_base
);
FromFfmpegTimeChecked
(
av_stream
.
duration
,
av_stream
.
time_base
);
decoder_initialized
(
decoder
,
audio_format
,
decoder_initialized
(
client
,
audio_format
,
input
.
IsSeekable
(),
total_time
);
input
.
IsSeekable
(),
total_time
);
FfmpegParseMetaData
(
decoder
,
format_context
,
audio_stream
);
FfmpegParseMetaData
(
client
,
format_context
,
audio_stream
);
#if LIBAVUTIL_VERSION_MAJOR >= 53
#if LIBAVUTIL_VERSION_MAJOR >= 53
AVFrame
*
frame
=
av_frame_alloc
();
AVFrame
*
frame
=
av_frame_alloc
();
...
@@ -718,11 +718,11 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
...
@@ -718,11 +718,11 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
uint64_t
min_frame
=
0
;
uint64_t
min_frame
=
0
;
DecoderCommand
cmd
=
decoder_get_command
(
decoder
);
DecoderCommand
cmd
=
decoder_get_command
(
client
);
while
(
cmd
!=
DecoderCommand
::
STOP
)
{
while
(
cmd
!=
DecoderCommand
::
STOP
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
int64_t
where
=
int64_t
where
=
ToFfmpegTime
(
decoder_seek_time
(
decoder
),
ToFfmpegTime
(
decoder_seek_time
(
client
),
av_stream
.
time_base
)
+
av_stream
.
time_base
)
+
start_time_fallback
(
av_stream
);
start_time_fallback
(
av_stream
);
...
@@ -731,11 +731,11 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
...
@@ -731,11 +731,11 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
stamp, not after */
stamp, not after */
if
(
av_seek_frame
(
&
format_context
,
audio_stream
,
where
,
if
(
av_seek_frame
(
&
format_context
,
audio_stream
,
where
,
AVSEEK_FLAG_ANY
|
AVSEEK_FLAG_BACKWARD
)
<
0
)
AVSEEK_FLAG_ANY
|
AVSEEK_FLAG_BACKWARD
)
<
0
)
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
else
{
else
{
avcodec_flush_buffers
(
codec_context
);
avcodec_flush_buffers
(
codec_context
);
min_frame
=
decoder_seek_where_frame
(
decoder
);
min_frame
=
decoder_seek_where_frame
(
client
);
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
}
}
}
...
@@ -745,11 +745,11 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
...
@@ -745,11 +745,11 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
break
;
break
;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)
FfmpegCheckTag
(
decoder
,
input
,
format_context
,
audio_stream
);
FfmpegCheckTag
(
client
,
input
,
format_context
,
audio_stream
);
#endif
#endif
if
(
packet
.
size
>
0
&&
packet
.
stream_index
==
audio_stream
)
{
if
(
packet
.
size
>
0
&&
packet
.
stream_index
==
audio_stream
)
{
cmd
=
ffmpeg_send_packet
(
decoder
,
input
,
cmd
=
ffmpeg_send_packet
(
client
,
input
,
packet
,
packet
,
*
codec_context
,
*
codec_context
,
av_stream
,
av_stream
,
...
@@ -758,7 +758,7 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
...
@@ -758,7 +758,7 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
interleaved_buffer
);
interleaved_buffer
);
min_frame
=
0
;
min_frame
=
0
;
}
else
}
else
cmd
=
decoder_get_command
(
decoder
);
cmd
=
decoder_get_command
(
client
);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 25, 100)
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 25, 100)
av_packet_unref
(
&
packet
);
av_packet_unref
(
&
packet
);
...
@@ -769,16 +769,16 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
...
@@ -769,16 +769,16 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
}
}
static
void
static
void
ffmpeg_decode
(
Decoder
&
decoder
,
InputStream
&
input
)
ffmpeg_decode
(
Decoder
Client
&
client
,
InputStream
&
input
)
{
{
AVInputFormat
*
input_format
=
ffmpeg_probe
(
&
decoder
,
input
);
AVInputFormat
*
input_format
=
ffmpeg_probe
(
&
client
,
input
);
if
(
input_format
==
nullptr
)
if
(
input_format
==
nullptr
)
return
;
return
;
FormatDebug
(
ffmpeg_domain
,
"detected input format '%s' (%s)"
,
FormatDebug
(
ffmpeg_domain
,
"detected input format '%s' (%s)"
,
input_format
->
name
,
input_format
->
long_name
);
input_format
->
name
,
input_format
->
long_name
);
AvioStream
stream
(
&
decoder
,
input
);
AvioStream
stream
(
&
client
,
input
);
if
(
!
stream
.
Open
())
{
if
(
!
stream
.
Open
())
{
LogError
(
ffmpeg_domain
,
"Failed to open stream"
);
LogError
(
ffmpeg_domain
,
"Failed to open stream"
);
return
;
return
;
...
@@ -797,7 +797,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
...
@@ -797,7 +797,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
avformat_close_input
(
&
format_context
);
avformat_close_input
(
&
format_context
);
};
};
FfmpegDecode
(
decoder
,
input
,
*
format_context
);
FfmpegDecode
(
client
,
input
,
*
format_context
);
}
}
static
bool
static
bool
...
...
src/decoder/plugins/FfmpegIo.cxx
View file @
fd77acc2
...
@@ -38,7 +38,7 @@ AvioStream::~AvioStream()
...
@@ -38,7 +38,7 @@ AvioStream::~AvioStream()
inline
int
inline
int
AvioStream
::
Read
(
void
*
dest
,
int
size
)
AvioStream
::
Read
(
void
*
dest
,
int
size
)
{
{
return
decoder_read
(
decoder
,
input
,
dest
,
size
);
return
decoder_read
(
client
,
input
,
dest
,
size
);
}
}
inline
int64_t
inline
int64_t
...
...
src/decoder/plugins/FfmpegIo.hxx
View file @
fd77acc2
...
@@ -28,17 +28,17 @@ extern "C" {
...
@@ -28,17 +28,17 @@ extern "C" {
#include <stdint.h>
#include <stdint.h>
class
DecoderClient
;
class
InputStream
;
class
InputStream
;
struct
Decoder
;
struct
AvioStream
{
struct
AvioStream
{
Decoder
*
const
decoder
;
Decoder
Client
*
const
client
;
InputStream
&
input
;
InputStream
&
input
;
AVIOContext
*
io
;
AVIOContext
*
io
;
AvioStream
(
Decoder
*
_decoder
,
InputStream
&
_input
)
AvioStream
(
Decoder
Client
*
_client
,
InputStream
&
_input
)
:
decoder
(
_decoder
),
input
(
_input
),
io
(
nullptr
)
{}
:
client
(
_client
),
input
(
_input
),
io
(
nullptr
)
{}
~
AvioStream
();
~
AvioStream
();
...
...
src/decoder/plugins/FlacCommon.cxx
View file @
fd77acc2
...
@@ -52,7 +52,7 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
...
@@ -52,7 +52,7 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
audio_format
.
sample_rate
)
audio_format
.
sample_rate
)
:
SignedSongTime
::
Negative
();
:
SignedSongTime
::
Negative
();
decoder_initialized
(
*
Get
Decoder
(),
audio_format
,
decoder_initialized
(
*
Get
Client
(),
audio_format
,
GetInputStream
().
IsSeekable
(),
GetInputStream
().
IsSeekable
(),
duration
);
duration
);
...
@@ -77,9 +77,9 @@ FlacDecoder::OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc)
...
@@ -77,9 +77,9 @@ FlacDecoder::OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc)
{
{
ReplayGainInfo
rgi
;
ReplayGainInfo
rgi
;
if
(
flac_parse_replay_gain
(
rgi
,
vc
))
if
(
flac_parse_replay_gain
(
rgi
,
vc
))
decoder_replay_gain
(
*
Get
Decoder
(),
&
rgi
);
decoder_replay_gain
(
*
Get
Client
(),
&
rgi
);
decoder_mixramp
(
*
Get
Decoder
(),
flac_parse_mixramp
(
vc
));
decoder_mixramp
(
*
Get
Client
(),
flac_parse_mixramp
(
vc
));
tag
=
flac_vorbis_comments_to_tag
(
&
vc
);
tag
=
flac_vorbis_comments_to_tag
(
&
vc
);
}
}
...
@@ -148,7 +148,7 @@ FlacDecoder::OnWrite(const FLAC__Frame &frame,
...
@@ -148,7 +148,7 @@ FlacDecoder::OnWrite(const FLAC__Frame &frame,
unsigned
bit_rate
=
nbytes
*
8
*
frame
.
header
.
sample_rate
/
unsigned
bit_rate
=
nbytes
*
8
*
frame
.
header
.
sample_rate
/
(
1000
*
frame
.
header
.
blocksize
);
(
1000
*
frame
.
header
.
blocksize
);
auto
cmd
=
decoder_data
(
*
Get
Decoder
(),
GetInputStream
(),
auto
cmd
=
decoder_data
(
*
Get
Client
(),
GetInputStream
(),
data
.
data
,
data
.
size
,
data
.
data
,
data
.
size
,
bit_rate
);
bit_rate
);
switch
(
cmd
)
{
switch
(
cmd
)
{
...
...
src/decoder/plugins/FlacCommon.hxx
View file @
fd77acc2
...
@@ -51,8 +51,8 @@ struct FlacDecoder : public FlacInput {
...
@@ -51,8 +51,8 @@ struct FlacDecoder : public FlacInput {
Tag
tag
;
Tag
tag
;
FlacDecoder
(
Decoder
&
_decoder
,
InputStream
&
_input_stream
)
FlacDecoder
(
Decoder
Client
&
_client
,
InputStream
&
_input_stream
)
:
FlacInput
(
_input_stream
,
&
_
decoder
)
{}
:
FlacInput
(
_input_stream
,
&
_
client
)
{}
/**
/**
* Wrapper for decoder_initialized().
* Wrapper for decoder_initialized().
...
...
src/decoder/plugins/FlacDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -142,25 +142,25 @@ flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd)
...
@@ -142,25 +142,25 @@ flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd)
static
void
static
void
flac_decoder_loop
(
FlacDecoder
*
data
,
FLAC__StreamDecoder
*
flac_dec
)
flac_decoder_loop
(
FlacDecoder
*
data
,
FLAC__StreamDecoder
*
flac_dec
)
{
{
Decoder
&
decoder
=
*
data
->
GetDecoder
();
Decoder
Client
&
client
=
*
data
->
GetClient
();
while
(
true
)
{
while
(
true
)
{
DecoderCommand
cmd
;
DecoderCommand
cmd
;
if
(
!
data
->
tag
.
IsEmpty
())
{
if
(
!
data
->
tag
.
IsEmpty
())
{
cmd
=
decoder_tag
(
decoder
,
data
->
GetInputStream
(),
cmd
=
decoder_tag
(
client
,
data
->
GetInputStream
(),
std
::
move
(
data
->
tag
));
std
::
move
(
data
->
tag
));
data
->
tag
.
Clear
();
data
->
tag
.
Clear
();
}
else
}
else
cmd
=
decoder_get_command
(
decoder
);
cmd
=
decoder_get_command
(
client
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
FLAC__uint64
seek_sample
=
FLAC__uint64
seek_sample
=
decoder_seek_where_frame
(
decoder
);
decoder_seek_where_frame
(
client
);
if
(
FLAC__stream_decoder_seek_absolute
(
flac_dec
,
seek_sample
))
{
if
(
FLAC__stream_decoder_seek_absolute
(
flac_dec
,
seek_sample
))
{
data
->
position
=
0
;
data
->
position
=
0
;
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
else
}
else
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
else
if
(
cmd
==
DecoderCommand
::
STOP
)
}
else
if
(
cmd
==
DecoderCommand
::
STOP
)
break
;
break
;
...
@@ -198,7 +198,7 @@ flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec)
...
@@ -198,7 +198,7 @@ flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec)
}
}
if
(
!
FLAC__stream_decoder_process_single
(
flac_dec
)
&&
if
(
!
FLAC__stream_decoder_process_single
(
flac_dec
)
&&
decoder_get_command
(
decoder
)
==
DecoderCommand
::
NONE
)
{
decoder_get_command
(
client
)
==
DecoderCommand
::
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
));
...
@@ -264,7 +264,7 @@ FlacInitAndDecode(FlacDecoder &data, FLAC__StreamDecoder *sd, bool is_ogg)
...
@@ -264,7 +264,7 @@ FlacInitAndDecode(FlacDecoder &data, FLAC__StreamDecoder *sd, bool is_ogg)
}
}
static
void
static
void
flac_decode_internal
(
Decoder
&
decoder
,
flac_decode_internal
(
Decoder
Client
&
client
,
InputStream
&
input_stream
,
InputStream
&
input_stream
,
bool
is_ogg
)
bool
is_ogg
)
{
{
...
@@ -272,15 +272,15 @@ flac_decode_internal(Decoder &decoder,
...
@@ -272,15 +272,15 @@ flac_decode_internal(Decoder &decoder,
if
(
!
flac_dec
)
if
(
!
flac_dec
)
return
;
return
;
FlacDecoder
data
(
decoder
,
input_stream
);
FlacDecoder
data
(
client
,
input_stream
);
FlacInitAndDecode
(
data
,
flac_dec
.
get
(),
is_ogg
);
FlacInitAndDecode
(
data
,
flac_dec
.
get
(),
is_ogg
);
}
}
static
void
static
void
flac_decode
(
Decoder
&
decoder
,
InputStream
&
input_stream
)
flac_decode
(
Decoder
Client
&
client
,
InputStream
&
input_stream
)
{
{
flac_decode_internal
(
decoder
,
input_stream
,
false
);
flac_decode_internal
(
client
,
input_stream
,
false
);
}
}
static
bool
static
bool
...
@@ -322,9 +322,9 @@ oggflac_scan_stream(InputStream &is,
...
@@ -322,9 +322,9 @@ oggflac_scan_stream(InputStream &is,
}
}
static
void
static
void
oggflac_decode
(
Decoder
&
decoder
,
InputStream
&
input_stream
)
oggflac_decode
(
Decoder
Client
&
client
,
InputStream
&
input_stream
)
{
{
if
(
ogg_codec_detect
(
&
decoder
,
input_stream
)
!=
OGG_CODEC_FLAC
)
if
(
ogg_codec_detect
(
&
client
,
input_stream
)
!=
OGG_CODEC_FLAC
)
return
;
return
;
/* rewind the stream, because ogg_codec_detect() has
/* rewind the stream, because ogg_codec_detect() has
...
@@ -334,7 +334,7 @@ oggflac_decode(Decoder &decoder, InputStream &input_stream)
...
@@ -334,7 +334,7 @@ oggflac_decode(Decoder &decoder, InputStream &input_stream)
}
catch
(
const
std
::
runtime_error
&
)
{
}
catch
(
const
std
::
runtime_error
&
)
{
}
}
flac_decode_internal
(
decoder
,
input_stream
,
true
);
flac_decode_internal
(
client
,
input_stream
,
true
);
}
}
static
const
char
*
const
oggflac_suffixes
[]
=
{
"ogg"
,
"oga"
,
nullptr
};
static
const
char
*
const
oggflac_suffixes
[]
=
{
"ogg"
,
"oga"
,
nullptr
};
...
...
src/decoder/plugins/FlacInput.cxx
View file @
fd77acc2
...
@@ -30,13 +30,13 @@
...
@@ -30,13 +30,13 @@
FLAC__StreamDecoderReadStatus
FLAC__StreamDecoderReadStatus
FlacInput
::
Read
(
FLAC__byte
buffer
[],
size_t
*
bytes
)
FlacInput
::
Read
(
FLAC__byte
buffer
[],
size_t
*
bytes
)
{
{
size_t
r
=
decoder_read
(
decoder
,
input_stream
,
(
void
*
)
buffer
,
*
bytes
);
size_t
r
=
decoder_read
(
client
,
input_stream
,
(
void
*
)
buffer
,
*
bytes
);
*
bytes
=
r
;
*
bytes
=
r
;
if
(
r
==
0
)
{
if
(
r
==
0
)
{
if
(
input_stream
.
LockIsEOF
()
||
if
(
input_stream
.
LockIsEOF
()
||
(
decoder
!=
nullptr
&&
(
client
!=
nullptr
&&
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
NONE
))
decoder_get_command
(
*
client
)
!=
DecoderCommand
::
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
;
...
@@ -83,17 +83,17 @@ FlacInput::Length(FLAC__uint64 *stream_length)
...
@@ -83,17 +83,17 @@ FlacInput::Length(FLAC__uint64 *stream_length)
FLAC__bool
FLAC__bool
FlacInput
::
Eof
()
FlacInput
::
Eof
()
{
{
return
(
decoder
!=
nullptr
&&
return
(
client
!=
nullptr
&&
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
NONE
&&
decoder_get_command
(
*
client
)
!=
DecoderCommand
::
NONE
&&
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
SEEK
)
||
decoder_get_command
(
*
client
)
!=
DecoderCommand
::
SEEK
)
||
input_stream
.
LockIsEOF
();
input_stream
.
LockIsEOF
();
}
}
void
void
FlacInput
::
Error
(
FLAC__StreamDecoderErrorStatus
status
)
FlacInput
::
Error
(
FLAC__StreamDecoderErrorStatus
status
)
{
{
if
(
decoder
==
nullptr
||
if
(
client
==
nullptr
||
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
STOP
)
decoder_get_command
(
*
client
)
!=
DecoderCommand
::
STOP
)
LogWarning
(
flac_domain
,
LogWarning
(
flac_domain
,
FLAC__StreamDecoderErrorStatusString
[
status
]);
FLAC__StreamDecoderErrorStatusString
[
status
]);
}
}
...
...
src/decoder/plugins/FlacInput.hxx
View file @
fd77acc2
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include <FLAC/stream_decoder.h>
#include <FLAC/stream_decoder.h>
struct
Decoder
;
class
DecoderClient
;
class
InputStream
;
class
InputStream
;
/**
/**
...
@@ -30,17 +30,17 @@ class InputStream;
...
@@ -30,17 +30,17 @@ class InputStream;
* callbacks.
* callbacks.
*/
*/
class
FlacInput
{
class
FlacInput
{
Decoder
*
const
decoder
;
Decoder
Client
*
const
client
;
InputStream
&
input_stream
;
InputStream
&
input_stream
;
public
:
public
:
FlacInput
(
InputStream
&
_input_stream
,
FlacInput
(
InputStream
&
_input_stream
,
Decoder
*
_decoder
=
nullptr
)
Decoder
Client
*
_client
=
nullptr
)
:
decoder
(
_decoder
),
input_stream
(
_input_stream
)
{}
:
client
(
_client
),
input_stream
(
_input_stream
)
{}
Decoder
*
GetDecoder
()
{
Decoder
Client
*
GetClient
()
{
return
decoder
;
return
client
;
}
}
InputStream
&
GetInputStream
()
{
InputStream
&
GetInputStream
()
{
...
...
src/decoder/plugins/FluidsynthDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -87,7 +87,7 @@ fluidsynth_init(const ConfigBlock &block)
...
@@ -87,7 +87,7 @@ fluidsynth_init(const ConfigBlock &block)
}
}
static
void
static
void
fluidsynth_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
fluidsynth_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
char
setting_sample_rate
[]
=
"synth.sample-rate"
;
char
setting_sample_rate
[]
=
"synth.sample-rate"
;
/*
/*
...
@@ -160,7 +160,7 @@ fluidsynth_file_decode(Decoder &decoder, Path path_fs)
...
@@ -160,7 +160,7 @@ fluidsynth_file_decode(Decoder &decoder, Path path_fs)
MPD core */
MPD core */
const
AudioFormat
audio_format
(
sample_rate
,
SampleFormat
::
S16
,
2
);
const
AudioFormat
audio_format
(
sample_rate
,
SampleFormat
::
S16
,
2
);
decoder_initialized
(
decoder
,
audio_format
,
false
,
decoder_initialized
(
client
,
audio_format
,
false
,
SignedSongTime
::
Negative
());
SignedSongTime
::
Negative
());
DecoderCommand
cmd
;
DecoderCommand
cmd
;
...
@@ -177,7 +177,7 @@ fluidsynth_file_decode(Decoder &decoder, Path path_fs)
...
@@ -177,7 +177,7 @@ fluidsynth_file_decode(Decoder &decoder, Path path_fs)
if
(
ret
!=
0
)
if
(
ret
!=
0
)
break
;
break
;
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
sizeof
(
buffer
),
cmd
=
decoder_data
(
client
,
nullptr
,
buffer
,
sizeof
(
buffer
),
0
);
0
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
break
;
break
;
...
...
src/decoder/plugins/GmeDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -129,7 +129,7 @@ gme_container_scan(Path path_fs, const unsigned int tnum)
...
@@ -129,7 +129,7 @@ gme_container_scan(Path path_fs, const unsigned int tnum)
}
}
static
void
static
void
gme_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
gme_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
const
auto
container
=
ParseContainerPath
(
path_fs
);
const
auto
container
=
ParseContainerPath
(
path_fs
);
...
@@ -171,7 +171,7 @@ gme_file_decode(Decoder &decoder, Path path_fs)
...
@@ -171,7 +171,7 @@ gme_file_decode(Decoder &decoder, Path path_fs)
SampleFormat
::
S16
,
SampleFormat
::
S16
,
GME_CHANNELS
);
GME_CHANNELS
);
decoder_initialized
(
decoder
,
audio_format
,
true
,
song_len
);
decoder_initialized
(
client
,
audio_format
,
true
,
song_len
);
gme_err
=
gme_start_track
(
emu
,
container
.
track
);
gme_err
=
gme_start_track
(
emu
,
container
.
track
);
if
(
gme_err
!=
nullptr
)
if
(
gme_err
!=
nullptr
)
...
@@ -190,15 +190,15 @@ gme_file_decode(Decoder &decoder, Path path_fs)
...
@@ -190,15 +190,15 @@ gme_file_decode(Decoder &decoder, Path path_fs)
return
;
return
;
}
}
cmd
=
decoder_data
(
decoder
,
nullptr
,
buf
,
sizeof
(
buf
),
0
);
cmd
=
decoder_data
(
client
,
nullptr
,
buf
,
sizeof
(
buf
),
0
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
unsigned
where
=
decoder_seek_time
(
decoder
).
ToMS
();
unsigned
where
=
decoder_seek_time
(
client
).
ToMS
();
gme_err
=
gme_seek
(
emu
,
where
);
gme_err
=
gme_seek
(
emu
,
where
);
if
(
gme_err
!=
nullptr
)
{
if
(
gme_err
!=
nullptr
)
{
LogWarning
(
gme_domain
,
gme_err
);
LogWarning
(
gme_domain
,
gme_err
);
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
else
}
else
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
}
if
(
gme_track_ended
(
emu
))
if
(
gme_track_ended
(
emu
))
...
...
src/decoder/plugins/MadDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -141,11 +141,11 @@ struct MadDecoder {
...
@@ -141,11 +141,11 @@ struct MadDecoder {
bool
found_first_frame
=
false
;
bool
found_first_frame
=
false
;
bool
decoded_first_frame
=
false
;
bool
decoded_first_frame
=
false
;
unsigned
long
bit_rate
;
unsigned
long
bit_rate
;
Decoder
*
const
decoder
;
Decoder
Client
*
const
client
;
InputStream
&
input_stream
;
InputStream
&
input_stream
;
enum
mad_layer
layer
=
mad_layer
(
0
);
enum
mad_layer
layer
=
mad_layer
(
0
);
MadDecoder
(
Decoder
*
decoder
,
InputStream
&
input_stream
);
MadDecoder
(
Decoder
Client
*
client
,
InputStream
&
input_stream
);
~
MadDecoder
();
~
MadDecoder
();
bool
Seek
(
long
offset
);
bool
Seek
(
long
offset
);
...
@@ -195,9 +195,9 @@ struct MadDecoder {
...
@@ -195,9 +195,9 @@ struct MadDecoder {
bool
Read
();
bool
Read
();
};
};
MadDecoder
::
MadDecoder
(
Decoder
*
_decoder
,
MadDecoder
::
MadDecoder
(
Decoder
Client
*
_client
,
InputStream
&
_input_stream
)
InputStream
&
_input_stream
)
:
decoder
(
_decoder
),
input_stream
(
_input_stream
)
:
client
(
_client
),
input_stream
(
_input_stream
)
{
{
mad_stream_init
(
&
stream
);
mad_stream_init
(
&
stream
);
mad_stream_options
(
&
stream
,
MAD_OPTION_IGNORECRC
);
mad_stream_options
(
&
stream
,
MAD_OPTION_IGNORECRC
);
...
@@ -243,7 +243,7 @@ MadDecoder::FillBuffer()
...
@@ -243,7 +243,7 @@ MadDecoder::FillBuffer()
if
(
length
==
0
)
if
(
length
==
0
)
return
false
;
return
false
;
length
=
decoder_read
(
decoder
,
input_stream
,
dest
,
length
);
length
=
decoder_read
(
client
,
input_stream
,
dest
,
length
);
if
(
length
==
0
)
if
(
length
==
0
)
return
false
;
return
false
;
...
@@ -333,7 +333,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
...
@@ -333,7 +333,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
memcpy
(
allocated
,
stream
.
this_frame
,
count
);
memcpy
(
allocated
,
stream
.
this_frame
,
count
);
mad_stream_skip
(
&
(
stream
),
count
);
mad_stream_skip
(
&
(
stream
),
count
);
if
(
!
decoder_read_full
(
decoder
,
input_stream
,
if
(
!
decoder_read_full
(
client
,
input_stream
,
allocated
+
count
,
tagsize
-
count
))
{
allocated
+
count
,
tagsize
-
count
))
{
LogDebug
(
mad_domain
,
"error parsing ID3 tag"
);
LogDebug
(
mad_domain
,
"error parsing ID3 tag"
);
delete
[]
allocated
;
delete
[]
allocated
;
...
@@ -357,15 +357,15 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
...
@@ -357,15 +357,15 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
}
}
}
}
if
(
decoder
!=
nullptr
)
{
if
(
client
!=
nullptr
)
{
ReplayGainInfo
rgi
;
ReplayGainInfo
rgi
;
if
(
parse_id3_replay_gain_info
(
rgi
,
id3_tag
))
{
if
(
parse_id3_replay_gain_info
(
rgi
,
id3_tag
))
{
decoder_replay_gain
(
*
decoder
,
&
rgi
);
decoder_replay_gain
(
*
client
,
&
rgi
);
found_replay_gain
=
true
;
found_replay_gain
=
true
;
}
}
decoder_mixramp
(
*
decoder
,
parse_id3_mixramp
(
id3_tag
));
decoder_mixramp
(
*
client
,
parse_id3_mixramp
(
id3_tag
));
}
}
id3_tag_delete
(
id3_tag
);
id3_tag_delete
(
id3_tag
);
...
@@ -383,7 +383,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
...
@@ -383,7 +383,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
mad_stream_skip
(
&
stream
,
tagsize
);
mad_stream_skip
(
&
stream
,
tagsize
);
}
else
{
}
else
{
mad_stream_skip
(
&
stream
,
count
);
mad_stream_skip
(
&
stream
,
count
);
decoder_skip
(
decoder
,
input_stream
,
tagsize
-
count
);
decoder_skip
(
client
,
input_stream
,
tagsize
-
count
);
}
}
#endif
#endif
}
}
...
@@ -800,13 +800,13 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
...
@@ -800,13 +800,13 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
/* Album gain isn't currently used. See comment in
/* Album gain isn't currently used. See comment in
* parse_lame() for details. -- jat */
* parse_lame() for details. -- jat */
if
(
decoder
!=
nullptr
&&
!
found_replay_gain
&&
if
(
client
!=
nullptr
&&
!
found_replay_gain
&&
lame
.
track_gain
)
{
lame
.
track_gain
)
{
ReplayGainInfo
rgi
;
ReplayGainInfo
rgi
;
rgi
.
Clear
();
rgi
.
Clear
();
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
lame
.
track_gain
;
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
lame
.
track_gain
;
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
lame
.
peak
;
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
lame
.
peak
;
decoder_replay_gain
(
*
decoder
,
&
rgi
);
decoder_replay_gain
(
*
client
,
&
rgi
);
}
}
}
}
}
}
...
@@ -903,7 +903,7 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
...
@@ -903,7 +903,7 @@ 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
);
auto
cmd
=
decoder_data
(
*
decoder
,
input_stream
,
output_buffer
,
auto
cmd
=
decoder_data
(
*
client
,
input_stream
,
output_buffer
,
sizeof
(
output_buffer
[
0
])
*
num_samples
,
sizeof
(
output_buffer
[
0
])
*
num_samples
,
bit_rate
/
1000
);
bit_rate
/
1000
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
...
@@ -986,17 +986,17 @@ MadDecoder::Read()
...
@@ -986,17 +986,17 @@ MadDecoder::Read()
assert
(
input_stream
.
IsSeekable
());
assert
(
input_stream
.
IsSeekable
());
unsigned
long
j
=
unsigned
long
j
=
TimeToFrame
(
decoder_seek_time
(
*
decoder
));
TimeToFrame
(
decoder_seek_time
(
*
client
));
if
(
j
<
highest_frame
)
{
if
(
j
<
highest_frame
)
{
if
(
Seek
(
frame_offsets
[
j
]))
{
if
(
Seek
(
frame_offsets
[
j
]))
{
current_frame
=
j
;
current_frame
=
j
;
decoder_command_finished
(
*
decoder
);
decoder_command_finished
(
*
client
);
}
else
}
else
decoder_seek_error
(
*
decoder
);
decoder_seek_error
(
*
client
);
}
else
{
}
else
{
seek_time
=
decoder_seek_time
(
*
decoder
);
seek_time
=
decoder_seek_time
(
*
client
);
mute_frame
=
MUTEFRAME_SEEK
;
mute_frame
=
MUTEFRAME_SEEK
;
decoder_command_finished
(
*
decoder
);
decoder_command_finished
(
*
client
);
}
}
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
return
false
;
return
false
;
...
@@ -1010,7 +1010,7 @@ MadDecoder::Read()
...
@@ -1010,7 +1010,7 @@ MadDecoder::Read()
ret
=
DecodeNextFrameHeader
(
&
tag
);
ret
=
DecodeNextFrameHeader
(
&
tag
);
if
(
tag
!=
nullptr
)
{
if
(
tag
!=
nullptr
)
{
decoder_tag
(
*
decoder
,
input_stream
,
decoder_tag
(
*
client
,
input_stream
,
std
::
move
(
*
tag
));
std
::
move
(
*
tag
));
delete
tag
;
delete
tag
;
}
}
...
@@ -1034,15 +1034,15 @@ MadDecoder::Read()
...
@@ -1034,15 +1034,15 @@ MadDecoder::Read()
}
}
static
void
static
void
mp3_decode
(
Decoder
&
decoder
,
InputStream
&
input_stream
)
mp3_decode
(
Decoder
Client
&
client
,
InputStream
&
input_stream
)
{
{
MadDecoder
data
(
&
decoder
,
input_stream
);
MadDecoder
data
(
&
client
,
input_stream
);
Tag
*
tag
=
nullptr
;
Tag
*
tag
=
nullptr
;
if
(
!
data
.
DecodeFirstFrame
(
&
tag
))
{
if
(
!
data
.
DecodeFirstFrame
(
&
tag
))
{
delete
tag
;
delete
tag
;
if
(
decoder_get_command
(
decoder
)
==
DecoderCommand
::
NONE
)
if
(
decoder_get_command
(
client
)
==
DecoderCommand
::
NONE
)
LogError
(
mad_domain
,
LogError
(
mad_domain
,
"input/Input does not appear to be a mp3 bit stream"
);
"input/Input does not appear to be a mp3 bit stream"
);
return
;
return
;
...
@@ -1050,7 +1050,7 @@ mp3_decode(Decoder &decoder, InputStream &input_stream)
...
@@ -1050,7 +1050,7 @@ mp3_decode(Decoder &decoder, InputStream &input_stream)
data
.
AllocateBuffers
();
data
.
AllocateBuffers
();
decoder_initialized
(
decoder
,
decoder_initialized
(
client
,
CheckAudioFormat
(
data
.
frame
.
header
.
samplerate
,
CheckAudioFormat
(
data
.
frame
.
header
.
samplerate
,
SampleFormat
::
S24_P32
,
SampleFormat
::
S24_P32
,
MAD_NCHANNELS
(
&
data
.
frame
.
header
)),
MAD_NCHANNELS
(
&
data
.
frame
.
header
)),
...
@@ -1058,7 +1058,7 @@ mp3_decode(Decoder &decoder, InputStream &input_stream)
...
@@ -1058,7 +1058,7 @@ mp3_decode(Decoder &decoder, InputStream &input_stream)
data
.
total_time
);
data
.
total_time
);
if
(
tag
!=
nullptr
)
{
if
(
tag
!=
nullptr
)
{
decoder_tag
(
decoder
,
input_stream
,
std
::
move
(
*
tag
));
decoder_tag
(
client
,
input_stream
,
std
::
move
(
*
tag
));
delete
tag
;
delete
tag
;
}
}
...
...
src/decoder/plugins/MikmodDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -147,7 +147,7 @@ mikmod_decoder_finish(void)
...
@@ -147,7 +147,7 @@ mikmod_decoder_finish(void)
}
}
static
void
static
void
mikmod_decoder_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
mikmod_decoder_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
/* deconstify the path because libmikmod wants a non-const
/* deconstify the path because libmikmod wants a non-const
string pointer */
string pointer */
...
@@ -170,7 +170,7 @@ mikmod_decoder_file_decode(Decoder &decoder, Path path_fs)
...
@@ -170,7 +170,7 @@ mikmod_decoder_file_decode(Decoder &decoder, Path path_fs)
const
AudioFormat
audio_format
(
mikmod_sample_rate
,
SampleFormat
::
S16
,
2
);
const
AudioFormat
audio_format
(
mikmod_sample_rate
,
SampleFormat
::
S16
,
2
);
assert
(
audio_format
.
IsValid
());
assert
(
audio_format
.
IsValid
());
decoder_initialized
(
decoder
,
audio_format
,
false
,
decoder_initialized
(
client
,
audio_format
,
false
,
SignedSongTime
::
Negative
());
SignedSongTime
::
Negative
());
Player_Start
(
handle
);
Player_Start
(
handle
);
...
@@ -178,7 +178,7 @@ mikmod_decoder_file_decode(Decoder &decoder, Path path_fs)
...
@@ -178,7 +178,7 @@ mikmod_decoder_file_decode(Decoder &decoder, Path path_fs)
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
while
(
cmd
==
DecoderCommand
::
NONE
&&
Player_Active
())
{
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
(
client
,
nullptr
,
buffer
,
ret
,
0
);
}
}
Player_Stop
();
Player_Stop
();
...
...
src/decoder/plugins/ModplugDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -52,7 +52,7 @@ modplug_decoder_init(const ConfigBlock &block)
...
@@ -52,7 +52,7 @@ modplug_decoder_init(const ConfigBlock &block)
}
}
static
WritableBuffer
<
uint8_t
>
static
WritableBuffer
<
uint8_t
>
mod_loadfile
(
Decoder
*
decoder
,
InputStream
&
is
)
mod_loadfile
(
Decoder
Client
*
client
,
InputStream
&
is
)
{
{
//known/unknown size, preallocate array, lets read in chunks
//known/unknown size, preallocate array, lets read in chunks
...
@@ -83,7 +83,7 @@ mod_loadfile(Decoder *decoder, InputStream &is)
...
@@ -83,7 +83,7 @@ mod_loadfile(Decoder *decoder, InputStream &is)
uint8_t
*
p
=
buffer
.
begin
();
uint8_t
*
p
=
buffer
.
begin
();
while
(
true
)
{
while
(
true
)
{
size_t
ret
=
decoder_read
(
decoder
,
is
,
p
,
end
-
p
);
size_t
ret
=
decoder_read
(
client
,
is
,
p
,
end
-
p
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
if
(
is
.
LockIsEOF
())
if
(
is
.
LockIsEOF
())
/* end of file */
/* end of file */
...
@@ -112,9 +112,9 @@ mod_loadfile(Decoder *decoder, InputStream &is)
...
@@ -112,9 +112,9 @@ mod_loadfile(Decoder *decoder, InputStream &is)
}
}
static
ModPlugFile
*
static
ModPlugFile
*
LoadModPlugFile
(
Decoder
*
decoder
,
InputStream
&
is
)
LoadModPlugFile
(
Decoder
Client
*
client
,
InputStream
&
is
)
{
{
const
auto
buffer
=
mod_loadfile
(
decoder
,
is
);
const
auto
buffer
=
mod_loadfile
(
client
,
is
);
if
(
buffer
.
IsNull
())
{
if
(
buffer
.
IsNull
())
{
LogWarning
(
modplug_domain
,
"could not load stream"
);
LogWarning
(
modplug_domain
,
"could not load stream"
);
return
nullptr
;
return
nullptr
;
...
@@ -126,7 +126,7 @@ LoadModPlugFile(Decoder *decoder, InputStream &is)
...
@@ -126,7 +126,7 @@ LoadModPlugFile(Decoder *decoder, InputStream &is)
}
}
static
void
static
void
mod_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
mod_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
ModPlug_Settings
settings
;
ModPlug_Settings
settings
;
int
ret
;
int
ret
;
...
@@ -142,7 +142,7 @@ mod_decode(Decoder &decoder, InputStream &is)
...
@@ -142,7 +142,7 @@ mod_decode(Decoder &decoder, InputStream &is)
/* insert more setting changes here */
/* insert more setting changes here */
ModPlug_SetSettings
(
&
settings
);
ModPlug_SetSettings
(
&
settings
);
ModPlugFile
*
f
=
LoadModPlugFile
(
&
decoder
,
is
);
ModPlugFile
*
f
=
LoadModPlugFile
(
&
client
,
is
);
if
(
f
==
nullptr
)
{
if
(
f
==
nullptr
)
{
LogWarning
(
modplug_domain
,
"could not decode stream"
);
LogWarning
(
modplug_domain
,
"could not decode stream"
);
return
;
return
;
...
@@ -151,7 +151,7 @@ mod_decode(Decoder &decoder, InputStream &is)
...
@@ -151,7 +151,7 @@ mod_decode(Decoder &decoder, InputStream &is)
static
constexpr
AudioFormat
audio_format
(
44100
,
SampleFormat
::
S16
,
2
);
static
constexpr
AudioFormat
audio_format
(
44100
,
SampleFormat
::
S16
,
2
);
assert
(
audio_format
.
IsValid
());
assert
(
audio_format
.
IsValid
());
decoder_initialized
(
decoder
,
audio_format
,
decoder_initialized
(
client
,
audio_format
,
is
.
IsSeekable
(),
is
.
IsSeekable
(),
SongTime
::
FromMS
(
ModPlug_GetLength
(
f
)));
SongTime
::
FromMS
(
ModPlug_GetLength
(
f
)));
...
@@ -161,13 +161,13 @@ mod_decode(Decoder &decoder, InputStream &is)
...
@@ -161,13 +161,13 @@ mod_decode(Decoder &decoder, InputStream &is)
if
(
ret
<=
0
)
if
(
ret
<=
0
)
break
;
break
;
cmd
=
decoder_data
(
decoder
,
nullptr
,
cmd
=
decoder_data
(
client
,
nullptr
,
audio_buffer
,
ret
,
audio_buffer
,
ret
,
0
);
0
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
ModPlug_Seek
(
f
,
decoder_seek_time
(
decoder
).
ToMS
());
ModPlug_Seek
(
f
,
decoder_seek_time
(
client
).
ToMS
());
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
}
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
...
...
src/decoder/plugins/MpcdecDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -37,10 +37,10 @@
...
@@ -37,10 +37,10 @@
struct
mpc_decoder_data
{
struct
mpc_decoder_data
{
InputStream
&
is
;
InputStream
&
is
;
Decoder
*
decoder
;
Decoder
Client
*
client
;
mpc_decoder_data
(
InputStream
&
_is
,
Decoder
*
_decoder
)
mpc_decoder_data
(
InputStream
&
_is
,
Decoder
Client
*
_client
)
:
is
(
_is
),
decoder
(
_decoder
)
{}
:
is
(
_is
),
client
(
_client
)
{}
};
};
static
constexpr
Domain
mpcdec_domain
(
"mpcdec"
);
static
constexpr
Domain
mpcdec_domain
(
"mpcdec"
);
...
@@ -54,7 +54,7 @@ mpc_read_cb(mpc_reader *reader, void *ptr, mpc_int32_t size)
...
@@ -54,7 +54,7 @@ mpc_read_cb(mpc_reader *reader, void *ptr, mpc_int32_t size)
struct
mpc_decoder_data
*
data
=
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_data
*
)
reader
->
data
;
(
struct
mpc_decoder_data
*
)
reader
->
data
;
return
decoder_read
(
data
->
decoder
,
data
->
is
,
ptr
,
size
);
return
decoder_read
(
data
->
client
,
data
->
is
,
ptr
,
size
);
}
}
static
mpc_bool_t
static
mpc_bool_t
...
@@ -138,9 +138,9 @@ mpc_to_mpd_buffer(MpcdecSampleTraits::pointer_type dest,
...
@@ -138,9 +138,9 @@ mpc_to_mpd_buffer(MpcdecSampleTraits::pointer_type dest,
}
}
static
void
static
void
mpcdec_decode
(
Decoder
&
mpd_decoder
,
InputStream
&
is
)
mpcdec_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
mpc_decoder_data
data
(
is
,
&
mpd_decoder
);
mpc_decoder_data
data
(
is
,
&
client
);
mpc_reader
reader
;
mpc_reader
reader
;
reader
.
read
=
mpc_read_cb
;
reader
.
read
=
mpc_read_cb
;
...
@@ -152,7 +152,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
...
@@ -152,7 +152,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &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
)
!=
DecoderCommand
::
STOP
)
if
(
decoder_get_command
(
client
)
!=
DecoderCommand
::
STOP
)
LogWarning
(
mpcdec_domain
,
LogWarning
(
mpcdec_domain
,
"Not a valid musepack stream"
);
"Not a valid musepack stream"
);
return
;
return
;
...
@@ -172,9 +172,9 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
...
@@ -172,9 +172,9 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
MPC_OLD_GAIN_REF
-
(
info
.
gain_title
/
256.
);
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
MPC_OLD_GAIN_REF
-
(
info
.
gain_title
/
256.
);
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
pow
(
10
,
info
.
peak_title
/
256.
/
20
)
/
32767
;
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
pow
(
10
,
info
.
peak_title
/
256.
/
20
)
/
32767
;
decoder_replay_gain
(
mpd_decoder
,
&
rgi
);
decoder_replay_gain
(
client
,
&
rgi
);
decoder_initialized
(
mpd_decoder
,
audio_format
,
decoder_initialized
(
client
,
audio_format
,
is
.
IsSeekable
(),
is
.
IsSeekable
(),
SongTime
::
FromS
(
mpc_streaminfo_get_length
(
&
info
)));
SongTime
::
FromS
(
mpc_streaminfo_get_length
(
&
info
)));
...
@@ -182,15 +182,15 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
...
@@ -182,15 +182,15 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
do
{
do
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
mpc_int64_t
where
=
mpc_int64_t
where
=
decoder_seek_where_frame
(
mpd_decoder
);
decoder_seek_where_frame
(
client
);
bool
success
;
bool
success
;
success
=
mpc_demux_seek_sample
(
demux
,
where
)
success
=
mpc_demux_seek_sample
(
demux
,
where
)
==
MPC_STATUS_OK
;
==
MPC_STATUS_OK
;
if
(
success
)
if
(
success
)
decoder_command_finished
(
mpd_decoder
);
decoder_command_finished
(
client
);
else
else
decoder_seek_error
(
mpd_decoder
);
decoder_seek_error
(
client
);
}
}
MPC_SAMPLE_FORMAT
sample_buffer
[
MPC_DECODER_BUFFER_LENGTH
];
MPC_SAMPLE_FORMAT
sample_buffer
[
MPC_DECODER_BUFFER_LENGTH
];
...
@@ -215,7 +215,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
...
@@ -215,7 +215,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
long
bit_rate
=
unsigned
(
frame
.
bits
)
*
audio_format
.
sample_rate
long
bit_rate
=
unsigned
(
frame
.
bits
)
*
audio_format
.
sample_rate
/
(
1000
*
frame
.
samples
);
/
(
1000
*
frame
.
samples
);
cmd
=
decoder_data
(
mpd_decoder
,
is
,
cmd
=
decoder_data
(
client
,
is
,
chunk
,
ret
*
sizeof
(
chunk
[
0
]),
chunk
,
ret
*
sizeof
(
chunk
[
0
]),
bit_rate
);
bit_rate
);
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
...
...
src/decoder/plugins/Mpg123DecoderPlugin.cxx
View file @
fd77acc2
...
@@ -116,7 +116,7 @@ AddTagItem(TagBuilder &tag, TagType type, const mpg123_string *s)
...
@@ -116,7 +116,7 @@ AddTagItem(TagBuilder &tag, TagType type, const mpg123_string *s)
}
}
static
void
static
void
mpd_mpg123_id3v2_tag
(
Decoder
&
decoder
,
const
mpg123_id3v2
&
id3v2
)
mpd_mpg123_id3v2_tag
(
Decoder
Client
&
client
,
const
mpg123_id3v2
&
id3v2
)
{
{
TagBuilder
tag
;
TagBuilder
tag
;
...
@@ -129,11 +129,11 @@ mpd_mpg123_id3v2_tag(Decoder &decoder, const mpg123_id3v2 &id3v2)
...
@@ -129,11 +129,11 @@ mpd_mpg123_id3v2_tag(Decoder &decoder, const mpg123_id3v2 &id3v2)
for
(
size_t
i
=
0
,
n
=
id3v2
.
comments
;
i
<
n
;
++
i
)
for
(
size_t
i
=
0
,
n
=
id3v2
.
comments
;
i
<
n
;
++
i
)
AddTagItem
(
tag
,
TAG_COMMENT
,
id3v2
.
comment_list
[
i
].
text
);
AddTagItem
(
tag
,
TAG_COMMENT
,
id3v2
.
comment_list
[
i
].
text
);
decoder_tag
(
decoder
,
nullptr
,
tag
.
Commit
());
decoder_tag
(
client
,
nullptr
,
tag
.
Commit
());
}
}
static
void
static
void
mpd_mpg123_id3v2_extras
(
Decoder
&
decoder
,
const
mpg123_id3v2
&
id3v2
)
mpd_mpg123_id3v2_extras
(
Decoder
Client
&
client
,
const
mpg123_id3v2
&
id3v2
)
{
{
ReplayGainInfo
replay_gain
;
ReplayGainInfo
replay_gain
;
replay_gain
.
Clear
();
replay_gain
.
Clear
();
...
@@ -154,21 +154,21 @@ mpd_mpg123_id3v2_extras(Decoder &decoder, const mpg123_id3v2 &id3v2)
...
@@ -154,21 +154,21 @@ mpd_mpg123_id3v2_extras(Decoder &decoder, const mpg123_id3v2 &id3v2)
}
}
if
(
found_replay_gain
)
if
(
found_replay_gain
)
decoder_replay_gain
(
decoder
,
&
replay_gain
);
decoder_replay_gain
(
client
,
&
replay_gain
);
if
(
found_mixramp
)
if
(
found_mixramp
)
decoder_mixramp
(
decoder
,
std
::
move
(
mix_ramp
));
decoder_mixramp
(
client
,
std
::
move
(
mix_ramp
));
}
}
static
void
static
void
mpd_mpg123_id3v2
(
Decoder
&
decoder
,
const
mpg123_id3v2
&
id3v2
)
mpd_mpg123_id3v2
(
Decoder
Client
&
client
,
const
mpg123_id3v2
&
id3v2
)
{
{
mpd_mpg123_id3v2_tag
(
decoder
,
id3v2
);
mpd_mpg123_id3v2_tag
(
client
,
id3v2
);
mpd_mpg123_id3v2_extras
(
decoder
,
id3v2
);
mpd_mpg123_id3v2_extras
(
client
,
id3v2
);
}
}
static
void
static
void
mpd_mpg123_meta
(
Decoder
&
decoder
,
mpg123_handle
*
const
handle
)
mpd_mpg123_meta
(
Decoder
Client
&
client
,
mpg123_handle
*
const
handle
)
{
{
if
((
mpg123_meta_check
(
handle
)
&
MPG123_NEW_ID3
)
==
0
)
if
((
mpg123_meta_check
(
handle
)
&
MPG123_NEW_ID3
)
==
0
)
return
;
return
;
...
@@ -179,11 +179,11 @@ mpd_mpg123_meta(Decoder &decoder, mpg123_handle *const handle)
...
@@ -179,11 +179,11 @@ mpd_mpg123_meta(Decoder &decoder, mpg123_handle *const handle)
return
;
return
;
if
(
v2
!=
nullptr
)
if
(
v2
!=
nullptr
)
mpd_mpg123_id3v2
(
decoder
,
*
v2
);
mpd_mpg123_id3v2
(
client
,
*
v2
);
}
}
static
void
static
void
mpd_mpg123_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
mpd_mpg123_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
/* open the file */
/* open the file */
...
@@ -210,7 +210,7 @@ mpd_mpg123_file_decode(Decoder &decoder, Path path_fs)
...
@@ -210,7 +210,7 @@ mpd_mpg123_file_decode(Decoder &decoder, Path path_fs)
SongTime
::
FromScale
<
uint64_t
>
(
num_samples
,
SongTime
::
FromScale
<
uint64_t
>
(
num_samples
,
audio_format
.
sample_rate
);
audio_format
.
sample_rate
);
decoder_initialized
(
decoder
,
audio_format
,
true
,
duration
);
decoder_initialized
(
client
,
audio_format
,
true
,
duration
);
struct
mpg123_frameinfo
info
;
struct
mpg123_frameinfo
info
;
if
(
mpg123_info
(
handle
,
&
info
)
!=
MPG123_OK
)
{
if
(
mpg123_info
(
handle
,
&
info
)
!=
MPG123_OK
)
{
...
@@ -232,7 +232,7 @@ mpd_mpg123_file_decode(Decoder &decoder, Path path_fs)
...
@@ -232,7 +232,7 @@ mpd_mpg123_file_decode(Decoder &decoder, Path path_fs)
DecoderCommand
cmd
;
DecoderCommand
cmd
;
do
{
do
{
/* read metadata */
/* read metadata */
mpd_mpg123_meta
(
decoder
,
handle
);
mpd_mpg123_meta
(
client
,
handle
);
/* decode */
/* decode */
...
@@ -257,16 +257,16 @@ mpd_mpg123_file_decode(Decoder &decoder, Path path_fs)
...
@@ -257,16 +257,16 @@ mpd_mpg123_file_decode(Decoder &decoder, Path path_fs)
/* send to MPD */
/* send to MPD */
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
nbytes
,
info
.
bitrate
);
cmd
=
decoder_data
(
client
,
nullptr
,
buffer
,
nbytes
,
info
.
bitrate
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
off_t
c
=
decoder_seek_where_frame
(
decoder
);
off_t
c
=
decoder_seek_where_frame
(
client
);
c
=
mpg123_seek
(
handle
,
c
,
SEEK_SET
);
c
=
mpg123_seek
(
handle
,
c
,
SEEK_SET
);
if
(
c
<
0
)
if
(
c
<
0
)
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
else
{
else
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
decoder_timestamp
(
decoder
,
c
/
(
double
)
audio_format
.
sample_rate
);
decoder_timestamp
(
client
,
c
/
(
double
)
audio_format
.
sample_rate
);
}
}
cmd
=
DecoderCommand
::
NONE
;
cmd
=
DecoderCommand
::
NONE
;
...
...
src/decoder/plugins/OggCodec.cxx
View file @
fd77acc2
...
@@ -28,13 +28,13 @@
...
@@ -28,13 +28,13 @@
#include <string.h>
#include <string.h>
enum
ogg_codec
enum
ogg_codec
ogg_codec_detect
(
Decoder
*
decoder
,
InputStream
&
is
)
ogg_codec_detect
(
Decoder
Client
*
client
,
InputStream
&
is
)
{
{
/* oggflac detection based on code in ogg123 and this post
/* oggflac detection based on code in ogg123 and this post
* http://lists.xiph.org/pipermail/flac/2004-December/000393.html
* http://lists.xiph.org/pipermail/flac/2004-December/000393.html
* ogg123 trunk still doesn't have this patch as of June 2005 */
* ogg123 trunk still doesn't have this patch as of June 2005 */
unsigned
char
buf
[
41
];
unsigned
char
buf
[
41
];
size_t
r
=
decoder_read
(
decoder
,
is
,
buf
,
sizeof
(
buf
));
size_t
r
=
decoder_read
(
client
,
is
,
buf
,
sizeof
(
buf
));
if
(
r
<
sizeof
(
buf
)
||
memcmp
(
buf
,
"OggS"
,
4
)
!=
0
)
if
(
r
<
sizeof
(
buf
)
||
memcmp
(
buf
,
"OggS"
,
4
)
!=
0
)
return
OGG_CODEC_UNKNOWN
;
return
OGG_CODEC_UNKNOWN
;
...
...
src/decoder/plugins/OggCodec.hxx
View file @
fd77acc2
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#ifndef MPD_OGG_CODEC_HXX
#ifndef MPD_OGG_CODEC_HXX
#define MPD_OGG_CODEC_HXX
#define MPD_OGG_CODEC_HXX
struct
Decoder
;
class
DecoderClient
;
class
InputStream
;
class
InputStream
;
enum
ogg_codec
{
enum
ogg_codec
{
...
@@ -35,6 +35,6 @@ enum ogg_codec {
...
@@ -35,6 +35,6 @@ enum ogg_codec {
};
};
enum
ogg_codec
enum
ogg_codec
ogg_codec_detect
(
Decoder
*
decoder
,
InputStream
&
is
);
ogg_codec_detect
(
Decoder
Client
*
client
,
InputStream
&
is
);
#endif
/* _OGG_COMMON_H */
#endif
/* _OGG_COMMON_H */
src/decoder/plugins/OggDecoder.cxx
View file @
fd77acc2
...
@@ -45,7 +45,7 @@ OggDecoder::LoadEndPacket(ogg_packet &packet) const
...
@@ -45,7 +45,7 @@ OggDecoder::LoadEndPacket(ogg_packet &packet) const
bool
result
;
bool
result
;
{
{
DecoderReader
reader
(
decoder
,
input_stream
);
DecoderReader
reader
(
client
,
input_stream
);
OggSyncState
sync2
(
reader
);
OggSyncState
sync2
(
reader
);
OggStreamState
stream2
(
GetSerialNo
());
OggStreamState
stream2
(
GetSerialNo
());
result
=
OggSeekFindEOS
(
sync2
,
stream2
,
packet
,
result
=
OggSeekFindEOS
(
sync2
,
stream2
,
packet
,
...
...
src/decoder/plugins/OggDecoder.hxx
View file @
fd77acc2
...
@@ -28,13 +28,13 @@ class OggDecoder : public OggVisitor {
...
@@ -28,13 +28,13 @@ class OggDecoder : public OggVisitor {
ogg_int64_t
end_granulepos
;
ogg_int64_t
end_granulepos
;
protected
:
protected
:
Decoder
&
decoder
;
Decoder
Client
&
client
;
InputStream
&
input_stream
;
InputStream
&
input_stream
;
public
:
public
:
explicit
OggDecoder
(
DecoderReader
&
reader
)
explicit
OggDecoder
(
DecoderReader
&
reader
)
:
OggVisitor
(
reader
),
:
OggVisitor
(
reader
),
decoder
(
reader
.
GetDecoder
()),
client
(
reader
.
GetClient
()),
input_stream
(
reader
.
GetInputStream
())
{}
input_stream
(
reader
.
GetInputStream
())
{}
bool
Seek
(
OggSyncState
&
oy
,
uint64_t
where_frame
);
bool
Seek
(
OggSyncState
&
oy
,
uint64_t
where_frame
);
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -175,14 +175,14 @@ MPDOpusDecoder::OnOggBeginning(const ogg_packet &packet)
...
@@ -175,14 +175,14 @@ MPDOpusDecoder::OnOggBeginning(const ogg_packet &packet)
previous_channels
=
channels
;
previous_channels
=
channels
;
const
AudioFormat
audio_format
(
opus_sample_rate
,
const
AudioFormat
audio_format
(
opus_sample_rate
,
SampleFormat
::
S16
,
channels
);
SampleFormat
::
S16
,
channels
);
decoder_initialized
(
decoder
,
audio_format
,
decoder_initialized
(
client
,
audio_format
,
eos_granulepos
>
0
,
duration
);
eos_granulepos
>
0
,
duration
);
frame_size
=
audio_format
.
GetFrameSize
();
frame_size
=
audio_format
.
GetFrameSize
();
output_buffer
=
new
opus_int16
[
opus_output_buffer_frames
output_buffer
=
new
opus_int16
[
opus_output_buffer_frames
*
audio_format
.
channels
];
*
audio_format
.
channels
];
auto
cmd
=
decoder_get_command
(
decoder
);
auto
cmd
=
decoder_get_command
(
client
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
throw
cmd
;
throw
cmd
;
}
}
...
@@ -213,10 +213,10 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
...
@@ -213,10 +213,10 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
&
rgi
,
&
rgi
,
add_tag_handler
,
&
tag_builder
)
&&
add_tag_handler
,
&
tag_builder
)
&&
!
tag_builder
.
IsEmpty
())
{
!
tag_builder
.
IsEmpty
())
{
decoder_replay_gain
(
decoder
,
&
rgi
);
decoder_replay_gain
(
client
,
&
rgi
);
Tag
tag
=
tag_builder
.
Commit
();
Tag
tag
=
tag_builder
.
Commit
();
auto
cmd
=
decoder_tag
(
decoder
,
input_stream
,
std
::
move
(
tag
));
auto
cmd
=
decoder_tag
(
client
,
input_stream
,
std
::
move
(
tag
));
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
throw
cmd
;
throw
cmd
;
}
}
...
@@ -238,14 +238,14 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
...
@@ -238,14 +238,14 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
if
(
nframes
>
0
)
{
if
(
nframes
>
0
)
{
const
size_t
nbytes
=
nframes
*
frame_size
;
const
size_t
nbytes
=
nframes
*
frame_size
;
auto
cmd
=
decoder_data
(
decoder
,
input_stream
,
auto
cmd
=
decoder_data
(
client
,
input_stream
,
output_buffer
,
nbytes
,
output_buffer
,
nbytes
,
0
);
0
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
throw
cmd
;
throw
cmd
;
if
(
packet
.
granulepos
>
0
)
if
(
packet
.
granulepos
>
0
)
decoder_timestamp
(
decoder
,
decoder_timestamp
(
client
,
double
(
packet
.
granulepos
)
double
(
packet
.
granulepos
)
/
opus_sample_rate
);
/
opus_sample_rate
);
}
}
...
@@ -269,10 +269,10 @@ MPDOpusDecoder::Seek(uint64_t where_frame)
...
@@ -269,10 +269,10 @@ MPDOpusDecoder::Seek(uint64_t where_frame)
}
}
static
void
static
void
mpd_opus_stream_decode
(
Decoder
&
decoder
,
mpd_opus_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
input_stream
)
InputStream
&
input_stream
)
{
{
if
(
ogg_codec_detect
(
&
decoder
,
input_stream
)
!=
OGG_CODEC_OPUS
)
if
(
ogg_codec_detect
(
&
client
,
input_stream
)
!=
OGG_CODEC_OPUS
)
return
;
return
;
/* rewind the stream, because ogg_codec_detect() has
/* rewind the stream, because ogg_codec_detect() has
...
@@ -282,7 +282,7 @@ mpd_opus_stream_decode(Decoder &decoder,
...
@@ -282,7 +282,7 @@ mpd_opus_stream_decode(Decoder &decoder,
}
catch
(
const
std
::
runtime_error
&
)
{
}
catch
(
const
std
::
runtime_error
&
)
{
}
}
DecoderReader
reader
(
decoder
,
input_stream
);
DecoderReader
reader
(
client
,
input_stream
);
MPDOpusDecoder
d
(
reader
);
MPDOpusDecoder
d
(
reader
);
...
@@ -292,10 +292,10 @@ mpd_opus_stream_decode(Decoder &decoder,
...
@@ -292,10 +292,10 @@ mpd_opus_stream_decode(Decoder &decoder,
break
;
break
;
}
catch
(
DecoderCommand
cmd
)
{
}
catch
(
DecoderCommand
cmd
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
d
.
Seek
(
decoder_seek_where_frame
(
decoder
)))
if
(
d
.
Seek
(
decoder_seek_where_frame
(
client
)))
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
else
else
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
break
;
break
;
}
}
...
...
src/decoder/plugins/PcmDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -39,13 +39,13 @@ static constexpr Domain pcm_decoder_domain("pcm_decoder");
...
@@ -39,13 +39,13 @@ static constexpr Domain pcm_decoder_domain("pcm_decoder");
template
<
typename
B
>
template
<
typename
B
>
static
bool
static
bool
FillBuffer
(
Decoder
&
decoder
,
InputStream
&
is
,
B
&
buffer
)
FillBuffer
(
Decoder
Client
&
client
,
InputStream
&
is
,
B
&
buffer
)
{
{
buffer
.
Shift
();
buffer
.
Shift
();
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
assert
(
!
w
.
IsEmpty
());
assert
(
!
w
.
IsEmpty
());
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
w
.
data
,
w
.
size
);
size_t
nbytes
=
decoder_read
(
client
,
is
,
w
.
data
,
w
.
size
);
if
(
nbytes
==
0
&&
is
.
LockIsEOF
())
if
(
nbytes
==
0
&&
is
.
LockIsEOF
())
return
false
;
return
false
;
...
@@ -54,7 +54,7 @@ FillBuffer(Decoder &decoder, InputStream &is, B &buffer)
...
@@ -54,7 +54,7 @@ FillBuffer(Decoder &decoder, InputStream &is, B &buffer)
}
}
static
void
static
void
pcm_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
pcm_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
AudioFormat
audio_format
=
{
AudioFormat
audio_format
=
{
44100
,
44100
,
...
@@ -143,14 +143,14 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -143,14 +143,14 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
audio_format
.
sample_rate
)
audio_format
.
sample_rate
)
:
SignedSongTime
::
Negative
();
:
SignedSongTime
::
Negative
();
decoder_initialized
(
decoder
,
audio_format
,
decoder_initialized
(
client
,
audio_format
,
is
.
IsSeekable
(),
total_time
);
is
.
IsSeekable
(),
total_time
);
StaticFifoBuffer
<
uint8_t
,
4096
>
buffer
;
StaticFifoBuffer
<
uint8_t
,
4096
>
buffer
;
DecoderCommand
cmd
;
DecoderCommand
cmd
;
do
{
do
{
if
(
!
FillBuffer
(
decoder
,
is
,
buffer
))
if
(
!
FillBuffer
(
client
,
is
,
buffer
))
break
;
break
;
auto
r
=
buffer
.
Read
();
auto
r
=
buffer
.
Read
();
...
@@ -166,19 +166,19 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -166,19 +166,19 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
(
uint16_t
*
)(
r
.
data
+
r
.
size
));
(
uint16_t
*
)(
r
.
data
+
r
.
size
));
cmd
=
!
r
.
IsEmpty
()
cmd
=
!
r
.
IsEmpty
()
?
decoder_data
(
decoder
,
is
,
r
.
data
,
r
.
size
,
0
)
?
decoder_data
(
client
,
is
,
r
.
data
,
r
.
size
,
0
)
:
decoder_get_command
(
decoder
);
:
decoder_get_command
(
client
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
uint64_t
frame
=
decoder_seek_where_frame
(
decoder
);
uint64_t
frame
=
decoder_seek_where_frame
(
client
);
offset_type
offset
=
frame
*
frame_size
;
offset_type
offset
=
frame
*
frame_size
;
try
{
try
{
is
.
LockSeek
(
offset
);
is
.
LockSeek
(
offset
);
buffer
.
Clear
();
buffer
.
Clear
();
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
LogError
(
e
);
LogError
(
e
);
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
}
cmd
=
DecoderCommand
::
NONE
;
cmd
=
DecoderCommand
::
NONE
;
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -179,7 +179,7 @@ get_song_length(SidTuneMod &tune)
...
@@ -179,7 +179,7 @@ get_song_length(SidTuneMod &tune)
#endif
#endif
static
void
static
void
sidplay_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
sidplay_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
int
channels
;
int
channels
;
...
@@ -337,7 +337,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
...
@@ -337,7 +337,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
const
AudioFormat
audio_format
(
48000
,
SampleFormat
::
S16
,
channels
);
const
AudioFormat
audio_format
(
48000
,
SampleFormat
::
S16
,
channels
);
assert
(
audio_format
.
IsValid
());
assert
(
audio_format
.
IsValid
());
decoder_initialized
(
decoder
,
audio_format
,
true
,
duration
);
decoder_initialized
(
client
,
audio_format
,
true
,
duration
);
/* .. and play */
/* .. and play */
...
@@ -366,14 +366,14 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
...
@@ -366,14 +366,14 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
const
size_t
nbytes
=
result
;
const
size_t
nbytes
=
result
;
#endif
#endif
decoder_timestamp
(
decoder
,
(
double
)
player
.
time
()
/
timebase
);
decoder_timestamp
(
client
,
(
double
)
player
.
time
()
/
timebase
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
buffer
,
nbytes
,
0
);
cmd
=
decoder_data
(
client
,
nullptr
,
buffer
,
nbytes
,
0
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
unsigned
data_time
=
player
.
time
();
unsigned
data_time
=
player
.
time
();
unsigned
target_time
=
unsigned
target_time
=
decoder_seek_time
(
decoder
).
ToScale
(
timebase
);
decoder_seek_time
(
client
).
ToScale
(
timebase
);
/* can't rewind so return to zero and seek forward */
/* can't rewind so return to zero and seek forward */
if
(
target_time
<
data_time
)
{
if
(
target_time
<
data_time
)
{
...
@@ -386,7 +386,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
...
@@ -386,7 +386,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
player
.
play
(
buffer
,
ARRAY_SIZE
(
buffer
))
>
0
)
player
.
play
(
buffer
,
ARRAY_SIZE
(
buffer
))
>
0
)
data_time
=
player
.
time
();
data_time
=
player
.
time
();
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
}
if
(
end
>
0
&&
player
.
time
()
>=
end
)
if
(
end
>
0
&&
player
.
time
()
>=
end
)
...
...
src/decoder/plugins/SndfileDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -40,13 +40,13 @@ sndfile_init(gcc_unused const ConfigBlock &block)
...
@@ -40,13 +40,13 @@ sndfile_init(gcc_unused const ConfigBlock &block)
}
}
struct
SndfileInputStream
{
struct
SndfileInputStream
{
Decoder
*
const
decoder
;
Decoder
Client
*
const
client
;
InputStream
&
is
;
InputStream
&
is
;
size_t
Read
(
void
*
buffer
,
size_t
size
)
{
size_t
Read
(
void
*
buffer
,
size_t
size
)
{
/* libsndfile chokes on partial reads; therefore
/* libsndfile chokes on partial reads; therefore
always force full reads */
always force full reads */
return
decoder_read_full
(
decoder
,
is
,
buffer
,
size
)
return
decoder_read_full
(
client
,
is
,
buffer
,
size
)
?
size
?
size
:
0
;
:
0
;
}
}
...
@@ -186,13 +186,13 @@ sndfile_read_frames(SNDFILE *sf, SampleFormat format,
...
@@ -186,13 +186,13 @@ sndfile_read_frames(SNDFILE *sf, SampleFormat format,
}
}
static
void
static
void
sndfile_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
sndfile_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
SF_INFO
info
;
SF_INFO
info
;
info
.
format
=
0
;
info
.
format
=
0
;
SndfileInputStream
sis
{
&
decoder
,
is
};
SndfileInputStream
sis
{
&
client
,
is
};
SNDFILE
*
const
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
&
sis
);
SNDFILE
*
const
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
&
sis
);
if
(
sf
==
nullptr
)
{
if
(
sf
==
nullptr
)
{
FormatWarning
(
sndfile_domain
,
"sf_open_virtual() failed: %s"
,
FormatWarning
(
sndfile_domain
,
"sf_open_virtual() failed: %s"
,
...
@@ -205,7 +205,7 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -205,7 +205,7 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
sndfile_sample_format
(
info
),
sndfile_sample_format
(
info
),
info
.
channels
);
info
.
channels
);
decoder_initialized
(
decoder
,
audio_format
,
info
.
seekable
,
decoder_initialized
(
client
,
audio_format
,
info
.
seekable
,
sndfile_duration
(
info
));
sndfile_duration
(
info
));
char
buffer
[
16384
];
char
buffer
[
16384
];
...
@@ -222,16 +222,16 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -222,16 +222,16 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
if
(
num_frames
<=
0
)
if
(
num_frames
<=
0
)
break
;
break
;
cmd
=
decoder_data
(
decoder
,
is
,
cmd
=
decoder_data
(
client
,
is
,
buffer
,
num_frames
*
frame_size
,
buffer
,
num_frames
*
frame_size
,
0
);
0
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
sf_count_t
c
=
decoder_seek_where_frame
(
decoder
);
sf_count_t
c
=
decoder_seek_where_frame
(
client
);
c
=
sf_seek
(
sf
,
c
,
SEEK_SET
);
c
=
sf_seek
(
sf
,
c
,
SEEK_SET
);
if
(
c
<
0
)
if
(
c
<
0
)
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
else
else
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
cmd
=
DecoderCommand
::
NONE
;
cmd
=
DecoderCommand
::
NONE
;
}
}
}
while
(
cmd
==
DecoderCommand
::
NONE
);
}
while
(
cmd
==
DecoderCommand
::
NONE
);
...
...
src/decoder/plugins/VorbisDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -149,14 +149,14 @@ VorbisDecoder::OnOggBeginning(const ogg_packet &_packet)
...
@@ -149,14 +149,14 @@ VorbisDecoder::OnOggBeginning(const ogg_packet &_packet)
}
}
static
void
static
void
vorbis_send_comments
(
Decoder
&
decoder
,
InputStream
&
is
,
vorbis_send_comments
(
Decoder
Client
&
client
,
InputStream
&
is
,
char
**
comments
)
char
**
comments
)
{
{
Tag
*
tag
=
vorbis_comments_to_tag
(
comments
);
Tag
*
tag
=
vorbis_comments_to_tag
(
comments
);
if
(
!
tag
)
if
(
!
tag
)
return
;
return
;
decoder_tag
(
decoder
,
is
,
std
::
move
(
*
tag
));
decoder_tag
(
client
,
is
,
std
::
move
(
*
tag
));
delete
tag
;
delete
tag
;
}
}
...
@@ -175,7 +175,7 @@ VorbisDecoder::SubmitInit()
...
@@ -175,7 +175,7 @@ VorbisDecoder::SubmitInit()
audio_format
.
sample_rate
)
audio_format
.
sample_rate
)
:
SignedSongTime
::
Negative
();
:
SignedSongTime
::
Negative
();
decoder_initialized
(
decoder
,
audio_format
,
decoder_initialized
(
client
,
audio_format
,
eos_granulepos
>
0
,
duration
);
eos_granulepos
>
0
,
duration
);
}
}
...
@@ -212,7 +212,7 @@ VorbisDecoder::SubmitSomePcm()
...
@@ -212,7 +212,7 @@ VorbisDecoder::SubmitSomePcm()
vorbis_synthesis_read
(
&
dsp
,
n_frames
);
vorbis_synthesis_read
(
&
dsp
,
n_frames
);
const
size_t
nbytes
=
n_frames
*
frame_size
;
const
size_t
nbytes
=
n_frames
*
frame_size
;
auto
cmd
=
decoder_data
(
decoder
,
input_stream
,
auto
cmd
=
decoder_data
(
client
,
input_stream
,
buffer
,
nbytes
,
buffer
,
nbytes
,
0
);
0
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
...
@@ -249,11 +249,11 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
...
@@ -249,11 +249,11 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
}
else
}
else
SubmitInit
();
SubmitInit
();
vorbis_send_comments
(
decoder
,
input_stream
,
vc
.
user_comments
);
vorbis_send_comments
(
client
,
input_stream
,
vc
.
user_comments
);
ReplayGainInfo
rgi
;
ReplayGainInfo
rgi
;
if
(
vorbis_comments_to_replay_gain
(
rgi
,
vc
.
user_comments
))
if
(
vorbis_comments_to_replay_gain
(
rgi
,
vc
.
user_comments
))
decoder_replay_gain
(
decoder
,
&
rgi
);
decoder_replay_gain
(
client
,
&
rgi
);
}
else
{
}
else
{
if
(
!
dsp_initialized
)
{
if
(
!
dsp_initialized
)
{
dsp_initialized
=
true
;
dsp_initialized
=
true
;
...
@@ -265,7 +265,7 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
...
@@ -265,7 +265,7 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
if
(
vorbis_synthesis
(
&
block
,
&
packet
)
!=
0
)
{
if
(
vorbis_synthesis
(
&
block
,
&
packet
)
!=
0
)
{
/* ignore bad packets, but give the MPD core a
/* ignore bad packets, but give the MPD core a
chance to stop us */
chance to stop us */
auto
cmd
=
decoder_get_command
(
decoder
);
auto
cmd
=
decoder_get_command
(
client
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
if
(
cmd
!=
DecoderCommand
::
NONE
)
throw
cmd
;
throw
cmd
;
return
;
return
;
...
@@ -278,7 +278,7 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
...
@@ -278,7 +278,7 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
#ifndef HAVE_TREMOR
#ifndef HAVE_TREMOR
if
(
packet
.
granulepos
>
0
)
if
(
packet
.
granulepos
>
0
)
decoder_timestamp
(
decoder
,
decoder_timestamp
(
client
,
vorbis_granule_time
(
&
dsp
,
packet
.
granulepos
));
vorbis_granule_time
(
&
dsp
,
packet
.
granulepos
));
#endif
#endif
}
}
...
@@ -301,10 +301,10 @@ vorbis_init(gcc_unused const ConfigBlock &block)
...
@@ -301,10 +301,10 @@ vorbis_init(gcc_unused const ConfigBlock &block)
}
}
static
void
static
void
vorbis_stream_decode
(
Decoder
&
decoder
,
vorbis_stream_decode
(
Decoder
Client
&
client
,
InputStream
&
input_stream
)
InputStream
&
input_stream
)
{
{
if
(
ogg_codec_detect
(
&
decoder
,
input_stream
)
!=
OGG_CODEC_VORBIS
)
if
(
ogg_codec_detect
(
&
client
,
input_stream
)
!=
OGG_CODEC_VORBIS
)
return
;
return
;
/* rewind the stream, because ogg_codec_detect() has
/* rewind the stream, because ogg_codec_detect() has
...
@@ -314,7 +314,7 @@ vorbis_stream_decode(Decoder &decoder,
...
@@ -314,7 +314,7 @@ vorbis_stream_decode(Decoder &decoder,
}
catch
(
const
std
::
runtime_error
&
)
{
}
catch
(
const
std
::
runtime_error
&
)
{
}
}
DecoderReader
reader
(
decoder
,
input_stream
);
DecoderReader
reader
(
client
,
input_stream
);
VorbisDecoder
d
(
reader
);
VorbisDecoder
d
(
reader
);
while
(
true
)
{
while
(
true
)
{
...
@@ -323,10 +323,10 @@ vorbis_stream_decode(Decoder &decoder,
...
@@ -323,10 +323,10 @@ vorbis_stream_decode(Decoder &decoder,
break
;
break
;
}
catch
(
DecoderCommand
cmd
)
{
}
catch
(
DecoderCommand
cmd
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
d
.
Seek
(
decoder_seek_where_frame
(
decoder
)))
if
(
d
.
Seek
(
decoder_seek_where_frame
(
client
)))
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
else
else
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
}
else
if
(
cmd
!=
DecoderCommand
::
NONE
)
break
;
break
;
}
}
...
...
src/decoder/plugins/WavpackDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -141,7 +141,7 @@ wavpack_bits_to_sample_format(bool is_float, int bytes_per_sample)
...
@@ -141,7 +141,7 @@ wavpack_bits_to_sample_format(bool is_float, int bytes_per_sample)
* Requires an already opened WavpackContext.
* Requires an already opened WavpackContext.
*/
*/
static
void
static
void
wavpack_decode
(
Decoder
&
decoder
,
WavpackContext
*
wpc
,
bool
can_seek
)
wavpack_decode
(
Decoder
Client
&
client
,
WavpackContext
*
wpc
,
bool
can_seek
)
{
{
bool
is_float
=
(
WavpackGetMode
(
wpc
)
&
MODE_FLOAT
)
!=
0
;
bool
is_float
=
(
WavpackGetMode
(
wpc
)
&
MODE_FLOAT
)
!=
0
;
SampleFormat
sample_format
=
SampleFormat
sample_format
=
...
@@ -168,21 +168,21 @@ wavpack_decode(Decoder &decoder, WavpackContext *wpc, bool can_seek)
...
@@ -168,21 +168,21 @@ wavpack_decode(Decoder &decoder, WavpackContext *wpc, bool can_seek)
const
uint32_t
samples_requested
=
ARRAY_SIZE
(
chunk
)
/
const
uint32_t
samples_requested
=
ARRAY_SIZE
(
chunk
)
/
audio_format
.
channels
;
audio_format
.
channels
;
decoder_initialized
(
decoder
,
audio_format
,
can_seek
,
total_time
);
decoder_initialized
(
client
,
audio_format
,
can_seek
,
total_time
);
DecoderCommand
cmd
=
decoder_get_command
(
decoder
);
DecoderCommand
cmd
=
decoder_get_command
(
client
);
while
(
cmd
!=
DecoderCommand
::
STOP
)
{
while
(
cmd
!=
DecoderCommand
::
STOP
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
can_seek
)
{
if
(
can_seek
)
{
auto
where
=
decoder_seek_where_frame
(
decoder
);
auto
where
=
decoder_seek_where_frame
(
client
);
if
(
WavpackSeekSample
(
wpc
,
where
))
{
if
(
WavpackSeekSample
(
wpc
,
where
))
{
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
}
else
{
}
else
{
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
}
}
else
{
}
else
{
decoder_seek_error
(
decoder
);
decoder_seek_error
(
client
);
}
}
}
}
...
@@ -196,7 +196,7 @@ wavpack_decode(Decoder &decoder, WavpackContext *wpc, bool can_seek)
...
@@ -196,7 +196,7 @@ wavpack_decode(Decoder &decoder, WavpackContext *wpc, bool can_seek)
format_samples
(
bytes_per_sample
,
chunk
,
format_samples
(
bytes_per_sample
,
chunk
,
samples_got
*
audio_format
.
channels
);
samples_got
*
audio_format
.
channels
);
cmd
=
decoder_data
(
decoder
,
nullptr
,
chunk
,
cmd
=
decoder_data
(
client
,
nullptr
,
chunk
,
samples_got
*
output_sample_size
,
samples_got
*
output_sample_size
,
bitrate
);
bitrate
);
}
}
...
@@ -323,13 +323,13 @@ wavpack_scan_file(Path path_fs,
...
@@ -323,13 +323,13 @@ wavpack_scan_file(Path path_fs,
/* This struct is needed for per-stream last_byte storage. */
/* This struct is needed for per-stream last_byte storage. */
struct
WavpackInput
{
struct
WavpackInput
{
Decoder
&
decoder
;
Decoder
Client
&
client
;
InputStream
&
is
;
InputStream
&
is
;
/* Needed for push_back_byte() */
/* Needed for push_back_byte() */
int
last_byte
;
int
last_byte
;
constexpr
WavpackInput
(
Decoder
&
_decoder
,
InputStream
&
_is
)
constexpr
WavpackInput
(
Decoder
Client
&
_client
,
InputStream
&
_is
)
:
decoder
(
_decoder
),
is
(
_is
),
last_byte
(
EOF
)
{}
:
client
(
_client
),
is
(
_is
),
last_byte
(
EOF
)
{}
int32_t
ReadBytes
(
void
*
data
,
size_t
bcount
);
int32_t
ReadBytes
(
void
*
data
,
size_t
bcount
);
};
};
...
@@ -366,7 +366,7 @@ WavpackInput::ReadBytes(void *data, size_t bcount)
...
@@ -366,7 +366,7 @@ WavpackInput::ReadBytes(void *data, size_t bcount)
/* wavpack fails if we return a partial read, so we just wait
/* wavpack fails if we return a partial read, so we just wait
until the buffer is full */
until the buffer is full */
while
(
bcount
>
0
)
{
while
(
bcount
>
0
)
{
size_t
nbytes
=
decoder_read
(
&
decoder
,
is
,
buf
,
bcount
);
size_t
nbytes
=
decoder_read
(
&
client
,
is
,
buf
,
bcount
);
if
(
nbytes
==
0
)
{
if
(
nbytes
==
0
)
{
/* EOF, error or a decoder command */
/* EOF, error or a decoder command */
break
;
break
;
...
@@ -481,7 +481,7 @@ static WavpackStreamReader mpd_is_reader = {
...
@@ -481,7 +481,7 @@ static WavpackStreamReader mpd_is_reader = {
};
};
static
InputStreamPtr
static
InputStreamPtr
wavpack_open_wvc
(
Decoder
&
decoder
,
const
char
*
uri
)
wavpack_open_wvc
(
Decoder
Client
&
client
,
const
char
*
uri
)
{
{
/*
/*
* As we use dc->utf8url, this function will be bad for
* As we use dc->utf8url, this function will be bad for
...
@@ -496,7 +496,7 @@ wavpack_open_wvc(Decoder &decoder, const char *uri)
...
@@ -496,7 +496,7 @@ wavpack_open_wvc(Decoder &decoder, const char *uri)
};
};
try
{
try
{
return
decoder_open_uri
(
decoder
,
uri
);
return
decoder_open_uri
(
client
,
uri
);
}
catch
(
const
std
::
runtime_error
&
)
{
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
return
nullptr
;
}
}
...
@@ -506,25 +506,25 @@ wavpack_open_wvc(Decoder &decoder, const char *uri)
...
@@ -506,25 +506,25 @@ wavpack_open_wvc(Decoder &decoder, const char *uri)
* Decodes a stream.
* Decodes a stream.
*/
*/
static
void
static
void
wavpack_streamdecode
(
Decoder
&
decoder
,
InputStream
&
is
)
wavpack_streamdecode
(
Decoder
Client
&
client
,
InputStream
&
is
)
{
{
int
open_flags
=
OPEN_NORMALIZE
;
int
open_flags
=
OPEN_NORMALIZE
;
bool
can_seek
=
is
.
IsSeekable
();
bool
can_seek
=
is
.
IsSeekable
();
std
::
unique_ptr
<
WavpackInput
>
wvc
;
std
::
unique_ptr
<
WavpackInput
>
wvc
;
auto
is_wvc
=
wavpack_open_wvc
(
decoder
,
is
.
GetURI
());
auto
is_wvc
=
wavpack_open_wvc
(
client
,
is
.
GetURI
());
if
(
is_wvc
)
{
if
(
is_wvc
)
{
open_flags
|=
OPEN_WVC
;
open_flags
|=
OPEN_WVC
;
can_seek
&=
wvc
->
is
.
IsSeekable
();
can_seek
&=
wvc
->
is
.
IsSeekable
();
wvc
.
reset
(
new
WavpackInput
(
decoder
,
*
is_wvc
));
wvc
.
reset
(
new
WavpackInput
(
client
,
*
is_wvc
));
}
}
if
(
!
can_seek
)
{
if
(
!
can_seek
)
{
open_flags
|=
OPEN_STREAMING
;
open_flags
|=
OPEN_STREAMING
;
}
}
WavpackInput
isp
(
decoder
,
is
);
WavpackInput
isp
(
client
,
is
);
char
error
[
ERRORLEN
];
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
=
WavpackContext
*
wpc
=
...
@@ -541,14 +541,14 @@ wavpack_streamdecode(Decoder &decoder, InputStream &is)
...
@@ -541,14 +541,14 @@ wavpack_streamdecode(Decoder &decoder, InputStream &is)
WavpackCloseFile
(
wpc
);
WavpackCloseFile
(
wpc
);
};
};
wavpack_decode
(
decoder
,
wpc
,
can_seek
);
wavpack_decode
(
client
,
wpc
,
can_seek
);
}
}
/*
/*
* Decodes a file.
* Decodes a file.
*/
*/
static
void
static
void
wavpack_filedecode
(
Decoder
&
decoder
,
Path
path_fs
)
wavpack_filedecode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
char
error
[
ERRORLEN
];
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
=
WavpackOpenFileInput
(
path_fs
.
c_str
(),
error
,
WavpackContext
*
wpc
=
WavpackOpenFileInput
(
path_fs
.
c_str
(),
error
,
...
@@ -563,9 +563,9 @@ wavpack_filedecode(Decoder &decoder, Path path_fs)
...
@@ -563,9 +563,9 @@ wavpack_filedecode(Decoder &decoder, Path path_fs)
ReplayGainInfo
rgi
;
ReplayGainInfo
rgi
;
if
(
wavpack_replaygain
(
rgi
,
wpc
))
if
(
wavpack_replaygain
(
rgi
,
wpc
))
decoder_replay_gain
(
decoder
,
&
rgi
);
decoder_replay_gain
(
client
,
&
rgi
);
wavpack_decode
(
decoder
,
wpc
,
true
);
wavpack_decode
(
client
,
wpc
,
true
);
WavpackCloseFile
(
wpc
);
WavpackCloseFile
(
wpc
);
}
}
...
...
src/decoder/plugins/WildmidiDecoderPlugin.cxx
View file @
fd77acc2
...
@@ -61,7 +61,7 @@ wildmidi_finish(void)
...
@@ -61,7 +61,7 @@ wildmidi_finish(void)
}
}
static
DecoderCommand
static
DecoderCommand
wildmidi_output
(
Decoder
&
decoder
,
midi
*
wm
)
wildmidi_output
(
Decoder
Client
&
client
,
midi
*
wm
)
{
{
#ifdef LIBWILDMIDI_VER_MAJOR
#ifdef LIBWILDMIDI_VER_MAJOR
/* WildMidi 0.4 has switched from "char*" to "int8_t*" */
/* WildMidi 0.4 has switched from "char*" to "int8_t*" */
...
@@ -75,11 +75,11 @@ wildmidi_output(Decoder &decoder, midi *wm)
...
@@ -75,11 +75,11 @@ wildmidi_output(Decoder &decoder, midi *wm)
if
(
length
<=
0
)
if
(
length
<=
0
)
return
DecoderCommand
::
STOP
;
return
DecoderCommand
::
STOP
;
return
decoder_data
(
decoder
,
nullptr
,
buffer
,
length
,
0
);
return
decoder_data
(
client
,
nullptr
,
buffer
,
length
,
0
);
}
}
static
void
static
void
wildmidi_file_decode
(
Decoder
&
decoder
,
Path
path_fs
)
wildmidi_file_decode
(
Decoder
Client
&
client
,
Path
path_fs
)
{
{
static
constexpr
AudioFormat
audio_format
=
{
static
constexpr
AudioFormat
audio_format
=
{
WILDMIDI_SAMPLE_RATE
,
WILDMIDI_SAMPLE_RATE
,
...
@@ -103,7 +103,7 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs)
...
@@ -103,7 +103,7 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs)
SongTime
::
FromScale
<
uint64_t
>
(
info
->
approx_total_samples
,
SongTime
::
FromScale
<
uint64_t
>
(
info
->
approx_total_samples
,
WILDMIDI_SAMPLE_RATE
);
WILDMIDI_SAMPLE_RATE
);
decoder_initialized
(
decoder
,
audio_format
,
true
,
duration
);
decoder_initialized
(
client
,
audio_format
,
true
,
duration
);
DecoderCommand
cmd
;
DecoderCommand
cmd
;
do
{
do
{
...
@@ -111,14 +111,14 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs)
...
@@ -111,14 +111,14 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs)
if
(
info
==
nullptr
)
if
(
info
==
nullptr
)
break
;
break
;
cmd
=
wildmidi_output
(
decoder
,
wm
);
cmd
=
wildmidi_output
(
client
,
wm
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
unsigned
long
seek_where
=
unsigned
long
seek_where
=
decoder_seek_where_frame
(
decoder
);
decoder_seek_where_frame
(
client
);
WildMidi_FastSeek
(
wm
,
&
seek_where
);
WildMidi_FastSeek
(
wm
,
&
seek_where
);
decoder_command_finished
(
decoder
);
decoder_command_finished
(
client
);
cmd
=
DecoderCommand
::
NONE
;
cmd
=
DecoderCommand
::
NONE
;
}
}
...
...
test/FakeDecoderAPI.cxx
View file @
fd77acc2
...
@@ -29,11 +29,12 @@
...
@@ -29,11 +29,12 @@
#include <stdio.h>
#include <stdio.h>
void
void
decoder_initialized
(
Decoder
&
decoder
,
decoder_initialized
(
Decoder
Client
&
client
,
const
AudioFormat
audio_format
,
const
AudioFormat
audio_format
,
gcc_unused
bool
seekable
,
gcc_unused
bool
seekable
,
SignedSongTime
duration
)
SignedSongTime
duration
)
{
{
auto
&
decoder
=
(
FakeDecoder
&
)
client
;
struct
audio_format_string
af_string
;
struct
audio_format_string
af_string
;
assert
(
!
decoder
.
initialized
);
assert
(
!
decoder
.
initialized
);
...
@@ -47,41 +48,42 @@ decoder_initialized(Decoder &decoder,
...
@@ -47,41 +48,42 @@ decoder_initialized(Decoder &decoder,
}
}
DecoderCommand
DecoderCommand
decoder_get_command
(
gcc_unused
Decoder
&
decoder
)
decoder_get_command
(
gcc_unused
Decoder
Client
&
client
)
{
{
return
DecoderCommand
::
NONE
;
return
DecoderCommand
::
NONE
;
}
}
void
void
decoder_command_finished
(
gcc_unused
Decoder
&
decoder
)
decoder_command_finished
(
gcc_unused
Decoder
Client
&
client
)
{
{
}
}
SongTime
SongTime
decoder_seek_time
(
gcc_unused
Decoder
&
decoder
)
decoder_seek_time
(
gcc_unused
Decoder
Client
&
client
)
{
{
return
SongTime
();
return
SongTime
();
}
}
uint64_t
uint64_t
decoder_seek_where_frame
(
gcc_unused
Decoder
&
decoder
)
decoder_seek_where_frame
(
gcc_unused
Decoder
Client
&
client
)
{
{
return
1
;
return
1
;
}
}
void
void
decoder_seek_error
(
gcc_unused
Decoder
&
decoder
)
decoder_seek_error
(
gcc_unused
Decoder
Client
&
client
)
{
{
}
}
InputStreamPtr
InputStreamPtr
decoder_open_uri
(
Decoder
&
decoder
,
const
char
*
uri
)
decoder_open_uri
(
Decoder
Client
&
client
,
const
char
*
uri
)
{
{
auto
&
decoder
=
(
FakeDecoder
&
)
client
;
return
InputStream
::
OpenReady
(
uri
,
decoder
.
mutex
,
decoder
.
cond
);
return
InputStream
::
OpenReady
(
uri
,
decoder
.
mutex
,
decoder
.
cond
);
}
}
size_t
size_t
decoder_read
(
gcc_unused
Decoder
*
decoder
,
decoder_read
(
gcc_unused
Decoder
Client
*
client
,
InputStream
&
is
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
void
*
buffer
,
size_t
length
)
{
{
...
@@ -93,13 +95,13 @@ decoder_read(gcc_unused Decoder *decoder,
...
@@ -93,13 +95,13 @@ decoder_read(gcc_unused Decoder *decoder,
}
}
bool
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
decoder_read_full
(
Decoder
Client
*
client
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
void
*
_buffer
,
size_t
size
)
{
{
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size
);
size_t
nbytes
=
decoder_read
(
client
,
is
,
buffer
,
size
);
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
return
false
;
return
false
;
...
@@ -111,11 +113,11 @@ decoder_read_full(Decoder *decoder, InputStream &is,
...
@@ -111,11 +113,11 @@ decoder_read_full(Decoder *decoder, InputStream &is,
}
}
bool
bool
decoder_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
)
decoder_skip
(
Decoder
Client
*
client
,
InputStream
&
is
,
size_t
size
)
{
{
while
(
size
>
0
)
{
while
(
size
>
0
)
{
char
buffer
[
1024
];
char
buffer
[
1024
];
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size_t
nbytes
=
decoder_read
(
client
,
is
,
buffer
,
std
::
min
(
sizeof
(
buffer
),
size
));
std
::
min
(
sizeof
(
buffer
),
size
));
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
return
false
;
return
false
;
...
@@ -127,13 +129,13 @@ decoder_skip(Decoder *decoder, InputStream &is, size_t size)
...
@@ -127,13 +129,13 @@ decoder_skip(Decoder *decoder, InputStream &is, size_t size)
}
}
void
void
decoder_timestamp
(
gcc_unused
Decoder
&
decoder
,
decoder_timestamp
(
gcc_unused
Decoder
Client
&
client
,
gcc_unused
double
t
)
gcc_unused
double
t
)
{
{
}
}
DecoderCommand
DecoderCommand
decoder_data
(
gcc_unused
Decoder
&
decoder
,
decoder_data
(
gcc_unused
Decoder
Client
&
client
,
gcc_unused
InputStream
*
is
,
gcc_unused
InputStream
*
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
)
...
@@ -149,7 +151,7 @@ decoder_data(gcc_unused Decoder &decoder,
...
@@ -149,7 +151,7 @@ decoder_data(gcc_unused Decoder &decoder,
}
}
DecoderCommand
DecoderCommand
decoder_tag
(
gcc_unused
Decoder
&
decoder
,
decoder_tag
(
gcc_unused
Decoder
Client
&
client
,
gcc_unused
InputStream
*
is
,
gcc_unused
InputStream
*
is
,
Tag
&&
tag
)
Tag
&&
tag
)
{
{
...
@@ -162,7 +164,7 @@ decoder_tag(gcc_unused Decoder &decoder,
...
@@ -162,7 +164,7 @@ decoder_tag(gcc_unused Decoder &decoder,
}
}
void
void
decoder_replay_gain
(
gcc_unused
Decoder
&
decoder
,
decoder_replay_gain
(
gcc_unused
Decoder
Client
&
client
,
const
ReplayGainInfo
*
rgi
)
const
ReplayGainInfo
*
rgi
)
{
{
const
ReplayGainTuple
*
tuple
=
&
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
];
const
ReplayGainTuple
*
tuple
=
&
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
];
...
@@ -177,7 +179,7 @@ decoder_replay_gain(gcc_unused Decoder &decoder,
...
@@ -177,7 +179,7 @@ decoder_replay_gain(gcc_unused Decoder &decoder,
}
}
void
void
decoder_mixramp
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
MixRampInfo
&&
mix_ramp
)
decoder_mixramp
(
gcc_unused
Decoder
Client
&
client
,
gcc_unused
MixRampInfo
&&
mix_ramp
)
{
{
fprintf
(
stderr
,
"MixRamp: start='%s' end='%s'
\n
"
,
fprintf
(
stderr
,
"MixRamp: start='%s' end='%s'
\n
"
,
mix_ramp
.
GetStart
(),
mix_ramp
.
GetEnd
());
mix_ramp
.
GetStart
(),
mix_ramp
.
GetEnd
());
...
...
test/FakeDecoderAPI.hxx
View file @
fd77acc2
...
@@ -21,17 +21,15 @@
...
@@ -21,17 +21,15 @@
#define FAKE_DECODER_API_HXX
#define FAKE_DECODER_API_HXX
#include "check.h"
#include "check.h"
#include "decoder/Client.hxx"
#include "thread/Mutex.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "thread/Cond.hxx"
struct
Decoder
{
struct
FakeDecoder
final
:
DecoderClient
{
Mutex
mutex
;
Mutex
mutex
;
Cond
cond
;
Cond
cond
;
bool
initialized
;
bool
initialized
=
false
;
Decoder
()
:
initialized
(
false
)
{}
};
};
#endif
#endif
test/run_decoder.cxx
View file @
fd77acc2
...
@@ -42,7 +42,7 @@ try {
...
@@ -42,7 +42,7 @@ try {
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
Decoder
decoder
;
Fake
Decoder
decoder
;
const
char
*
const
decoder_name
=
argv
[
1
];
const
char
*
const
decoder_name
=
argv
[
1
];
const
char
*
const
uri
=
argv
[
2
];
const
char
*
const
uri
=
argv
[
2
];
...
...
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