X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/0205fc57bbfdf03e5cdd5eb3c908f5531c4fdbf1..fa499dad06ba6558111cdef64c18f2401e803cff:/polyp/oss-util.c diff --git a/polyp/oss-util.c b/polyp/oss-util.c index 4fb2b929..8c83cbbf 100644 --- a/polyp/oss-util.c +++ b/polyp/oss-util.c @@ -4,7 +4,7 @@ This file is part of polypaudio. polypaudio is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published + it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with polypaudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. @@ -35,6 +35,8 @@ #include #include "oss-util.h" +#include "util.h" +#include "log.h" int pa_oss_open(const char *device, int *mode, int* pcaps) { int fd = -1; @@ -48,7 +50,7 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { tcaps = pcaps ? pcaps : &dcaps; if (ioctl(fd, SNDCTL_DSP_GETCAPS, tcaps) < 0) { - fprintf(stderr, __FILE__": SNDCTL_DSP_GETCAPS: %s\n", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s\n", strerror(errno)); goto fail; } @@ -60,23 +62,25 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { if ((fd = open(device, (*mode = O_WRONLY)|O_NDELAY)) < 0) { if ((fd = open(device, (*mode = O_RDONLY)|O_NDELAY)) < 0) { - fprintf(stderr, __FILE__": open('%s'): %s\n", device, strerror(errno)); + pa_log(__FILE__": open('%s'): %s\n", device, strerror(errno)); goto fail; } } } else { if ((fd = open(device, *mode|O_NDELAY)) < 0) { - fprintf(stderr, __FILE__": open('%s'): %s\n", device, strerror(errno)); + pa_log(__FILE__": open('%s'): %s\n", device, strerror(errno)); goto fail; } } if (pcaps) { if (ioctl(fd, SNDCTL_DSP_GETCAPS, pcaps) < 0) { - fprintf(stderr, "SNDCTL_DSP_GETCAPS: %s\n", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s\n", strerror(errno)); goto fail; } } + + pa_fd_set_cloexec(fd, 1); return fd; @@ -109,7 +113,7 @@ int pa_oss_auto_format(int fd, struct pa_sample_spec *ss) { if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != f) { format = AFMT_U8; if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != AFMT_U8) { - fprintf(stderr, "SNDCTL_DSP_SETFMT: %s\n", format != AFMT_U8 ? "No supported sample format" : strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SETFMT: %s\n", format != AFMT_U8 ? "No supported sample format" : strerror(errno)); return -1; } else ss->format = PA_SAMPLE_U8; @@ -121,7 +125,7 @@ int pa_oss_auto_format(int fd, struct pa_sample_spec *ss) { channels = ss->channels; if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0) { - fprintf(stderr, "SNDCTL_DSP_CHANNELS: %s\n", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_CHANNELS: %s\n", strerror(errno)); return -1; } assert(channels); @@ -129,7 +133,7 @@ int pa_oss_auto_format(int fd, struct pa_sample_spec *ss) { speed = ss->rate; if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) { - fprintf(stderr, "SNDCTL_DSP_SPEED: %s\n", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SPEED: %s\n", strerror(errno)); return -1; } assert(speed); @@ -155,7 +159,7 @@ int pa_oss_set_fragments(int fd, int nfrags, int frag_size) { arg = ((int) nfrags << 16) | simple_log2(frag_size); if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) { - fprintf(stderr, "SNDCTL_DSP_SETFRAGMENT: %s\n", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SETFRAGMENT: %s\n", strerror(errno)); return -1; }