Mercurial > audlegacy-plugins
diff src/OSS4/audio.c @ 3049:9ec8a613a1d6
More OSS4 plugin changes
| author | Michal Lipski <tallica@o2.pl> |
|---|---|
| date | Sat, 18 Apr 2009 13:59:58 +0200 |
| parents | c269a0351b53 |
| children |
line wrap: on
line diff
--- a/src/OSS4/audio.c Fri Apr 17 17:31:14 2009 +0200 +++ b/src/OSS4/audio.c Sat Apr 18 13:59:58 2009 +0200 @@ -19,9 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -static void oss_describe_error(); -static void close_mixer_device(); - #include <glib.h> #include <string.h> @@ -36,8 +33,7 @@ #define NFRAGS 32 -static gint fd = -1, mixerfd = -1; -static oss_sysinfo sysinfo; +static gint fd = -1; static char *buffer; static gboolean going, prebuffer, paused, unpause, do_pause, remove_prebuffer; static gint device_buffer_used, buffer_size, prebuffer_size, blk_size; @@ -85,17 +81,18 @@ */ struct format_info output; -int oss_hardware_present() +gint oss_hardware_present() { + gint mixerfd; + oss_sysinfo sysinfo; + /* - * Open the mixer device used for calling SNDCTL_SYSINFO and - * SNDCTL_AUDIOINFO. + * Open the mixer device used for calling SNDCTL_SYSINFO */ - if ((mixerfd = open("/dev/mixer", O_RDWR, 0)) == -1) + if ((mixerfd = open(DEFAULT_MIXER, O_RDWR, 0)) == -1) { - perror("/dev/mixer"); + perror(DEFAULT_MIXER); oss_describe_error(); - close_mixer_device(); return 0; } @@ -104,13 +101,13 @@ { perror("SNDCTL_SYSINFO"); oss_describe_error(); - close_mixer_device(); + close(mixerfd); return 0; } else { - close_mixer_device(); + close(mixerfd); if (sysinfo.numaudios > 0) { @@ -123,7 +120,7 @@ } } -static void +void oss_describe_error() { switch (errno) @@ -574,7 +571,11 @@ wr_index = 0; rd_index = 0; - close_mixer_device(); + if (fd != -1) + { + close(fd); + fd = -1; + } } void @@ -808,19 +809,3 @@ vol = (r << 8) | l; ioctl(fd, cmd, &vol); } - -void -close_mixer_device() -{ - if (fd != -1) - { - close(fd); - fd = -1; - } - - if (mixerfd != -1) - { - close(mixerfd); - mixerfd = -1; - } -}
