output: use bool for return values and flags
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -65,7 +65,7 @@ struct shout_data {
|
||||
float quality;
|
||||
int bitrate;
|
||||
|
||||
int opened;
|
||||
bool opened;
|
||||
|
||||
struct tag *tag;
|
||||
int tag_to_send;
|
||||
|
||||
Reference in New Issue
Block a user