oss: moved code from oss_open() to oss_setup()
Eliminate one label and a bunch of gotos.
This commit is contained in:
@@ -469,23 +469,20 @@ oss_close(struct oss_data *od)
|
|||||||
od->fd = -1;
|
od->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the OSS device which was opened before.
|
||||||
|
*/
|
||||||
static bool
|
static bool
|
||||||
oss_open(struct oss_data *od)
|
oss_setup(struct oss_data *od)
|
||||||
{
|
{
|
||||||
int tmp;
|
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;
|
tmp = od->audio_format.channels;
|
||||||
if (oss_set_param(od, SNDCTL_DSP_CHANNELS, &tmp)) {
|
if (oss_set_param(od, SNDCTL_DSP_CHANNELS, &tmp)) {
|
||||||
g_warning("OSS device \"%s\" does not support %u channels: %s\n",
|
g_warning("OSS device \"%s\" does not support %u channels: %s\n",
|
||||||
od->device, od->audio_format.channels,
|
od->device, od->audio_format.channels,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto fail;
|
return false;
|
||||||
}
|
}
|
||||||
od->audio_format.channels = tmp;
|
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",
|
g_warning("OSS device \"%s\" does not support %u Hz audio: %s\n",
|
||||||
od->device, od->audio_format.sample_rate,
|
od->device, od->audio_format.sample_rate,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto fail;
|
return false;
|
||||||
}
|
}
|
||||||
od->audio_format.sample_rate = tmp;
|
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)) {
|
if (oss_set_param(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) {
|
||||||
g_warning("OSS device \"%s\" does not support %u bit audio: %s\n",
|
g_warning("OSS device \"%s\" does not support %u bit audio: %s\n",
|
||||||
od->device, tmp, strerror(errno));
|
od->device, tmp, strerror(errno));
|
||||||
goto fail;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
fail:
|
static bool
|
||||||
oss_close(od);
|
oss_open(struct oss_data *od)
|
||||||
return false;
|
{
|
||||||
|
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
|
static bool
|
||||||
|
Reference in New Issue
Block a user