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
93deb844
Commit
93deb844
authored
Oct 23, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input_stream: rename struct to InputStream
parent
c4d4011c
Show whitespace changes
Inline
Side-by-side
Showing
77 changed files
with
512 additions
and
504 deletions
+512
-504
ArchiveFile.hxx
src/ArchiveFile.hxx
+2
-2
ArchivePlugin.hxx
src/ArchivePlugin.hxx
+1
-1
DecoderAPI.cxx
src/DecoderAPI.cxx
+11
-12
DecoderAPI.hxx
src/DecoderAPI.hxx
+18
-4
DecoderBuffer.cxx
src/DecoderBuffer.cxx
+4
-5
DecoderBuffer.hxx
src/DecoderBuffer.hxx
+2
-2
DecoderInternal.hxx
src/DecoderInternal.hxx
+1
-1
DecoderPlugin.hxx
src/DecoderPlugin.hxx
+7
-7
DecoderThread.cxx
src/DecoderThread.cxx
+16
-17
InputPlugin.hxx
src/InputPlugin.hxx
+10
-10
InputStream.cxx
src/InputStream.cxx
+20
-20
InputStream.hxx
src/InputStream.hxx
+5
-5
PlaylistAny.cxx
src/PlaylistAny.cxx
+4
-4
PlaylistAny.hxx
src/PlaylistAny.hxx
+2
-2
PlaylistMapper.cxx
src/PlaylistMapper.cxx
+4
-4
PlaylistMapper.hxx
src/PlaylistMapper.hxx
+2
-2
PlaylistPlugin.hxx
src/PlaylistPlugin.hxx
+3
-3
PlaylistPrint.cxx
src/PlaylistPrint.cxx
+1
-1
PlaylistQueue.cxx
src/PlaylistQueue.cxx
+1
-1
PlaylistRegistry.cxx
src/PlaylistRegistry.cxx
+13
-14
PlaylistRegistry.hxx
src/PlaylistRegistry.hxx
+3
-3
TagFile.cxx
src/TagFile.cxx
+3
-3
TextInputStream.cxx
src/TextInputStream.cxx
+1
-1
TextInputStream.hxx
src/TextInputStream.hxx
+3
-3
Bzip2ArchivePlugin.cxx
src/archive/Bzip2ArchivePlugin.cxx
+9
-9
Iso9660ArchivePlugin.cxx
src/archive/Iso9660ArchivePlugin.cxx
+6
-6
ZzipArchivePlugin.cxx
src/archive/ZzipArchivePlugin.cxx
+7
-7
AudiofileDecoderPlugin.cxx
src/decoder/AudiofileDecoderPlugin.cxx
+14
-14
DsdLib.cxx
src/decoder/DsdLib.cxx
+15
-15
DsdLib.hxx
src/decoder/DsdLib.hxx
+5
-4
DsdiffDecoderPlugin.cxx
src/decoder/DsdiffDecoderPlugin.cxx
+28
-28
DsfDecoderPlugin.cxx
src/decoder/DsfDecoderPlugin.cxx
+7
-7
FaadDecoderPlugin.cxx
src/decoder/FaadDecoderPlugin.cxx
+9
-9
FfmpegDecoderPlugin.cxx
src/decoder/FfmpegDecoderPlugin.cxx
+15
-15
FlacCommon.cxx
src/decoder/FlacCommon.cxx
+2
-2
FlacCommon.hxx
src/decoder/FlacCommon.hxx
+2
-2
FlacDecoderPlugin.cxx
src/decoder/FlacDecoderPlugin.cxx
+8
-8
FlacIOHandle.cxx
src/decoder/FlacIOHandle.cxx
+5
-5
FlacIOHandle.hxx
src/decoder/FlacIOHandle.hxx
+4
-4
FlacInput.cxx
src/decoder/FlacInput.cxx
+8
-8
FlacInput.hxx
src/decoder/FlacInput.hxx
+4
-3
FlacMetadata.hxx
src/decoder/FlacMetadata.hxx
+2
-2
MadDecoderPlugin.cxx
src/decoder/MadDecoderPlugin.cxx
+17
-17
ModplugDecoderPlugin.cxx
src/decoder/ModplugDecoderPlugin.cxx
+8
-8
MpcdecDecoderPlugin.cxx
src/decoder/MpcdecDecoderPlugin.cxx
+14
-15
OggCodec.cxx
src/decoder/OggCodec.cxx
+1
-1
OggCodec.hxx
src/decoder/OggCodec.hxx
+1
-1
OggSyncState.hxx
src/decoder/OggSyncState.hxx
+8
-8
OggUtil.cxx
src/decoder/OggUtil.cxx
+6
-6
OggUtil.hxx
src/decoder/OggUtil.hxx
+8
-8
OpusDecoderPlugin.cxx
src/decoder/OpusDecoderPlugin.cxx
+11
-11
PcmDecoderPlugin.cxx
src/decoder/PcmDecoderPlugin.cxx
+7
-7
SndfileDecoderPlugin.cxx
src/decoder/SndfileDecoderPlugin.cxx
+11
-11
VorbisDecoderPlugin.cxx
src/decoder/VorbisDecoderPlugin.cxx
+9
-9
WavpackDecoderPlugin.cxx
src/decoder/WavpackDecoderPlugin.cxx
+14
-14
ArchiveInputPlugin.cxx
src/input/ArchiveInputPlugin.cxx
+2
-2
CdioParanoiaInputPlugin.cxx
src/input/CdioParanoiaInputPlugin.cxx
+6
-6
CurlInputPlugin.cxx
src/input/CurlInputPlugin.cxx
+10
-10
DespotifyInputPlugin.cxx
src/input/DespotifyInputPlugin.cxx
+6
-6
FfmpegInputPlugin.cxx
src/input/FfmpegInputPlugin.cxx
+6
-6
FileInputPlugin.cxx
src/input/FileInputPlugin.cxx
+6
-6
MmsInputPlugin.cxx
src/input/MmsInputPlugin.cxx
+5
-5
RewindInputPlugin.cxx
src/input/RewindInputPlugin.cxx
+15
-15
RewindInputPlugin.hxx
src/input/RewindInputPlugin.hxx
+3
-3
AsxPlaylistPlugin.cxx
src/playlist/AsxPlaylistPlugin.cxx
+2
-2
CuePlaylistPlugin.cxx
src/playlist/CuePlaylistPlugin.cxx
+3
-3
ExtM3uPlaylistPlugin.cxx
src/playlist/ExtM3uPlaylistPlugin.cxx
+2
-2
M3uPlaylistPlugin.cxx
src/playlist/M3uPlaylistPlugin.cxx
+2
-2
PlsPlaylistPlugin.cxx
src/playlist/PlsPlaylistPlugin.cxx
+2
-2
RssPlaylistPlugin.cxx
src/playlist/RssPlaylistPlugin.cxx
+2
-2
SoundCloudPlaylistPlugin.cxx
src/playlist/SoundCloudPlaylistPlugin.cxx
+1
-1
XspfPlaylistPlugin.cxx
src/playlist/XspfPlaylistPlugin.cxx
+2
-2
dump_playlist.cxx
test/dump_playlist.cxx
+8
-9
dump_text_file.cxx
test/dump_text_file.cxx
+12
-13
read_tags.cxx
test/read_tags.cxx
+5
-6
run_decoder.cxx
test/run_decoder.cxx
+7
-7
run_input.cxx
test/run_input.cxx
+3
-3
No files found.
src/ArchiveFile.hxx
View file @
93deb844
...
...
@@ -46,11 +46,11 @@ public:
virtual
void
Visit
(
ArchiveVisitor
&
visitor
)
=
0
;
/**
* Opens an
input_s
tream of a file within the archive.
* Opens an
InputS
tream of a file within the archive.
*
* @param path the path within the archive
*/
virtual
input_s
tream
*
OpenStream
(
const
char
*
path
,
virtual
InputS
tream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
=
0
;
};
...
...
src/ArchivePlugin.hxx
View file @
93deb844
...
...
@@ -20,7 +20,7 @@
#ifndef MPD_ARCHIVE_PLUGIN_HXX
#define MPD_ARCHIVE_PLUGIN_HXX
struct
input_s
tream
;
struct
InputS
tream
;
class
ArchiveFile
;
class
ArchiveVisitor
;
class
Error
;
...
...
src/DecoderAPI.cxx
View file @
93deb844
...
...
@@ -251,7 +251,7 @@ decoder_check_cancel_read(const Decoder *decoder)
size_t
decoder_read
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
{
/* XXX don't allow decoder==nullptr */
...
...
@@ -259,35 +259,34 @@ decoder_read(Decoder *decoder,
assert
(
decoder
==
nullptr
||
decoder
->
dc
.
state
==
DecoderState
::
START
||
decoder
->
dc
.
state
==
DecoderState
::
DECODE
);
assert
(
is
!=
nullptr
);
assert
(
buffer
!=
nullptr
);
if
(
length
==
0
)
return
0
;
is
->
Lock
();
is
.
Lock
();
while
(
true
)
{
if
(
decoder_check_cancel_read
(
decoder
))
{
is
->
Unlock
();
is
.
Unlock
();
return
0
;
}
if
(
is
->
IsAvailable
())
if
(
is
.
IsAvailable
())
break
;
is
->
cond
.
wait
(
is
->
mutex
);
is
.
cond
.
wait
(
is
.
mutex
);
}
Error
error
;
size_t
nbytes
=
is
->
Read
(
buffer
,
length
,
error
);
size_t
nbytes
=
is
.
Read
(
buffer
,
length
,
error
);
assert
(
nbytes
==
0
||
!
error
.
IsDefined
());
assert
(
nbytes
>
0
||
error
.
IsDefined
()
||
is
->
IsEOF
());
assert
(
nbytes
>
0
||
error
.
IsDefined
()
||
is
.
IsEOF
());
if
(
gcc_unlikely
(
nbytes
==
0
&&
error
.
IsDefined
()))
LogError
(
error
);
is
->
Unlock
();
is
.
Unlock
();
return
nbytes
;
}
...
...
@@ -329,7 +328,7 @@ do_send_tag(Decoder &decoder, const Tag &tag)
}
static
bool
update_stream_tag
(
Decoder
&
decoder
,
struct
input_s
tream
*
is
)
update_stream_tag
(
Decoder
&
decoder
,
InputS
tream
*
is
)
{
Tag
*
tag
;
...
...
@@ -353,7 +352,7 @@ update_stream_tag(Decoder &decoder, struct input_stream *is)
DecoderCommand
decoder_data
(
Decoder
&
decoder
,
struct
input_s
tream
*
is
,
InputS
tream
*
is
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
{
...
...
@@ -462,7 +461,7 @@ decoder_data(Decoder &decoder,
}
DecoderCommand
decoder_tag
(
Decoder
&
decoder
,
struct
input_s
tream
*
is
,
decoder_tag
(
Decoder
&
decoder
,
InputS
tream
*
is
,
Tag
&&
tag
)
{
gcc_unused
const
decoder_control
&
dc
=
decoder
.
dc
;
...
...
src/DecoderAPI.hxx
View file @
93deb844
...
...
@@ -99,11 +99,11 @@ decoder_seek_error(Decoder &decoder);
* occurs: end of file; error; command (like SEEK or STOP).
*/
size_t
decoder_read
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
decoder_read
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
);
static
inline
size_t
decoder_read
(
Decoder
&
decoder
,
input_stream
*
is
,
decoder_read
(
Decoder
&
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
{
return
decoder_read
(
&
decoder
,
is
,
buffer
,
length
);
...
...
@@ -131,10 +131,18 @@ decoder_timestamp(Decoder &decoder, double t);
* command pending
*/
DecoderCommand
decoder_data
(
Decoder
&
decoder
,
struct
input_s
tream
*
is
,
decoder_data
(
Decoder
&
decoder
,
InputS
tream
*
is
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
);
static
inline
DecoderCommand
decoder_data
(
Decoder
&
decoder
,
InputStream
&
is
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
{
return
decoder_data
(
decoder
,
&
is
,
data
,
length
,
kbit_rate
);
}
/**
* This function is called by the decoder plugin when it has
* successfully decoded a tag.
...
...
@@ -147,7 +155,13 @@ decoder_data(Decoder &decoder, struct input_stream *is,
* command pending
*/
DecoderCommand
decoder_tag
(
Decoder
&
decoder
,
struct
input_stream
*
is
,
Tag
&&
tag
);
decoder_tag
(
Decoder
&
decoder
,
InputStream
*
is
,
Tag
&&
tag
);
static
inline
DecoderCommand
decoder_tag
(
Decoder
&
decoder
,
InputStream
&
is
,
Tag
&&
tag
)
{
return
decoder_tag
(
decoder
,
&
is
,
std
::
move
(
tag
));
}
/**
* Set replay gain values for the following chunks.
...
...
src/DecoderBuffer.cxx
View file @
93deb844
...
...
@@ -28,7 +28,7 @@
struct
DecoderBuffer
{
Decoder
*
decoder
;
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
/** the allocated size of the buffer */
size_t
size
;
...
...
@@ -45,17 +45,16 @@ struct DecoderBuffer {
};
DecoderBuffer
*
decoder_buffer_new
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
decoder_buffer_new
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
)
{
DecoderBuffer
*
buffer
=
(
DecoderBuffer
*
)
g_malloc
(
sizeof
(
*
buffer
)
-
sizeof
(
buffer
->
data
)
+
size
);
assert
(
is
!=
nullptr
);
assert
(
size
>
0
);
buffer
->
decoder
=
decoder
;
buffer
->
is
=
is
;
buffer
->
is
=
&
is
;
buffer
->
size
=
size
;
buffer
->
length
=
0
;
buffer
->
consumed
=
0
;
...
...
@@ -105,7 +104,7 @@ decoder_buffer_fill(DecoderBuffer *buffer)
/* buffer is full */
return
false
;
nbytes
=
decoder_read
(
buffer
->
decoder
,
buffer
->
is
,
nbytes
=
decoder_read
(
buffer
->
decoder
,
*
buffer
->
is
,
buffer
->
data
+
buffer
->
length
,
buffer
->
size
-
buffer
->
length
);
if
(
nbytes
==
0
)
...
...
src/DecoderBuffer.hxx
View file @
93deb844
...
...
@@ -30,7 +30,7 @@
struct
DecoderBuffer
;
struct
Decoder
;
struct
input_s
tream
;
struct
InputS
tream
;
/**
* Creates a new buffer.
...
...
@@ -41,7 +41,7 @@ struct input_stream;
* @return the new decoder_buffer object
*/
DecoderBuffer
*
decoder_buffer_new
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
decoder_buffer_new
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
);
/**
...
...
src/DecoderInternal.hxx
View file @
93deb844
...
...
@@ -25,7 +25,7 @@
#include "ReplayGainInfo.hxx"
struct
decoder_control
;
struct
input_s
tream
;
struct
InputS
tream
;
struct
Tag
;
struct
Decoder
{
...
...
src/DecoderPlugin.hxx
View file @
93deb844
...
...
@@ -23,7 +23,7 @@
#include "Compiler.h"
struct
config_param
;
struct
input_s
tream
;
struct
InputS
tream
;
struct
Tag
;
struct
tag_handler
;
...
...
@@ -59,7 +59,7 @@ struct DecoderPlugin {
* possible, it is recommended to implement this method,
* because it is more versatile.
*/
void
(
*
stream_decode
)(
Decoder
&
decoder
,
input_stream
*
is
);
void
(
*
stream_decode
)(
Decoder
&
decoder
,
InputStream
&
is
);
/**
* Decode a local file.
...
...
@@ -82,7 +82,7 @@ struct DecoderPlugin {
*
* @return false if the operation has failed
*/
bool
(
*
scan_stream
)(
struct
input_stream
*
is
,
bool
(
*
scan_stream
)(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
);
...
...
@@ -127,8 +127,8 @@ struct DecoderPlugin {
/**
* Decode a stream.
*/
void
StreamDecode
(
Decoder
&
decoder
,
input_s
tream
&
is
)
const
{
stream_decode
(
decoder
,
&
is
);
void
StreamDecode
(
Decoder
&
decoder
,
InputS
tream
&
is
)
const
{
stream_decode
(
decoder
,
is
);
}
/**
...
...
@@ -151,10 +151,10 @@ struct DecoderPlugin {
/**
* Read the tag of a stream.
*/
bool
ScanStream
(
input_s
tream
&
is
,
bool
ScanStream
(
InputS
tream
&
is
,
const
tag_handler
&
handler
,
void
*
handler_ctx
)
const
{
return
scan_stream
!=
nullptr
?
scan_stream
(
&
is
,
&
handler
,
handler_ctx
)
?
scan_stream
(
is
,
&
handler
,
handler_ctx
)
:
false
;
}
...
...
src/DecoderThread.cxx
View file @
93deb844
...
...
@@ -67,12 +67,12 @@ decoder_command_finished_locked(decoder_control &dc)
* @return an input_stream on success or if #DecoderCommand::STOP is
* received, nullptr on error
*/
static
struct
input_s
tream
*
static
InputS
tream
*
decoder_input_stream_open
(
decoder_control
&
dc
,
const
char
*
uri
)
{
Error
error
;
input_stream
*
is
=
input_s
tream
::
Open
(
uri
,
dc
.
mutex
,
dc
.
cond
,
error
);
InputStream
*
is
=
InputS
tream
::
Open
(
uri
,
dc
.
mutex
,
dc
.
cond
,
error
);
if
(
is
==
nullptr
)
{
if
(
error
.
IsDefined
())
LogError
(
error
);
...
...
@@ -108,13 +108,12 @@ decoder_input_stream_open(decoder_control &dc, const char *uri)
static
bool
decoder_stream_decode
(
const
DecoderPlugin
&
plugin
,
Decoder
&
decoder
,
struct
input_stream
*
input_stream
)
InputStream
&
input_stream
)
{
assert
(
plugin
.
stream_decode
!=
nullptr
);
assert
(
decoder
.
stream_tag
==
nullptr
);
assert
(
decoder
.
decoder_tag
==
nullptr
);
assert
(
input_stream
!=
nullptr
);
assert
(
input_stream
->
ready
);
assert
(
input_stream
.
ready
);
assert
(
decoder
.
dc
.
state
==
DecoderState
::
START
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
.
name
);
...
...
@@ -123,11 +122,11 @@ decoder_stream_decode(const DecoderPlugin &plugin,
return
true
;
/* rewind the stream, so each plugin gets a fresh start */
input_stream
->
Rewind
(
IgnoreError
());
input_stream
.
Rewind
(
IgnoreError
());
decoder
.
dc
.
Unlock
();
plugin
.
StreamDecode
(
decoder
,
*
input_stream
);
plugin
.
StreamDecode
(
decoder
,
input_stream
);
decoder
.
dc
.
Lock
();
...
...
@@ -167,7 +166,7 @@ decoder_file_decode(const DecoderPlugin &plugin,
gcc_pure
static
bool
decoder_check_plugin_mime
(
const
DecoderPlugin
&
plugin
,
const
input_s
tream
&
is
)
decoder_check_plugin_mime
(
const
DecoderPlugin
&
plugin
,
const
InputS
tream
&
is
)
{
assert
(
plugin
.
stream_decode
!=
nullptr
);
...
...
@@ -185,7 +184,7 @@ decoder_check_plugin_suffix(const DecoderPlugin &plugin, const char *suffix)
gcc_pure
static
bool
decoder_check_plugin
(
const
DecoderPlugin
&
plugin
,
const
input_s
tream
&
is
,
decoder_check_plugin
(
const
DecoderPlugin
&
plugin
,
const
InputS
tream
&
is
,
const
char
*
suffix
)
{
return
plugin
.
stream_decode
!=
nullptr
&&
...
...
@@ -194,7 +193,7 @@ decoder_check_plugin(const DecoderPlugin &plugin, const input_stream &is,
}
static
bool
decoder_run_stream_plugin
(
Decoder
&
decoder
,
input_s
tream
&
is
,
decoder_run_stream_plugin
(
Decoder
&
decoder
,
InputS
tream
&
is
,
const
char
*
suffix
,
const
DecoderPlugin
&
plugin
,
bool
&
tried_r
)
...
...
@@ -203,11 +202,11 @@ decoder_run_stream_plugin(Decoder &decoder, input_stream &is,
return
false
;
tried_r
=
true
;
return
decoder_stream_decode
(
plugin
,
decoder
,
&
is
);
return
decoder_stream_decode
(
plugin
,
decoder
,
is
);
}
static
bool
decoder_run_stream_locked
(
Decoder
&
decoder
,
input_s
tream
&
is
,
decoder_run_stream_locked
(
Decoder
&
decoder
,
InputS
tream
&
is
,
const
char
*
uri
,
bool
&
tried_r
)
{
const
char
*
const
suffix
=
uri_get_suffix
(
uri
);
...
...
@@ -223,7 +222,7 @@ decoder_run_stream_locked(Decoder &decoder, input_stream &is,
* Try decoding a stream, using the fallback plugin.
*/
static
bool
decoder_run_stream_fallback
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
decoder_run_stream_fallback
(
Decoder
&
decoder
,
InputStream
&
is
)
{
const
struct
DecoderPlugin
*
plugin
;
...
...
@@ -239,7 +238,7 @@ static bool
decoder_run_stream
(
Decoder
&
decoder
,
const
char
*
uri
)
{
decoder_control
&
dc
=
decoder
.
dc
;
struct
input_s
tream
*
input_stream
;
InputS
tream
*
input_stream
;
bool
success
;
dc
.
Unlock
();
...
...
@@ -259,7 +258,7 @@ decoder_run_stream(Decoder &decoder, const char *uri)
/* fallback to mp3: this is needed for bastard streams
that don't have a suffix or set the mimeType */
(
!
tried
&&
decoder_run_stream_fallback
(
decoder
,
input_stream
));
decoder_run_stream_fallback
(
decoder
,
*
input_stream
));
dc
.
Unlock
();
input_stream
->
Close
();
...
...
@@ -306,7 +305,7 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
dc
.
Unlock
();
}
else
if
(
plugin
->
stream_decode
!=
nullptr
)
{
struct
input_s
tream
*
input_stream
;
InputS
tream
*
input_stream
;
bool
success
;
input_stream
=
decoder_input_stream_open
(
dc
,
path_fs
);
...
...
@@ -316,7 +315,7 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
dc
.
Lock
();
success
=
decoder_stream_decode
(
*
plugin
,
decoder
,
input_stream
);
*
input_stream
);
dc
.
Unlock
();
...
...
src/InputPlugin.hxx
View file @
93deb844
...
...
@@ -27,7 +27,7 @@
#include <stdint.h>
struct
config_param
;
struct
input_s
tream
;
struct
InputS
tream
;
class
Error
;
struct
Tag
;
...
...
@@ -50,10 +50,10 @@ struct InputPlugin {
*/
void
(
*
finish
)(
void
);
struct
input_s
tream
*
(
*
open
)(
const
char
*
uri
,
InputS
tream
*
(
*
open
)(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
);
void
(
*
close
)(
struct
input_s
tream
*
is
);
void
(
*
close
)(
InputS
tream
*
is
);
/**
* Check for errors that may have occurred in the I/O thread.
...
...
@@ -61,15 +61,15 @@ struct InputPlugin {
*
* @return false on error
*/
bool
(
*
check
)(
struct
input_s
tream
*
is
,
Error
&
error
);
bool
(
*
check
)(
InputS
tream
*
is
,
Error
&
error
);
/**
* Update the public attributes. Call before access. Can be
* nullptr if the plugin always keeps its attributes up to date.
*/
void
(
*
update
)(
struct
input_s
tream
*
is
);
void
(
*
update
)(
InputS
tream
*
is
);
Tag
*
(
*
tag
)(
struct
input_s
tream
*
is
);
Tag
*
(
*
tag
)(
InputS
tream
*
is
);
/**
* Returns true if the next read operation will not block:
...
...
@@ -79,12 +79,12 @@ struct InputPlugin {
* If this method is unimplemented, then it is assumed that
* reading will never block.
*/
bool
(
*
available
)(
struct
input_s
tream
*
is
);
bool
(
*
available
)(
InputS
tream
*
is
);
size_t
(
*
read
)(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
size_t
(
*
read
)(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
);
bool
(
*
eof
)(
struct
input_s
tream
*
is
);
bool
(
*
seek
)(
struct
input_s
tream
*
is
,
offset_type
offset
,
int
whence
,
bool
(
*
eof
)(
InputS
tream
*
is
);
bool
(
*
seek
)(
InputS
tream
*
is
,
offset_type
offset
,
int
whence
,
Error
&
error
);
};
...
...
src/InputStream.cxx
View file @
93deb844
...
...
@@ -31,13 +31,13 @@
static
constexpr
Domain
input_domain
(
"input"
);
struct
input_s
tream
*
input_s
tream
::
Open
(
const
char
*
url
,
InputS
tream
*
InputS
tream
::
Open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
{
input_plugins_for_each_enabled
(
plugin
)
{
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
is
=
plugin
->
open
(
url
,
mutex
,
cond
,
error
);
if
(
is
!=
nullptr
)
{
...
...
@@ -58,20 +58,20 @@ input_stream::Open(const char *url,
}
bool
input_s
tream
::
Check
(
Error
&
error
)
InputS
tream
::
Check
(
Error
&
error
)
{
return
plugin
.
check
==
nullptr
||
plugin
.
check
(
this
,
error
);
}
void
input_s
tream
::
Update
()
InputS
tream
::
Update
()
{
if
(
plugin
.
update
!=
nullptr
)
plugin
.
update
(
this
);
}
void
input_s
tream
::
WaitReady
()
InputS
tream
::
WaitReady
()
{
while
(
true
)
{
Update
();
...
...
@@ -83,20 +83,20 @@ input_stream::WaitReady()
}
void
input_s
tream
::
LockWaitReady
()
InputS
tream
::
LockWaitReady
()
{
const
ScopeLock
protect
(
mutex
);
WaitReady
();
}
bool
input_s
tream
::
CheapSeeking
()
const
InputS
tream
::
CheapSeeking
()
const
{
return
IsSeekable
()
&&
!
uri_has_scheme
(
uri
.
c_str
());
}
bool
input_s
tream
::
Seek
(
offset_type
_offset
,
int
whence
,
Error
&
error
)
InputS
tream
::
Seek
(
offset_type
_offset
,
int
whence
,
Error
&
error
)
{
if
(
plugin
.
seek
==
nullptr
)
return
false
;
...
...
@@ -105,7 +105,7 @@ input_stream::Seek(offset_type _offset, int whence, Error &error)
}
bool
input_s
tream
::
LockSeek
(
offset_type
_offset
,
int
whence
,
Error
&
error
)
InputS
tream
::
LockSeek
(
offset_type
_offset
,
int
whence
,
Error
&
error
)
{
if
(
plugin
.
seek
==
nullptr
)
return
false
;
...
...
@@ -115,19 +115,19 @@ input_stream::LockSeek(offset_type _offset, int whence, Error &error)
}
bool
input_s
tream
::
Rewind
(
Error
&
error
)
InputS
tream
::
Rewind
(
Error
&
error
)
{
return
Seek
(
0
,
SEEK_SET
,
error
);
}
bool
input_s
tream
::
LockRewind
(
Error
&
error
)
InputS
tream
::
LockRewind
(
Error
&
error
)
{
return
LockSeek
(
0
,
SEEK_SET
,
error
);
}
Tag
*
input_s
tream
::
ReadTag
()
InputS
tream
::
ReadTag
()
{
return
plugin
.
tag
!=
nullptr
?
plugin
.
tag
(
this
)
...
...
@@ -135,7 +135,7 @@ input_stream::ReadTag()
}
Tag
*
input_s
tream
::
LockReadTag
()
InputS
tream
::
LockReadTag
()
{
if
(
plugin
.
tag
==
nullptr
)
return
nullptr
;
...
...
@@ -145,7 +145,7 @@ input_stream::LockReadTag()
}
bool
input_s
tream
::
IsAvailable
()
InputS
tream
::
IsAvailable
()
{
return
plugin
.
available
!=
nullptr
?
plugin
.
available
(
this
)
...
...
@@ -153,7 +153,7 @@ input_stream::IsAvailable()
}
size_t
input_s
tream
::
Read
(
void
*
ptr
,
size_t
_size
,
Error
&
error
)
InputS
tream
::
Read
(
void
*
ptr
,
size_t
_size
,
Error
&
error
)
{
assert
(
ptr
!=
nullptr
);
assert
(
_size
>
0
);
...
...
@@ -162,7 +162,7 @@ input_stream::Read(void *ptr, size_t _size, Error &error)
}
size_t
input_s
tream
::
LockRead
(
void
*
ptr
,
size_t
_size
,
Error
&
error
)
InputS
tream
::
LockRead
(
void
*
ptr
,
size_t
_size
,
Error
&
error
)
{
assert
(
ptr
!=
nullptr
);
assert
(
_size
>
0
);
...
...
@@ -172,19 +172,19 @@ input_stream::LockRead(void *ptr, size_t _size, Error &error)
}
void
input_s
tream
::
Close
()
InputS
tream
::
Close
()
{
plugin
.
close
(
this
);
}
bool
input_s
tream
::
IsEOF
()
InputS
tream
::
IsEOF
()
{
return
plugin
.
eof
(
this
);
}
bool
input_s
tream
::
LockIsEOF
()
InputS
tream
::
LockIsEOF
()
{
const
ScopeLock
protect
(
mutex
);
return
IsEOF
();
...
...
src/InputStream.hxx
View file @
93deb844
...
...
@@ -34,7 +34,7 @@ class Error;
struct
Tag
;
struct
InputPlugin
;
struct
input_s
tream
{
struct
InputS
tream
{
typedef
int64_t
offset_type
;
/**
...
...
@@ -93,7 +93,7 @@ struct input_stream {
*/
std
::
string
mime
;
input_s
tream
(
const
InputPlugin
&
_plugin
,
InputS
tream
(
const
InputPlugin
&
_plugin
,
const
char
*
_uri
,
Mutex
&
_mutex
,
Cond
&
_cond
)
:
plugin
(
_plugin
),
uri
(
_uri
),
mutex
(
_mutex
),
cond
(
_cond
),
...
...
@@ -111,11 +111,11 @@ struct input_stream {
* @param cond a cond that gets signalled when the state of
* this object changes; may be nullptr if the caller doesn't want to get
* notifications
* @return an #
input_s
tream object on success, nullptr on error
* @return an #
InputS
tream object on success, nullptr on error
*/
gcc_nonnull_all
gcc_malloc
static
input_s
tream
*
Open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
static
InputS
tream
*
Open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
);
/**
...
...
@@ -273,7 +273,7 @@ struct input_stream {
*
* The caller must lock the mutex.
*
* @param is the
input_s
tream object
* @param is the
InputS
tream object
* @param ptr the buffer to read into
* @param size the maximum number of bytes to read
* @return the number of bytes read
...
...
src/PlaylistAny.cxx
View file @
93deb844
...
...
@@ -31,7 +31,7 @@
static
SongEnumerator
*
playlist_open_remote
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
assert
(
uri_has_scheme
(
uri
));
...
...
@@ -42,7 +42,7 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
}
Error
error
;
input_stream
*
is
=
input_s
tream
::
Open
(
uri
,
mutex
,
cond
,
error
);
InputStream
*
is
=
InputS
tream
::
Open
(
uri
,
mutex
,
cond
,
error
);
if
(
is
==
nullptr
)
{
if
(
error
.
IsDefined
())
FormatError
(
error
,
"Failed to open %s"
,
uri
);
...
...
@@ -50,7 +50,7 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
return
nullptr
;
}
playlist
=
playlist_list_open_stream
(
is
,
uri
);
playlist
=
playlist_list_open_stream
(
*
is
,
uri
);
if
(
playlist
==
nullptr
)
{
is
->
Close
();
return
nullptr
;
...
...
@@ -62,7 +62,7 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
SongEnumerator
*
playlist_open_any
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
return
uri_has_scheme
(
uri
)
?
playlist_open_remote
(
uri
,
mutex
,
cond
,
is_r
)
...
...
src/PlaylistAny.hxx
View file @
93deb844
...
...
@@ -23,7 +23,7 @@
class
Mutex
;
class
Cond
;
class
SongEnumerator
;
struct
input_s
tream
;
struct
InputS
tream
;
/**
* Opens a playlist from the specified URI, which can be either an
...
...
@@ -36,6 +36,6 @@ struct input_stream;
*/
SongEnumerator
*
playlist_open_any
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
);
InputS
tream
**
is_r
);
#endif
src/PlaylistMapper.cxx
View file @
93deb844
...
...
@@ -29,7 +29,7 @@
static
SongEnumerator
*
playlist_open_path
(
const
char
*
path_fs
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
auto
playlist
=
playlist_list_open_uri
(
path_fs
,
mutex
,
cond
);
if
(
playlist
!=
nullptr
)
...
...
@@ -45,7 +45,7 @@ playlist_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
*/
static
SongEnumerator
*
playlist_open_in_playlist_dir
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
assert
(
spl_valid_name
(
uri
));
...
...
@@ -69,7 +69,7 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond,
*/
static
SongEnumerator
*
playlist_open_in_music_dir
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
assert
(
uri_safe_local
(
uri
));
...
...
@@ -82,7 +82,7 @@ playlist_open_in_music_dir(const char *uri, Mutex &mutex, Cond &cond,
SongEnumerator
*
playlist_mapper_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
if
(
spl_valid_name
(
uri
))
{
auto
playlist
=
playlist_open_in_playlist_dir
(
uri
,
mutex
,
cond
,
...
...
src/PlaylistMapper.hxx
View file @
93deb844
...
...
@@ -23,7 +23,7 @@
class
Mutex
;
class
Cond
;
class
SongEnumerator
;
struct
input_s
tream
;
struct
InputS
tream
;
/**
* Opens a playlist from an URI relative to the playlist or music
...
...
@@ -35,6 +35,6 @@ struct input_stream;
*/
SongEnumerator
*
playlist_mapper_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
);
InputS
tream
**
is_r
);
#endif
src/PlaylistPlugin.hxx
View file @
93deb844
...
...
@@ -21,7 +21,7 @@
#define MPD_PLAYLIST_PLUGIN_HXX
struct
config_param
;
struct
input_s
tream
;
struct
InputS
tream
;
struct
Tag
;
class
Mutex
;
class
Cond
;
...
...
@@ -58,7 +58,7 @@ struct playlist_plugin {
* either matched one of the suffixes or one of the MIME
* types.
*/
SongEnumerator
*
(
*
open_stream
)(
struct
input_stream
*
is
);
SongEnumerator
*
(
*
open_stream
)(
InputStream
&
is
);
const
char
*
const
*
schemes
;
const
char
*
const
*
suffixes
;
...
...
@@ -101,7 +101,7 @@ playlist_plugin_open_uri(const struct playlist_plugin *plugin, const char *uri,
static
inline
SongEnumerator
*
playlist_plugin_open_stream
(
const
struct
playlist_plugin
*
plugin
,
struct
input_stream
*
is
)
InputStream
&
is
)
{
return
plugin
->
open_stream
(
is
);
}
...
...
src/PlaylistPrint.cxx
View file @
93deb844
...
...
@@ -175,7 +175,7 @@ playlist_file_print(Client &client, const char *uri, bool detail)
Mutex
mutex
;
Cond
cond
;
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
SongEnumerator
*
playlist
=
playlist_open_any
(
uri
,
mutex
,
cond
,
&
is
);
if
(
playlist
==
nullptr
)
return
false
;
...
...
src/PlaylistQueue.cxx
View file @
93deb844
...
...
@@ -72,7 +72,7 @@ playlist_open_into_queue(const char *uri,
Mutex
mutex
;
Cond
cond
;
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
auto
playlist
=
playlist_open_any
(
uri
,
mutex
,
cond
,
&
is
);
if
(
playlist
==
nullptr
)
return
PlaylistResult
::
NO_SUCH_LIST
;
...
...
src/PlaylistRegistry.cxx
View file @
93deb844
...
...
@@ -209,9 +209,8 @@ playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond)
}
static
SongEnumerator
*
playlist_list_open_stream_mime2
(
struct
input_stream
*
is
,
const
char
*
mime
)
playlist_list_open_stream_mime2
(
InputStream
&
is
,
const
char
*
mime
)
{
assert
(
is
!=
nullptr
);
assert
(
mime
!=
nullptr
);
playlist_plugins_for_each_enabled
(
plugin
)
{
...
...
@@ -220,9 +219,10 @@ playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
string_array_contains
(
plugin
->
mime_types
,
mime
))
{
/* rewind the stream, so each plugin gets a
fresh start */
is
->
Rewind
(
IgnoreError
());
is
.
Rewind
(
IgnoreError
());
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
if
(
playlist
!=
nullptr
)
return
playlist
;
}
...
...
@@ -232,7 +232,7 @@ playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
}
static
SongEnumerator
*
playlist_list_open_stream_mime
(
struct
input_stream
*
is
,
const
char
*
full_mime
)
playlist_list_open_stream_mime
(
InputStream
&
is
,
const
char
*
full_mime
)
{
assert
(
full_mime
!=
nullptr
);
...
...
@@ -249,9 +249,8 @@ playlist_list_open_stream_mime(struct input_stream *is, const char *full_mime)
}
static
SongEnumerator
*
playlist_list_open_stream_suffix
(
struct
input_stream
*
is
,
const
char
*
suffix
)
playlist_list_open_stream_suffix
(
InputStream
&
is
,
const
char
*
suffix
)
{
assert
(
is
!=
nullptr
);
assert
(
suffix
!=
nullptr
);
playlist_plugins_for_each_enabled
(
plugin
)
{
...
...
@@ -260,7 +259,7 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
string_array_contains
(
plugin
->
suffixes
,
suffix
))
{
/* rewind the stream, so each plugin gets a
fresh start */
is
->
Rewind
(
IgnoreError
());
is
.
Rewind
(
IgnoreError
());
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
if
(
playlist
!=
nullptr
)
...
...
@@ -272,13 +271,13 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
}
SongEnumerator
*
playlist_list_open_stream
(
struct
input_stream
*
is
,
const
char
*
uri
)
playlist_list_open_stream
(
InputStream
&
is
,
const
char
*
uri
)
{
const
char
*
suffix
;
is
->
LockWaitReady
();
is
.
LockWaitReady
();
const
char
*
const
mime
=
is
->
GetMimeType
();
const
char
*
const
mime
=
is
.
GetMimeType
();
if
(
mime
!=
nullptr
)
{
auto
playlist
=
playlist_list_open_stream_mime
(
is
,
mime
);
if
(
playlist
!=
nullptr
)
...
...
@@ -311,7 +310,7 @@ playlist_suffix_supported(const char *suffix)
SongEnumerator
*
playlist_list_open_path
(
const
char
*
path_fs
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
)
InputS
tream
**
is_r
)
{
const
char
*
suffix
;
...
...
@@ -322,7 +321,7 @@ playlist_list_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
return
nullptr
;
Error
error
;
input_stream
*
is
=
input_s
tream
::
Open
(
path_fs
,
mutex
,
cond
,
error
);
InputStream
*
is
=
InputS
tream
::
Open
(
path_fs
,
mutex
,
cond
,
error
);
if
(
is
==
nullptr
)
{
if
(
error
.
IsDefined
())
LogError
(
error
);
...
...
@@ -332,7 +331,7 @@ playlist_list_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
is
->
LockWaitReady
();
auto
playlist
=
playlist_list_open_stream_suffix
(
is
,
suffix
);
auto
playlist
=
playlist_list_open_stream_suffix
(
*
is
,
suffix
);
if
(
playlist
!=
nullptr
)
*
is_r
=
is
;
else
...
...
src/PlaylistRegistry.hxx
View file @
93deb844
...
...
@@ -23,7 +23,7 @@
class
Mutex
;
class
Cond
;
class
SongEnumerator
;
struct
input_s
tream
;
struct
InputS
tream
;
extern
const
struct
playlist_plugin
*
const
playlist_plugins
[];
...
...
@@ -59,7 +59,7 @@ playlist_list_open_uri(const char *uri, Mutex &mutex, Cond &cond);
* used to select the appropriate playlist plugin
*/
SongEnumerator
*
playlist_list_open_stream
(
struct
input_stream
*
is
,
const
char
*
uri
);
playlist_list_open_stream
(
InputStream
&
is
,
const
char
*
uri
);
/**
* Determines if there is a playlist plugin which can handle the
...
...
@@ -78,6 +78,6 @@ playlist_suffix_supported(const char *suffix);
*/
SongEnumerator
*
playlist_list_open_path
(
const
char
*
path_fs
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
input_s
tream
**
is_r
);
InputS
tream
**
is_r
);
#endif
src/TagFile.cxx
View file @
93deb844
...
...
@@ -46,7 +46,7 @@ tag_file_scan(const char *path_fs,
if
(
plugin
==
nullptr
)
return
false
;
struct
input_s
tream
*
is
=
nullptr
;
InputS
tream
*
is
=
nullptr
;
Mutex
mutex
;
Cond
cond
;
...
...
@@ -58,10 +58,10 @@ tag_file_scan(const char *path_fs,
/* fall back to stream tag */
if
(
plugin
->
scan_stream
!=
nullptr
)
{
/* open the
input_s
tream (if not already
/* open the
InputS
tream (if not already
open) */
if
(
is
==
nullptr
)
is
=
input_s
tream
::
Open
(
path_fs
,
mutex
,
cond
,
is
=
InputS
tream
::
Open
(
path_fs
,
mutex
,
cond
,
IgnoreError
());
/* now try the stream_tag() method */
...
...
src/TextInputStream.cxx
View file @
93deb844
...
...
@@ -42,7 +42,7 @@ bool TextInputStream::ReadLine(std::string &line)
--
dest
.
size
;
Error
error
;
nbytes
=
is
->
LockRead
(
dest
.
data
,
dest
.
size
,
error
);
nbytes
=
is
.
LockRead
(
dest
.
data
,
dest
.
size
,
error
);
if
(
nbytes
>
0
)
buffer
.
Append
(
nbytes
);
else
if
(
error
.
IsDefined
())
{
...
...
src/TextInputStream.hxx
View file @
93deb844
...
...
@@ -24,11 +24,11 @@
#include <string>
struct
input_s
tream
;
struct
InputS
tream
;
struct
fifo_buffer
;
class
TextInputStream
{
struct
input_stream
*
is
;
InputStream
&
is
;
FifoBuffer
<
char
,
4096
>
buffer
;
public
:
...
...
@@ -38,7 +38,7 @@ public:
*
* @param _is an open #input_stream object
*/
explicit
TextInputStream
(
struct
input_stream
*
_is
)
explicit
TextInputStream
(
InputStream
&
_is
)
:
is
(
_is
)
{}
TextInputStream
(
const
TextInputStream
&
)
=
delete
;
...
...
src/archive/Bzip2ArchivePlugin.cxx
View file @
93deb844
...
...
@@ -49,9 +49,9 @@ public:
RefCount
ref
;
std
::
string
name
;
struct
input_s
tream
*
const
istream
;
InputS
tream
*
const
istream
;
Bzip2ArchiveFile
(
const
char
*
path
,
input_s
tream
*
_is
)
Bzip2ArchiveFile
(
const
char
*
path
,
InputS
tream
*
_is
)
:
ArchiveFile
(
bz2_archive_plugin
),
name
(
PathTraits
::
GetBaseUTF8
(
path
)),
istream
(
_is
)
{
...
...
@@ -84,13 +84,13 @@ public:
visitor
.
VisitArchiveEntry
(
name
.
c_str
());
}
virtual
input_s
tream
*
OpenStream
(
const
char
*
path
,
virtual
InputS
tream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
override
;
};
struct
Bzip2InputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
Bzip2ArchiveFile
*
archive
;
...
...
@@ -148,7 +148,7 @@ bz2_open(const char *pathname, Error &error)
{
static
Mutex
mutex
;
static
Cond
cond
;
input_stream
*
is
=
input_s
tream
::
Open
(
pathname
,
mutex
,
cond
,
error
);
InputStream
*
is
=
InputS
tream
::
Open
(
pathname
,
mutex
,
cond
,
error
);
if
(
is
==
nullptr
)
return
nullptr
;
...
...
@@ -170,7 +170,7 @@ Bzip2InputStream::~Bzip2InputStream()
archive
->
Unref
();
}
input_s
tream
*
InputS
tream
*
Bzip2ArchiveFile
::
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -185,7 +185,7 @@ Bzip2ArchiveFile::OpenStream(const char *path,
}
static
void
bz2_is_close
(
struct
input_s
tream
*
is
)
bz2_is_close
(
InputS
tream
*
is
)
{
Bzip2InputStream
*
bis
=
(
Bzip2InputStream
*
)
is
;
...
...
@@ -215,7 +215,7 @@ bz2_fillbuffer(Bzip2InputStream *bis, Error &error)
}
static
size_t
bz2_is_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
length
,
bz2_is_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
length
,
Error
&
error
)
{
Bzip2InputStream
*
bis
=
(
Bzip2InputStream
*
)
is
;
...
...
@@ -255,7 +255,7 @@ bz2_is_read(struct input_stream *is, void *ptr, size_t length,
}
static
bool
bz2_is_eof
(
struct
input_s
tream
*
is
)
bz2_is_eof
(
InputS
tream
*
is
)
{
Bzip2InputStream
*
bis
=
(
Bzip2InputStream
*
)
is
;
...
...
src/archive/Iso9660ArchivePlugin.cxx
View file @
93deb844
...
...
@@ -66,7 +66,7 @@ public:
virtual
void
Visit
(
ArchiveVisitor
&
visitor
)
override
;
virtual
input_s
tream
*
OpenStream
(
const
char
*
path
,
virtual
InputS
tream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
override
;
};
...
...
@@ -132,7 +132,7 @@ Iso9660ArchiveFile::Visit(ArchiveVisitor &visitor)
/* single archive handling */
struct
Iso9660InputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
Iso9660ArchiveFile
*
archive
;
...
...
@@ -158,7 +158,7 @@ struct Iso9660InputStream {
}
};
input_s
tream
*
InputS
tream
*
Iso9660ArchiveFile
::
OpenStream
(
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -177,7 +177,7 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
}
static
void
iso9660_input_close
(
struct
input_s
tream
*
is
)
iso9660_input_close
(
InputS
tream
*
is
)
{
Iso9660InputStream
*
iis
=
(
Iso9660InputStream
*
)
is
;
...
...
@@ -186,7 +186,7 @@ iso9660_input_close(struct input_stream *is)
static
size_t
iso9660_input_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
iso9660_input_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
Iso9660InputStream
*
iis
=
(
Iso9660InputStream
*
)
is
;
...
...
@@ -226,7 +226,7 @@ iso9660_input_read(struct input_stream *is, void *ptr, size_t size,
}
static
bool
iso9660_input_eof
(
struct
input_s
tream
*
is
)
iso9660_input_eof
(
InputS
tream
*
is
)
{
return
is
->
offset
==
is
->
size
;
}
...
...
src/archive/ZzipArchivePlugin.cxx
View file @
93deb844
...
...
@@ -60,7 +60,7 @@ public:
virtual
void
Visit
(
ArchiveVisitor
&
visitor
)
override
;
virtual
input_s
tream
*
OpenStream
(
const
char
*
path
,
virtual
InputS
tream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
override
;
};
...
...
@@ -99,7 +99,7 @@ ZzipArchiveFile::Visit(ArchiveVisitor &visitor)
/* single archive handling */
struct
ZzipInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
ZzipArchiveFile
*
archive
;
...
...
@@ -127,7 +127,7 @@ struct ZzipInputStream {
}
};
input_s
tream
*
InputS
tream
*
ZzipArchiveFile
::
OpenStream
(
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -147,7 +147,7 @@ ZzipArchiveFile::OpenStream(const char *pathname,
}
static
void
zzip_input_close
(
struct
input_s
tream
*
is
)
zzip_input_close
(
InputS
tream
*
is
)
{
ZzipInputStream
*
zis
=
(
ZzipInputStream
*
)
is
;
...
...
@@ -155,7 +155,7 @@ zzip_input_close(struct input_stream *is)
}
static
size_t
zzip_input_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
zzip_input_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
ZzipInputStream
*
zis
=
(
ZzipInputStream
*
)
is
;
...
...
@@ -173,7 +173,7 @@ zzip_input_read(struct input_stream *is, void *ptr, size_t size,
}
static
bool
zzip_input_eof
(
struct
input_s
tream
*
is
)
zzip_input_eof
(
InputS
tream
*
is
)
{
ZzipInputStream
*
zis
=
(
ZzipInputStream
*
)
is
;
...
...
@@ -181,7 +181,7 @@ zzip_input_eof(struct input_stream *is)
}
static
bool
zzip_input_seek
(
struct
input_s
tream
*
is
,
InputPlugin
::
offset_type
offset
,
zzip_input_seek
(
InputS
tream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
ZzipInputStream
*
zis
=
(
ZzipInputStream
*
)
is
;
...
...
src/decoder/AudiofileDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -54,10 +54,10 @@ static int audiofile_get_duration(const char *file)
static
ssize_t
audiofile_file_read
(
AFvirtualfile
*
vfile
,
void
*
data
,
size_t
length
)
{
struct
input_stream
*
is
=
(
struct
input_stream
*
)
vfile
->
closure
;
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
Error
error
;
size_t
nbytes
=
is
->
LockRead
(
data
,
length
,
error
);
size_t
nbytes
=
is
.
LockRead
(
data
,
length
,
error
);
if
(
nbytes
==
0
&&
error
.
IsDefined
())
{
LogError
(
error
);
return
-
1
;
...
...
@@ -69,15 +69,15 @@ audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length)
static
AFfileoffset
audiofile_file_length
(
AFvirtualfile
*
vfile
)
{
struct
input_stream
*
is
=
(
struct
input_stream
*
)
vfile
->
closure
;
return
is
->
GetSize
();
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
return
is
.
GetSize
();
}
static
AFfileoffset
audiofile_file_tell
(
AFvirtualfile
*
vfile
)
{
struct
input_stream
*
is
=
(
struct
input_stream
*
)
vfile
->
closure
;
return
is
->
GetOffset
();
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
return
is
.
GetOffset
();
}
static
void
...
...
@@ -91,22 +91,22 @@ audiofile_file_destroy(AFvirtualfile *vfile)
static
AFfileoffset
audiofile_file_seek
(
AFvirtualfile
*
vfile
,
AFfileoffset
offset
,
int
is_relative
)
{
struct
input_stream
*
is
=
(
struct
input_stream
*
)
vfile
->
closure
;
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
int
whence
=
(
is_relative
?
SEEK_CUR
:
SEEK_SET
);
Error
error
;
if
(
is
->
LockSeek
(
offset
,
whence
,
error
))
{
return
is
->
GetOffset
();
if
(
is
.
LockSeek
(
offset
,
whence
,
error
))
{
return
is
.
GetOffset
();
}
else
{
return
-
1
;
}
}
static
AFvirtualfile
*
setup_virtual_fops
(
struct
input_stream
*
stream
)
setup_virtual_fops
(
InputStream
&
stream
)
{
AFvirtualfile
*
vf
=
new
AFvirtualfile
();
vf
->
closure
=
stream
;
vf
->
closure
=
&
stream
;
vf
->
write
=
nullptr
;
vf
->
read
=
audiofile_file_read
;
vf
->
length
=
audiofile_file_length
;
...
...
@@ -157,7 +157,7 @@ audiofile_setup_sample_format(AFfilehandle af_fp)
}
static
void
audiofile_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
audiofile_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
AFvirtualfile
*
vf
;
int
fs
,
frame_count
;
...
...
@@ -168,7 +168,7 @@ audiofile_stream_decode(Decoder &decoder, struct input_stream *is)
int
ret
;
char
chunk
[
CHUNK_SIZE
];
if
(
!
is
->
IsSeekable
())
{
if
(
!
is
.
IsSeekable
())
{
LogWarning
(
audiofile_domain
,
"not seekable"
);
return
;
}
...
...
@@ -196,7 +196,7 @@ audiofile_stream_decode(Decoder &decoder, struct input_stream *is)
total_time
=
((
float
)
frame_count
/
(
float
)
audio_format
.
sample_rate
);
bit_rate
=
(
uint16_t
)(
is
->
GetSize
()
*
8.0
/
total_time
/
1000.0
+
0.5
);
bit_rate
=
(
uint16_t
)(
is
.
GetSize
()
*
8.0
/
total_time
/
1000.0
+
0.5
);
fs
=
(
int
)
afGetVirtualFrameSize
(
af_fp
,
AF_DEFAULT_TRACK
,
1
);
...
...
src/decoder/DsdLib.cxx
View file @
93deb844
...
...
@@ -51,7 +51,7 @@ dsdlib_id_equals(const struct dsdlib_id *id, const char *s)
}
bool
dsdlib_read
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdlib_read
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
data
,
size_t
length
)
{
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
data
,
length
);
...
...
@@ -62,27 +62,27 @@ dsdlib_read(Decoder *decoder, struct input_stream *is,
* Skip the #input_stream to the specified offset.
*/
bool
dsdlib_skip_to
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
int64_t
offset
)
{
if
(
is
->
IsSeekable
())
return
is
->
Seek
(
offset
,
SEEK_SET
,
IgnoreError
());
if
(
is
.
IsSeekable
())
return
is
.
Seek
(
offset
,
SEEK_SET
,
IgnoreError
());
if
(
is
->
GetOffset
()
>
offset
)
if
(
is
.
GetOffset
()
>
offset
)
return
false
;
char
buffer
[
8192
];
while
(
is
->
GetOffset
()
<
offset
)
{
while
(
is
.
GetOffset
()
<
offset
)
{
size_t
length
=
sizeof
(
buffer
);
if
(
offset
-
is
->
GetOffset
()
<
(
int64_t
)
length
)
length
=
offset
-
is
->
GetOffset
();
if
(
offset
-
is
.
GetOffset
()
<
(
int64_t
)
length
)
length
=
offset
-
is
.
GetOffset
();
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
length
);
if
(
nbytes
==
0
)
return
false
;
}
assert
(
is
->
GetOffset
()
==
offset
);
assert
(
is
.
GetOffset
()
==
offset
);
return
true
;
}
...
...
@@ -90,7 +90,7 @@ dsdlib_skip_to(Decoder *decoder, struct input_stream *is,
* Skip some bytes from the #input_stream.
*/
bool
dsdlib_skip
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
int64_t
delta
)
{
assert
(
delta
>=
0
);
...
...
@@ -98,8 +98,8 @@ dsdlib_skip(Decoder *decoder, struct input_stream *is,
if
(
delta
==
0
)
return
true
;
if
(
is
->
IsSeekable
())
return
is
->
Seek
(
delta
,
SEEK_CUR
,
IgnoreError
());
if
(
is
.
IsSeekable
())
return
is
.
Seek
(
delta
,
SEEK_CUR
,
IgnoreError
());
char
buffer
[
8192
];
while
(
delta
>
0
)
{
...
...
@@ -124,7 +124,7 @@ dsdlib_skip(Decoder *decoder, struct input_stream *is,
#ifdef HAVE_ID3TAG
void
dsdlib_tag_id3
(
struct
input_stream
*
is
,
dsdlib_tag_id3
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
,
int64_t
tagoffset
)
{
...
...
@@ -140,8 +140,8 @@ dsdlib_tag_id3(struct input_stream *is,
id3_length_t
count
;
/* Prevent broken files causing problems */
const
auto
size
=
is
->
GetSize
();
const
auto
offset
=
is
->
GetOffset
();
const
auto
size
=
is
.
GetSize
();
const
auto
offset
=
is
.
GetOffset
();
if
(
offset
>=
size
)
return
;
...
...
src/decoder/DsdLib.hxx
View file @
93deb844
...
...
@@ -24,6 +24,7 @@
#include <stdint.h>
struct
Decoder
;
struct
InputStream
;
struct
dsdlib_id
{
char
value
[
4
];
...
...
@@ -33,19 +34,19 @@ bool
dsdlib_id_equals
(
const
struct
dsdlib_id
*
id
,
const
char
*
s
);
bool
dsdlib_read
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdlib_read
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
data
,
size_t
length
);
bool
dsdlib_skip_to
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
int64_t
offset
);
bool
dsdlib_skip
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
int64_t
delta
);
void
dsdlib_tag_id3
(
struct
input_stream
*
is
,
dsdlib_tag_id3
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
,
int64_t
tagoffset
);
...
...
src/decoder/DsdiffDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -72,13 +72,13 @@ struct DsdiffMetaData {
bool
bitreverse
;
uint64_t
chunk_size
;
#ifdef HAVE_ID3TAG
input_s
tream
::
offset_type
id3_offset
;
InputS
tream
::
offset_type
id3_offset
;
uint64_t
id3_size
;
#endif
/** offset for artist tag */
input_s
tream
::
offset_type
diar_offset
;
InputS
tream
::
offset_type
diar_offset
;
/** offset for title tag */
input_s
tream
::
offset_type
diti_offset
;
InputS
tream
::
offset_type
diti_offset
;
};
static
bool
lsbitfirst
;
...
...
@@ -91,21 +91,21 @@ dsdiff_init(const config_param ¶m)
}
static
bool
dsdiff_read_id
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_id
(
Decoder
*
decoder
,
InputStream
&
is
,
struct
dsdlib_id
*
id
)
{
return
dsdlib_read
(
decoder
,
is
,
id
,
sizeof
(
*
id
));
}
static
bool
dsdiff_read_chunk_header
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_chunk_header
(
Decoder
*
decoder
,
InputStream
&
is
,
DsdiffChunkHeader
*
header
)
{
return
dsdlib_read
(
decoder
,
is
,
header
,
sizeof
(
*
header
));
}
static
bool
dsdiff_read_payload
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_payload
(
Decoder
*
decoder
,
InputStream
&
is
,
const
DsdiffChunkHeader
*
header
,
void
*
data
,
size_t
length
)
{
...
...
@@ -121,16 +121,16 @@ dsdiff_read_payload(Decoder *decoder, struct input_stream *is,
* Read and parse a "SND" chunk inside "PROP".
*/
static
bool
dsdiff_read_prop_snd
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_prop_snd
(
Decoder
*
decoder
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
input_s
tream
::
offset_type
end_offset
)
InputS
tream
::
offset_type
end_offset
)
{
DsdiffChunkHeader
header
;
while
((
input_stream
::
offset_type
)(
is
->
GetOffset
()
+
sizeof
(
header
))
<=
end_offset
)
{
while
((
InputStream
::
offset_type
)(
is
.
GetOffset
()
+
sizeof
(
header
))
<=
end_offset
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
&
header
))
return
false
;
input_stream
::
offset_type
chunk_end_offset
=
is
->
GetOffset
()
InputStream
::
offset_type
chunk_end_offset
=
is
.
GetOffset
()
+
header
.
GetSize
();
if
(
chunk_end_offset
>
end_offset
)
return
false
;
...
...
@@ -172,19 +172,19 @@ dsdiff_read_prop_snd(Decoder *decoder, struct input_stream *is,
}
}
return
is
->
GetOffset
()
==
end_offset
;
return
is
.
GetOffset
()
==
end_offset
;
}
/**
* Read and parse a "PROP" chunk.
*/
static
bool
dsdiff_read_prop
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_prop
(
Decoder
*
decoder
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
const
DsdiffChunkHeader
*
prop_header
)
{
uint64_t
prop_size
=
prop_header
->
GetSize
();
input_stream
::
offset_type
end_offset
=
is
->
GetOffset
()
+
prop_size
;
InputStream
::
offset_type
end_offset
=
is
.
GetOffset
()
+
prop_size
;
struct
dsdlib_id
prop_id
;
if
(
prop_size
<
sizeof
(
prop_id
)
||
...
...
@@ -199,9 +199,9 @@ dsdiff_read_prop(Decoder *decoder, struct input_stream *is,
}
static
void
dsdiff_handle_native_tag
(
struct
input_stream
*
is
,
dsdiff_handle_native_tag
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
,
input_s
tream
::
offset_type
tagoffset
,
void
*
handler_ctx
,
InputS
tream
::
offset_type
tagoffset
,
TagType
type
)
{
if
(
!
dsdlib_skip_to
(
nullptr
,
is
,
tagoffset
))
...
...
@@ -239,7 +239,7 @@ dsdiff_handle_native_tag(struct input_stream *is,
*/
static
bool
dsdiff_read_metadata_extra
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_metadata_extra
(
Decoder
*
decoder
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
DsdiffChunkHeader
*
chunk_header
,
const
struct
tag_handler
*
handler
,
...
...
@@ -259,8 +259,8 @@ dsdiff_read_metadata_extra(Decoder *decoder, struct input_stream *is,
/* Now process all the remaining chunk headers in the stream
and record their position and size */
const
auto
size
=
is
->
GetSize
();
while
(
is
->
GetOffset
()
<
size
)
{
const
auto
size
=
is
.
GetSize
();
while
(
is
.
GetOffset
()
<
size
)
{
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
/* DIIN chunk, is directly followed by other chunks */
...
...
@@ -270,19 +270,19 @@ dsdiff_read_metadata_extra(Decoder *decoder, struct input_stream *is,
/* DIAR chunk - DSDIFF native tag for Artist */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DIAR"
))
{
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
diar_offset
=
is
->
GetOffset
();
metadata
->
diar_offset
=
is
.
GetOffset
();
}
/* DITI chunk - DSDIFF native tag for Title */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DITI"
))
{
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
diti_offset
=
is
->
GetOffset
();
metadata
->
diti_offset
=
is
.
GetOffset
();
}
#ifdef HAVE_ID3TAG
/* 'ID3 ' chunk, offspec. Used by sacdextract */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"ID3 "
))
{
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
id3_offset
=
is
->
GetOffset
();
metadata
->
id3_offset
=
is
.
GetOffset
();
metadata
->
id3_size
=
chunk_size
;
}
#endif
...
...
@@ -291,7 +291,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, struct input_stream *is,
break
;
}
if
(
is
->
GetOffset
()
<
size
)
{
if
(
is
.
GetOffset
()
<
size
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
chunk_header
))
return
false
;
}
...
...
@@ -325,7 +325,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, struct input_stream *is,
* "chunk_header" parameter.
*/
static
bool
dsdiff_read_metadata
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsdiff_read_metadata
(
Decoder
*
decoder
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
DsdiffChunkHeader
*
chunk_header
)
{
...
...
@@ -351,8 +351,8 @@ dsdiff_read_metadata(Decoder *decoder, struct input_stream *is,
}
else
{
/* ignore unknown chunk */
const
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
input_s
tream
::
offset_type
chunk_end_offset
=
is
->
GetOffset
()
+
chunk_size
;
InputS
tream
::
offset_type
chunk_end_offset
=
is
.
GetOffset
()
+
chunk_size
;
if
(
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
return
false
;
...
...
@@ -371,7 +371,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
* Decode one "DSD" chunk.
*/
static
bool
dsdiff_decode_chunk
(
Decoder
&
decoder
,
struct
input_stream
*
is
,
dsdiff_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
unsigned
channels
,
uint64_t
chunk_size
)
{
...
...
@@ -422,7 +422,7 @@ dsdiff_decode_chunk(Decoder &decoder, struct input_stream *is,
}
static
void
dsdiff_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
dsdiff_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
DsdiffMetaData
metadata
;
...
...
@@ -474,7 +474,7 @@ dsdiff_stream_decode(Decoder &decoder, struct input_stream *is)
}
static
bool
dsdiff_scan_stream
(
struct
input_stream
*
is
,
dsdiff_scan_stream
(
InputStream
&
is
,
gcc_unused
const
struct
tag_handler
*
handler
,
gcc_unused
void
*
handler_ctx
)
{
...
...
src/decoder/DsfDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -47,7 +47,7 @@ struct DsfMetaData {
bool
bitreverse
;
uint64_t
chunk_size
;
#ifdef HAVE_ID3TAG
input_s
tream
::
offset_type
id3_offset
;
InputS
tream
::
offset_type
id3_offset
;
uint64_t
id3_size
;
#endif
};
...
...
@@ -99,7 +99,7 @@ struct DsfDataChunk {
* Read and parse all needed metadata chunks for DSF files.
*/
static
bool
dsf_read_metadata
(
Decoder
*
decoder
,
struct
input_stream
*
is
,
dsf_read_metadata
(
Decoder
*
decoder
,
InputStream
&
is
,
DsfMetaData
*
metadata
)
{
uint64_t
chunk_size
;
...
...
@@ -165,7 +165,7 @@ dsf_read_metadata(Decoder *decoder, struct input_stream *is,
metadata
->
chunk_size
=
data_size
;
/* data_size cannot be bigger or equal to total file size */
const
uint64_t
size
=
(
uint64_t
)
is
->
GetSize
();
const
uint64_t
size
=
(
uint64_t
)
is
.
GetSize
();
if
(
data_size
>=
size
)
return
false
;
...
...
@@ -176,7 +176,7 @@ dsf_read_metadata(Decoder *decoder, struct input_stream *is,
if
(
metadata_offset
>=
size
)
metadata
->
id3_offset
=
0
;
else
metadata
->
id3_offset
=
(
input_s
tream
::
offset_type
)
metadata_offset
;
metadata
->
id3_offset
=
(
InputS
tream
::
offset_type
)
metadata_offset
;
#endif
/* check bits per sample format, determine if bitreverse is needed */
metadata
->
bitreverse
=
dsf_fmt_chunk
.
bitssample
==
1
;
...
...
@@ -219,7 +219,7 @@ dsf_to_pcm_order(uint8_t *dest, uint8_t *scratch, size_t nrbytes)
* Decode one complete DSF 'data' chunk i.e. a complete song
*/
static
bool
dsf_decode_chunk
(
Decoder
&
decoder
,
struct
input_stream
*
is
,
dsf_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
unsigned
channels
,
uint64_t
chunk_size
,
bool
bitreverse
)
...
...
@@ -277,7 +277,7 @@ dsf_decode_chunk(Decoder &decoder, struct input_stream *is,
}
static
void
dsf_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
dsf_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
/* check if it is a proper DSF file */
DsfMetaData
metadata
;
...
...
@@ -307,7 +307,7 @@ dsf_stream_decode(Decoder &decoder, struct input_stream *is)
}
static
bool
dsf_scan_stream
(
struct
input_stream
*
is
,
dsf_scan_stream
(
InputStream
&
is
,
gcc_unused
const
struct
tag_handler
*
handler
,
gcc_unused
void
*
handler_ctx
)
{
...
...
src/decoder/FaadDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -163,14 +163,14 @@ adts_song_duration(DecoderBuffer *buffer)
}
static
float
faad_song_duration
(
DecoderBuffer
*
buffer
,
struct
input_stream
*
is
)
faad_song_duration
(
DecoderBuffer
*
buffer
,
InputStream
&
is
)
{
size_t
fileread
;
size_t
tagsize
;
size_t
length
;
bool
success
;
const
auto
size
=
is
->
GetSize
();
const
auto
size
=
is
.
GetSize
();
fileread
=
size
>=
0
?
size
:
0
;
decoder_buffer_fill
(
buffer
);
...
...
@@ -198,12 +198,12 @@ faad_song_duration(DecoderBuffer *buffer, struct input_stream *is)
return
-
1
;
}
if
(
is
->
IsSeekable
()
&&
length
>=
2
&&
if
(
is
.
IsSeekable
()
&&
length
>=
2
&&
data
[
0
]
==
0xFF
&&
((
data
[
1
]
&
0xF6
)
==
0xF0
))
{
/* obtain the duration from the ADTS header */
float
song_length
=
adts_song_duration
(
buffer
);
is
->
LockSeek
(
tagsize
,
SEEK_SET
,
IgnoreError
());
is
.
LockSeek
(
tagsize
,
SEEK_SET
,
IgnoreError
());
data
=
(
const
uint8_t
*
)
decoder_buffer_read
(
buffer
,
&
length
);
if
(
data
!=
nullptr
)
...
...
@@ -304,7 +304,7 @@ faad_decoder_decode(NeAACDecHandle decoder, DecoderBuffer *buffer,
* file is invalid.
*/
static
float
faad_get_file_time_float
(
struct
input_stream
*
is
)
faad_get_file_time_float
(
InputStream
&
is
)
{
DecoderBuffer
*
buffer
;
float
length
;
...
...
@@ -345,7 +345,7 @@ faad_get_file_time_float(struct input_stream *is)
* file is invalid.
*/
static
int
faad_get_file_time
(
struct
input_stream
*
is
)
faad_get_file_time
(
InputStream
&
is
)
{
int
file_time
=
-
1
;
float
length
;
...
...
@@ -357,7 +357,7 @@ faad_get_file_time(struct input_stream *is)
}
static
void
faad_stream_decode
(
Decoder
&
mpd_decoder
,
struct
input_stream
*
is
)
faad_stream_decode
(
Decoder
&
mpd_decoder
,
InputStream
&
is
)
{
float
total_time
=
0
;
AudioFormat
audio_format
;
...
...
@@ -380,7 +380,7 @@ faad_stream_decode(Decoder &mpd_decoder, struct input_stream *is)
config
->
dontUpSampleImplicitSBR
=
0
;
NeAACDecSetConfiguration
(
decoder
,
config
);
while
(
!
decoder_buffer_is_full
(
buffer
)
&&
!
is
->
LockIsEOF
()
&&
while
(
!
decoder_buffer_is_full
(
buffer
)
&&
!
is
.
LockIsEOF
()
&&
decoder_get_command
(
mpd_decoder
)
==
DecoderCommand
::
NONE
)
{
adts_find_frame
(
buffer
);
decoder_buffer_fill
(
buffer
);
...
...
@@ -464,7 +464,7 @@ faad_stream_decode(Decoder &mpd_decoder, struct input_stream *is)
}
static
bool
faad_scan_stream
(
struct
input_stream
*
is
,
faad_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
int
file_time
=
faad_get_file_time
(
is
);
...
...
src/decoder/FfmpegDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -86,13 +86,13 @@ mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
struct
AvioStream
{
Decoder
*
const
decoder
;
struct
input_stream
*
input
;
InputStream
&
input
;
AVIOContext
*
io
;
unsigned
char
buffer
[
8192
];
AvioStream
(
Decoder
*
_decoder
,
input_stream
*
_input
)
AvioStream
(
Decoder
*
_decoder
,
InputStream
&
_input
)
:
decoder
(
_decoder
),
input
(
_input
),
io
(
nullptr
)
{}
~
AvioStream
()
{
...
...
@@ -118,13 +118,13 @@ mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
AvioStream
*
stream
=
(
AvioStream
*
)
opaque
;
if
(
whence
==
AVSEEK_SIZE
)
return
stream
->
input
->
size
;
return
stream
->
input
.
size
;
Error
error
;
if
(
!
stream
->
input
->
LockSeek
(
pos
,
whence
,
error
))
if
(
!
stream
->
input
.
LockSeek
(
pos
,
whence
,
error
))
return
-
1
;
return
stream
->
input
->
offset
;
return
stream
->
input
.
offset
;
}
bool
...
...
@@ -133,7 +133,7 @@ AvioStream::Open()
io
=
avio_alloc_context
(
buffer
,
sizeof
(
buffer
),
false
,
this
,
mpd_ffmpeg_stream_read
,
nullptr
,
input
->
seekable
input
.
seekable
?
mpd_ffmpeg_stream_seek
:
nullptr
);
return
io
!=
nullptr
;
}
...
...
@@ -249,7 +249,7 @@ copy_interleave_frame(const AVCodecContext *codec_context,
}
static
DecoderCommand
ffmpeg_send_packet
(
Decoder
&
decoder
,
struct
input_stream
*
is
,
ffmpeg_send_packet
(
Decoder
&
decoder
,
InputStream
&
is
,
const
AVPacket
*
packet
,
AVCodecContext
*
codec_context
,
const
AVRational
*
time_base
,
...
...
@@ -335,7 +335,7 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
}
static
AVInputFormat
*
ffmpeg_probe
(
Decoder
*
decoder
,
struct
input_stream
*
is
)
ffmpeg_probe
(
Decoder
*
decoder
,
InputStream
&
is
)
{
enum
{
BUFFER_SIZE
=
16384
,
...
...
@@ -346,7 +346,7 @@ ffmpeg_probe(Decoder *decoder, struct input_stream *is)
unsigned
char
buffer
[
BUFFER_SIZE
];
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
BUFFER_SIZE
);
if
(
nbytes
<=
PADDING
||
!
is
->
LockRewind
(
error
))
if
(
nbytes
<=
PADDING
||
!
is
.
LockRewind
(
error
))
return
nullptr
;
/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
...
...
@@ -358,13 +358,13 @@ ffmpeg_probe(Decoder *decoder, struct input_stream *is)
AVProbeData
avpd
;
avpd
.
buf
=
buffer
;
avpd
.
buf_size
=
nbytes
;
avpd
.
filename
=
is
->
uri
.
c_str
();
avpd
.
filename
=
is
.
uri
.
c_str
();
return
av_probe_input_format
(
&
avpd
,
true
);
}
static
void
ffmpeg_decode
(
Decoder
&
decoder
,
struct
input_stream
*
input
)
ffmpeg_decode
(
Decoder
&
decoder
,
InputStream
&
input
)
{
AVInputFormat
*
input_format
=
ffmpeg_probe
(
&
decoder
,
input
);
if
(
input_format
==
nullptr
)
...
...
@@ -382,7 +382,7 @@ ffmpeg_decode(Decoder &decoder, struct input_stream *input)
//ffmpeg works with ours "fileops" helper
AVFormatContext
*
format_context
=
nullptr
;
if
(
mpd_ffmpeg_open_input
(
&
format_context
,
stream
.
io
,
input
->
uri
.
c_str
(),
input
.
uri
.
c_str
(),
input_format
)
!=
0
)
{
LogError
(
ffmpeg_domain
,
"Open failed"
);
return
;
...
...
@@ -451,7 +451,7 @@ ffmpeg_decode(Decoder &decoder, struct input_stream *input)
:
0
;
decoder_initialized
(
decoder
,
audio_format
,
input
->
seekable
,
total_time
);
input
.
seekable
,
total_time
);
AVFrame
*
frame
=
avcodec_alloc_frame
();
if
(
!
frame
)
{
...
...
@@ -509,7 +509,7 @@ ffmpeg_decode(Decoder &decoder, struct input_stream *input)
//no tag reading in ffmpeg, check if playable
static
bool
ffmpeg_scan_stream
(
struct
input_stream
*
is
,
ffmpeg_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
AVInputFormat
*
input_format
=
ffmpeg_probe
(
nullptr
,
is
);
...
...
@@ -521,7 +521,7 @@ ffmpeg_scan_stream(struct input_stream *is,
return
false
;
AVFormatContext
*
f
=
nullptr
;
if
(
mpd_ffmpeg_open_input
(
&
f
,
stream
.
io
,
is
->
uri
.
c_str
(),
if
(
mpd_ffmpeg_open_input
(
&
f
,
stream
.
io
,
is
.
uri
.
c_str
(),
input_format
)
!=
0
)
return
false
;
...
...
src/decoder/FlacCommon.cxx
View file @
93deb844
...
...
@@ -33,7 +33,7 @@
#include <assert.h>
flac_data
::
flac_data
(
Decoder
&
_decoder
,
struct
input_stream
*
_input_stream
)
InputStream
&
_input_stream
)
:
FlacInput
(
_input_stream
,
&
_decoder
),
initialized
(
false
),
unsupported
(
false
),
total_frames
(
0
),
first_frame
(
0
),
next_frame
(
0
),
position
(
0
),
...
...
@@ -144,7 +144,7 @@ flac_got_first_frame(struct flac_data *data, const FLAC__FrameHeader *header)
data
->
frame_size
=
data
->
audio_format
.
GetFrameSize
();
decoder_initialized
(
data
->
decoder
,
data
->
audio_format
,
data
->
input_stream
->
seekable
,
data
->
input_stream
.
seekable
,
(
float
)
data
->
total_frames
/
(
float
)
data
->
audio_format
.
sample_rate
);
...
...
src/decoder/FlacCommon.hxx
View file @
93deb844
...
...
@@ -76,11 +76,11 @@ struct flac_data : public FlacInput {
FLAC__uint64
position
;
Decoder
&
decoder
;
struct
input_stream
*
input_stream
;
InputStream
&
input_stream
;
Tag
tag
;
flac_data
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
);
flac_data
(
Decoder
&
decoder
,
InputStream
&
input_stream
);
};
void
flac_metadata_common_cb
(
const
FLAC__StreamMetadata
*
block
,
...
...
src/decoder/FlacDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -99,7 +99,7 @@ flac_scan_file(const char *file,
}
static
bool
flac_scan_stream
(
struct
input_stream
*
is
,
flac_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
FlacMetadataChain
chain
;
...
...
@@ -148,13 +148,13 @@ flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd,
if
(
data
->
initialized
)
{
/* done */
decoder_initialized
(
data
->
decoder
,
data
->
audio_format
,
data
->
input_stream
->
seekable
,
data
->
input_stream
.
seekable
,
(
float
)
data
->
total_frames
/
(
float
)
data
->
audio_format
.
sample_rate
);
return
true
;
}
if
(
data
->
input_stream
->
seekable
)
if
(
data
->
input_stream
.
seekable
)
/* allow the workaround below only for nonseekable
streams*/
return
false
;
...
...
@@ -252,7 +252,7 @@ stream_init(FLAC__StreamDecoder *flac_dec, struct flac_data *data, bool is_ogg)
static
void
flac_decode_internal
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
,
InputStream
&
input_stream
,
bool
is_ogg
)
{
FLAC__StreamDecoder
*
flac_dec
;
...
...
@@ -285,7 +285,7 @@ flac_decode_internal(Decoder &decoder,
}
static
void
flac_decode
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
)
flac_decode
(
Decoder
&
decoder
,
InputStream
&
input_stream
)
{
flac_decode_internal
(
decoder
,
input_stream
,
false
);
}
...
...
@@ -313,7 +313,7 @@ oggflac_scan_file(const char *file,
}
static
bool
oggflac_scan_stream
(
struct
input_stream
*
is
,
oggflac_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
FlacMetadataChain
chain
;
...
...
@@ -329,14 +329,14 @@ oggflac_scan_stream(struct input_stream *is,
}
static
void
oggflac_decode
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
)
oggflac_decode
(
Decoder
&
decoder
,
InputStream
&
input_stream
)
{
if
(
ogg_codec_detect
(
&
decoder
,
input_stream
)
!=
OGG_CODEC_FLAC
)
return
;
/* rewind the stream, because ogg_codec_detect() has
moved it */
input_stream
->
LockRewind
(
IgnoreError
());
input_stream
.
LockRewind
(
IgnoreError
());
flac_decode_internal
(
decoder
,
input_stream
,
true
);
}
...
...
src/decoder/FlacIOHandle.cxx
View file @
93deb844
...
...
@@ -27,7 +27,7 @@
static
size_t
FlacIORead
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FLAC__IOHandle
handle
)
{
input_stream
*
is
=
(
input_s
tream
*
)
handle
;
InputStream
*
is
=
(
InputS
tream
*
)
handle
;
uint8_t
*
const
p0
=
(
uint8_t
*
)
ptr
,
*
p
=
p0
,
*
const
end
=
p0
+
size
*
nmemb
;
...
...
@@ -64,7 +64,7 @@ FlacIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
static
int
FlacIOSeek
(
FLAC__IOHandle
handle
,
FLAC__int64
offset
,
int
whence
)
{
input_stream
*
is
=
(
input_s
tream
*
)
handle
;
InputStream
*
is
=
(
InputS
tream
*
)
handle
;
Error
error
;
return
is
->
LockSeek
(
offset
,
whence
,
error
)
?
0
:
-
1
;
...
...
@@ -73,7 +73,7 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 offset, int whence)
static
FLAC__int64
FlacIOTell
(
FLAC__IOHandle
handle
)
{
input_stream
*
is
=
(
input_s
tream
*
)
handle
;
InputStream
*
is
=
(
InputS
tream
*
)
handle
;
return
is
->
offset
;
}
...
...
@@ -81,7 +81,7 @@ FlacIOTell(FLAC__IOHandle handle)
static
int
FlacIOEof
(
FLAC__IOHandle
handle
)
{
input_stream
*
is
=
(
input_s
tream
*
)
handle
;
InputStream
*
is
=
(
InputS
tream
*
)
handle
;
return
is
->
LockIsEOF
();
}
...
...
@@ -90,7 +90,7 @@ static int
FlacIOClose
(
gcc_unused
FLAC__IOHandle
handle
)
{
/* no-op because the libFLAC caller is repsonsible for closing
the #
input_s
tream */
the #
InputS
tream */
return
0
;
}
...
...
src/decoder/FlacIOHandle.hxx
View file @
93deb844
...
...
@@ -29,15 +29,15 @@ extern const FLAC__IOCallbacks flac_io_callbacks;
extern
const
FLAC__IOCallbacks
flac_io_callbacks_seekable
;
static
inline
FLAC__IOHandle
ToFlacIOHandle
(
input_stream
*
is
)
ToFlacIOHandle
(
InputStream
&
is
)
{
return
(
FLAC__IOHandle
)
is
;
return
(
FLAC__IOHandle
)
&
is
;
}
static
inline
const
FLAC__IOCallbacks
&
GetFlacIOCallbacks
(
const
input_stream
*
is
)
GetFlacIOCallbacks
(
const
InputStream
&
is
)
{
return
is
->
seekable
return
is
.
seekable
?
flac_io_callbacks_seekable
:
flac_io_callbacks
;
}
...
...
src/decoder/FlacInput.cxx
View file @
93deb844
...
...
@@ -33,7 +33,7 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
*
bytes
=
r
;
if
(
r
==
0
)
{
if
(
input_stream
->
LockIsEOF
()
||
if
(
input_stream
.
LockIsEOF
()
||
(
decoder
!=
nullptr
&&
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
NONE
))
return
FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM
;
...
...
@@ -47,11 +47,11 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
FLAC__StreamDecoderSeekStatus
FlacInput
::
Seek
(
FLAC__uint64
absolute_byte_offset
)
{
if
(
!
input_stream
->
seekable
)
if
(
!
input_stream
.
seekable
)
return
FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
;
::
Error
error
;
if
(
!
input_stream
->
LockSeek
(
absolute_byte_offset
,
SEEK_SET
,
error
))
{
if
(
!
input_stream
.
LockSeek
(
absolute_byte_offset
,
SEEK_SET
,
error
))
{
LogError
(
error
);
return
FLAC__STREAM_DECODER_SEEK_STATUS_ERROR
;
}
...
...
@@ -62,20 +62,20 @@ FlacInput::Seek(FLAC__uint64 absolute_byte_offset)
FLAC__StreamDecoderTellStatus
FlacInput
::
Tell
(
FLAC__uint64
*
absolute_byte_offset
)
{
if
(
!
input_stream
->
seekable
)
if
(
!
input_stream
.
seekable
)
return
FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
;
*
absolute_byte_offset
=
(
FLAC__uint64
)
input_stream
->
offset
;
*
absolute_byte_offset
=
(
FLAC__uint64
)
input_stream
.
offset
;
return
FLAC__STREAM_DECODER_TELL_STATUS_OK
;
}
FLAC__StreamDecoderLengthStatus
FlacInput
::
Length
(
FLAC__uint64
*
stream_length
)
{
if
(
input_stream
->
size
<
0
)
if
(
input_stream
.
size
<
0
)
return
FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
;
*
stream_length
=
(
FLAC__uint64
)
input_stream
->
size
;
*
stream_length
=
(
FLAC__uint64
)
input_stream
.
size
;
return
FLAC__STREAM_DECODER_LENGTH_STATUS_OK
;
}
...
...
@@ -85,7 +85,7 @@ FlacInput::Eof()
return
(
decoder
!=
nullptr
&&
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
NONE
&&
decoder_get_command
(
*
decoder
)
!=
DecoderCommand
::
SEEK
)
||
input_stream
->
LockIsEOF
();
input_stream
.
LockIsEOF
();
}
void
...
...
src/decoder/FlacInput.hxx
View file @
93deb844
...
...
@@ -23,18 +23,19 @@
#include <FLAC/stream_decoder.h>
struct
Decoder
;
struct
InputStream
;
/**
* This class wraps an #
input_s
tream in libFLAC stream decoder
* This class wraps an #
InputS
tream in libFLAC stream decoder
* callbacks.
*/
class
FlacInput
{
Decoder
*
const
decoder
;
struct
input_stream
*
input_stream
;
InputStream
&
input_stream
;
public
:
FlacInput
(
struct
input_stream
*
_input_stream
,
FlacInput
(
InputStream
&
_input_stream
,
Decoder
*
_decoder
=
nullptr
)
:
decoder
(
_decoder
),
input_stream
(
_input_stream
)
{}
...
...
src/decoder/FlacMetadata.hxx
View file @
93deb844
...
...
@@ -51,7 +51,7 @@ public:
callbacks
);
}
bool
Read
(
input_stream
*
is
)
{
bool
Read
(
InputStream
&
is
)
{
return
Read
(
::
ToFlacIOHandle
(
is
),
::
GetFlacIOCallbacks
(
is
));
}
...
...
@@ -65,7 +65,7 @@ public:
callbacks
);
}
bool
ReadOgg
(
input_stream
*
is
)
{
bool
ReadOgg
(
InputStream
&
is
)
{
return
ReadOgg
(
::
ToFlacIOHandle
(
is
),
::
GetFlacIOCallbacks
(
is
));
}
...
...
src/decoder/MadDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -140,10 +140,10 @@ struct MadDecoder {
bool
decoded_first_frame
;
unsigned
long
bit_rate
;
Decoder
*
const
decoder
;
struct
input_stream
*
input_stream
;
InputStream
&
input_stream
;
enum
mad_layer
layer
;
MadDecoder
(
Decoder
*
decoder
,
struct
input_stream
*
input_stream
);
MadDecoder
(
Decoder
*
decoder
,
InputStream
&
input_stream
);
~
MadDecoder
();
bool
Seek
(
long
offset
);
...
...
@@ -153,10 +153,10 @@ struct MadDecoder {
enum
mp3_action
DecodeNextFrame
();
gcc_pure
input_s
tream
::
offset_type
ThisFrameOffset
()
const
;
InputS
tream
::
offset_type
ThisFrameOffset
()
const
;
gcc_pure
input_s
tream
::
offset_type
RestIncludingThisFrame
()
const
;
InputS
tream
::
offset_type
RestIncludingThisFrame
()
const
;
/**
* Attempt to calulcate the length of the song from filesize
...
...
@@ -185,7 +185,7 @@ struct MadDecoder {
};
MadDecoder
::
MadDecoder
(
Decoder
*
_decoder
,
struct
input_stream
*
_input_stream
)
InputStream
&
_input_stream
)
:
mute_frame
(
MUTEFRAME_NONE
),
frame_offsets
(
nullptr
),
times
(
nullptr
),
...
...
@@ -208,7 +208,7 @@ inline bool
MadDecoder
::
Seek
(
long
offset
)
{
Error
error
;
if
(
!
input_stream
->
LockSeek
(
offset
,
SEEK_SET
,
error
))
if
(
!
input_stream
.
LockSeek
(
offset
,
SEEK_SET
,
error
))
return
false
;
mad_stream_buffer
(
&
stream
,
input_buffer
,
0
);
...
...
@@ -777,10 +777,10 @@ mp3_frame_duration(const struct mad_frame *frame)
MAD_UNITS_MILLISECONDS
)
/
1000.0
;
}
inline
input_s
tream
::
offset_type
inline
InputS
tream
::
offset_type
MadDecoder
::
ThisFrameOffset
()
const
{
auto
offset
=
input_stream
->
GetOffset
();
auto
offset
=
input_stream
.
GetOffset
();
if
(
stream
.
this_frame
!=
nullptr
)
offset
-=
stream
.
bufend
-
stream
.
this_frame
;
...
...
@@ -790,16 +790,16 @@ MadDecoder::ThisFrameOffset() const
return
offset
;
}
inline
input_s
tream
::
offset_type
inline
InputS
tream
::
offset_type
MadDecoder
::
RestIncludingThisFrame
()
const
{
return
input_stream
->
GetSize
()
-
ThisFrameOffset
();
return
input_stream
.
GetSize
()
-
ThisFrameOffset
();
}
inline
void
MadDecoder
::
FileSizeToSongLength
()
{
input_s
tream
::
offset_type
rest
=
RestIncludingThisFrame
();
InputS
tream
::
offset_type
rest
=
RestIncludingThisFrame
();
if
(
rest
>
0
)
{
float
frame_duration
=
mp3_frame_duration
(
&
frame
);
...
...
@@ -861,7 +861,7 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
}
if
(
parse_lame
(
&
lame
,
&
ptr
,
&
bitlen
))
{
if
(
gapless_playback
&&
input_stream
->
IsSeekable
())
{
if
(
gapless_playback
&&
input_stream
.
IsSeekable
())
{
drop_start_samples
=
lame
.
encoder_delay
+
DECODERDELAY
;
drop_end_samples
=
lame
.
encoder_padding
;
...
...
@@ -908,7 +908,7 @@ MadDecoder::~MadDecoder()
/* this is primarily used for getting total time for tags */
static
int
mad_decoder_total_file_time
(
struct
input_stream
*
is
)
mad_decoder_total_file_time
(
InputStream
&
is
)
{
MadDecoder
data
(
nullptr
,
is
);
return
data
.
DecodeFirstFrame
(
nullptr
)
...
...
@@ -1063,7 +1063,7 @@ MadDecoder::Read()
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
unsigned
long
j
;
assert
(
input_stream
->
IsSeekable
());
assert
(
input_stream
.
IsSeekable
());
j
=
TimeToFrame
(
decoder_seek_where
(
*
decoder
));
if
(
j
<
highest_frame
)
{
...
...
@@ -1116,7 +1116,7 @@ MadDecoder::Read()
}
static
void
mp3_decode
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
)
mp3_decode
(
Decoder
&
decoder
,
InputStream
&
input_stream
)
{
MadDecoder
data
(
&
decoder
,
input_stream
);
...
...
@@ -1143,7 +1143,7 @@ mp3_decode(Decoder &decoder, struct input_stream *input_stream)
}
decoder_initialized
(
decoder
,
audio_format
,
input_stream
->
IsSeekable
(),
input_stream
.
IsSeekable
(),
data
.
total_time
);
if
(
tag
!=
nullptr
)
{
...
...
@@ -1155,7 +1155,7 @@ mp3_decode(Decoder &decoder, struct input_stream *input_stream)
}
static
bool
mad_decoder_scan_stream
(
struct
input_stream
*
is
,
mad_decoder_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
int
total_time
;
...
...
src/decoder/ModplugDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -36,7 +36,7 @@ static constexpr Domain modplug_domain("modplug");
static
constexpr
size_t
MODPLUG_FRAME_SIZE
=
4096
;
static
constexpr
size_t
MODPLUG_PREALLOC_BLOCK
=
256
*
1024
;
static
constexpr
input_s
tream
::
offset_type
MODPLUG_FILE_LIMIT
=
100
*
1024
*
1024
;
static
constexpr
InputS
tream
::
offset_type
MODPLUG_FILE_LIMIT
=
100
*
1024
*
1024
;
static
int
modplug_loop_count
;
...
...
@@ -52,9 +52,9 @@ modplug_decoder_init(const config_param ¶m)
}
static
WritableBuffer
<
uint8_t
>
mod_loadfile
(
Decoder
*
decoder
,
struct
input_stream
*
is
)
mod_loadfile
(
Decoder
*
decoder
,
InputStream
&
is
)
{
const
input_stream
::
offset_type
size
=
is
->
GetSize
();
const
InputStream
::
offset_type
size
=
is
.
GetSize
();
if
(
size
==
0
)
{
LogWarning
(
modplug_domain
,
"file is empty"
);
...
...
@@ -80,7 +80,7 @@ mod_loadfile(Decoder *decoder, struct input_stream *is)
while
(
true
)
{
size_t
ret
=
decoder_read
(
decoder
,
is
,
p
,
end
-
p
);
if
(
ret
==
0
)
{
if
(
is
->
LockIsEOF
())
if
(
is
.
LockIsEOF
())
/* end of file */
break
;
...
...
@@ -107,7 +107,7 @@ mod_loadfile(Decoder *decoder, struct input_stream *is)
}
static
ModPlugFile
*
LoadModPlugFile
(
Decoder
*
decoder
,
struct
input_stream
*
is
)
LoadModPlugFile
(
Decoder
*
decoder
,
InputStream
&
is
)
{
const
auto
buffer
=
mod_loadfile
(
decoder
,
is
);
if
(
buffer
.
IsNull
())
{
...
...
@@ -121,7 +121,7 @@ LoadModPlugFile(Decoder *decoder, struct input_stream *is)
}
static
void
mod_decode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
mod_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
ModPlug_Settings
settings
;
int
ret
;
...
...
@@ -147,7 +147,7 @@ mod_decode(Decoder &decoder, struct input_stream *is)
assert
(
audio_format
.
IsValid
());
decoder_initialized
(
decoder
,
audio_format
,
is
->
IsSeekable
(),
is
.
IsSeekable
(),
ModPlug_GetLength
(
f
)
/
1000.0
);
DecoderCommand
cmd
;
...
...
@@ -174,7 +174,7 @@ mod_decode(Decoder &decoder, struct input_stream *is)
}
static
bool
modplug_scan_stream
(
struct
input_stream
*
is
,
modplug_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
ModPlugFile
*
f
=
LoadModPlugFile
(
nullptr
,
is
);
...
...
src/decoder/MpcdecDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -35,8 +35,11 @@
#include <math.h>
struct
mpc_decoder_data
{
struct
input_stream
*
is
;
InputStream
&
is
;
Decoder
*
decoder
;
mpc_decoder_data
(
InputStream
&
_is
,
Decoder
*
_decoder
)
:
is
(
_is
),
decoder
(
_decoder
)
{}
};
static
constexpr
Domain
mpcdec_domain
(
"mpcdec"
);
...
...
@@ -56,7 +59,7 @@ mpc_seek_cb(mpc_reader *reader, mpc_int32_t offset)
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_data
*
)
reader
->
data
;
return
data
->
is
->
LockSeek
(
offset
,
SEEK_SET
,
IgnoreError
());
return
data
->
is
.
LockSeek
(
offset
,
SEEK_SET
,
IgnoreError
());
}
static
mpc_int32_t
...
...
@@ -65,7 +68,7 @@ mpc_tell_cb(mpc_reader *reader)
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_data
*
)
reader
->
data
;
return
(
long
)
data
->
is
->
GetOffset
();
return
(
long
)
data
->
is
.
GetOffset
();
}
static
mpc_bool_t
...
...
@@ -74,7 +77,7 @@ mpc_canseek_cb(mpc_reader *reader)
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_data
*
)
reader
->
data
;
return
data
->
is
->
IsSeekable
();
return
data
->
is
.
IsSeekable
();
}
static
mpc_int32_t
...
...
@@ -83,7 +86,7 @@ mpc_getsize_cb(mpc_reader *reader)
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_data
*
)
reader
->
data
;
return
data
->
is
->
GetSize
();
return
data
->
is
.
GetSize
();
}
/* this _looks_ performance-critical, don't de-inline -- eric */
...
...
@@ -130,13 +133,11 @@ mpc_to_mpd_buffer(int32_t *dest, const MPC_SAMPLE_FORMAT *src,
}
static
void
mpcdec_decode
(
Decoder
&
mpd_decoder
,
struct
input_stream
*
is
)
mpcdec_decode
(
Decoder
&
mpd_decoder
,
InputStream
&
is
)
{
MPC_SAMPLE_FORMAT
sample_buffer
[
MPC_DECODER_BUFFER_LENGTH
];
struct
mpc_decoder_data
data
;
data
.
is
=
is
;
data
.
decoder
=
&
mpd_decoder
;
mpc_decoder_data
data
(
is
,
&
mpd_decoder
);
mpc_reader
reader
;
reader
.
read
=
mpc_read_cb
;
...
...
@@ -177,7 +178,7 @@ mpcdec_decode(Decoder &mpd_decoder, struct input_stream *is)
decoder_replay_gain
(
mpd_decoder
,
&
replay_gain_info
);
decoder_initialized
(
mpd_decoder
,
audio_format
,
is
->
IsSeekable
(),
is
.
IsSeekable
(),
mpc_streaminfo_get_length
(
&
info
));
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
...
...
@@ -227,11 +228,9 @@ mpcdec_decode(Decoder &mpd_decoder, struct input_stream *is)
}
static
float
mpcdec_get_file_duration
(
struct
input_stream
*
is
)
mpcdec_get_file_duration
(
InputStream
&
is
)
{
struct
mpc_decoder_data
data
;
data
.
is
=
is
;
data
.
decoder
=
nullptr
;
mpc_decoder_data
data
(
is
,
nullptr
);
mpc_reader
reader
;
reader
.
read
=
mpc_read_cb
;
...
...
@@ -253,7 +252,7 @@ mpcdec_get_file_duration(struct input_stream *is)
}
static
bool
mpcdec_scan_stream
(
struct
input_stream
*
is
,
mpcdec_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
float
total_time
=
mpcdec_get_file_duration
(
is
);
...
...
src/decoder/OggCodec.cxx
View file @
93deb844
...
...
@@ -27,7 +27,7 @@
#include <string.h>
enum
ogg_codec
ogg_codec_detect
(
Decoder
*
decoder
,
struct
input_stream
*
is
)
ogg_codec_detect
(
Decoder
*
decoder
,
InputStream
&
is
)
{
/* oggflac detection based on code in ogg123 and this post
* http://lists.xiph.org/pipermail/flac/2004-December/000393.html
...
...
src/decoder/OggCodec.hxx
View file @
93deb844
...
...
@@ -34,6 +34,6 @@ enum ogg_codec {
};
enum
ogg_codec
ogg_codec_detect
(
Decoder
*
decoder
,
struct
input_stream
*
is
);
ogg_codec_detect
(
Decoder
*
decoder
,
InputStream
&
is
);
#endif
/* _OGG_COMMON_H */
src/decoder/OggSyncState.hxx
View file @
93deb844
...
...
@@ -33,11 +33,11 @@
class
OggSyncState
{
ogg_sync_state
oy
;
input_s
tream
&
is
;
InputS
tream
&
is
;
Decoder
*
const
decoder
;
public
:
OggSyncState
(
input_s
tream
&
_is
,
Decoder
*
const
_decoder
=
nullptr
)
OggSyncState
(
InputS
tream
&
_is
,
Decoder
*
const
_decoder
=
nullptr
)
:
is
(
_is
),
decoder
(
_decoder
)
{
ogg_sync_init
(
&
oy
);
}
...
...
@@ -51,27 +51,27 @@ public:
}
bool
Feed
(
size_t
size
)
{
return
OggFeed
(
oy
,
decoder
,
&
is
,
size
);
return
OggFeed
(
oy
,
decoder
,
is
,
size
);
}
bool
ExpectPage
(
ogg_page
&
page
)
{
return
OggExpectPage
(
oy
,
page
,
decoder
,
&
is
);
return
OggExpectPage
(
oy
,
page
,
decoder
,
is
);
}
bool
ExpectFirstPage
(
ogg_stream_state
&
os
)
{
return
OggExpectFirstPage
(
oy
,
os
,
decoder
,
&
is
);
return
OggExpectFirstPage
(
oy
,
os
,
decoder
,
is
);
}
bool
ExpectPageIn
(
ogg_stream_state
&
os
)
{
return
OggExpectPageIn
(
oy
,
os
,
decoder
,
&
is
);
return
OggExpectPageIn
(
oy
,
os
,
decoder
,
is
);
}
bool
ExpectPageSeek
(
ogg_page
&
page
)
{
return
OggExpectPageSeek
(
oy
,
page
,
decoder
,
&
is
);
return
OggExpectPageSeek
(
oy
,
page
,
decoder
,
is
);
}
bool
ExpectPageSeekIn
(
ogg_stream_state
&
os
)
{
return
OggExpectPageSeekIn
(
oy
,
os
,
decoder
,
&
is
);
return
OggExpectPageSeekIn
(
oy
,
os
,
decoder
,
is
);
}
};
...
...
src/decoder/OggUtil.cxx
View file @
93deb844
...
...
@@ -23,7 +23,7 @@
bool
OggFeed
(
ogg_sync_state
&
oy
,
Decoder
*
decoder
,
input_stream
*
input_stream
,
size_t
size
)
InputStream
&
input_stream
,
size_t
size
)
{
char
*
buffer
=
ogg_sync_buffer
(
&
oy
,
size
);
if
(
buffer
==
nullptr
)
...
...
@@ -40,7 +40,7 @@ OggFeed(ogg_sync_state &oy, Decoder *decoder,
bool
OggExpectPage
(
ogg_sync_state
&
oy
,
ogg_page
&
page
,
Decoder
*
decoder
,
input_stream
*
input_stream
)
Decoder
*
decoder
,
InputStream
&
input_stream
)
{
while
(
true
)
{
int
r
=
ogg_sync_pageout
(
&
oy
,
&
page
);
...
...
@@ -54,7 +54,7 @@ OggExpectPage(ogg_sync_state &oy, ogg_page &page,
bool
OggExpectFirstPage
(
ogg_sync_state
&
oy
,
ogg_stream_state
&
os
,
Decoder
*
decoder
,
input_stream
*
is
)
Decoder
*
decoder
,
InputStream
&
is
)
{
ogg_page
page
;
if
(
!
OggExpectPage
(
oy
,
page
,
decoder
,
is
))
...
...
@@ -67,7 +67,7 @@ OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
bool
OggExpectPageIn
(
ogg_sync_state
&
oy
,
ogg_stream_state
&
os
,
Decoder
*
decoder
,
input_stream
*
is
)
Decoder
*
decoder
,
InputStream
&
is
)
{
ogg_page
page
;
if
(
!
OggExpectPage
(
oy
,
page
,
decoder
,
is
))
...
...
@@ -79,7 +79,7 @@ OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os,
bool
OggExpectPageSeek
(
ogg_sync_state
&
oy
,
ogg_page
&
page
,
Decoder
*
decoder
,
input_stream
*
input_stream
)
Decoder
*
decoder
,
InputStream
&
input_stream
)
{
size_t
remaining_skipped
=
16384
;
...
...
@@ -107,7 +107,7 @@ OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page,
bool
OggExpectPageSeekIn
(
ogg_sync_state
&
oy
,
ogg_stream_state
&
os
,
Decoder
*
decoder
,
input_stream
*
is
)
Decoder
*
decoder
,
InputStream
&
is
)
{
ogg_page
page
;
if
(
!
OggExpectPageSeek
(
oy
,
page
,
decoder
,
is
))
...
...
src/decoder/OggUtil.hxx
View file @
93deb844
...
...
@@ -26,16 +26,16 @@
#include <stddef.h>
struct
input_s
tream
;
struct
InputS
tream
;
struct
Decoder
;
/**
* Feed data from the #
input_s
tream into the #ogg_sync_state.
* Feed data from the #
InputS
tream into the #ogg_sync_state.
*
* @return false on error or end-of-file
*/
bool
OggFeed
(
ogg_sync_state
&
oy
,
Decoder
*
decoder
,
input_stream
*
is
,
OggFeed
(
ogg_sync_state
&
oy
,
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
);
/**
...
...
@@ -46,7 +46,7 @@ OggFeed(ogg_sync_state &oy, Decoder *decoder, input_stream *is,
*/
bool
OggExpectPage
(
ogg_sync_state
&
oy
,
ogg_page
&
page
,
Decoder
*
decoder
,
input_stream
*
input_stream
);
Decoder
*
decoder
,
InputStream
&
is
);
/**
* Combines OggExpectPage(), ogg_stream_init() and
...
...
@@ -57,7 +57,7 @@ OggExpectPage(ogg_sync_state &oy, ogg_page &page,
*/
bool
OggExpectFirstPage
(
ogg_sync_state
&
oy
,
ogg_stream_state
&
os
,
Decoder
*
decoder
,
input_stream
*
is
);
Decoder
*
decoder
,
InputStream
&
is
);
/**
* Combines OggExpectPage() and ogg_stream_pagein().
...
...
@@ -66,14 +66,14 @@ OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
*/
bool
OggExpectPageIn
(
ogg_sync_state
&
oy
,
ogg_stream_state
&
os
,
Decoder
*
decoder
,
input_stream
*
is
);
Decoder
*
decoder
,
InputStream
&
is
);
/**
* Like OggExpectPage(), but allow skipping garbage (after seeking).
*/
bool
OggExpectPageSeek
(
ogg_sync_state
&
oy
,
ogg_page
&
page
,
Decoder
*
decoder
,
input_stream
*
input_stream
);
Decoder
*
decoder
,
InputStream
&
is
);
/**
* Combines OggExpectPageSeek() and ogg_stream_pagein().
...
...
@@ -82,6 +82,6 @@ OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page,
*/
bool
OggExpectPageSeekIn
(
ogg_sync_state
&
oy
,
ogg_stream_state
&
os
,
Decoder
*
decoder
,
input_stream
*
is
);
Decoder
*
decoder
,
InputStream
&
is
);
#endif
src/decoder/OpusDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -67,7 +67,7 @@ mpd_opus_init(gcc_unused const config_param ¶m)
class
MPDOpusDecoder
{
Decoder
&
decoder
;
struct
input_stream
*
input_stream
;
InputStream
&
input_stream
;
ogg_stream_state
os
;
...
...
@@ -84,7 +84,7 @@ class MPDOpusDecoder {
public
:
MPDOpusDecoder
(
Decoder
&
_decoder
,
struct
input_stream
*
_input_stream
)
InputStream
&
_input_stream
)
:
decoder
(
_decoder
),
input_stream
(
_input_stream
),
opus_decoder
(
nullptr
),
output_buffer
(
nullptr
),
output_size
(
0
),
...
...
@@ -265,17 +265,17 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
static
void
mpd_opus_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
)
InputStream
&
input_stream
)
{
if
(
ogg_codec_detect
(
&
decoder
,
input_stream
)
!=
OGG_CODEC_OPUS
)
return
;
/* rewind the stream, because ogg_codec_detect() has
moved it */
input_stream
->
LockRewind
(
IgnoreError
());
input_stream
.
LockRewind
(
IgnoreError
());
MPDOpusDecoder
d
(
decoder
,
input_stream
);
OggSyncState
oy
(
*
input_stream
,
&
decoder
);
OggSyncState
oy
(
input_stream
,
&
decoder
);
if
(
!
d
.
ReadFirstPage
(
oy
))
return
;
...
...
@@ -293,27 +293,27 @@ mpd_opus_stream_decode(Decoder &decoder,
static
bool
SeekFindEOS
(
OggSyncState
&
oy
,
ogg_stream_state
&
os
,
ogg_packet
&
packet
,
input_stream
*
is
)
InputStream
&
is
)
{
if
(
is
->
size
>
0
&&
is
->
size
-
is
->
offset
<
65536
)
if
(
is
.
size
>
0
&&
is
.
size
-
is
.
offset
<
65536
)
return
OggFindEOS
(
oy
,
os
,
packet
);
if
(
!
is
->
CheapSeeking
())
if
(
!
is
.
CheapSeeking
())
return
false
;
oy
.
Reset
();
Error
error
;
return
is
->
LockSeek
(
-
65536
,
SEEK_END
,
error
)
&&
return
is
.
LockSeek
(
-
65536
,
SEEK_END
,
error
)
&&
oy
.
ExpectPageSeekIn
(
os
)
&&
OggFindEOS
(
oy
,
os
,
packet
);
}
static
bool
mpd_opus_scan_stream
(
struct
input_stream
*
is
,
mpd_opus_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
OggSyncState
oy
(
*
is
);
OggSyncState
oy
(
is
);
ogg_stream_state
os
;
if
(
!
oy
.
ExpectFirstPage
(
os
))
...
...
src/decoder/PcmDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -31,7 +31,7 @@
#include <stdio.h>
/* for SEEK_SET */
static
void
pcm_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
pcm_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
static
constexpr
AudioFormat
audio_format
=
{
44100
,
...
...
@@ -39,19 +39,19 @@ pcm_stream_decode(Decoder &decoder, struct input_stream *is)
2
,
};
const
char
*
const
mime
=
is
->
GetMimeType
();
const
char
*
const
mime
=
is
.
GetMimeType
();
const
bool
reverse_endian
=
mime
!=
nullptr
&&
strcmp
(
mime
,
"audio/x-mpd-cdda-pcm-reverse"
)
==
0
;
const
double
time_to_size
=
audio_format
.
GetTimeToSize
();
float
total_time
=
-
1
;
const
auto
size
=
is
->
GetSize
();
const
auto
size
=
is
.
GetSize
();
if
(
size
>=
0
)
total_time
=
size
/
time_to_size
;
decoder_initialized
(
decoder
,
audio_format
,
is
->
IsSeekable
(),
total_time
);
is
.
IsSeekable
(),
total_time
);
DecoderCommand
cmd
;
do
{
...
...
@@ -60,7 +60,7 @@ pcm_stream_decode(Decoder &decoder, struct input_stream *is)
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
sizeof
(
buffer
));
if
(
nbytes
==
0
&&
is
->
LockIsEOF
())
if
(
nbytes
==
0
&&
is
.
LockIsEOF
())
break
;
if
(
reverse_endian
)
...
...
@@ -74,11 +74,11 @@ pcm_stream_decode(Decoder &decoder, struct input_stream *is)
buffer
,
nbytes
,
0
)
:
decoder_get_command
(
decoder
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
input_s
tream
::
offset_type
offset
(
time_to_size
*
InputS
tream
::
offset_type
offset
(
time_to_size
*
decoder_seek_where
(
decoder
));
Error
error
;
if
(
is
->
LockSeek
(
offset
,
SEEK_SET
,
error
))
{
if
(
is
.
LockSeek
(
offset
,
SEEK_SET
,
error
))
{
decoder_command_finished
(
decoder
);
}
else
{
LogError
(
error
);
...
...
src/decoder/SndfileDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -34,29 +34,29 @@ static constexpr Domain sndfile_domain("sndfile");
static
sf_count_t
sndfile_vio_get_filelen
(
void
*
user_data
)
{
const
struct
input_stream
*
is
=
(
const
struct
input_s
tream
*
)
user_data
;
const
InputStream
&
is
=
*
(
const
InputS
tream
*
)
user_data
;
return
is
->
GetSize
();
return
is
.
GetSize
();
}
static
sf_count_t
sndfile_vio_seek
(
sf_count_t
offset
,
int
whence
,
void
*
user_data
)
{
struct
input_stream
*
is
=
(
struct
input_s
tream
*
)
user_data
;
InputStream
&
is
=
*
(
InputS
tream
*
)
user_data
;
if
(
!
is
->
LockSeek
(
offset
,
whence
,
IgnoreError
()))
if
(
!
is
.
LockSeek
(
offset
,
whence
,
IgnoreError
()))
return
-
1
;
return
is
->
GetOffset
();
return
is
.
GetOffset
();
}
static
sf_count_t
sndfile_vio_read
(
void
*
ptr
,
sf_count_t
count
,
void
*
user_data
)
{
struct
input_stream
*
is
=
(
struct
input_s
tream
*
)
user_data
;
InputStream
&
is
=
*
(
InputS
tream
*
)
user_data
;
Error
error
;
size_t
nbytes
=
is
->
LockRead
(
ptr
,
count
,
error
);
size_t
nbytes
=
is
.
LockRead
(
ptr
,
count
,
error
);
if
(
nbytes
==
0
&&
error
.
IsDefined
())
{
LogError
(
error
);
return
-
1
;
...
...
@@ -77,9 +77,9 @@ sndfile_vio_write(gcc_unused const void *ptr,
static
sf_count_t
sndfile_vio_tell
(
void
*
user_data
)
{
const
struct
input_stream
*
is
=
(
const
struct
input_s
tream
*
)
user_data
;
const
InputStream
&
is
=
*
(
const
InputS
tream
*
)
user_data
;
return
is
->
GetOffset
();
return
is
.
GetOffset
();
}
/**
...
...
@@ -113,7 +113,7 @@ time_to_frame(float t, const AudioFormat *audio_format)
}
static
void
sndfile_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
sndfile_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
SNDFILE
*
sf
;
SF_INFO
info
;
...
...
@@ -123,7 +123,7 @@ sndfile_stream_decode(Decoder &decoder, struct input_stream *is)
info
.
format
=
0
;
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
is
);
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
&
is
);
if
(
sf
==
nullptr
)
{
LogWarning
(
sndfile_domain
,
"sf_open_virtual() failed"
);
return
;
...
...
src/decoder/VorbisDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -54,14 +54,14 @@
struct
vorbis_input_stream
{
Decoder
*
decoder
;
struct
input_s
tream
*
input_stream
;
InputS
tream
*
input_stream
;
bool
seekable
;
};
static
size_t
ogg_read_cb
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
void
*
data
)
{
struct
vorbis_input_stream
*
vis
=
(
struct
vorbis_input_stream
*
)
data
;
size_t
ret
=
decoder_read
(
vis
->
decoder
,
vis
->
input_stream
,
size_t
ret
=
decoder_read
(
vis
->
decoder
,
*
vis
->
input_stream
,
ptr
,
size
*
nmemb
);
errno
=
0
;
...
...
@@ -127,11 +127,11 @@ vorbis_strerror(int code)
static
bool
vorbis_is_open
(
struct
vorbis_input_stream
*
vis
,
OggVorbis_File
*
vf
,
Decoder
*
decoder
,
struct
input_stream
*
input_stream
)
Decoder
*
decoder
,
InputStream
&
input_stream
)
{
vis
->
decoder
=
decoder
;
vis
->
input_stream
=
input_stream
;
vis
->
seekable
=
input_stream
->
CheapSeeking
();
vis
->
input_stream
=
&
input_stream
;
vis
->
seekable
=
input_stream
.
CheapSeeking
();
int
ret
=
ov_open_callbacks
(
vis
,
vf
,
NULL
,
0
,
vorbis_is_callbacks
);
if
(
ret
<
0
)
{
...
...
@@ -147,7 +147,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
}
static
void
vorbis_send_comments
(
Decoder
&
decoder
,
struct
input_stream
*
is
,
vorbis_send_comments
(
Decoder
&
decoder
,
InputStream
&
is
,
char
**
comments
)
{
Tag
*
tag
=
vorbis_comments_to_tag
(
comments
);
...
...
@@ -176,14 +176,14 @@ vorbis_interleave(float *dest, const float *const*src,
/* public */
static
void
vorbis_stream_decode
(
Decoder
&
decoder
,
struct
input_stream
*
input_stream
)
InputStream
&
input_stream
)
{
if
(
ogg_codec_detect
(
&
decoder
,
input_stream
)
!=
OGG_CODEC_VORBIS
)
return
;
/* rewind the stream, because ogg_codec_detect() has
moved it */
input_stream
->
LockRewind
(
IgnoreError
());
input_stream
.
LockRewind
(
IgnoreError
());
struct
vorbis_input_stream
vis
;
OggVorbis_File
vf
;
...
...
@@ -303,7 +303,7 @@ vorbis_stream_decode(Decoder &decoder,
}
static
bool
vorbis_scan_stream
(
struct
input_stream
*
is
,
vorbis_scan_stream
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
struct
vorbis_input_stream
vis
;
...
...
src/decoder/WavpackDecoderPlugin.cxx
View file @
93deb844
...
...
@@ -346,7 +346,7 @@ wavpack_scan_file(const char *fname,
/* This struct is needed for per-stream last_byte storage. */
struct
wavpack_input
{
Decoder
*
decoder
;
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
/* Needed for push_back_byte() */
int
last_byte
;
};
...
...
@@ -378,7 +378,7 @@ wavpack_input_read_bytes(void *id, void *data, int32_t bcount)
until the buffer is full */
while
(
bcount
>
0
)
{
size_t
nbytes
=
decoder_read
(
wpin
(
id
)
->
decoder
,
wpin
(
id
)
->
is
,
buf
,
bcount
wpin
(
id
)
->
decoder
,
*
wpin
(
id
)
->
is
,
buf
,
bcount
);
if
(
nbytes
==
0
)
{
/* EOF, error or a decoder command */
...
...
@@ -450,19 +450,19 @@ static WavpackStreamReader mpd_is_reader = {
static
void
wavpack_input_init
(
struct
wavpack_input
*
isp
,
Decoder
&
decoder
,
struct
input_stream
*
is
)
InputStream
&
is
)
{
isp
->
decoder
=
&
decoder
;
isp
->
is
=
is
;
isp
->
is
=
&
is
;
isp
->
last_byte
=
EOF
;
}
static
struct
input_s
tream
*
static
InputS
tream
*
wavpack_open_wvc
(
Decoder
&
decoder
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
struct
wavpack_input
*
wpi
)
{
struct
input_s
tream
*
is_wvc
;
InputS
tream
*
is_wvc
;
char
*
wvc_url
=
nullptr
;
char
first_byte
;
size_t
nbytes
;
...
...
@@ -476,7 +476,7 @@ wavpack_open_wvc(Decoder &decoder, const char *uri,
wvc_url
=
g_strconcat
(
uri
,
"c"
,
nullptr
);
is_wvc
=
input_s
tream
::
Open
(
wvc_url
,
mutex
,
cond
,
IgnoreError
());
is_wvc
=
InputS
tream
::
Open
(
wvc_url
,
mutex
,
cond
,
IgnoreError
());
g_free
(
wvc_url
);
if
(
is_wvc
==
nullptr
)
...
...
@@ -487,7 +487,7 @@ wavpack_open_wvc(Decoder &decoder, const char *uri,
* about a possible 404 error.
*/
nbytes
=
decoder_read
(
decoder
,
is_wvc
,
&
first_byte
,
sizeof
(
first_byte
)
decoder
,
*
is_wvc
,
&
first_byte
,
sizeof
(
first_byte
)
);
if
(
nbytes
==
0
)
{
is_wvc
->
Close
();
...
...
@@ -495,7 +495,7 @@ wavpack_open_wvc(Decoder &decoder, const char *uri,
}
/* push it back */
wavpack_input_init
(
wpi
,
decoder
,
is_wvc
);
wavpack_input_init
(
wpi
,
decoder
,
*
is_wvc
);
wpi
->
last_byte
=
first_byte
;
return
is_wvc
;
}
...
...
@@ -504,17 +504,17 @@ wavpack_open_wvc(Decoder &decoder, const char *uri,
* Decodes a stream.
*/
static
void
wavpack_streamdecode
(
Decoder
&
decoder
,
struct
input_stream
*
is
)
wavpack_streamdecode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
;
struct
input_s
tream
*
is_wvc
;
InputS
tream
*
is_wvc
;
int
open_flags
=
OPEN_NORMALIZE
;
struct
wavpack_input
isp
,
isp_wvc
;
bool
can_seek
=
is
->
seekable
;
bool
can_seek
=
is
.
seekable
;
is_wvc
=
wavpack_open_wvc
(
decoder
,
is
->
uri
.
c_str
(),
is
->
mutex
,
is
->
cond
,
is_wvc
=
wavpack_open_wvc
(
decoder
,
is
.
uri
.
c_str
(),
is
.
mutex
,
is
.
cond
,
&
isp_wvc
);
if
(
is_wvc
!=
nullptr
)
{
open_flags
|=
OPEN_WVC
;
...
...
src/input/ArchiveInputPlugin.cxx
View file @
93deb844
...
...
@@ -39,13 +39,13 @@
* parent_stream so tar plugin fetches file data from gzip
* plugin and gzip fetches file from disk
*/
static
struct
input_s
tream
*
static
InputS
tream
*
input_archive_open
(
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
{
const
struct
archive_plugin
*
arplug
;
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
if
(
!
PathTraits
::
IsAbsoluteFS
(
pathname
))
return
NULL
;
...
...
src/input/CdioParanoiaInputPlugin.cxx
View file @
93deb844
...
...
@@ -43,7 +43,7 @@
#include <cdio/cd_types.h>
struct
CdioParanoiaInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
cdrom_drive_t
*
drv
;
CdIo_t
*
cdio
;
...
...
@@ -78,7 +78,7 @@ struct CdioParanoiaInputStream {
static
constexpr
Domain
cdio_domain
(
"cdio"
);
static
void
input_cdio_close
(
struct
input_s
tream
*
is
)
input_cdio_close
(
InputS
tream
*
is
)
{
CdioParanoiaInputStream
*
i
=
(
CdioParanoiaInputStream
*
)
is
;
...
...
@@ -149,7 +149,7 @@ cdio_detect_device(void)
return
path
;
}
static
struct
input_s
tream
*
static
InputS
tream
*
input_cdio_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -247,7 +247,7 @@ input_cdio_open(const char *uri,
}
static
bool
input_cdio_seek
(
struct
input_s
tream
*
is
,
input_cdio_seek
(
InputS
tream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
CdioParanoiaInputStream
*
cis
=
(
CdioParanoiaInputStream
*
)
is
;
...
...
@@ -284,7 +284,7 @@ input_cdio_seek(struct input_stream *is,
}
static
size_t
input_cdio_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
length
,
input_cdio_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
length
,
Error
&
error
)
{
CdioParanoiaInputStream
*
cis
=
(
CdioParanoiaInputStream
*
)
is
;
...
...
@@ -354,7 +354,7 @@ input_cdio_read(struct input_stream *is, void *ptr, size_t length,
}
static
bool
input_cdio_eof
(
struct
input_s
tream
*
is
)
input_cdio_eof
(
InputS
tream
*
is
)
{
CdioParanoiaInputStream
*
cis
=
(
CdioParanoiaInputStream
*
)
is
;
...
...
src/input/CurlInputPlugin.cxx
View file @
93deb844
...
...
@@ -131,7 +131,7 @@ public:
};
struct
input_curl
{
struct
input_s
tream
base
;
InputS
tream
base
;
/* some buffers which were passed to libcurl, which we have
too free */
...
...
@@ -162,7 +162,7 @@ struct input_curl {
std
::
string
meta_name
;
/** the tag object ready to be requested via
input_s
tream::ReadTag() */
InputS
tream::ReadTag() */
Tag
*
tag
;
Error
postponed_error
;
...
...
@@ -636,7 +636,7 @@ input_curl::~input_curl()
}
static
bool
input_curl_check
(
struct
input_s
tream
*
is
,
Error
&
error
)
input_curl_check
(
InputS
tream
*
is
,
Error
&
error
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
...
...
@@ -650,7 +650,7 @@ input_curl_check(struct input_stream *is, Error &error)
}
static
Tag
*
input_curl_tag
(
struct
input_s
tream
*
is
)
input_curl_tag
(
InputS
tream
*
is
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
Tag
*
tag
=
c
->
tag
;
...
...
@@ -741,7 +741,7 @@ copy_icy_tag(struct input_curl *c)
}
static
bool
input_curl_available
(
struct
input_s
tream
*
is
)
input_curl_available
(
InputS
tream
*
is
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
...
...
@@ -750,7 +750,7 @@ input_curl_available(struct input_stream *is)
}
static
size_t
input_curl_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
input_curl_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
...
...
@@ -795,7 +795,7 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size,
}
static
void
input_curl_close
(
struct
input_s
tream
*
is
)
input_curl_close
(
InputS
tream
*
is
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
...
...
@@ -803,7 +803,7 @@ input_curl_close(struct input_stream *is)
}
static
bool
input_curl_eof
(
gcc_unused
struct
input_s
tream
*
is
)
input_curl_eof
(
gcc_unused
InputS
tream
*
is
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
...
...
@@ -976,7 +976,7 @@ input_curl_easy_init(struct input_curl *c, Error &error)
}
static
bool
input_curl_seek
(
struct
input_s
tream
*
is
,
InputPlugin
::
offset_type
offset
,
input_curl_seek
(
InputS
tream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
...
...
@@ -1080,7 +1080,7 @@ input_curl_seek(struct input_stream *is, InputPlugin::offset_type offset,
return
true
;
}
static
struct
input_s
tream
*
static
InputS
tream
*
input_curl_open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
{
...
...
src/input/DespotifyInputPlugin.cxx
View file @
93deb844
...
...
@@ -38,7 +38,7 @@ extern "C" {
#include <stdio.h>
struct
DespotifyInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
struct
despotify_session
*
session
;
struct
ds_track
*
track
;
...
...
@@ -121,7 +121,7 @@ static void callback(gcc_unused struct despotify_session* ds,
}
static
struct
input_s
tream
*
static
InputS
tream
*
input_despotify_open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
,
gcc_unused
Error
&
error
)
...
...
@@ -171,7 +171,7 @@ input_despotify_open(const char *url,
}
static
size_t
input_despotify_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
input_despotify_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
gcc_unused
Error
&
error
)
{
DespotifyInputStream
*
ctx
=
(
DespotifyInputStream
*
)
is
;
...
...
@@ -191,7 +191,7 @@ input_despotify_read(struct input_stream *is, void *ptr, size_t size,
}
static
void
input_despotify_close
(
struct
input_s
tream
*
is
)
input_despotify_close
(
InputS
tream
*
is
)
{
DespotifyInputStream
*
ctx
=
(
DespotifyInputStream
*
)
is
;
...
...
@@ -200,7 +200,7 @@ input_despotify_close(struct input_stream *is)
}
static
bool
input_despotify_eof
(
struct
input_s
tream
*
is
)
input_despotify_eof
(
InputS
tream
*
is
)
{
DespotifyInputStream
*
ctx
=
(
DespotifyInputStream
*
)
is
;
...
...
@@ -208,7 +208,7 @@ input_despotify_eof(struct input_stream *is)
}
static
Tag
*
input_despotify_tag
(
struct
input_s
tream
*
is
)
input_despotify_tag
(
InputS
tream
*
is
)
{
DespotifyInputStream
*
ctx
=
(
DespotifyInputStream
*
)
is
;
Tag
*
tag
=
ctx
->
tag
;
...
...
src/input/FfmpegInputPlugin.cxx
View file @
93deb844
...
...
@@ -36,7 +36,7 @@ extern "C" {
#include <glib.h>
struct
FfmpegInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
AVIOContext
*
h
;
...
...
@@ -86,7 +86,7 @@ input_ffmpeg_init(gcc_unused const config_param ¶m,
return
true
;
}
static
struct
input_s
tream
*
static
InputS
tream
*
input_ffmpeg_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -112,7 +112,7 @@ input_ffmpeg_open(const char *uri,
}
static
size_t
input_ffmpeg_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
input_ffmpeg_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
FfmpegInputStream
*
i
=
(
FfmpegInputStream
*
)
is
;
...
...
@@ -131,7 +131,7 @@ input_ffmpeg_read(struct input_stream *is, void *ptr, size_t size,
}
static
void
input_ffmpeg_close
(
struct
input_s
tream
*
is
)
input_ffmpeg_close
(
InputS
tream
*
is
)
{
FfmpegInputStream
*
i
=
(
FfmpegInputStream
*
)
is
;
...
...
@@ -139,7 +139,7 @@ input_ffmpeg_close(struct input_stream *is)
}
static
bool
input_ffmpeg_eof
(
struct
input_s
tream
*
is
)
input_ffmpeg_eof
(
InputS
tream
*
is
)
{
FfmpegInputStream
*
i
=
(
FfmpegInputStream
*
)
is
;
...
...
@@ -147,7 +147,7 @@ input_ffmpeg_eof(struct input_stream *is)
}
static
bool
input_ffmpeg_seek
(
struct
input_s
tream
*
is
,
InputPlugin
::
offset_type
offset
,
input_ffmpeg_seek
(
InputS
tream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
...
...
src/input/FileInputPlugin.cxx
View file @
93deb844
...
...
@@ -36,7 +36,7 @@
static
constexpr
Domain
file_domain
(
"file"
);
struct
FileInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
int
fd
;
...
...
@@ -54,7 +54,7 @@ struct FileInputStream {
}
};
static
struct
input_s
tream
*
static
InputS
tream
*
input_file_open
(
const
char
*
filename
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -96,7 +96,7 @@ input_file_open(const char *filename,
}
static
bool
input_file_seek
(
struct
input_s
tream
*
is
,
InputPlugin
::
offset_type
offset
,
input_file_seek
(
InputS
tream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
...
...
@@ -113,7 +113,7 @@ input_file_seek(struct input_stream *is, InputPlugin::offset_type offset,
}
static
size_t
input_file_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
input_file_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
FileInputStream
*
fis
=
(
FileInputStream
*
)
is
;
...
...
@@ -130,7 +130,7 @@ input_file_read(struct input_stream *is, void *ptr, size_t size,
}
static
void
input_file_close
(
struct
input_s
tream
*
is
)
input_file_close
(
InputS
tream
*
is
)
{
FileInputStream
*
fis
=
(
FileInputStream
*
)
is
;
...
...
@@ -138,7 +138,7 @@ input_file_close(struct input_stream *is)
}
static
bool
input_file_eof
(
struct
input_s
tream
*
is
)
input_file_eof
(
InputS
tream
*
is
)
{
return
is
->
offset
>=
is
->
size
;
}
...
...
src/input/MmsInputPlugin.cxx
View file @
93deb844
...
...
@@ -31,7 +31,7 @@
#include <errno.h>
struct
MmsInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
mmsx_t
*
mms
;
...
...
@@ -56,7 +56,7 @@ struct MmsInputStream {
static
constexpr
Domain
mms_domain
(
"mms"
);
static
struct
input_s
tream
*
static
InputS
tream
*
input_mms_open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
...
...
@@ -78,7 +78,7 @@ input_mms_open(const char *url,
}
static
size_t
input_mms_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
input_mms_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
MmsInputStream
*
m
=
(
MmsInputStream
*
)
is
;
...
...
@@ -99,7 +99,7 @@ input_mms_read(struct input_stream *is, void *ptr, size_t size,
}
static
void
input_mms_close
(
struct
input_s
tream
*
is
)
input_mms_close
(
InputS
tream
*
is
)
{
MmsInputStream
*
m
=
(
MmsInputStream
*
)
is
;
...
...
@@ -107,7 +107,7 @@ input_mms_close(struct input_stream *is)
}
static
bool
input_mms_eof
(
struct
input_s
tream
*
is
)
input_mms_eof
(
InputS
tream
*
is
)
{
MmsInputStream
*
m
=
(
MmsInputStream
*
)
is
;
...
...
src/input/RewindInputPlugin.cxx
View file @
93deb844
...
...
@@ -30,9 +30,9 @@
extern
const
InputPlugin
rewind_input_plugin
;
struct
RewindInputStream
{
struct
input_s
tream
base
;
InputS
tream
base
;
struct
input_s
tream
*
input
;
InputS
tream
*
input
;
/**
* The read position within the buffer. Undefined as long as
...
...
@@ -55,7 +55,7 @@ struct RewindInputStream {
*/
char
buffer
[
64
*
1024
];
RewindInputStream
(
input_s
tream
*
_input
)
RewindInputStream
(
InputS
tream
*
_input
)
:
base
(
rewind_input_plugin
,
_input
->
uri
.
c_str
(),
_input
->
mutex
,
_input
->
cond
),
input
(
_input
),
tail
(
0
)
{
...
...
@@ -80,8 +80,8 @@ struct RewindInputStream {
* attributes.
*/
void
CopyAttributes
()
{
struct
input_s
tream
*
dest
=
&
base
;
const
struct
input_s
tream
*
src
=
input
;
InputS
tream
*
dest
=
&
base
;
const
InputS
tream
*
src
=
input
;
assert
(
dest
!=
src
);
...
...
@@ -98,7 +98,7 @@ struct RewindInputStream {
};
static
void
input_rewind_close
(
struct
input_s
tream
*
is
)
input_rewind_close
(
InputS
tream
*
is
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -106,7 +106,7 @@ input_rewind_close(struct input_stream *is)
}
static
bool
input_rewind_check
(
struct
input_s
tream
*
is
,
Error
&
error
)
input_rewind_check
(
InputS
tream
*
is
,
Error
&
error
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -114,7 +114,7 @@ input_rewind_check(struct input_stream *is, Error &error)
}
static
void
input_rewind_update
(
struct
input_s
tream
*
is
)
input_rewind_update
(
InputS
tream
*
is
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -123,7 +123,7 @@ input_rewind_update(struct input_stream *is)
}
static
Tag
*
input_rewind_tag
(
struct
input_s
tream
*
is
)
input_rewind_tag
(
InputS
tream
*
is
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -131,7 +131,7 @@ input_rewind_tag(struct input_stream *is)
}
static
bool
input_rewind_available
(
struct
input_s
tream
*
is
)
input_rewind_available
(
InputS
tream
*
is
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -139,7 +139,7 @@ input_rewind_available(struct input_stream *is)
}
static
size_t
input_rewind_read
(
struct
input_s
tream
*
is
,
void
*
ptr
,
size_t
size
,
input_rewind_read
(
InputS
tream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -182,7 +182,7 @@ input_rewind_read(struct input_stream *is, void *ptr, size_t size,
}
static
bool
input_rewind_eof
(
struct
input_s
tream
*
is
)
input_rewind_eof
(
InputS
tream
*
is
)
{
RewindInputStream
*
r
=
(
RewindInputStream
*
)
is
;
...
...
@@ -190,7 +190,7 @@ input_rewind_eof(struct input_stream *is)
}
static
bool
input_rewind_seek
(
struct
input_s
tream
*
is
,
InputPlugin
::
offset_type
offset
,
input_rewind_seek
(
InputS
tream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
...
...
@@ -237,8 +237,8 @@ const InputPlugin rewind_input_plugin = {
input_rewind_seek
,
};
struct
input_s
tream
*
input_rewind_open
(
struct
input_s
tream
*
is
)
InputS
tream
*
input_rewind_open
(
InputS
tream
*
is
)
{
assert
(
is
!=
NULL
);
assert
(
is
->
offset
==
0
);
...
...
src/input/RewindInputPlugin.hxx
View file @
93deb844
...
...
@@ -29,9 +29,9 @@
#include "check.h"
struct
input_s
tream
;
struct
InputS
tream
;
struct
input_s
tream
*
input_rewind_open
(
struct
input_s
tream
*
is
);
InputS
tream
*
input_rewind_open
(
InputS
tream
*
is
);
#endif
src/playlist/AsxPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -205,7 +205,7 @@ asx_parser_destroy(gpointer data)
*/
static
SongEnumerator
*
asx_open_stream
(
struct
input_stream
*
is
)
asx_open_stream
(
InputStream
&
is
)
{
AsxParser
parser
;
GMarkupParseContext
*
context
;
...
...
@@ -222,7 +222,7 @@ asx_open_stream(struct input_stream *is)
&
parser
,
asx_parser_destroy
);
while
(
true
)
{
nbytes
=
is
->
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
nbytes
=
is
.
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
if
(
nbytes
==
0
)
{
if
(
error2
.
IsDefined
())
{
g_markup_parse_context_free
(
context
);
...
...
src/playlist/CuePlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -30,12 +30,12 @@
#include <string.h>
class
CuePlaylist
final
:
public
SongEnumerator
{
struct
input_stream
*
is
;
InputStream
&
is
;
TextInputStream
tis
;
CueParser
parser
;
public
:
CuePlaylist
(
struct
input_stream
*
_is
)
CuePlaylist
(
InputStream
&
_is
)
:
is
(
_is
),
tis
(
is
)
{
}
...
...
@@ -43,7 +43,7 @@ class CuePlaylist final : public SongEnumerator {
};
static
SongEnumerator
*
cue_playlist_open_stream
(
struct
input_stream
*
is
)
cue_playlist_open_stream
(
InputStream
&
is
)
{
return
new
CuePlaylist
(
is
);
}
...
...
src/playlist/ExtM3uPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -35,7 +35,7 @@ class ExtM3uPlaylist final : public SongEnumerator {
TextInputStream
tis
;
public
:
ExtM3uPlaylist
(
input_stream
*
is
)
ExtM3uPlaylist
(
InputStream
&
is
)
:
tis
(
is
)
{
}
...
...
@@ -49,7 +49,7 @@ public:
};
static
SongEnumerator
*
extm3u_open_stream
(
struct
input_stream
*
is
)
extm3u_open_stream
(
InputStream
&
is
)
{
ExtM3uPlaylist
*
playlist
=
new
ExtM3uPlaylist
(
is
);
...
...
src/playlist/M3uPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -29,7 +29,7 @@ class M3uPlaylist final : public SongEnumerator {
TextInputStream
tis
;
public
:
M3uPlaylist
(
input_stream
*
is
)
M3uPlaylist
(
InputStream
&
is
)
:
tis
(
is
)
{
}
...
...
@@ -37,7 +37,7 @@ public:
};
static
SongEnumerator
*
m3u_open_stream
(
struct
input_stream
*
is
)
m3u_open_stream
(
InputStream
&
is
)
{
return
new
M3uPlaylist
(
is
);
}
...
...
src/playlist/PlsPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -107,7 +107,7 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
}
static
SongEnumerator
*
pls_open_stream
(
struct
input_stream
*
is
)
pls_open_stream
(
InputStream
&
is
)
{
GError
*
error
=
NULL
;
Error
error2
;
...
...
@@ -119,7 +119,7 @@ pls_open_stream(struct input_stream *is)
std
::
string
kf_data
;
do
{
nbytes
=
is
->
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
nbytes
=
is
.
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
if
(
nbytes
==
0
)
{
if
(
error2
.
IsDefined
())
{
LogError
(
error2
);
...
...
src/playlist/RssPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -202,7 +202,7 @@ rss_parser_destroy(gpointer data)
*/
static
SongEnumerator
*
rss_open_stream
(
struct
input_stream
*
is
)
rss_open_stream
(
InputStream
&
is
)
{
RssParser
parser
;
GMarkupParseContext
*
context
;
...
...
@@ -219,7 +219,7 @@ rss_open_stream(struct input_stream *is)
&
parser
,
rss_parser_destroy
);
while
(
true
)
{
nbytes
=
is
->
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
nbytes
=
is
.
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
if
(
nbytes
==
0
)
{
if
(
error2
.
IsDefined
())
{
g_markup_parse_context_free
(
context
);
...
...
src/playlist/SoundCloudPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -253,7 +253,7 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
unsigned
char
*
ubuffer
=
(
unsigned
char
*
)
buffer
;
Error
error
;
input_stream
*
input_stream
=
input_s
tream
::
Open
(
url
,
mutex
,
cond
,
InputStream
*
input_stream
=
InputS
tream
::
Open
(
url
,
mutex
,
cond
,
error
);
if
(
input_stream
==
NULL
)
{
if
(
error
.
IsDefined
())
...
...
src/playlist/XspfPlaylistPlugin.cxx
View file @
93deb844
...
...
@@ -220,7 +220,7 @@ xspf_parser_destroy(gpointer data)
*/
static
SongEnumerator
*
xspf_open_stream
(
struct
input_stream
*
is
)
xspf_open_stream
(
InputStream
&
is
)
{
XspfParser
parser
;
GMarkupParseContext
*
context
;
...
...
@@ -237,7 +237,7 @@ xspf_open_stream(struct input_stream *is)
&
parser
,
xspf_parser_destroy
);
while
(
true
)
{
nbytes
=
is
->
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
nbytes
=
is
.
LockRead
(
buffer
,
sizeof
(
buffer
),
error2
);
if
(
nbytes
==
0
)
{
if
(
error2
.
IsDefined
())
{
g_markup_parse_context_free
(
context
);
...
...
test/dump_playlist.cxx
View file @
93deb844
...
...
@@ -85,11 +85,10 @@ decoder_seek_error(gcc_unused Decoder &decoder)
size_t
decoder_read
(
gcc_unused
Decoder
*
decoder
,
struct
input_stream
*
is
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
{
Error
error
;
return
is
->
LockRead
(
buffer
,
length
,
error
);
return
is
.
LockRead
(
buffer
,
length
,
IgnoreError
());
}
void
...
...
@@ -100,7 +99,7 @@ decoder_timestamp(gcc_unused Decoder &decoder,
DecoderCommand
decoder_data
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
struct
input_s
tream
*
is
,
gcc_unused
InputS
tream
*
is
,
const
void
*
data
,
size_t
datalen
,
gcc_unused
uint16_t
kbit_rate
)
{
...
...
@@ -110,7 +109,7 @@ decoder_data(gcc_unused Decoder &decoder,
DecoderCommand
decoder_tag
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
struct
input_s
tream
*
is
,
gcc_unused
InputS
tream
*
is
,
gcc_unused
Tag
&&
tag
)
{
return
DecoderCommand
::
NONE
;
...
...
@@ -143,7 +142,7 @@ decoder_mixramp(gcc_unused Decoder &decoder,
int
main
(
int
argc
,
char
**
argv
)
{
const
char
*
uri
;
struct
input_s
tream
*
is
=
NULL
;
InputS
tream
*
is
=
NULL
;
Song
*
song
;
if
(
argc
!=
3
)
{
...
...
@@ -192,12 +191,12 @@ int main(int argc, char **argv)
if
(
playlist
==
NULL
)
{
/* open the stream and wait until it becomes ready */
is
=
input_s
tream
::
Open
(
uri
,
mutex
,
cond
,
error
);
is
=
InputS
tream
::
Open
(
uri
,
mutex
,
cond
,
error
);
if
(
is
==
NULL
)
{
if
(
error
.
IsDefined
())
LogError
(
error
);
else
g_printerr
(
"
input_s
tream::Open() failed
\n
"
);
g_printerr
(
"
InputS
tream::Open() failed
\n
"
);
return
2
;
}
...
...
@@ -205,7 +204,7 @@ int main(int argc, char **argv)
/* open the playlist */
playlist
=
playlist_list_open_stream
(
is
,
uri
);
playlist
=
playlist_list_open_stream
(
*
is
,
uri
);
if
(
playlist
==
NULL
)
{
is
->
Close
();
g_printerr
(
"Failed to open playlist
\n
"
);
...
...
test/dump_text_file.cxx
View file @
93deb844
...
...
@@ -57,46 +57,45 @@ dump_text_file(TextInputStream &is)
}
static
int
dump_input_stream
(
struct
input_stream
*
is
)
dump_input_stream
(
InputStream
&
is
)
{
Error
error
;
is
->
Lock
();
is
.
Lock
();
/* wait until the stream becomes ready */
is
->
WaitReady
();
is
.
WaitReady
();
if
(
!
is
->
Check
(
error
))
{
if
(
!
is
.
Check
(
error
))
{
LogError
(
error
);
is
->
Unlock
();
is
.
Unlock
();
return
EXIT_FAILURE
;
}
/* read data and tags from the stream */
is
->
Unlock
();
is
.
Unlock
();
{
TextInputStream
tis
(
is
);
dump_text_file
(
tis
);
}
is
->
Lock
();
is
.
Lock
();
if
(
!
is
->
Check
(
error
))
{
if
(
!
is
.
Check
(
error
))
{
LogError
(
error
);
is
->
Unlock
();
is
.
Unlock
();
return
EXIT_FAILURE
;
}
is
->
Unlock
();
is
.
Unlock
();
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
input_stream
*
is
;
int
ret
;
if
(
argc
!=
2
)
{
...
...
@@ -134,9 +133,9 @@ int main(int argc, char **argv)
Mutex
mutex
;
Cond
cond
;
is
=
input_s
tream
::
Open
(
argv
[
1
],
mutex
,
cond
,
error
);
InputStream
*
is
=
InputS
tream
::
Open
(
argv
[
1
],
mutex
,
cond
,
error
);
if
(
is
!=
NULL
)
{
ret
=
dump_input_stream
(
is
);
ret
=
dump_input_stream
(
*
is
);
is
->
Close
();
}
else
{
if
(
error
.
IsDefined
())
...
...
test/read_tags.cxx
View file @
93deb844
...
...
@@ -73,11 +73,10 @@ decoder_seek_error(gcc_unused Decoder &decoder)
size_t
decoder_read
(
gcc_unused
Decoder
*
decoder
,
struct
input_stream
*
is
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
{
Error
error
;
return
is
->
LockRead
(
buffer
,
length
,
error
);
return
is
.
LockRead
(
buffer
,
length
,
IgnoreError
());
}
void
...
...
@@ -88,7 +87,7 @@ decoder_timestamp(gcc_unused Decoder &decoder,
DecoderCommand
decoder_data
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
struct
input_s
tream
*
is
,
gcc_unused
InputS
tream
*
is
,
const
void
*
data
,
size_t
datalen
,
gcc_unused
uint16_t
kbit_rate
)
{
...
...
@@ -98,7 +97,7 @@ decoder_data(gcc_unused Decoder &decoder,
DecoderCommand
decoder_tag
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
struct
input_s
tream
*
is
,
gcc_unused
InputS
tream
*
is
,
gcc_unused
Tag
&&
tag
)
{
return
DecoderCommand
::
NONE
;
...
...
@@ -189,7 +188,7 @@ int main(int argc, char **argv)
Mutex
mutex
;
Cond
cond
;
input_stream
*
is
=
input_s
tream
::
Open
(
path
,
mutex
,
cond
,
InputStream
*
is
=
InputS
tream
::
Open
(
path
,
mutex
,
cond
,
error
);
if
(
is
==
NULL
)
{
g_printerr
(
"Failed to open %s: %s
\n
"
,
...
...
test/run_decoder.cxx
View file @
93deb844
...
...
@@ -94,10 +94,10 @@ decoder_seek_error(gcc_unused Decoder &decoder)
size_t
decoder_read
(
gcc_unused
Decoder
*
decoder
,
struct
input_stream
*
is
,
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
{
return
is
->
LockRead
(
buffer
,
length
,
IgnoreError
());
return
is
.
LockRead
(
buffer
,
length
,
IgnoreError
());
}
void
...
...
@@ -108,7 +108,7 @@ decoder_timestamp(gcc_unused Decoder &decoder,
DecoderCommand
decoder_data
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
struct
input_s
tream
*
is
,
gcc_unused
InputS
tream
*
is
,
const
void
*
data
,
size_t
datalen
,
gcc_unused
uint16_t
kbit_rate
)
{
...
...
@@ -118,7 +118,7 @@ decoder_data(gcc_unused Decoder &decoder,
DecoderCommand
decoder_tag
(
gcc_unused
Decoder
&
decoder
,
gcc_unused
struct
input_s
tream
*
is
,
gcc_unused
InputS
tream
*
is
,
gcc_unused
Tag
&&
tag
)
{
return
DecoderCommand
::
NONE
;
...
...
@@ -192,13 +192,13 @@ int main(int argc, char **argv)
Mutex
mutex
;
Cond
cond
;
input_s
tream
*
is
=
input_s
tream
::
Open
(
decoder
.
uri
,
mutex
,
cond
,
error
);
InputS
tream
*
is
=
InputS
tream
::
Open
(
decoder
.
uri
,
mutex
,
cond
,
error
);
if
(
is
==
NULL
)
{
if
(
error
.
IsDefined
())
LogError
(
error
);
else
g_printerr
(
"
input_s
tream::Open() failed
\n
"
);
g_printerr
(
"
InputS
tream::Open() failed
\n
"
);
return
1
;
}
...
...
test/run_input.cxx
View file @
93deb844
...
...
@@ -49,7 +49,7 @@ my_log_func(const gchar *log_domain, gcc_unused GLogLevelFlags log_level,
}
static
int
dump_input_stream
(
struct
input_s
tream
*
is
)
dump_input_stream
(
InputS
tream
*
is
)
{
Error
error
;
char
buffer
[
4096
];
...
...
@@ -110,7 +110,7 @@ dump_input_stream(struct input_stream *is)
int
main
(
int
argc
,
char
**
argv
)
{
Error
error
;
struct
input_s
tream
*
is
;
InputS
tream
*
is
;
int
ret
;
if
(
argc
!=
2
)
{
...
...
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
Mutex
mutex
;
Cond
cond
;
is
=
input_s
tream
::
Open
(
argv
[
1
],
mutex
,
cond
,
error
);
is
=
InputS
tream
::
Open
(
argv
[
1
],
mutex
,
cond
,
error
);
if
(
is
!=
NULL
)
{
ret
=
dump_input_stream
(
is
);
is
->
Close
();
...
...
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