aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-26 19:18:16 +0100
committerMax Kellermann <max@duempel.org>2009-02-26 19:18:16 +0100
commit4f2ac7ec2c789f290a9563f79ddbea1faeed24c9 (patch)
tree0831d5953af96e834433615f87af99e6d08e5859 /src/output
parent749d6c7766c4713c283b57c47aca07227fc76cee (diff)
downloadmpd-4f2ac7ec2c789f290a9563f79ddbea1faeed24c9.tar.gz
mpd-4f2ac7ec2c789f290a9563f79ddbea1faeed24c9.tar.xz
mpd-4f2ac7ec2c789f290a9563f79ddbea1faeed24c9.zip
oss: moved code from oss_open() to oss_setup()
Eliminate one label and a bunch of gotos.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/oss_plugin.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c
index 2e5580239..b070b9a9d 100644
--- a/src/output/oss_plugin.c
+++ b/src/output/oss_plugin.c
@@ -469,23 +469,20 @@ oss_close(struct oss_data *od)
od->fd = -1;
}
+/**
+ * Sets up the OSS device which was opened before.
+ */
static bool
-oss_open(struct oss_data *od)
+oss_setup(struct oss_data *od)
{
int tmp;
- if ((od->fd = open(od->device, O_WRONLY)) < 0) {
- g_warning("Error opening OSS device \"%s\": %s\n", od->device,
- strerror(errno));
- goto fail;
- }
-
tmp = od->audio_format.channels;
if (oss_set_param(od, SNDCTL_DSP_CHANNELS, &tmp)) {
g_warning("OSS device \"%s\" does not support %u channels: %s\n",
od->device, od->audio_format.channels,
strerror(errno));
- goto fail;
+ return false;
}
od->audio_format.channels = tmp;
@@ -494,7 +491,7 @@ oss_open(struct oss_data *od)
g_warning("OSS device \"%s\" does not support %u Hz audio: %s\n",
od->device, od->audio_format.sample_rate,
strerror(errno));
- goto fail;
+ return false;
}
od->audio_format.sample_rate = tmp;
@@ -516,14 +513,30 @@ oss_open(struct oss_data *od)
if (oss_set_param(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) {
g_warning("OSS device \"%s\" does not support %u bit audio: %s\n",
od->device, tmp, strerror(errno));
- goto fail;
+ return false;
}
return true;
+}
-fail:
- oss_close(od);
- return false;
+static bool
+oss_open(struct oss_data *od)
+{
+ bool success;
+
+ if ((od->fd = open(od->device, O_WRONLY)) < 0) {
+ g_warning("Error opening OSS device \"%s\": %s\n", od->device,
+ strerror(errno));
+ return false;
+ }
+
+ success = oss_setup(od);
+ if (!success) {
+ oss_close(od);
+ return false;
+ }
+
+ return true;
}
static bool