aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio.c3
-rw-r--r--src/audio.h3
-rw-r--r--src/audio_format.h7
-rw-r--r--src/decoder_api.c2
-rw-r--r--src/decoder_api.h7
-rw-r--r--src/decoder_internal.h2
-rw-r--r--src/decoder_thread.c6
-rw-r--r--src/inputPlugins/flac_plugin.c4
-rw-r--r--src/inputPlugins/mp4_plugin.c14
-rw-r--r--src/inputPlugins/oggflac_plugin.c6
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c6
-rw-r--r--src/inputPlugins/wavpack_plugin.c6
-rw-r--r--src/notify.c6
-rw-r--r--src/notify.h3
-rw-r--r--src/outputBuffer.c4
-rw-r--r--src/outputBuffer.h5
-rw-r--r--src/player_thread.c8
-rw-r--r--src/playlist.c26
-rw-r--r--src/playlist.h15
-rw-r--r--src/song.h6
20 files changed, 74 insertions, 65 deletions
diff --git a/src/audio.c b/src/audio.c
index b38c47d72..9022061f4 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -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);
diff --git a/src/audio.h b/src/audio.h
index f5e89d245..9140afd58 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -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);
diff --git a/src/audio_format.h b/src/audio_format.h
index 1c9caee7d..794ebaaff 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -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 &&
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 8c2d64da1..3ce2622a4 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -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;
}
diff --git a/src/decoder_api.h b/src/decoder_api.h
index d5e76f610..d0985f123 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -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
diff --git a/src/decoder_internal.h b/src/decoder_internal.h
index 6d8bc7a87..174ca019d 100644
--- a/src/decoder_internal.h
+++ b/src/decoder_internal.h
@@ -27,7 +27,7 @@ struct decoder {
ConvState conv_state;
- int seeking;
+ bool seeking;
};
#endif
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index c5a2794cc..fd617a6ac 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -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);
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index 0b4fbf27e..cd8a8efd3 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -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 };
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index 1a4c495d6..6a2d167b2 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -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) {
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index ea36cb82b..3a2db5c03 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -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)
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index a01556cb3..0e1d523b9 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -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 };
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index e98eb7365..af7c3a2f3 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -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,
diff --git a/src/notify.c b/src/notify.c
index e6bb98bba..7d25db517 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -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);
}
diff --git a/src/notify.h b/src/notify.h
index 91140d356..0875eb3ce 100644
--- a/src/notify.h
+++ b/src/notify.h
@@ -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 { \
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index d89dcb308..5a397ac42 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -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;
}
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index 03d15c9de..e1878196e 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -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);
diff --git a/src/player_thread.c b/src/player_thread.c
index 0c07778ed..a9e594eea 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -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;
}
diff --git a/src/playlist.c b/src/playlist.c
index fe172ebbf..402b57ea3 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -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;
diff --git a/src/playlist.h b/src/playlist.h
index a5b340ddc..e50f57bc4 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -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);
diff --git a/src/song.h b/src/song.h
index 142ea52f4..2510f3770 100644
--- a/src/song.h
+++ b/src/song.h
@@ -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