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
dbc7e9ba
Commit
dbc7e9ba
authored
Oct 26, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input_stream: no CamelCase
Renamed all functions and variables.
parent
97a9c7a8
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
158 additions
and
160 deletions
+158
-160
_ogg_common.c
src/decoder/_ogg_common.c
+2
-2
aac_plugin.c
src/decoder/aac_plugin.c
+5
-5
ffmpeg_plugin.c
src/decoder/ffmpeg_plugin.c
+6
-6
flac_plugin.c
src/decoder/flac_plugin.c
+3
-3
mp3_plugin.c
src/decoder/mp3_plugin.c
+20
-20
mp4_plugin.c
src/decoder/mp4_plugin.c
+7
-7
mpc_plugin.c
src/decoder/mpc_plugin.c
+4
-4
oggflac_plugin.c
src/decoder/oggflac_plugin.c
+6
-6
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+2
-2
wavpack_plugin.c
src/decoder/wavpack_plugin.c
+10
-10
decoder_api.c
src/decoder_api.c
+3
-3
decoder_thread.c
src/decoder_thread.c
+5
-5
input_file.c
src/input_file.c
+36
-35
input_file.h
src/input_file.h
+2
-1
input_stream.c
src/input_stream.c
+31
-31
input_stream.h
src/input_stream.h
+15
-19
main.c
src/main.c
+1
-1
No files found.
src/decoder/_ogg_common.c
View file @
dbc7e9ba
...
...
@@ -31,12 +31,12 @@ ogg_stream_type ogg_stream_type_detect(struct input_stream *inStream)
unsigned
char
buf
[
41
];
size_t
r
;
seekInputStream
(
inStream
,
0
,
SEEK_SET
);
input_stream_seek
(
inStream
,
0
,
SEEK_SET
);
r
=
decoder_read
(
NULL
,
inStream
,
buf
,
sizeof
(
buf
));
if
(
r
>
0
)
seekInputStream
(
inStream
,
0
,
SEEK_SET
);
input_stream_seek
(
inStream
,
0
,
SEEK_SET
);
if
(
r
>=
32
&&
memcmp
(
buf
,
"OggS"
,
4
)
==
0
&&
(
(
memcmp
(
buf
+
29
,
"FLAC"
,
4
)
==
0
...
...
src/decoder/aac_plugin.c
View file @
dbc7e9ba
...
...
@@ -67,7 +67,7 @@ static void fillAacBuffer(AacBuffer * b)
bread
=
decoder_read
(
b
->
decoder
,
b
->
inStream
,
(
void
*
)(
b
->
buffer
+
b
->
bytesIntoBuffer
),
rest
);
if
(
bread
==
0
&&
input
StreamAtEOF
(
b
->
inStream
))
if
(
bread
==
0
&&
input
_stream_eof
(
b
->
inStream
))
b
->
atEof
=
1
;
b
->
bytesIntoBuffer
+=
bread
;
}
...
...
@@ -215,7 +215,7 @@ static void aac_parse_header(AacBuffer * b, float *length)
if
(
b
->
bytesIntoBuffer
>=
2
&&
(
b
->
buffer
[
0
]
==
0xFF
)
&&
((
b
->
buffer
[
1
]
&
0xF6
)
==
0xF0
))
{
adtsParse
(
b
,
length
);
seekInputStream
(
b
->
inStream
,
tagsize
,
SEEK_SET
);
input_stream_seek
(
b
->
inStream
,
tagsize
,
SEEK_SET
);
b
->
bytesIntoBuffer
=
0
;
b
->
bytesConsumed
=
0
;
...
...
@@ -257,7 +257,7 @@ static float getAacFloatTotalTime(char *file)
struct
input_stream
inStream
;
long
bread
;
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
return
-
1
;
initAacBuffer
(
&
b
,
NULL
,
&
inStream
);
...
...
@@ -285,7 +285,7 @@ static float getAacFloatTotalTime(char *file)
if
(
b
.
buffer
)
free
(
b
.
buffer
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
length
;
}
...
...
@@ -461,7 +461,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if
((
totalTime
=
getAacFloatTotalTime
(
path
))
<
0
)
return
-
1
;
if
(
openInputStream
(
&
inStream
,
path
)
<
0
)
if
(
input_stream_open
(
&
inStream
,
path
)
<
0
)
return
-
1
;
initAacBuffer
(
&
b
,
mpd_decoder
,
&
inStream
);
...
...
src/decoder/ffmpeg_plugin.c
View file @
dbc7e9ba
...
...
@@ -85,10 +85,10 @@ static int mpdurl_read(URLContext *h, unsigned char *buf, int size)
int
ret
;
FopsHelper
*
base
=
(
FopsHelper
*
)
h
->
priv_data
;
while
(
1
)
{
ret
=
readFromInputStream
(
base
->
input
,
(
void
*
)
buf
,
size
);
ret
=
input_stream_read
(
base
->
input
,
(
void
*
)
buf
,
size
);
if
(
ret
==
0
)
{
DEBUG
(
"ret 0
\n
"
);
if
(
input
StreamAtEOF
(
base
->
input
)
||
if
(
input
_stream_eof
(
base
->
input
)
||
(
base
->
decoder
&&
decoder_get_command
(
base
->
decoder
)
!=
DECODE_COMMAND_NONE
))
{
DEBUG
(
"eof stream
\n
"
);
...
...
@@ -107,7 +107,7 @@ static int64_t mpdurl_seek(URLContext *h, int64_t pos, int whence)
{
FopsHelper
*
base
=
(
FopsHelper
*
)
h
->
priv_data
;
if
(
whence
!=
AVSEEK_SIZE
)
{
//only ftell
(
void
)
seekInputStream
(
base
->
input
,
pos
,
whence
);
(
void
)
input_stream_seek
(
base
->
input
,
pos
,
whence
);
}
return
base
->
input
->
offset
;
}
...
...
@@ -116,7 +116,7 @@ static int mpdurl_close(URLContext *h)
{
FopsHelper
*
base
=
(
FopsHelper
*
)
h
->
priv_data
;
if
(
base
&&
base
->
input
->
seekable
)
{
(
void
)
seekInputStream
(
base
->
input
,
0
,
SEEK_SET
);
(
void
)
input_stream_seek
(
base
->
input
,
0
,
SEEK_SET
);
}
h
->
priv_data
=
0
;
return
0
;
...
...
@@ -360,7 +360,7 @@ static struct tag *ffmpeg_tag(char *file)
int
ret
;
struct
tag
*
tag
=
NULL
;
if
(
openInputStream
(
&
input
,
file
)
<
0
)
{
if
(
input_stream_open
(
&
input
,
file
)
<
0
)
{
ERROR
(
"failed to open %s
\n
"
,
file
);
return
NULL
;
}
...
...
@@ -375,7 +375,7 @@ static struct tag *ffmpeg_tag(char *file)
tag
=
NULL
;
}
closeInputStream
(
&
input
);
input_stream_close
(
&
input
);
return
tag
;
}
...
...
src/decoder/flac_plugin.c
View file @
dbc7e9ba
...
...
@@ -37,7 +37,7 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec,
if
(
r
==
0
)
{
if
(
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_NONE
||
input
StreamAtEOF
(
data
->
inStream
))
input
_stream_eof
(
data
->
inStream
))
return
flac_read_status_eof
;
else
return
flac_read_status_abort
;
...
...
@@ -52,7 +52,7 @@ static flac_seek_status flacSeek(mpd_unused const flac_decoder * flacDec,
{
FlacData
*
data
=
(
FlacData
*
)
fdata
;
if
(
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
return
flac_seek_status_error
;
}
...
...
@@ -87,7 +87,7 @@ static FLAC__bool flacEOF(mpd_unused const flac_decoder * flacDec, void *fdata)
return
(
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_NONE
&&
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_SEEK
)
||
input
StreamAtEOF
(
data
->
inStream
);
input
_stream_eof
(
data
->
inStream
);
}
static
void
flacError
(
mpd_unused
const
flac_decoder
*
dec
,
...
...
src/decoder/mp3_plugin.c
View file @
dbc7e9ba
...
...
@@ -158,7 +158,7 @@ static void initMp3DecodeData(mp3DecodeData * data, struct decoder *decoder,
static
int
seekMp3InputBuffer
(
mp3DecodeData
*
data
,
long
offset
)
{
if
(
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
return
-
1
;
}
...
...
@@ -757,7 +757,7 @@ static int getMp3TotalTime(char *file)
mp3DecodeData
data
;
int
ret
;
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
return
-
1
;
initMp3DecodeData
(
&
data
,
NULL
,
&
inStream
);
if
(
decodeFirstFrame
(
&
data
,
NULL
,
NULL
)
<
0
)
...
...
@@ -765,7 +765,7 @@ static int getMp3TotalTime(char *file)
else
ret
=
data
.
totalTime
+
0
.
5
;
mp3DecodeDataFinalize
(
&
data
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
ret
;
}
...
...
@@ -854,16 +854,16 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
return
DECODE_BREAK
;
}
if
(
data
->
inStream
->
meta
T
itle
)
{
if
(
data
->
inStream
->
meta
_t
itle
)
{
struct
tag
*
tag
=
tag_new
();
if
(
data
->
inStream
->
meta
N
ame
)
{
if
(
data
->
inStream
->
meta
_n
ame
)
{
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
data
->
inStream
->
meta
N
ame
);
data
->
inStream
->
meta
_n
ame
);
}
tag_add_item
(
tag
,
TAG_ITEM_TITLE
,
data
->
inStream
->
meta
T
itle
);
free
(
data
->
inStream
->
meta
T
itle
);
data
->
inStream
->
meta
T
itle
=
NULL
;
data
->
inStream
->
meta
_t
itle
);
free
(
data
->
inStream
->
meta
_t
itle
);
data
->
inStream
->
meta
_t
itle
=
NULL
;
tag_free
(
tag
);
}
...
...
@@ -1009,27 +1009,27 @@ mp3_decode(struct decoder * decoder, struct input_stream *inStream)
initAudioFormatFromMp3DecodeData
(
&
data
,
&
audio_format
);
if
(
inStream
->
meta
T
itle
)
{
if
(
inStream
->
meta
_t
itle
)
{
if
(
tag
)
tag_free
(
tag
);
tag
=
tag_new
();
tag_add_item
(
tag
,
TAG_ITEM_TITLE
,
inStream
->
meta
T
itle
);
free
(
inStream
->
meta
T
itle
);
inStream
->
meta
T
itle
=
NULL
;
if
(
inStream
->
meta
N
ame
)
{
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
inStream
->
meta
N
ame
);
tag_add_item
(
tag
,
TAG_ITEM_TITLE
,
inStream
->
meta
_t
itle
);
free
(
inStream
->
meta
_t
itle
);
inStream
->
meta
_t
itle
=
NULL
;
if
(
inStream
->
meta
_n
ame
)
{
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
inStream
->
meta
_n
ame
);
}
tag_free
(
tag
);
}
else
if
(
tag
)
{
if
(
inStream
->
meta
N
ame
)
{
if
(
inStream
->
meta
_n
ame
)
{
tag_clear_items_by_type
(
tag
,
TAG_ITEM_NAME
);
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
inStream
->
meta
N
ame
);
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
inStream
->
meta
_n
ame
);
}
tag_free
(
tag
);
}
else
if
(
inStream
->
meta
N
ame
)
{
}
else
if
(
inStream
->
meta
_n
ame
)
{
tag
=
tag_new
();
if
(
inStream
->
meta
N
ame
)
{
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
inStream
->
meta
N
ame
);
if
(
inStream
->
meta
_n
ame
)
{
tag_add_item
(
tag
,
TAG_ITEM_NAME
,
inStream
->
meta
_n
ame
);
}
tag_free
(
tag
);
}
...
...
src/decoder/mp4_plugin.c
View file @
dbc7e9ba
...
...
@@ -68,13 +68,13 @@ static int mp4_getAACTrack(mp4ff_t * infile)
static
uint32_t
mp4_inputStreamReadCallback
(
void
*
inStream
,
void
*
buffer
,
uint32_t
length
)
{
return
readFromInputStream
((
struct
input_stream
*
)
inStream
,
return
input_stream_read
((
struct
input_stream
*
)
inStream
,
buffer
,
length
);
}
static
uint32_t
mp4_inputStreamSeekCallback
(
void
*
inStream
,
uint64_t
position
)
{
return
seekInputStream
((
struct
input_stream
*
)
inStream
,
return
input_stream_seek
((
struct
input_stream
*
)
inStream
,
position
,
SEEK_SET
);
}
...
...
@@ -317,7 +317,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
*
mp4MetadataFound
=
0
;
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
{
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
{
DEBUG
(
"mp4DataDup: Failed to open file: %s
\n
"
,
file
);
return
NULL
;
}
...
...
@@ -330,14 +330,14 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
mp4fh
=
mp4ff_open_read
(
callback
);
if
(
!
mp4fh
)
{
free
(
callback
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
NULL
;
}
track
=
mp4_getAACTrack
(
mp4fh
);
if
(
track
<
0
)
{
mp4ff_close
(
mp4fh
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
free
(
callback
);
return
NULL
;
}
...
...
@@ -347,7 +347,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
scale
=
mp4ff_time_scale
(
mp4fh
,
track
);
if
(
scale
<
0
)
{
mp4ff_close
(
mp4fh
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
free
(
callback
);
tag_free
(
ret
);
return
NULL
;
...
...
@@ -388,7 +388,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
}
mp4ff_close
(
mp4fh
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
ret
;
}
...
...
src/decoder/mpc_plugin.c
View file @
dbc7e9ba
...
...
@@ -38,7 +38,7 @@ static mpc_bool_t mpc_seek_cb(void *vdata, mpc_int32_t offset)
{
MpcCallbackData
*
data
=
(
MpcCallbackData
*
)
vdata
;
return
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
?
0
:
1
;
return
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
?
0
:
1
;
}
static
mpc_int32_t
mpc_tell_cb
(
void
*
vdata
)
...
...
@@ -260,19 +260,19 @@ static float mpcGetTime(char *file)
mpc_streaminfo_init
(
&
info
);
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
{
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
{
DEBUG
(
"mpcGetTime: Failed to open file: %s
\n
"
,
file
);
return
-
1
;
}
if
(
mpc_streaminfo_read
(
&
info
,
&
reader
)
!=
ERROR_CODE_OK
)
{
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
-
1
;
}
total_time
=
mpc_streaminfo_get_length
(
&
info
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
total_time
;
}
...
...
src/decoder/oggflac_plugin.c
View file @
dbc7e9ba
...
...
@@ -49,7 +49,7 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(mpd_unused const
r
=
decoder_read
(
data
->
decoder
,
data
->
inStream
,
(
void
*
)
buf
,
*
bytes
);
*
bytes
=
r
;
if
(
r
==
0
&&
!
input
StreamAtEOF
(
data
->
inStream
)
&&
if
(
r
==
0
&&
!
input
_stream_eof
(
data
->
inStream
)
&&
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_NONE
)
return
OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
;
...
...
@@ -64,7 +64,7 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(mpd_unused const
{
FlacData
*
data
=
(
FlacData
*
)
fdata
;
if
(
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
;
}
...
...
@@ -105,7 +105,7 @@ static FLAC__bool of_EOF_cb(mpd_unused const OggFLAC__SeekableStreamDecoder * de
return
(
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_NONE
&&
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_SEEK
)
||
input
StreamAtEOF
(
data
->
inStream
);
input
_stream_eof
(
data
->
inStream
);
}
static
void
of_error_cb
(
mpd_unused
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
...
...
@@ -261,10 +261,10 @@ static struct tag *oggflac_TagDup(char *file)
OggFLAC__SeekableStreamDecoder
*
decoder
;
FlacData
data
;
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
return
NULL
;
if
(
ogg_stream_type_detect
(
&
inStream
)
!=
FLAC
)
{
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
NULL
;
}
...
...
@@ -275,7 +275,7 @@ static struct tag *oggflac_TagDup(char *file)
decoder
=
full_decoder_init_and_read_metadata
(
&
data
,
1
);
oggflac_cleanup
(
&
data
,
decoder
);
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
return
data
.
tag
;
}
...
...
src/decoder/oggvorbis_plugin.c
View file @
dbc7e9ba
...
...
@@ -66,7 +66,7 @@ static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
const
OggCallbackData
*
data
=
(
const
OggCallbackData
*
)
vdata
;
if
(
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_STOP
)
return
-
1
;
return
seekInputStream
(
data
->
inStream
,
offset
,
whence
);
return
input_stream_seek
(
data
->
inStream
,
offset
,
whence
);
}
/* TODO: check Ogg libraries API and see if we can just not have this func */
...
...
@@ -284,7 +284,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
initialized
=
1
;
}
comments
=
ov_comment
(
&
vf
,
-
1
)
->
user_comments
;
putOggCommentsIntoOutputBuffer
(
inStream
->
meta
N
ame
,
putOggCommentsIntoOutputBuffer
(
inStream
->
meta
_n
ame
,
comments
);
ogg_getReplayGainInfo
(
comments
,
&
replayGainInfo
);
}
...
...
src/decoder/wavpack_plugin.c
View file @
dbc7e9ba
...
...
@@ -366,12 +366,12 @@ static uint32_t get_pos(void *id)
static
int
set_pos_abs
(
void
*
id
,
uint32_t
pos
)
{
return
seekInputStream
(((
InputStreamPlus
*
)
id
)
->
is
,
pos
,
SEEK_SET
);
return
input_stream_seek
(((
InputStreamPlus
*
)
id
)
->
is
,
pos
,
SEEK_SET
);
}
static
int
set_pos_rel
(
void
*
id
,
int32_t
delta
,
int
mode
)
{
return
seekInputStream
(((
InputStreamPlus
*
)
id
)
->
is
,
delta
,
mode
);
return
input_stream_seek
(((
InputStreamPlus
*
)
id
)
->
is
,
delta
,
mode
);
}
static
int
push_back_byte
(
void
*
id
,
int
c
)
...
...
@@ -427,7 +427,7 @@ static bool wavpack_trydecode(struct input_stream *is)
WavpackCloseFile
(
wpc
);
/* Seek it back in order to play from the first byte. */
seekInputStream
(
is
,
0
,
SEEK_SET
);
input_stream_seek
(
is
,
0
,
SEEK_SET
);
return
true
;
}
...
...
@@ -461,7 +461,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
wvc_url
[
len
]
=
'c'
;
wvc_url
[
len
+
1
]
=
'\0'
;
ret
=
openInputStream
(
is_wvc
,
wvc_url
);
ret
=
input_stream_open
(
is_wvc
,
wvc_url
);
free
(
wvc_url
);
if
(
ret
)
...
...
@@ -472,21 +472,21 @@ static int wavpack_open_wvc(struct decoder *decoder,
* about a possible 404 error.
*/
for
(;;)
{
if
(
input
StreamAtEOF
(
is_wvc
))
{
if
(
input
_stream_eof
(
is_wvc
))
{
/*
* EOF is reached even without
* a single byte is read...
* So, this is not good :/
*/
closeInputStream
(
is_wvc
);
input_stream_close
(
is_wvc
);
return
0
;
}
if
(
bufferInputStream
(
is_wvc
)
>=
0
)
if
(
input_stream_buffer
(
is_wvc
)
>=
0
)
return
1
;
if
(
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_NONE
)
{
closeInputStream
(
is_wvc
);
input_stream_close
(
is_wvc
);
return
0
;
}
...
...
@@ -525,8 +525,8 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
WavpackCloseFile
(
wpc
);
if
(
open_flags
&
OPEN_WVC
)
closeInputStream
(
&
is_wvc
);
closeInputStream
(
is
);
input_stream_close
(
&
is_wvc
);
input_stream_close
(
is
);
return
0
;
}
...
...
src/decoder_api.c
View file @
dbc7e9ba
...
...
@@ -115,8 +115,8 @@ size_t decoder_read(struct decoder *decoder,
dc
.
command
!=
DECODE_COMMAND_NONE
)
return
0
;
nbytes
=
readFromInputStream
(
inStream
,
buffer
,
length
);
if
(
nbytes
>
0
||
input
StreamAtEOF
(
inStream
))
nbytes
=
input_stream_read
(
inStream
,
buffer
,
length
);
if
(
nbytes
>
0
||
input
_stream_eof
(
inStream
))
return
nbytes
;
/* sleep for a fraction of a second! */
...
...
@@ -145,7 +145,7 @@ need_chunks(struct decoder *decoder,
}
if
(
!
inStream
||
bufferInputStream
(
inStream
)
<=
0
)
{
input_stream_buffer
(
inStream
)
<=
0
)
{
notify_wait
(
&
dc
.
notify
);
notify_signal
(
&
pc
.
notify
);
}
...
...
src/decoder_thread.c
View file @
dbc7e9ba
...
...
@@ -43,7 +43,7 @@ static void decodeStart(void)
song_get_url
(
song
,
path_max_fs
);
dc
.
current_song
=
dc
.
next_song
;
/* NEED LOCK */
if
(
openInputStream
(
&
inStream
,
path_max_fs
)
<
0
)
{
if
(
input_stream_open
(
&
inStream
,
path_max_fs
)
<
0
)
{
dc
.
error
=
DECODE_ERROR_FILE
;
goto
stop_no_close
;
}
...
...
@@ -61,12 +61,12 @@ static void decodeStart(void)
if
(
dc
.
command
!=
DECODE_COMMAND_NONE
)
goto
stop
;
ret
=
bufferInputStream
(
&
inStream
);
ret
=
input_stream_buffer
(
&
inStream
);
if
(
ret
<
0
)
goto
stop
;
}
/* for http streams, seekable is determined in
bufferInputStream
*/
/* for http streams, seekable is determined in
input_stream_buffer
*/
dc
.
seekable
=
inStream
.
seekable
;
if
(
dc
.
command
==
DECODE_COMMAND_STOP
)
...
...
@@ -132,7 +132,7 @@ static void decodeStart(void)
continue
;
if
(
plugin
->
file_decode
!=
NULL
)
{
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
close_instream
=
false
;
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
file_decode
(
&
decoder
,
...
...
@@ -156,7 +156,7 @@ static void decodeStart(void)
stop:
if
(
close_instream
)
closeInputStream
(
&
inStream
);
input_stream_close
(
&
inStream
);
stop_no_close:
dc
.
state
=
DECODE_STATE_STOP
;
dc
.
command
=
DECODE_COMMAND_NONE
;
...
...
src/input_file.c
View file @
dbc7e9ba
...
...
@@ -22,59 +22,60 @@
#include "os_compat.h"
static
int
input
Stream_fileS
eek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
input
_file_s
eek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
static
size_t
input
Stream_fileR
ead
(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
);
input
_file_r
ead
(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
);
static
int
input
Stream_fileC
lose
(
struct
input_stream
*
is
);
input
_file_c
lose
(
struct
input_stream
*
is
);
static
int
input
Stream_fileAtEOF
(
struct
input_stream
*
is
);
input
_file_eof
(
struct
input_stream
*
is
);
static
int
input
Stream_fileB
uffer
(
struct
input_stream
*
is
);
input
_file_b
uffer
(
struct
input_stream
*
is
);
int
inputStream_fileOpen
(
struct
input_stream
*
inStream
,
char
*
filename
)
int
input_file_open
(
struct
input_stream
*
is
,
char
*
filename
)
{
FILE
*
fp
;
fp
=
fopen
(
filename
,
"r"
);
if
(
!
fp
)
{
i
nStream
->
error
=
errno
;
i
s
->
error
=
errno
;
return
-
1
;
}
i
nStream
->
seekable
=
1
;
i
s
->
seekable
=
1
;
fseek
(
fp
,
0
,
SEEK_END
);
i
nStream
->
size
=
ftell
(
fp
);
i
s
->
size
=
ftell
(
fp
);
fseek
(
fp
,
0
,
SEEK_SET
);
#ifdef POSIX_FADV_SEQUENTIAL
posix_fadvise
(
fileno
(
fp
),
(
off_t
)
0
,
i
nStream
->
size
,
POSIX_FADV_SEQUENTIAL
);
posix_fadvise
(
fileno
(
fp
),
(
off_t
)
0
,
i
s
->
size
,
POSIX_FADV_SEQUENTIAL
);
#endif
i
nStream
->
data
=
fp
;
i
nStream
->
seekFunc
=
inputStream_fileS
eek
;
i
nStream
->
closeFunc
=
inputStream_fileC
lose
;
i
nStream
->
readFunc
=
inputStream_fileR
ead
;
i
nStream
->
atEOFFunc
=
inputStream_fileAtEOF
;
i
nStream
->
bufferFunc
=
inputStream_fileB
uffer
;
i
s
->
data
=
fp
;
i
s
->
seekFunc
=
input_file_s
eek
;
i
s
->
closeFunc
=
input_file_c
lose
;
i
s
->
readFunc
=
input_file_r
ead
;
i
s
->
atEOFFunc
=
input_file_eof
;
i
s
->
bufferFunc
=
input_file_b
uffer
;
i
nStream
->
ready
=
1
;
i
s
->
ready
=
1
;
return
0
;
}
static
int
input
Stream_fileSeek
(
struct
input_stream
*
inStream
,
long
offset
,
int
whence
)
input
_file_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
)
{
if
(
fseek
((
FILE
*
)
i
nStream
->
data
,
offset
,
whence
)
==
0
)
{
i
nStream
->
offset
=
ftell
((
FILE
*
)
inStream
->
data
);
if
(
fseek
((
FILE
*
)
i
s
->
data
,
offset
,
whence
)
==
0
)
{
i
s
->
offset
=
ftell
((
FILE
*
)
is
->
data
);
}
else
{
i
nStream
->
error
=
errno
;
i
s
->
error
=
errno
;
return
-
1
;
}
...
...
@@ -82,27 +83,27 @@ inputStream_fileSeek(struct input_stream *inStream, long offset, int whence)
}
static
size_t
input
Stream_fileRead
(
struct
input_stream
*
inStream
,
void
*
ptr
,
size_t
size
)
input
_file_read
(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
)
{
size_t
readSize
;
readSize
=
fread
(
ptr
,
1
,
size
,
(
FILE
*
)
i
nStream
->
data
);
if
(
readSize
<=
0
&&
ferror
((
FILE
*
)
i
nStream
->
data
))
{
i
nStream
->
error
=
errno
;
DEBUG
(
"input
Stream_fileR
ead: error reading: %s
\n
"
,
strerror
(
i
nStream
->
error
));
readSize
=
fread
(
ptr
,
1
,
size
,
(
FILE
*
)
i
s
->
data
);
if
(
readSize
<=
0
&&
ferror
((
FILE
*
)
i
s
->
data
))
{
i
s
->
error
=
errno
;
DEBUG
(
"input
_file_r
ead: error reading: %s
\n
"
,
strerror
(
i
s
->
error
));
}
i
nStream
->
offset
=
ftell
((
FILE
*
)
inStream
->
data
);
i
s
->
offset
=
ftell
((
FILE
*
)
is
->
data
);
return
readSize
;
}
static
int
input
Stream_fileClose
(
struct
input_stream
*
inStream
)
input
_file_close
(
struct
input_stream
*
is
)
{
if
(
fclose
((
FILE
*
)
i
nStream
->
data
)
<
0
)
{
i
nStream
->
error
=
errno
;
if
(
fclose
((
FILE
*
)
i
s
->
data
)
<
0
)
{
i
s
->
error
=
errno
;
return
-
1
;
}
...
...
@@ -110,12 +111,12 @@ inputStream_fileClose(struct input_stream *inStream)
}
static
int
input
Stream_fileAtEOF
(
struct
input_stream
*
inStream
)
input
_file_eof
(
struct
input_stream
*
is
)
{
if
(
feof
((
FILE
*
)
i
nStream
->
data
))
if
(
feof
((
FILE
*
)
i
s
->
data
))
return
1
;
if
(
ferror
((
FILE
*
)
i
nStream
->
data
)
&&
inStream
->
error
!=
EINTR
)
{
if
(
ferror
((
FILE
*
)
i
s
->
data
)
&&
is
->
error
!=
EINTR
)
{
return
1
;
}
...
...
@@ -123,7 +124,7 @@ inputStream_fileAtEOF(struct input_stream *inStream)
}
static
int
input
Stream_fileBuffer
(
mpd_unused
struct
input_stream
*
inStream
)
input
_file_buffer
(
mpd_unused
struct
input_stream
*
is
)
{
return
0
;
}
src/input_file.h
View file @
dbc7e9ba
...
...
@@ -21,6 +21,7 @@
#include "input_stream.h"
int
inputStream_fileOpen
(
struct
input_stream
*
inStream
,
char
*
filename
);
int
input_file_open
(
struct
input_stream
*
is
,
char
*
filename
);
#endif
src/input_stream.c
View file @
dbc7e9ba
...
...
@@ -27,7 +27,7 @@
#include <stdlib.h>
void
in
itInputStream
(
void
)
void
in
put_stream_global_init
(
void
)
{
#ifdef HAVE_CURL
input_curl_global_init
();
...
...
@@ -41,57 +41,57 @@ void input_stream_global_finish(void)
#endif
}
int
openInputStream
(
struct
input_stream
*
inStream
,
char
*
url
)
int
input_stream_open
(
struct
input_stream
*
is
,
char
*
url
)
{
i
nStream
->
ready
=
0
;
i
nStream
->
offset
=
0
;
i
nStream
->
size
=
0
;
i
nStream
->
error
=
0
;
i
nStream
->
mime
=
NULL
;
i
nStream
->
seekable
=
0
;
i
nStream
->
metaN
ame
=
NULL
;
i
nStream
->
metaT
itle
=
NULL
;
if
(
input
Stream_fileOpen
(
inStream
,
url
)
==
0
)
i
s
->
ready
=
0
;
i
s
->
offset
=
0
;
i
s
->
size
=
0
;
i
s
->
error
=
0
;
i
s
->
mime
=
NULL
;
i
s
->
seekable
=
0
;
i
s
->
meta_n
ame
=
NULL
;
i
s
->
meta_t
itle
=
NULL
;
if
(
input
_file_open
(
is
,
url
)
==
0
)
return
0
;
#ifdef HAVE_CURL
if
(
input_curl_open
(
i
nStream
,
url
))
if
(
input_curl_open
(
i
s
,
url
))
return
0
;
#endif
return
-
1
;
}
int
seekInputStream
(
struct
input_stream
*
inStream
,
long
offset
,
int
whence
)
int
input_stream_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
)
{
return
i
nStream
->
seekFunc
(
inStream
,
offset
,
whence
);
return
i
s
->
seekFunc
(
is
,
offset
,
whence
);
}
size_t
readFromInputStream
(
struct
input_stream
*
inStream
,
void
*
ptr
,
size_t
size
)
size_t
input_stream_read
(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
)
{
return
i
nStream
->
readFunc
(
inStream
,
ptr
,
size
);
return
i
s
->
readFunc
(
is
,
ptr
,
size
);
}
int
closeInputStream
(
struct
input_stream
*
inStream
)
int
input_stream_close
(
struct
input_stream
*
is
)
{
if
(
i
nStream
->
mime
)
free
(
i
nStream
->
mime
);
if
(
i
nStream
->
metaN
ame
)
free
(
i
nStream
->
metaN
ame
);
if
(
i
nStream
->
metaT
itle
)
free
(
i
nStream
->
metaT
itle
);
return
i
nStream
->
closeFunc
(
inStream
);
if
(
i
s
->
mime
)
free
(
i
s
->
mime
);
if
(
i
s
->
meta_n
ame
)
free
(
i
s
->
meta_n
ame
);
if
(
i
s
->
meta_t
itle
)
free
(
i
s
->
meta_t
itle
);
return
i
s
->
closeFunc
(
is
);
}
int
input
StreamAtEOF
(
struct
input_stream
*
inStream
)
int
input
_stream_eof
(
struct
input_stream
*
is
)
{
return
i
nStream
->
atEOFFunc
(
inStream
);
return
i
s
->
atEOFFunc
(
is
);
}
int
bufferInputStream
(
struct
input_stream
*
inStream
)
int
input_stream_buffer
(
struct
input_stream
*
is
)
{
return
i
nStream
->
bufferFunc
(
inStream
);
return
i
s
->
bufferFunc
(
is
);
}
src/input_stream.h
View file @
dbc7e9ba
...
...
@@ -30,37 +30,33 @@ struct input_stream {
char
*
mime
;
int
seekable
;
int
(
*
seekFunc
)(
struct
input_stream
*
inStream
,
long
offset
,
int
whence
);
size_t
(
*
readFunc
)(
struct
input_stream
*
inStream
,
void
*
ptr
,
size_t
size
);
int
(
*
closeFunc
)(
struct
input_stream
*
inStream
);
int
(
*
atEOFFunc
)(
struct
input_stream
*
inStream
);
int
(
*
bufferFunc
)(
struct
input_stream
*
inStream
);
int
(
*
seekFunc
)(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
size_t
(
*
readFunc
)(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
);
int
(
*
closeFunc
)(
struct
input_stream
*
is
);
int
(
*
atEOFFunc
)(
struct
input_stream
*
is
);
int
(
*
bufferFunc
)(
struct
input_stream
*
is
);
void
*
data
;
char
*
meta
N
ame
;
char
*
meta
T
itle
;
char
*
meta
_n
ame
;
char
*
meta
_t
itle
;
};
void
in
itInputStream
(
void
);
void
in
put_stream_global_init
(
void
);
void
input_stream_global_finish
(
void
);
int
isUrlSaneForInputStream
(
char
*
url
);
/* if an error occurs for these 3 functions, then -1 is returned and errno
for the input stream is set */
int
openInputStream
(
struct
input_stream
*
inStream
,
char
*
url
);
int
seekInputStream
(
struct
input_stream
*
inStream
,
long
offset
,
int
whence
);
int
closeInputStream
(
struct
input_stream
*
inStream
);
int
input
StreamAtEOF
(
struct
input_stream
*
inStream
);
int
input_stream_open
(
struct
input_stream
*
is
,
char
*
url
);
int
input_stream_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
int
input_stream_close
(
struct
input_stream
*
is
);
int
input
_stream_eof
(
struct
input_stream
*
is
);
/* return value: -1 is error, 1 inidicates stuff was buffered, 0 means nothing
was buffered */
int
bufferInputStream
(
struct
input_stream
*
inStream
);
int
input_stream_buffer
(
struct
input_stream
*
is
);
size_t
readFromInputStream
(
struct
input_stream
*
inStream
,
void
*
ptr
,
size_t
size
);
size_t
input_stream_read
(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
);
#endif
src/main.c
View file @
dbc7e9ba
...
...
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
client_manager_init
();
initReplayGainState
();
initNormalization
();
in
itInputStream
();
in
put_stream_global_init
();
daemonize
(
&
options
);
...
...
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