oss_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a consistent state. This means we can remove lots of checks from the volume methods.
This commit is contained in:
parent
dd8c6d6738
commit
881026623c
@ -21,6 +21,8 @@
|
|||||||
#include "../mixer_api.h"
|
#include "../mixer_api.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -58,7 +60,6 @@ oss_mixer_init(const struct config_param *param)
|
|||||||
VOLUME_MIXER_OSS_DEFAULT);
|
VOLUME_MIXER_OSS_DEFAULT);
|
||||||
om->control = config_get_block_string(param, "mixer_control", NULL);
|
om->control = config_get_block_string(param, "mixer_control", NULL);
|
||||||
|
|
||||||
om->device_fd = -1;
|
|
||||||
om->volume_control = SOUND_MIXER_PCM;
|
om->volume_control = SOUND_MIXER_PCM;
|
||||||
|
|
||||||
return &om->base;
|
return &om->base;
|
||||||
@ -76,9 +77,10 @@ static void
|
|||||||
oss_mixer_close(struct mixer *data)
|
oss_mixer_close(struct mixer *data)
|
||||||
{
|
{
|
||||||
struct oss_mixer *om = (struct oss_mixer *) data;
|
struct oss_mixer *om = (struct oss_mixer *) data;
|
||||||
if (om->device_fd != -1)
|
|
||||||
while (close(om->device_fd) && errno == EINTR) ;
|
assert(om->device_fd >= 0);
|
||||||
om->device_fd = -1;
|
|
||||||
|
close(om->device_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -141,8 +143,7 @@ oss_mixer_get_volume(struct mixer *mixer)
|
|||||||
int left, right, level;
|
int left, right, level;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (om->device_fd < 0 && !oss_mixer_open(mixer))
|
assert(om->device_fd >= 0);
|
||||||
return false;
|
|
||||||
|
|
||||||
ret = ioctl(om->device_fd, MIXER_READ(om->volume_control), &level);
|
ret = ioctl(om->device_fd, MIXER_READ(om->volume_control), &level);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -168,8 +169,7 @@ oss_mixer_set_volume(struct mixer *mixer, unsigned volume)
|
|||||||
int level;
|
int level;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (om->device_fd < 0 && !oss_mixer_open(mixer))
|
assert(om->device_fd >= 0);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (volume > 100)
|
if (volume > 100)
|
||||||
volume = 100;
|
volume = 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user