aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio.c28
-rw-r--r--src/audio.h4
-rw-r--r--src/output/alsa_plugin.c19
-rw-r--r--src/output/ao_plugin.c17
-rw-r--r--src/output/fifo_plugin.c24
-rw-r--r--src/output/jack_plugin.c16
-rw-r--r--src/output/mvp_plugin.c28
-rw-r--r--src/output/null_plugin.c12
-rw-r--r--src/output/oss_plugin.c33
-rw-r--r--src/output/osx_plugin.c29
-rw-r--r--src/output/pulse_plugin.c22
-rw-r--r--src/output/shout_plugin.c24
-rw-r--r--src/output/shout_plugin.h2
-rw-r--r--src/output_api.c2
-rw-r--r--src/output_api.h6
-rw-r--r--src/output_control.c9
-rw-r--r--src/output_control.h7
-rw-r--r--src/output_init.c4
-rw-r--r--src/output_internal.h12
-rw-r--r--src/output_thread.c8
-rw-r--r--src/player_thread.c9
21 files changed, 162 insertions, 153 deletions
diff --git a/src/audio.c b/src/audio.c
index 0eff63f8f..f4f0ffe14 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -247,9 +247,9 @@ static void syncAudioDeviceStates(void)
}
}
-int playAudio(const char *buffer, size_t length)
+bool playAudio(const char *buffer, size_t length)
{
- int ret = -1, err;
+ bool ret = false;
unsigned int i;
/* no partial frames allowed */
@@ -262,8 +262,8 @@ int playAudio(const char *buffer, size_t length)
audio_output_play(&audioOutputArray[i],
buffer, length);
- while (1) {
- int finished = 1;
+ while (true) {
+ bool finished = true;
for (i = 0; i < audioOutputArraySize; ++i) {
struct audio_output *ao = &audioOutputArray[i];
@@ -272,16 +272,16 @@ int playAudio(const char *buffer, size_t length)
continue;
if (audio_output_command_is_finished(ao)) {
- err = audio_output_get_result(ao);
- if (!err)
- ret = 0;
- else if (err < 0)
+ bool success = audio_output_get_result(ao);
+ if (success)
+ ret = true;
+ else
/* device should already be
closed if the play func
returned an error */
audioDeviceStates[i] = true;
} else {
- finished = 0;
+ finished = false;
audio_output_signal(ao);
}
}
@@ -295,13 +295,13 @@ int playAudio(const char *buffer, size_t length)
return ret;
}
-int openAudioDevice(const struct audio_format *audioFormat)
+bool openAudioDevice(const struct audio_format *audioFormat)
{
- int ret = -1;
+ bool ret = false;
unsigned int i;
if (!audioOutputArray)
- return -1;
+ return false;
if (audioFormat != NULL)
input_audio_format = *audioFormat;
@@ -310,10 +310,10 @@ int openAudioDevice(const struct audio_format *audioFormat)
for (i = 0; i < audioOutputArraySize; ++i) {
if (audioOutputArray[i].open)
- ret = 0;
+ ret = true;
}
- if (ret != 0)
+ if (!ret)
/* close all devices if there was an error */
closeAudioDevice();
diff --git a/src/audio.h b/src/audio.h
index 9140afd58..c6f6cbde0 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -42,9 +42,9 @@ void initAudioDriver(void);
void finishAudioDriver(void);
-int openAudioDevice(const struct audio_format *audioFormat);
+bool openAudioDevice(const struct audio_format *audioFormat);
-int playAudio(const char *playChunk, size_t size);
+bool playAudio(const char *playChunk, size_t size);
void audio_output_pause_all(void);
diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c
index e812e49fc..2d4f9c239 100644
--- a/src/output/alsa_plugin.c
+++ b/src/output/alsa_plugin.c
@@ -125,7 +125,7 @@ static void alsa_finishDriver(void *data)
freeAlsaData(ad);
}
-static int alsa_testDefault(void)
+static bool alsa_testDefault(void)
{
snd_pcm_t *handle;
@@ -134,11 +134,11 @@ static int alsa_testDefault(void)
if (ret) {
WARNING("Error opening default ALSA device: %s\n",
snd_strerror(-ret));
- return -1;
+ return false;
} else
snd_pcm_close(handle);
- return 0;
+ return true;
}
static snd_pcm_format_t get_bitformat(const struct audio_format *af)
@@ -152,7 +152,7 @@ static snd_pcm_format_t get_bitformat(const struct audio_format *af)
return SND_PCM_FORMAT_UNKNOWN;
}
-static int alsa_openDevice(void *data, struct audio_format *audioFormat)
+static bool alsa_openDevice(void *data, struct audio_format *audioFormat)
{
AlsaData *ad = data;
snd_pcm_format_t bitformat;
@@ -318,7 +318,7 @@ configure_hw:
"%u Hz\n", ad->device, audioFormat->bits,
channels, sample_rate);
- return 0;
+ return true;
error:
if (cmd) {
@@ -332,7 +332,7 @@ fail:
if (ad->pcmHandle)
snd_pcm_close(ad->pcmHandle);
ad->pcmHandle = NULL;
- return -1;
+ return false;
}
static int alsa_errorRecovery(AlsaData * ad, int err)
@@ -393,7 +393,8 @@ static void alsa_closeDevice(void *data)
}
}
-static int alsa_playAudio(void *data, const char *playChunk, size_t size)
+static bool
+alsa_playAudio(void *data, const char *playChunk, size_t size)
{
AlsaData *ad = data;
int ret;
@@ -412,7 +413,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size)
"error: %s\n", ad->device,
snd_strerror(-errno));
alsa_closeDevice(ad);
- return -1;
+ return false;
}
continue;
}
@@ -421,7 +422,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size)
size -= ret;
}
- return 0;
+ return true;
}
const struct audio_output_plugin alsaPlugin = {
diff --git a/src/output/ao_plugin.c b/src/output/ao_plugin.c
index b5cebc93b..d2c7dab6e 100644
--- a/src/output/ao_plugin.c
+++ b/src/output/ao_plugin.c
@@ -168,8 +168,8 @@ static void audioOutputAo_closeDevice(void *data)
}
}
-static int audioOutputAo_openDevice(void *data,
- struct audio_format *audio_format)
+static bool
+audioOutputAo_openDevice(void *data, struct audio_format *audio_format)
{
ao_sample_format format;
AoData *ad = (AoData *)data;
@@ -186,9 +186,9 @@ static int audioOutputAo_openDevice(void *data,
ad->device = ao_open_live(ad->driverId, &format, ad->options);
if (ad->device == NULL)
- return -1;
+ return false;
- return 0;
+ return true;
}
/**
@@ -208,13 +208,14 @@ static int ao_play_deconst(ao_device *device, const void *output_samples,
return ao_play(device, u.out, num_bytes);
}
-static int audioOutputAo_play(void *data, const char *playChunk, size_t size)
+static bool
+audioOutputAo_play(void *data, const char *playChunk, size_t size)
{
AoData *ad = (AoData *)data;
size_t chunk_size;
if (ad->device == NULL)
- return -1;
+ return false;
while (size > 0) {
chunk_size = (size_t)ad->writeSize > size
@@ -224,14 +225,14 @@ static int audioOutputAo_play(void *data, const char *playChunk, size_t size)
audioOutputAo_error();
ERROR("closing audio device due to write error\n");
audioOutputAo_closeDevice(ad);
- return -1;
+ return false;
}
playChunk += chunk_size;
size -= chunk_size;
}
- return 0;
+ return true;
}
const struct audio_output_plugin aoPlugin = {
diff --git a/src/output/fifo_plugin.c b/src/output/fifo_plugin.c
index cd83177f8..fe85d6644 100644
--- a/src/output/fifo_plugin.c
+++ b/src/output/fifo_plugin.c
@@ -128,17 +128,17 @@ static int checkFifo(FifoData *fd)
return 0;
}
-static int openFifo(FifoData *fd)
+static bool openFifo(FifoData *fd)
{
if (checkFifo(fd) < 0)
- return -1;
+ return false;
fd->input = open(fd->path, O_RDONLY|O_NONBLOCK);
if (fd->input < 0) {
ERROR("Could not open FIFO \"%s\" for reading: %s\n",
fd->path, strerror(errno));
closeFifo(fd);
- return -1;
+ return false;
}
fd->output = open(fd->path, O_WRONLY|O_NONBLOCK);
@@ -146,10 +146,10 @@ static int openFifo(FifoData *fd)
ERROR("Could not open FIFO \"%s\" for writing: %s\n",
fd->path, strerror(errno));
closeFifo(fd);
- return -1;
+ return false;
}
- return 0;
+ return true;
}
static void *fifo_initDriver(mpd_unused struct audio_output *ao,
@@ -175,7 +175,7 @@ static void *fifo_initDriver(mpd_unused struct audio_output *ao,
fd = newFifoData();
fd->path = path;
- if (openFifo(fd) < 0) {
+ if (!openFifo(fd)) {
freeFifoData(fd);
return NULL;
}
@@ -191,7 +191,7 @@ static void fifo_finishDriver(void *data)
freeFifoData(fd);
}
-static int fifo_openDevice(void *data,
+static bool fifo_openDevice(void *data,
struct audio_format *audio_format)
{
FifoData *fd = (FifoData *)data;
@@ -201,7 +201,7 @@ static int fifo_openDevice(void *data,
fd->timer = timer_new(audio_format);
- return 0;
+ return true;
}
static void fifo_closeDevice(void *data)
@@ -231,8 +231,8 @@ static void fifo_dropBufferedAudio(void *data)
}
}
-static int fifo_playAudio(void *data,
- const char *playChunk, size_t size)
+static bool
+fifo_playAudio(void *data, const char *playChunk, size_t size)
{
FifoData *fd = (FifoData *)data;
size_t offset = 0;
@@ -260,14 +260,14 @@ static int fifo_playAudio(void *data,
ERROR("Closing FIFO output \"%s\" due to write error: "
"%s\n", fd->path, strerror(errno));
fifo_closeDevice(fd);
- return -1;
+ return false;
}
size -= bytes;
offset += bytes;
}
- return 0;
+ return true;
}
const struct audio_output_plugin fifoPlugin = {
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index 7f10db976..1e6c81b75 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -242,10 +242,10 @@ mpd_jack_init(struct audio_output *ao,
return jd;
}
-static int
+static bool
mpd_jack_test_default_device(void)
{
- return 0;
+ return true;
}
static int
@@ -328,7 +328,7 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
return 1;
}
-static int
+static bool
mpd_jack_open(void *data, struct audio_format *audio_format)
{
struct jack_data *jd = data;
@@ -337,12 +337,12 @@ mpd_jack_open(void *data, struct audio_format *audio_format)
if (jd->client == NULL && mpd_jack_connect(jd, audio_format) < 0) {
mpd_jack_client_free(jd);
- return -1;
+ return false;
}
set_audioformat(jd, audio_format);
- return 0;
+ return true;
}
static void
@@ -422,7 +422,7 @@ mpd_jack_write_samples(struct jack_data *jd, const void *src,
}
}
-static int
+static bool
mpd_jack_play(void *data, const char *buff, size_t size)
{
struct jack_data *jd = data;
@@ -433,7 +433,7 @@ mpd_jack_play(void *data, const char *buff, size_t size)
ERROR("Refusing to play, because there is no client thread.\n");
mpd_jack_client_free(jd);
audio_output_closed(jd->ao);
- return 0;
+ return true;
}
assert(size % frame_size == 0);
@@ -462,7 +462,7 @@ mpd_jack_play(void *data, const char *buff, size_t size)
}
- return 0;
+ return true;
}
const struct audio_output_plugin jackPlugin = {
diff --git a/src/output/mvp_plugin.c b/src/output/mvp_plugin.c
index 94f4f0ea7..9a56e7943 100644
--- a/src/output/mvp_plugin.c
+++ b/src/output/mvp_plugin.c
@@ -81,7 +81,7 @@ static unsigned pcmfrequencies[][3] = {
static const unsigned numfrequencies =
sizeof(pcmfrequencies) / sizeof(pcmfrequencies[0]);
-static int mvp_testDefault(void)
+static bool mvp_testDefault(void)
{
int fd;
@@ -89,13 +89,13 @@ static int mvp_testDefault(void)
if (fd) {
close(fd);
- return 0;
+ return true;
}
WARNING("Error opening PCM device \"/dev/adec_pcm\": %s\n",
strerror(errno));
- return -1;
+ return false;
}
static void *mvp_initDriver(mpd_unused struct audio_output *audio_output,
@@ -178,7 +178,8 @@ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
return 0;
}
-static int mvp_openDevice(void *data, struct audio_format *audioFormat)
+static bool
+mvp_openDevice(void *data, struct audio_format *audioFormat)
{
MvpData *md = data;
long long int stc = 0;
@@ -186,24 +187,24 @@ static int mvp_openDevice(void *data, struct audio_format *audioFormat)
if ((md->fd = open("/dev/adec_pcm", O_RDWR | O_NONBLOCK)) < 0) {
ERROR("Error opening /dev/adec_pcm: %s\n", strerror(errno));
- return -1;
+ return false;
}
if (ioctl(md->fd, MVP_SET_AUD_SRC, 1) < 0) {
ERROR("Error setting audio source: %s\n", strerror(errno));
- return -1;
+ return false;
}
if (ioctl(md->fd, MVP_SET_AUD_STREAMTYPE, 0) < 0) {
ERROR("Error setting audio streamtype: %s\n", strerror(errno));
- return -1;
+ return false;
}
if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) {
ERROR("Error setting audio format: %s\n", strerror(errno));
- return -1;
+ return false;
}
ioctl(md->fd, MVP_SET_AUD_STC, &stc);
if (ioctl(md->fd, MVP_SET_AUD_BYPASS, 1) < 0) {
ERROR("Error setting audio streamtype: %s\n", strerror(errno));
- return -1;
+ return false;
}
#ifdef WORDS_BIGENDIAN
mvp_setPcmParams(md, audioFormat->sample_rate, audioFormat->channels,
@@ -213,7 +214,7 @@ static int mvp_openDevice(void *data, struct audio_format *audioFormat)
1, audioFormat->bits);
#endif
md->audio_format = *audioFormat;
- return 0;
+ return true;
}
static void mvp_closeDevice(void *data)
@@ -235,7 +236,8 @@ static void mvp_dropBufferedAudio(void *data)
}
}
-static int mvp_playAudio(void *data, const char *playChunk, size_t size)
+static bool
+mvp_playAudio(void *data, const char *playChunk, size_t size)
{
MvpData *md = data;
ssize_t ret;
@@ -252,12 +254,12 @@ static int mvp_playAudio(void *data, const char *playChunk, size_t size)
ERROR("closing mvp PCM device due to write error: "
"%s\n", strerror(errno));
mvp_closeDevice(md);
- return -1;
+ return false;
}
playChunk += ret;
size -= ret;
}
- return 0;
+ return true;
}
const struct audio_output_plugin mvpPlugin = {
diff --git a/src/output/null_plugin.c b/src/output/null_plugin.c
index ff3a9833c..bef2ff924 100644
--- a/src/output/null_plugin.c
+++ b/src/output/null_plugin.c
@@ -33,13 +33,13 @@ static void *null_initDriver(mpd_unused struct audio_output *audioOutput,
return nd;
}
-static int null_openDevice(void *data,
- struct audio_format *audio_format)
+static bool
+null_openDevice(void *data, struct audio_format *audio_format)
{
struct null_data *nd = data;
nd->timer = timer_new(audio_format);
- return 0;
+ return true;
}
static void null_closeDevice(void *data)
@@ -52,8 +52,8 @@ static void null_closeDevice(void *data)
}
}
-static int null_playAudio(void *data,
- mpd_unused const char *playChunk, size_t size)
+static bool
+null_playAudio(void *data, mpd_unused const char *playChunk, size_t size)
{
struct null_data *nd = data;
Timer *timer = nd->timer;
@@ -65,7 +65,7 @@ static int null_playAudio(void *data,
timer_add(timer, size);
- return 0;
+ return true;
}
static void null_dropBufferedAudio(void *data)
diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c
index 2992368d9..26bc1b3aa 100644
--- a/src/output/oss_plugin.c
+++ b/src/output/oss_plugin.c
@@ -322,20 +322,20 @@ static int oss_statDevice(const char *device, int *stErrno)
static const char *default_devices[] = { "/dev/sound/dsp", "/dev/dsp" };
-static int oss_testDefault(void)
+static bool oss_testDefault(void)
{
int fd, i;
for (i = ARRAY_SIZE(default_devices); --i >= 0; ) {
if ((fd = open(default_devices[i], O_WRONLY)) >= 0) {
xclose(fd);
- return 0;
+ return true;
}
WARNING("Error opening OSS device \"%s\": %s\n",
default_devices[i], strerror(errno));
}
- return -1;
+ return false;
}
static void *oss_open_default(ConfigParam *param)
@@ -438,7 +438,7 @@ static void oss_close(OssData * od)
od->fd = -1;
}
-static int oss_open(OssData *od)
+static bool oss_open(OssData *od)
{
int tmp;
@@ -486,23 +486,24 @@ static int oss_open(OssData *od)
goto fail;
}
- return 0;
+ return true;
fail:
oss_close(od);
- return -1;
+ return false;
}
-static int oss_openDevice(void *data,
- struct audio_format *audioFormat)
+static bool
+oss_openDevice(void *data, struct audio_format *audioFormat)
{
- int ret;
+ bool ret;
OssData *od = data;
od->audio_format = *audioFormat;
- if ((ret = oss_open(od)) < 0)
- return ret;
+ ret = oss_open(od);
+ if (!ret)
+ return false;
*audioFormat = od->audio_format;
@@ -531,15 +532,15 @@ static void oss_dropBufferedAudio(void *data)
}
}
-static int oss_playAudio(void *data,
- const char *playChunk, size_t size)
+static bool
+oss_playAudio(void *data, const char *playChunk, size_t size)
{
OssData *od = data;
ssize_t ret;
/* reopen the device since it was closed by dropBufferedAudio */
if (od->fd < 0 && oss_open(od) < 0)
- return -1;
+ return false;
while (size > 0) {
ret = write(od->fd, playChunk, size);
@@ -549,13 +550,13 @@ static int oss_playAudio(void *data,
ERROR("closing oss device \"%s\" due to write error: "
"%s\n", od->device, strerror(errno));
oss_closeDevice(od);
- return -1;
+ return false;
}
playChunk += ret;
size -= ret;
}
- return 0;
+ return true;
}
const struct audio_output_plugin ossPlugin = {
diff --git a/src/output/osx_plugin.c b/src/output/osx_plugin.c
index a3f67fa68..a31a6e736 100644
--- a/src/output/osx_plugin.c
+++ b/src/output/osx_plugin.c
@@ -49,7 +49,7 @@ static OsxData *newOsxData()
return ret;
}
-static int osx_testDefault()
+static bool osx_testDefault()
{
/*AudioUnit au;
ComponentDescription desc;
@@ -74,7 +74,7 @@ static int osx_testDefault()
CloseComponent(au); */
- return 0;
+ return true;
}
static int osx_initDriver(struct audio_output *audioOutput,
@@ -212,8 +212,9 @@ static OSStatus osx_render(void *vdata,
return 0;
}
-static int osx_openDevice(struct audio_output *audioOutput,
- struct audio_format *audioFormat)
+static bool
+osx_openDevice(struct audio_output *audioOutput,
+ struct audio_format *audioFormat)
{
OsxData *od = (OsxData *) audioOutput->data;
ComponentDescription desc;
@@ -230,18 +231,18 @@ static int osx_openDevice(struct audio_output *audioOutput,
comp = FindNextComponent(NULL, &desc);
if (comp == 0) {
ERROR("Error finding OS X component\n");
- return -1;
+ return false;
}
if (OpenAComponent(comp, &od->au) != noErr) {
ERROR("Unable to open OS X component\n");
- return -1;
+ return false;
}
if (AudioUnitInitialize(od->au) != 0) {
CloseComponent(od->au);
ERROR("Unable to initialize OS X audio unit\n");
- return -1;
+ return false;
}
callback.inputProc = osx_render;
@@ -253,7 +254,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
AudioUnitUninitialize(od->au);
CloseComponent(od->au);
ERROR("unable to set callback for OS X audio unit\n");
- return -1;
+ return false;
}
streamDesc.mSampleRate = audioFormat->sample_rate;
@@ -275,7 +276,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
AudioUnitUninitialize(od->au);
CloseComponent(od->au);
ERROR("Unable to set format on OS X device\n");
- return -1;
+ return false;
}
/* create a buffer of 1s */
@@ -286,11 +287,11 @@ static int osx_openDevice(struct audio_output *audioOutput,
od->pos = 0;
od->len = 0;
- return 0;
+ return true;
}
-static int osx_play(struct audio_output *audioOutput,
- const char *playChunk, size_t size)
+static bool
+osx_play(struct audio_output *audioOutput, const char *playChunk, size_t size)
{
OsxData *od = (OsxData *) audioOutput->data;
size_t bytesToCopy;
@@ -304,7 +305,7 @@ static int osx_play(struct audio_output *audioOutput,
err = AudioOutputUnitStart(od->au);
if (err) {
ERROR("unable to start audio output: %i\n", err);
- return -1;
+ return false;
}
}
@@ -345,7 +346,7 @@ static int osx_play(struct audio_output *audioOutput,
pthread_mutex_unlock(&od->mutex);
/* DEBUG("osx_play: leave\n"); */
- return 0;
+ return true;
}
const struct audio_output_plugin osxPlugin = {
diff --git a/src/output/pulse_plugin.c b/src/output/pulse_plugin.c
index 2104fe81e..c6849dbc6 100644
--- a/src/output/pulse_plugin.c
+++ b/src/output/pulse_plugin.c
@@ -86,7 +86,7 @@ static void pulse_finish(void *data)
pulse_free_data(pd);
}
-static int pulse_test_default_device(void)
+static bool pulse_test_default_device(void)
{
pa_simple *s;
pa_sample_spec ss;
@@ -101,15 +101,15 @@ static int pulse_test_default_device(void)
if (!s) {
g_message("Cannot connect to default PulseAudio server: %s\n",
pa_strerror(error));
- return -1;
+ return false;
}
pa_simple_free(s);
- return 0;
+ return true;
}
-static int
+static bool
pulse_open(void *data, struct audio_format *audio_format)
{
struct pulse_data *pd = data;
@@ -121,7 +121,7 @@ pulse_open(void *data, struct audio_format *audio_format)
if (pd->num_connect_attempts != 0 &&
(t - pd->last_connect_attempt) < CONN_ATTEMPT_INTERVAL)
- return -1;
+ return false;
pd->num_connect_attempts++;
pd->last_connect_attempt = t;
@@ -143,7 +143,7 @@ pulse_open(void *data, struct audio_format *audio_format)
"\"%s\" (attempt %i): %s\n",
audio_output_get_name(pd->ao),
pd->num_connect_attempts, pa_strerror(error));
- return -1;
+ return false;
}
pd->num_connect_attempts = 0;
@@ -154,7 +154,7 @@ pulse_open(void *data, struct audio_format *audio_format)
audio_format->bits,
audio_format->channels, audio_format->sample_rate);
- return 0;
+ return true;
}
static void pulse_cancel(void *data)
@@ -179,8 +179,8 @@ static void pulse_close(void *data)
}
}
-static int pulse_play(void *data,
- const char *playChunk, size_t size)
+static bool
+pulse_play(void *data, const char *playChunk, size_t size)
{
struct pulse_data *pd = data;
int error;
@@ -191,10 +191,10 @@ static int pulse_play(void *data,
audio_output_get_name(pd->ao),
pa_strerror(error));
pulse_close(pd);
- return -1;
+ return false;
}
- return 0;
+ return true;
}
const struct audio_output_plugin pulse_plugin = {
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c
index dd909bdae..7bd806d36 100644
--- a/src/output/shout_plugin.c
+++ b/src/output/shout_plugin.c
@@ -354,7 +354,7 @@ static void close_shout_conn(struct shout_data * sd)
shout_get_error(sd->shout_conn));
}
- sd->opened = 0;
+ sd->opened = false;
}
static void my_shout_finish_driver(void *data)
@@ -465,27 +465,27 @@ static int open_shout_conn(void *data)
write_page(sd);
sd->shout_error = 0;
- sd->opened = 1;
+ sd->opened = true;
sd->tag_to_send = 1;
sd->conn_attempts = 0;
return 0;
}
-static int my_shout_open_device(void *data,
+static bool my_shout_open_device(void *data,
struct audio_format *audio_format)
{
struct shout_data *sd = (struct shout_data *)data;
if (!sd->opened && open_shout_conn(sd) < 0)
- return -1;
+ return false;
if (sd->timer)
timer_free(sd->timer);
sd->timer = timer_new(audio_format);
- return 0;
+ return true;
}
static void send_metadata(struct shout_data * sd)
@@ -508,8 +508,8 @@ static void send_metadata(struct shout_data * sd)
sd->tag_to_send = 0;
}
-static int my_shout_play(void *data,
- const char *chunk, size_t size)
+static bool
+my_shout_play(void *data, const char *chunk, size_t size)
{
struct shout_data *sd = (struct shout_data *)data;
int status;
@@ -526,24 +526,24 @@ static int my_shout_play(void *data,
status = open_shout_conn(sd);
if (status < 0) {
my_shout_close_device(sd);
- return -1;
+ return false;
} else if (status > 0) {
timer_sync(sd->timer);
- return 0;
+ return true;
}
}
if (sd->encoder->encode_func(sd, chunk, size)) {
my_shout_close_device(sd);
- return -1;
+ return false;
}
if (write_page(sd) < 0) {
my_shout_close_device(sd);
- return -1;
+ return false;
}
- return 0;
+ return true;
}
static void my_shout_pause(void *data)
diff --git a/src/output/shout_plugin.h b/src/output/shout_plugin.h
index ae7d23b03..2ddde22ae 100644
--- a/src/output/shout_plugin.h
+++ b/src/output/shout_plugin.h
@@ -65,7 +65,7 @@ struct shout_data {
float quality;
int bitrate;
- int opened;
+ bool opened;
struct tag *tag;
int tag_to_send;
diff --git a/src/output_api.c b/src/output_api.c
index 3d3230376..7737fc9d7 100644
--- a/src/output_api.c
+++ b/src/output_api.c
@@ -30,7 +30,7 @@ void audio_output_closed(struct audio_output *ao)
{
assert(ao->open);
- ao->open = 0;
+ ao->open = false;
}
bool audio_output_is_pending(const struct audio_output *ao)
diff --git a/src/output_api.h b/src/output_api.h
index 11d4620f6..fb0844cd8 100644
--- a/src/output_api.h
+++ b/src/output_api.h
@@ -45,7 +45,7 @@ struct audio_output_plugin {
* Test if this plugin can provide a default output, in case
* none has been configured. This method is optional.
*/
- int (*test_default_device)(void);
+ bool (*test_default_device)(void);
/**
* Configure and initialize the device, but do not open it
@@ -73,12 +73,12 @@ struct audio_output_plugin {
* @param audio_format the audio format in which data is going
* to be delivered; may be modified by the plugin
*/
- int (*open)(void *data, struct audio_format *audio_format);
+ bool (*open)(void *data, struct audio_format *audio_format);
/**
* Play a chunk of audio data.
*/
- int (*play)(void *data, const char *playChunk, size_t size);
+ bool (*play)(void *data, const char *playChunk, size_t size);
/**
* Pause the device. If supported, it may perform a special
diff --git a/src/output_control.c b/src/output_control.c
index 15b4eb19c..9193e92eb 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -51,14 +51,15 @@ static void ao_command_async(struct audio_output *ao,
notify_signal(&ao->notify);
}
-int audio_output_open(struct audio_output *audioOutput,
- const struct audio_format *audioFormat)
+bool
+audio_output_open(struct audio_output *audioOutput,
+ const struct audio_format *audioFormat)
{
- int ret = 0;
+ bool ret = true;
if (audioOutput->open &&
audio_format_equals(audioFormat, &audioOutput->inAudioFormat)) {
- return 0;
+ return true;
}
audioOutput->inAudioFormat = *audioFormat;
diff --git a/src/output_control.h b/src/output_control.h
index 275e58aa9..b2b9a6c64 100644
--- a/src/output_control.h
+++ b/src/output_control.h
@@ -22,6 +22,7 @@
#include "conf.h"
#include <stddef.h>
+#include <stdbool.h>
struct audio_output;
struct audio_output_plugin;
@@ -29,8 +30,10 @@ struct audio_format;
struct tag;
int audio_output_init(struct audio_output *, ConfigParam * param);
-int audio_output_open(struct audio_output *audioOutput,
- const struct audio_format *audioFormat);
+
+bool
+audio_output_open(struct audio_output *audioOutput,
+ const struct audio_format *audioFormat);
/**
* Wakes up the audio output thread. This is part of a workaround for
diff --git a/src/output_init.c b/src/output_init.c
index ebfbf137e..16b4dfb73 100644
--- a/src/output_init.c
+++ b/src/output_init.c
@@ -67,7 +67,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
if (plugin->test_default_device) {
WARNING("Attempting to detect a %s audio "
"device\n", plugin->name);
- if (plugin->test_default_device() == 0) {
+ if (plugin->test_default_device()) {
WARNING("Successfully detected a %s "
"audio device\n", plugin->name);
break;
@@ -85,7 +85,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
ao->name = name;
ao->plugin = plugin;
- ao->open = 0;
+ ao->open = false;
ao->convBuffer = NULL;
ao->convBufferLen = 0;
diff --git a/src/output_internal.h b/src/output_internal.h
index fc146546a..d3f650086 100644
--- a/src/output_internal.h
+++ b/src/output_internal.h
@@ -43,7 +43,7 @@ struct audio_output {
/**
* Is the device (already) open and functional?
*/
- int open;
+ bool open;
/**
* The audio_format in which audio data is received from the
@@ -98,9 +98,9 @@ struct audio_output {
} args;
/**
- * Result value of the command. Generally, "0" means success.
+ * Result value of the command. true means success.
*/
- int result;
+ bool result;
};
/**
@@ -109,19 +109,19 @@ struct audio_output {
*/
extern struct notify audio_output_client_notify;
-static inline int
+static inline bool
audio_output_is_open(const struct audio_output *ao)
{
return ao->open;
}
-static inline int
+static inline bool
audio_output_command_is_finished(const struct audio_output *ao)
{
return ao->command == AO_COMMAND_NONE;
}
-static inline int
+static inline bool
audio_output_get_result(const struct audio_output *ao)
{
return ao->result;
diff --git a/src/output_thread.c b/src/output_thread.c
index e2f360d9b..f03520013 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -74,7 +74,7 @@ static void ao_pause(struct audio_output *ao)
} else {
/* pause is not supported - simply close the device */
ao->plugin->close(ao->data);
- ao->open = 0;
+ ao->open = false;
ao_command_finished(ao);
}
}
@@ -94,8 +94,8 @@ static void *audio_output_task(void *arg)
&ao->outAudioFormat);
assert(!ao->open);
- if (ao->result == 0)
- ao->open = 1;
+ if (ao->result == true)
+ ao->open = true;
ao_command_finished(ao);
break;
@@ -103,7 +103,7 @@ static void *audio_output_task(void *arg)
case AO_COMMAND_CLOSE:
assert(ao->open);
ao->plugin->close(ao->data);
- ao->open = 0;
+ ao->open = false;
ao_command_finished(ao);
break;
diff --git a/src/player_thread.c b/src/player_thread.c
index 35796d95d..0275b680a 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -156,7 +156,7 @@ static void processDecodeInput(struct player *player)
audio_output_pause_all();
pc.state = PLAYER_STATE_PAUSE;
} else {
- if (openAudioDevice(NULL) >= 0) {
+ if (openAudioDevice(NULL)) {
pc.state = PLAYER_STATE_PLAY;
} else {
char tmp[MPD_PATH_MAX];
@@ -215,8 +215,7 @@ static int playChunk(ob_chunk * chunk,
pcm_volume(chunk->data, chunk->chunkSize,
format, pc.softwareVolume);
- if (playAudio(chunk->data,
- chunk->chunkSize) < 0)
+ if (!playAudio(chunk->data, chunk->chunkSize))
return -1;
pc.totalPlayTime += sizeToTime * chunk->chunkSize;
@@ -288,7 +287,7 @@ static void do_play(void)
else if (!decoder_is_starting()) {
/* the decoder is ready and ok */
player.decoder_starting = false;
- if(openAudioDevice(&(ob.audioFormat))<0) {
+ if (!openAudioDevice(&ob.audioFormat)) {
char tmp[MPD_PATH_MAX];
assert(dc.next_song == NULL || dc.next_song->url != NULL);
pc.errored_song = dc.next_song;
@@ -439,7 +438,7 @@ static void do_play(void)
unsigned num_frames = CHUNK_SIZE / frame_size;
/*DEBUG("waiting for decoded audio, play silence\n");*/
- if (playAudio(silence, num_frames * frame_size) < 0)
+ if (!playAudio(silence, num_frames * frame_size))
break;
}
}