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
5c19776f
Commit
5c19776f
authored
Oct 26, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input_stream: use "bool" instead of "int"
For boolean values and success flags, use bool instead of integer (1/0 for true/false, 0/-1 for success/failure).
parent
464b6117
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
55 additions
and
49 deletions
+55
-49
aac_plugin.c
src/decoder/aac_plugin.c
+2
-2
ffmpeg_plugin.c
src/decoder/ffmpeg_plugin.c
+1
-1
flac_plugin.c
src/decoder/flac_plugin.c
+1
-2
mp3_plugin.c
src/decoder/mp3_plugin.c
+2
-3
mp4_plugin.c
src/decoder/mp4_plugin.c
+3
-2
mpc_plugin.c
src/decoder/mpc_plugin.c
+2
-2
oggflac_plugin.c
src/decoder/oggflac_plugin.c
+2
-3
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+1
-1
wavpack_plugin.c
src/decoder/wavpack_plugin.c
+6
-4
decoder_thread.c
src/decoder_thread.c
+1
-1
input_curl.c
src/input_curl.c
+8
-8
input_file.c
src/input_file.c
+6
-6
input_stream.c
src/input_stream.c
+9
-7
input_stream.h
src/input_stream.h
+11
-7
No files found.
src/decoder/aac_plugin.c
View file @
5c19776f
...
...
@@ -257,7 +257,7 @@ static float getAacFloatTotalTime(char *file)
struct
input_stream
inStream
;
long
bread
;
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
if
(
!
input_stream_open
(
&
inStream
,
file
)
)
return
-
1
;
initAacBuffer
(
&
b
,
NULL
,
&
inStream
);
...
...
@@ -461,7 +461,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if
((
totalTime
=
getAacFloatTotalTime
(
path
))
<
0
)
return
-
1
;
if
(
input_stream_open
(
&
inStream
,
path
)
<
0
)
if
(
!
input_stream_open
(
&
inStream
,
path
)
)
return
-
1
;
initAacBuffer
(
&
b
,
mpd_decoder
,
&
inStream
);
...
...
src/decoder/ffmpeg_plugin.c
View file @
5c19776f
...
...
@@ -360,7 +360,7 @@ static struct tag *ffmpeg_tag(char *file)
int
ret
;
struct
tag
*
tag
=
NULL
;
if
(
input_stream_open
(
&
input
,
file
)
<
0
)
{
if
(
!
input_stream_open
(
&
input
,
file
)
)
{
ERROR
(
"failed to open %s
\n
"
,
file
);
return
NULL
;
}
...
...
src/decoder/flac_plugin.c
View file @
5c19776f
...
...
@@ -52,9 +52,8 @@ static flac_seek_status flacSeek(mpd_unused const flac_decoder * flacDec,
{
FlacData
*
data
=
(
FlacData
*
)
fdata
;
if
(
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
!
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
))
return
flac_seek_status_error
;
}
return
flac_seek_status_ok
;
}
...
...
src/decoder/mp3_plugin.c
View file @
5c19776f
...
...
@@ -158,9 +158,8 @@ static void initMp3DecodeData(mp3DecodeData * data, struct decoder *decoder,
static
int
seekMp3InputBuffer
(
mp3DecodeData
*
data
,
long
offset
)
{
if
(
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
!
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
))
return
-
1
;
}
mad_stream_buffer
(
&
data
->
stream
,
data
->
readBuffer
,
0
);
(
data
->
stream
).
error
=
0
;
...
...
@@ -757,7 +756,7 @@ static int getMp3TotalTime(char *file)
mp3DecodeData
data
;
int
ret
;
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
if
(
!
input_stream_open
(
&
inStream
,
file
)
)
return
-
1
;
initMp3DecodeData
(
&
data
,
NULL
,
&
inStream
);
if
(
decodeFirstFrame
(
&
data
,
NULL
,
NULL
)
<
0
)
...
...
src/decoder/mp4_plugin.c
View file @
5c19776f
...
...
@@ -75,7 +75,8 @@ static uint32_t mp4_inputStreamReadCallback(void *inStream, void *buffer,
static
uint32_t
mp4_inputStreamSeekCallback
(
void
*
inStream
,
uint64_t
position
)
{
return
input_stream_seek
((
struct
input_stream
*
)
inStream
,
position
,
SEEK_SET
);
position
,
SEEK_SET
)
?
0
:
-
1
;
}
static
int
...
...
@@ -317,7 +318,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
*
mp4MetadataFound
=
0
;
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
{
if
(
!
input_stream_open
(
&
inStream
,
file
)
)
{
DEBUG
(
"mp4DataDup: Failed to open file: %s
\n
"
,
file
);
return
NULL
;
}
...
...
src/decoder/mpc_plugin.c
View file @
5c19776f
...
...
@@ -38,7 +38,7 @@ static mpc_bool_t mpc_seek_cb(void *vdata, mpc_int32_t offset)
{
MpcCallbackData
*
data
=
(
MpcCallbackData
*
)
vdata
;
return
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
?
0
:
1
;
return
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
?
0
:
1
;
}
static
mpc_int32_t
mpc_tell_cb
(
void
*
vdata
)
...
...
@@ -260,7 +260,7 @@ static float mpcGetTime(char *file)
mpc_streaminfo_init
(
&
info
);
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
{
if
(
!
input_stream_open
(
&
inStream
,
file
)
)
{
DEBUG
(
"mpcGetTime: Failed to open file: %s
\n
"
,
file
);
return
-
1
;
}
...
...
src/decoder/oggflac_plugin.c
View file @
5c19776f
...
...
@@ -64,9 +64,8 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(mpd_unused const
{
FlacData
*
data
=
(
FlacData
*
)
fdata
;
if
(
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
!
input_stream_seek
(
data
->
inStream
,
offset
,
SEEK_SET
))
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
;
}
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
;
}
...
...
@@ -261,7 +260,7 @@ static struct tag *oggflac_TagDup(char *file)
OggFLAC__SeekableStreamDecoder
*
decoder
;
FlacData
data
;
if
(
input_stream_open
(
&
inStream
,
file
)
<
0
)
if
(
!
input_stream_open
(
&
inStream
,
file
)
)
return
NULL
;
if
(
ogg_stream_type_detect
(
&
inStream
)
!=
FLAC
)
{
input_stream_close
(
&
inStream
);
...
...
src/decoder/oggvorbis_plugin.c
View file @
5c19776f
...
...
@@ -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
input_stream_seek
(
data
->
inStream
,
offset
,
whence
);
return
input_stream_seek
(
data
->
inStream
,
offset
,
whence
)
?
0
:
-
1
;
}
/* TODO: check Ogg libraries API and see if we can just not have this func */
...
...
src/decoder/wavpack_plugin.c
View file @
5c19776f
...
...
@@ -366,12 +366,14 @@ static uint32_t get_pos(void *id)
static
int
set_pos_abs
(
void
*
id
,
uint32_t
pos
)
{
return
input_stream_seek
(((
InputStreamPlus
*
)
id
)
->
is
,
pos
,
SEEK_SET
);
return
input_stream_seek
(((
InputStreamPlus
*
)
id
)
->
is
,
pos
,
SEEK_SET
)
?
0
:
-
1
;
}
static
int
set_pos_rel
(
void
*
id
,
int32_t
delta
,
int
mode
)
{
return
input_stream_seek
(((
InputStreamPlus
*
)
id
)
->
is
,
delta
,
mode
);
return
input_stream_seek
(((
InputStreamPlus
*
)
id
)
->
is
,
delta
,
mode
)
?
0
:
-
1
;
}
static
int
push_back_byte
(
void
*
id
,
int
c
)
...
...
@@ -439,7 +441,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
const
char
*
utf8url
;
size_t
len
;
char
*
wvc_url
=
NULL
;
int
ret
;
bool
ret
;
/*
* As we use dc->utf8url, this function will be bad for
...
...
@@ -464,7 +466,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
ret
=
input_stream_open
(
is_wvc
,
wvc_url
);
free
(
wvc_url
);
if
(
ret
)
if
(
!
ret
)
return
0
;
/*
...
...
src/decoder_thread.c
View file @
5c19776f
...
...
@@ -43,7 +43,7 @@ static void decodeStart(void)
song_get_url
(
song
,
path_max_fs
);
dc
.
current_song
=
dc
.
next_song
;
/* NEED LOCK */
if
(
input_stream_open
(
&
inStream
,
path_max_fs
)
<
0
)
{
if
(
!
input_stream_open
(
&
inStream
,
path_max_fs
)
)
{
dc
.
error
=
DECODE_ERROR_FILE
;
goto
stop_no_close
;
}
...
...
src/input_curl.c
View file @
5c19776f
...
...
@@ -241,7 +241,7 @@ input_curl_close(struct input_stream *is)
input_curl_free
(
is
);
}
static
int
static
bool
input_curl_eof
(
mpd_unused
struct
input_stream
*
is
)
{
struct
input_curl
*
c
=
is
->
data
;
...
...
@@ -397,7 +397,7 @@ input_curl_send_request(struct input_curl *c)
return
true
;
}
static
int
static
bool
input_curl_seek
(
struct
input_stream
*
is
,
mpd_unused
long
offset
,
mpd_unused
int
whence
)
{
...
...
@@ -405,7 +405,7 @@ input_curl_seek(struct input_stream *is, mpd_unused long offset,
bool
ret
;
if
(
!
is
->
seekable
)
return
-
1
;
return
false
;
/* calculate the absolute offset */
...
...
@@ -423,11 +423,11 @@ input_curl_seek(struct input_stream *is, mpd_unused long offset,
break
;
default:
return
-
1
;
return
false
;
}
if
(
is
->
offset
<
0
)
return
-
1
;
return
false
;
/* close the old connection and open a new one */
...
...
@@ -435,7 +435,7 @@ input_curl_seek(struct input_stream *is, mpd_unused long offset,
ret
=
input_curl_easy_init
(
is
);
if
(
!
ret
)
return
-
1
;
return
false
;
/* send the "Range" header */
...
...
@@ -446,9 +446,9 @@ input_curl_seek(struct input_stream *is, mpd_unused long offset,
ret
=
input_curl_send_request
(
c
);
if
(
!
ret
)
return
-
1
;
return
false
;
return
0
;
return
true
;
}
static
bool
...
...
src/input_file.c
View file @
5c19776f
...
...
@@ -32,7 +32,7 @@ input_file_open(struct input_stream *is, const char *filename)
return
false
;
}
is
->
seekable
=
1
;
is
->
seekable
=
true
;
fseek
(
fp
,
0
,
SEEK_END
);
is
->
size
=
ftell
(
fp
);
...
...
@@ -43,22 +43,22 @@ input_file_open(struct input_stream *is, const char *filename)
#endif
is
->
data
=
fp
;
is
->
ready
=
1
;
is
->
ready
=
true
;
return
true
;
}
static
int
static
bool
input_file_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
)
{
if
(
fseek
((
FILE
*
)
is
->
data
,
offset
,
whence
)
==
0
)
{
is
->
offset
=
ftell
((
FILE
*
)
is
->
data
);
}
else
{
is
->
error
=
errno
;
return
-
1
;
return
false
;
}
return
0
;
return
true
;
}
static
size_t
...
...
@@ -84,7 +84,7 @@ input_file_close(struct input_stream *is)
fclose
((
FILE
*
)
is
->
data
);
}
static
int
static
bool
input_file_eof
(
struct
input_stream
*
is
)
{
if
(
feof
((
FILE
*
)
is
->
data
))
...
...
src/input_stream.c
View file @
5c19776f
...
...
@@ -51,14 +51,15 @@ void input_stream_global_finish(void)
#endif
}
int
input_stream_open
(
struct
input_stream
*
is
,
char
*
url
)
bool
input_stream_open
(
struct
input_stream
*
is
,
char
*
url
)
{
is
->
ready
=
0
;
is
->
seekable
=
false
;
is
->
ready
=
false
;
is
->
offset
=
0
;
is
->
size
=
0
;
is
->
error
=
0
;
is
->
mime
=
NULL
;
is
->
seekable
=
0
;
is
->
meta_name
=
NULL
;
is
->
meta_title
=
NULL
;
...
...
@@ -67,14 +68,15 @@ int input_stream_open(struct input_stream *is, char *url)
if
(
plugin
->
open
(
is
,
url
))
{
is
->
plugin
=
plugin
;
return
0
;
return
true
;
}
}
return
-
1
;
return
false
;
}
int
input_stream_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
)
bool
input_stream_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
)
{
return
is
->
plugin
->
seek
(
is
,
offset
,
whence
);
}
...
...
@@ -97,7 +99,7 @@ void input_stream_close(struct input_stream *is)
is
->
plugin
->
close
(
is
);
}
int
input_stream_eof
(
struct
input_stream
*
is
)
bool
input_stream_eof
(
struct
input_stream
*
is
)
{
return
is
->
plugin
->
eof
(
is
);
}
...
...
src/input_stream.h
View file @
5c19776f
...
...
@@ -30,20 +30,20 @@ struct input_plugin {
int
(
*
buffer
)(
struct
input_stream
*
is
);
size_t
(
*
read
)(
struct
input_stream
*
is
,
void
*
ptr
,
size_t
size
);
int
(
*
eof
)(
struct
input_stream
*
is
);
int
(
*
seek
)(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
bool
(
*
eof
)(
struct
input_stream
*
is
);
bool
(
*
seek
)(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
};
struct
input_stream
{
const
struct
input_plugin
*
plugin
;
int
ready
;
bool
seekable
;
bool
ready
;
int
error
;
long
offset
;
size_t
size
;
char
*
mime
;
int
seekable
;
void
*
data
;
char
*
meta_name
;
...
...
@@ -56,10 +56,14 @@ void input_stream_global_finish(void);
/* if an error occurs for these 3 functions, then -1 is returned and errno
for the input stream is set */
int
input_stream_open
(
struct
input_stream
*
is
,
char
*
url
);
int
input_stream_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
bool
input_stream_open
(
struct
input_stream
*
is
,
char
*
url
);
bool
input_stream_seek
(
struct
input_stream
*
is
,
long
offset
,
int
whence
);
void
input_stream_close
(
struct
input_stream
*
is
);
int
input_stream_eof
(
struct
input_stream
*
is
);
bool
input_stream_eof
(
struct
input_stream
*
is
);
/* return value: -1 is error, 1 inidicates stuff was buffered, 0 means nothing
was buffered */
...
...
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