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