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
b084bc28
Commit
b084bc28
authored
Oct 08, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the "bool" data type instead of "int"
"bool" should be used in C99 programs for boolean values.
parent
71351160
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
74 additions
and
65 deletions
+74
-65
audio.c
src/audio.c
+2
-1
audio.h
src/audio.h
+2
-1
audio_format.h
src/audio_format.h
+4
-3
decoder_api.c
src/decoder_api.c
+1
-1
decoder_api.h
src/decoder_api.h
+4
-3
decoder_internal.h
src/decoder_internal.h
+1
-1
decoder_thread.c
src/decoder_thread.c
+3
-3
flac_plugin.c
src/inputPlugins/flac_plugin.c
+2
-2
mp4_plugin.c
src/inputPlugins/mp4_plugin.c
+7
-7
oggflac_plugin.c
src/inputPlugins/oggflac_plugin.c
+3
-3
oggvorbis_plugin.c
src/inputPlugins/oggvorbis_plugin.c
+3
-3
wavpack_plugin.c
src/inputPlugins/wavpack_plugin.c
+3
-3
notify.c
src/notify.c
+3
-3
notify.h
src/notify.h
+2
-1
outputBuffer.c
src/outputBuffer.c
+2
-2
outputBuffer.h
src/outputBuffer.h
+3
-2
player_thread.c
src/player_thread.c
+4
-4
playlist.c
src/playlist.c
+13
-13
playlist.h
src/playlist.h
+8
-7
song.h
src/song.h
+4
-2
No files found.
src/audio.c
View file @
b084bc28
...
...
@@ -204,7 +204,8 @@ void finishAudioDriver(void)
audioOutputArraySize
=
0
;
}
int
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
)
bool
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
)
{
assert
(
audioFormat
!=
NULL
);
...
...
src/audio.h
View file @
b084bc28
...
...
@@ -19,6 +19,7 @@
#ifndef AUDIO_H
#define AUDIO_H
#include <stdbool.h>
#include <stdio.h>
#define AUDIO_AO_DRIVER_DEFAULT "default"
...
...
@@ -51,7 +52,7 @@ void dropBufferedAudio(void);
void
closeAudioDevice
(
void
);
int
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
);
bool
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
);
void
sendMetadataToAudioDevice
(
const
struct
tag
*
tag
);
...
...
src/audio_format.h
View file @
b084bc28
...
...
@@ -20,6 +20,7 @@
#define AUDIO_FORMAT_H
#include <stdint.h>
#include <stdbool.h>
struct
audio_format
{
uint32_t
sampleRate
;
...
...
@@ -34,13 +35,13 @@ static inline void audio_format_clear(struct audio_format *af)
af
->
channels
=
0
;
}
static
inline
int
audio_format_defined
(
const
struct
audio_format
*
af
)
static
inline
bool
audio_format_defined
(
const
struct
audio_format
*
af
)
{
return
af
->
sampleRate
!=
0
;
}
static
inline
int
audio_format_equals
(
const
struct
audio_format
*
a
,
const
struct
audio_format
*
b
)
static
inline
bool
audio_format_equals
(
const
struct
audio_format
*
a
,
const
struct
audio_format
*
b
)
{
return
a
->
sampleRate
==
b
->
sampleRate
&&
a
->
bits
==
b
->
bits
&&
...
...
src/decoder_api.c
View file @
b084bc28
...
...
@@ -85,7 +85,7 @@ double decoder_seek_where(mpd_unused struct decoder * decoder)
{
assert
(
dc
.
command
==
DECODE_COMMAND_SEEK
);
decoder
->
seeking
=
1
;
decoder
->
seeking
=
true
;
return
dc
.
seekWhere
;
}
...
...
src/decoder_api.h
View file @
b084bc28
...
...
@@ -33,6 +33,7 @@
#include "audio_format.h"
#include "playerData.h"
#include <stdbool.h>
/* valid values for streamTypes in the InputPlugin struct: */
#define INPUT_PLUGIN_STREAM_FILE 0x01
...
...
@@ -65,10 +66,10 @@ struct decoder_plugin {
void
(
*
finish
)(
void
);
/**
*
boolean return value, returns 1 if the InputStream is
*
decodable by the InputPlugin, 0
if not
*
returns true if the InputStream is decodable by the
*
InputPlugin, false
if not
*/
unsigned
int
(
*
try_decode
)(
InputStream
*
);
bool
(
*
try_decode
)(
InputStream
*
);
/**
* this will be used to decode InputStreams, and is
...
...
src/decoder_internal.h
View file @
b084bc28
...
...
@@ -27,7 +27,7 @@ struct decoder {
ConvState
conv_state
;
int
seeking
;
bool
seeking
;
};
#endif
src/decoder_thread.c
View file @
b084bc28
...
...
@@ -31,7 +31,7 @@ static void decodeStart(void)
{
struct
decoder
decoder
;
int
ret
;
int
close_instream
=
1
;
bool
close_instream
=
true
;
InputStream
inStream
;
struct
decoder_plugin
*
plugin
=
NULL
;
char
path_max_fs
[
MPD_PATH_MAX
];
...
...
@@ -53,7 +53,7 @@ static void decodeStart(void)
goto
stop_no_close
;
}
decoder
.
seeking
=
0
;
decoder
.
seeking
=
false
;
dc
.
state
=
DECODE_STATE_START
;
dc
.
command
=
DECODE_COMMAND_NONE
;
...
...
@@ -137,7 +137,7 @@ static void decodeStart(void)
if
(
plugin
->
file_decode
!=
NULL
)
{
closeInputStream
(
&
inStream
);
close_instream
=
0
;
close_instream
=
false
;
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
file_decode
(
&
decoder
,
path_max_fs
);
...
...
src/inputPlugins/flac_plugin.c
View file @
b084bc28
...
...
@@ -427,9 +427,9 @@ static int oggflac_decode(struct decoder *decoder, InputStream * inStream)
return
flac_decode_internal
(
decoder
,
inStream
,
1
);
}
static
unsigned
int
oggflac_try_decode
(
InputStream
*
inStream
)
static
bool
oggflac_try_decode
(
InputStream
*
inStream
)
{
return
(
ogg_stream_type_detect
(
inStream
)
==
FLAC
)
?
1
:
0
;
return
ogg_stream_type_detect
(
inStream
)
==
FLAC
;
}
static
const
char
*
oggflac_suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
...
...
src/inputPlugins/mp4_plugin.c
View file @
b084bc28
...
...
@@ -103,12 +103,12 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
unsigned
int
initial
=
1
;
float
*
seekTable
;
long
seekTableEnd
=
-
1
;
int
seekPositionFound
=
0
;
bool
seekPositionFound
=
false
;
long
offset
;
uint16_t
bitRate
=
0
;
int
seeking
=
0
;
bool
seeking
=
false
;
double
seek_where
=
0
;
int
initialized
=
0
;
bool
initialized
=
false
;
mp4cb
=
xmalloc
(
sizeof
(
mp4ff_callback_t
));
mp4cb
->
read
=
mp4_inputStreamReadCallback
;
...
...
@@ -189,7 +189,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
for
(
sampleId
=
0
;
sampleId
<
numSamples
;
sampleId
++
)
{
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
seeking
=
1
;
seeking
=
true
;
seek_where
=
decoder_seek_where
(
mpd_decoder
);
}
...
...
@@ -219,10 +219,10 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
file_time
+=
((
float
)
dur
)
/
scale
;
if
(
seeking
&&
file_time
>
seek_where
)
seekPositionFound
=
1
;
seekPositionFound
=
true
;
if
(
seeking
&&
seekPositionFound
)
{
seekPositionFound
=
0
;
seekPositionFound
=
false
;
decoder_clear
(
mpd_decoder
);
seeking
=
0
;
decoder_command_finished
(
mpd_decoder
);
...
...
@@ -259,7 +259,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
audio_format
.
channels
=
frameInfo
.
channels
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
total_time
);
initialized
=
1
;
initialized
=
true
;
}
if
(
channels
*
(
unsigned
long
)(
dur
+
offset
)
>
frameInfo
.
samples
)
{
...
...
src/inputPlugins/oggflac_plugin.c
View file @
b084bc28
...
...
@@ -283,14 +283,14 @@ static struct tag *oggflac_TagDup(char *file)
return
data
.
tag
;
}
static
unsigned
int
oggflac_try_decode
(
InputStream
*
inStream
)
static
bool
oggflac_try_decode
(
InputStream
*
inStream
)
{
if
(
!
inStream
->
seekable
)
/* we cannot seek after the detection, so don't bother
checking */
return
1
;
return
true
;
return
(
ogg_stream_type_detect
(
inStream
)
==
FLAC
)
?
1
:
0
;
return
ogg_stream_type_detect
(
inStream
)
==
FLAC
;
}
static
int
oggflac_decode
(
struct
decoder
*
mpd_decoder
,
InputStream
*
inStream
)
...
...
src/inputPlugins/oggvorbis_plugin.c
View file @
b084bc28
...
...
@@ -365,14 +365,14 @@ static struct tag *oggvorbis_TagDup(char *file)
return
ret
;
}
static
unsigned
int
oggvorbis_try_decode
(
InputStream
*
inStream
)
static
bool
oggvorbis_try_decode
(
InputStream
*
inStream
)
{
if
(
!
inStream
->
seekable
)
/* we cannot seek after the detection, so don't bother
checking */
return
1
;
return
true
;
return
(
ogg_stream_type_detect
(
inStream
)
==
VORBIS
)
?
1
:
0
;
return
ogg_stream_type_detect
(
inStream
)
==
VORBIS
;
}
static
const
char
*
oggvorbis_Suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
...
...
src/inputPlugins/wavpack_plugin.c
View file @
b084bc28
...
...
@@ -417,7 +417,7 @@ initInputStreamPlus(InputStreamPlus *isp, struct decoder *decoder,
/*
* Tries to decode the specified stream, and gives true if managed to do it.
*/
static
unsigned
int
wavpack_trydecode
(
InputStream
*
is
)
static
bool
wavpack_trydecode
(
InputStream
*
is
)
{
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
;
...
...
@@ -427,13 +427,13 @@ static unsigned int wavpack_trydecode(InputStream *is)
wpc
=
WavpackOpenFileInputEx
(
&
mpd_is_reader
,
&
isp
,
NULL
,
error
,
OPEN_STREAMING
,
0
);
if
(
wpc
==
NULL
)
return
0
;
return
false
;
WavpackCloseFile
(
wpc
);
/* Seek it back in order to play from the first byte. */
seekInputStream
(
is
,
0
,
SEEK_SET
);
return
1
;
return
true
;
}
static
int
wavpack_open_wvc
(
struct
decoder
*
decoder
,
...
...
src/notify.c
View file @
b084bc28
...
...
@@ -31,7 +31,7 @@ void notify_init(struct notify *notify)
if
(
ret
!=
0
)
FATAL
(
"pthread_mutex_init() failed"
);
notify
->
pending
=
0
;
notify
->
pending
=
false
;
}
void
notify_deinit
(
struct
notify
*
notify
)
...
...
@@ -45,14 +45,14 @@ void notify_wait(struct notify *notify)
pthread_mutex_lock
(
&
notify
->
mutex
);
while
(
!
notify
->
pending
)
pthread_cond_wait
(
&
notify
->
cond
,
&
notify
->
mutex
);
notify
->
pending
=
0
;
notify
->
pending
=
false
;
pthread_mutex_unlock
(
&
notify
->
mutex
);
}
void
notify_signal
(
struct
notify
*
notify
)
{
pthread_mutex_lock
(
&
notify
->
mutex
);
notify
->
pending
=
1
;
notify
->
pending
=
true
;
pthread_cond_signal
(
&
notify
->
cond
);
pthread_mutex_unlock
(
&
notify
->
mutex
);
}
src/notify.h
View file @
b084bc28
...
...
@@ -19,12 +19,13 @@
#ifndef NOTIFY_H
#define NOTIFY_H
#include <stdbool.h>
#include <pthread.h>
struct
notify
{
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
int
pending
;
bool
pending
;
};
#define NOTIFY_INITIALIZER { \
...
...
src/outputBuffer.c
View file @
b084bc28
...
...
@@ -34,7 +34,7 @@ ob_init(unsigned int size, struct notify *notify)
ob
.
size
=
size
;
ob
.
begin
=
0
;
ob
.
end
=
0
;
ob
.
lazy
=
0
;
ob
.
lazy
=
false
;
ob
.
notify
=
notify
;
ob
.
chunks
[
0
].
chunkSize
=
0
;
}
...
...
@@ -96,7 +96,7 @@ void ob_flush(void)
}
}
void
ob_set_lazy
(
int
lazy
)
void
ob_set_lazy
(
bool
lazy
)
{
ob
.
lazy
=
lazy
;
}
...
...
src/outputBuffer.h
View file @
b084bc28
...
...
@@ -22,6 +22,7 @@
#include "audio_format.h"
#include <stddef.h>
#include <stdbool.h>
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020
...
...
@@ -50,7 +51,7 @@ struct output_buffer {
/** non-zero if the player thread should only we woken up if
the buffer becomes non-empty */
int
lazy
;
bool
lazy
;
struct
audio_format
audioFormat
;
...
...
@@ -74,7 +75,7 @@ void ob_flush(void);
* previously empty, i.e. when the player thread has really been
* waiting for us.
*/
void
ob_set_lazy
(
int
lazy
);
void
ob_set_lazy
(
bool
lazy
);
/** is the buffer empty? */
int
ob_is_empty
(
void
);
...
...
src/player_thread.c
View file @
b084bc28
...
...
@@ -192,7 +192,7 @@ static void do_play(void)
int
next
=
-
1
;
ob_clear
();
ob_set_lazy
(
0
);
ob_set_lazy
(
false
);
dc_start
(
&
pc
.
notify
,
pc
.
next_song
);
if
(
waitOnDecode
(
&
decodeWaitedOn
)
<
0
)
{
...
...
@@ -222,7 +222,7 @@ static void do_play(void)
}
else
{
/* buffering is complete */
buffering
=
0
;
ob_set_lazy
(
1
);
ob_set_lazy
(
true
);
}
}
...
...
@@ -314,7 +314,7 @@ static void do_play(void)
}
nextChunk
=
ob_absolute
(
crossFadeChunks
);
if
(
nextChunk
>=
0
)
{
ob_set_lazy
(
1
);
ob_set_lazy
(
true
);
cross_fade_apply
(
beginChunk
,
ob_get_chunk
(
nextChunk
),
&
(
ob
.
audioFormat
),
...
...
@@ -331,7 +331,7 @@ static void do_play(void)
}
else
{
/* wait for the
decoder */
ob_set_lazy
(
0
);
ob_set_lazy
(
false
);
notify_wait
(
&
pc
.
notify
);
continue
;
}
...
...
src/playlist.c
View file @
b084bc28
...
...
@@ -57,7 +57,7 @@
#define PLAYLIST_HASH_MULT 4
#define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
#define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
0
#define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
false
static
Playlist
playlist
;
static
int
playlist_state
=
PLAYLIST_STATE_STOP
;
...
...
@@ -66,7 +66,7 @@ static int playlist_stopOnError;
static
int
playlist_errorCount
;
static
int
playlist_noGoToNext
;
int
playlist_saveAbsolutePaths
=
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
;
bool
playlist_saveAbsolutePaths
=
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
;
static
void
swapOrder
(
int
a
,
int
b
);
static
void
playPlaylistOrderNumber
(
int
orderNum
);
...
...
@@ -119,9 +119,9 @@ void initPlaylist(void)
ConfigParam
*
param
;
playlist
.
length
=
0
;
playlist
.
repeat
=
0
;
playlist
.
repeat
=
false
;
playlist
.
version
=
1
;
playlist
.
random
=
0
;
playlist
.
random
=
false
;
playlist
.
queued
=
-
1
;
playlist
.
current
=
-
1
;
...
...
@@ -329,9 +329,9 @@ void readPlaylistState(FILE *fp)
if
(
strcmp
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_REPEAT
)]),
"1"
)
==
0
)
{
setPlaylistRepeatStatus
(
1
);
setPlaylistRepeatStatus
(
true
);
}
else
setPlaylistRepeatStatus
(
0
);
setPlaylistRepeatStatus
(
false
);
}
else
if
(
!
prefixcmp
(
buffer
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
setPlayerCrossFade
(
atoi
(
&
...
...
@@ -344,9 +344,9 @@ void readPlaylistState(FILE *fp)
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_RANDOM
)]),
"1"
)
==
0
)
{
setPlaylistRandomStatus
(
1
);
setPlaylistRandomStatus
(
true
);
}
else
setPlaylistRandomStatus
(
0
);
setPlaylistRandomStatus
(
false
);
}
else
if
(
!
prefixcmp
(
buffer
,
PLAYLIST_STATE_FILE_CURRENT
))
{
if
(
strlen
(
buffer
)
==
strlen
(
PLAYLIST_STATE_FILE_CURRENT
))
...
...
@@ -980,17 +980,17 @@ void playPlaylistIfPlayerStopped(void)
}
}
int
getPlaylistRepeatStatus
(
void
)
bool
getPlaylistRepeatStatus
(
void
)
{
return
playlist
.
repeat
;
}
int
getPlaylistRandomStatus
(
void
)
bool
getPlaylistRandomStatus
(
void
)
{
return
playlist
.
random
;
}
void
setPlaylistRepeatStatus
(
int
status
)
void
setPlaylistRepeatStatus
(
bool
status
)
{
if
(
playlist_state
==
PLAYLIST_STATE_PLAY
)
{
if
(
playlist
.
repeat
&&
!
status
&&
playlist
.
queued
==
0
)
...
...
@@ -1150,9 +1150,9 @@ static void randomizeOrder(int start, int end)
}
}
void
setPlaylistRandomStatus
(
int
status
)
void
setPlaylistRandomStatus
(
bool
status
)
{
int
statusWas
=
playlist
.
random
;
bool
statusWas
=
playlist
.
random
;
playlist
.
random
=
status
;
...
...
src/playlist.h
View file @
b084bc28
...
...
@@ -21,6 +21,7 @@
#include "locate.h"
#include <stdbool.h>
#include <stdio.h>
#define PLAYLIST_FILE_SUFFIX "m3u"
...
...
@@ -50,12 +51,12 @@ typedef struct _Playlist {
int
length
;
int
current
;
int
queued
;
int
repeat
;
int
random
;
bool
repeat
;
bool
random
;
uint32_t
version
;
}
Playlist
;
extern
int
playlist_saveAbsolutePaths
;
extern
bool
playlist_saveAbsolutePaths
;
extern
int
playlist_max_length
;
...
...
@@ -119,13 +120,13 @@ enum playlist_result swapSongsInPlaylistById(int id1, int id2);
enum
playlist_result
loadPlaylist
(
struct
client
*
client
,
const
char
*
utf8file
);
int
getPlaylistRepeatStatus
(
void
);
bool
getPlaylistRepeatStatus
(
void
);
void
setPlaylistRepeatStatus
(
int
status
);
void
setPlaylistRepeatStatus
(
bool
status
);
int
getPlaylistRandomStatus
(
void
);
bool
getPlaylistRandomStatus
(
void
);
void
setPlaylistRandomStatus
(
int
status
);
void
setPlaylistRandomStatus
(
bool
status
);
int
getPlaylistCurrentSong
(
void
);
...
...
src/song.h
View file @
b084bc28
...
...
@@ -19,6 +19,8 @@
#ifndef SONG_H
#define SONG_H
#include <stddef.h>
#include <stdbool.h>
#include <sys/time.h>
#define SONG_BEGIN "songList begin"
...
...
@@ -55,10 +57,10 @@ updateSongInfo(struct song *song);
char
*
get_song_url
(
char
*
path_max_tmp
,
struct
song
*
song
);
static
inline
int
static
inline
bool
song_is_file
(
const
struct
song
*
song
)
{
return
!!
song
->
parentDir
;
return
song
->
parentDir
!=
NULL
;
}
#endif
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