···598598PCE_DIR_ETC
599599PCE_READLINE_LIBS
600600PCE_ENABLE_READLINE
601601+PCE_ENABLE_SOUND_OSS
601602PCE_ENABLE_CHAR_TIOS
602603PCE_ENABLE_CHAR_TCP
603604PCE_ENABLE_CHAR_SLIP
···723724enable_char_slip
724725enable_char_tcp
725726enable_char_termios
727727+enable_sound_oss
726728enable_readline
727729'
728730 ac_precious_vars='build_alias
···13691371 --enable-char-slip Enable the SLIP character driver [guessed]
13701372 --enable-char-tcp Enable the TCP character driver [guessed]
13711373 --enable-char-termios Enable the termios character driver [guessed]
13741374+ --enable-sound-oss Enable the OSS sound driver driver [guessed]
13721375 --enable-readline Enable readline [guessed]
1373137613741377Optional Packages:
···40094012 sys/ioctl.h \
40104013 sys/poll.h \
40114014 sys/socket.h \
40154015+ sys/soundcard.h \
40124016 sys/stat.h \
40134017 sys/time.h \
40144018 sys/types.h \
···52285232fi
522952335230523452355235+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the OSS sound driver" >&5
52365236+$as_echo_n "checking whether to enable the OSS sound driver... " >&6; }
52375237+# Check whether --enable-sound-oss was given.
52385238+if test "${enable_sound_oss+set}" = set; then :
52395239+ enableval=$enable_sound_oss;
52405240+ if test "x$enableval" = "xyes" ; then
52415241+ PCE_ENABLE_SOUND_OSS=1
52425242+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
52435243+$as_echo "yes" >&6; }
52445244+ else
52455245+ PCE_ENABLE_SOUND_OSS=0
52465246+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
52475247+$as_echo "no" >&6; }
52485248+ fi
52495249+52505250+else
52515251+52525252+ PCE_ENABLE_SOUND_OSS=1
52535253+ test "x$ac_cv_header_fcntl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0
52545254+ test "x$ac_cv_header_sys_ioctl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0
52555255+ test "x$ac_cv_header_sys_soundcard_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0
52565256+ if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then
52575257+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (guess)" >&5
52585258+$as_echo "yes (guess)" >&6; }
52595259+ else
52605260+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (guess)" >&5
52615261+$as_echo "no (guess)" >&6; }
52625262+ fi
52635263+52645264+52655265+fi
52665266+52675267+52685268+if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then
52695269+ $as_echo "#define PCE_ENABLE_SOUND_OSS 1" >>confdefs.h
52705270+52715271+fi
52725272+52735273+52315274{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable readline" >&5
52325275$as_echo_n "checking whether to enable readline... " >&6; }
52335276# Check whether --enable-readline was given.
···5540558355415584sound1=" null wav"
55425585sound2=""
55865586+55875587+if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then
55885588+ sound1="$sound1 oss"
55895589+else
55905590+ sound2="$sound2 oss"
55915591+fi
554355925544559355455594option1=""
+36
configure.in
···205205 sys/ioctl.h \
206206 sys/poll.h \
207207 sys/socket.h \
208208+ sys/soundcard.h \
208209 sys/stat.h \
209210 sys/time.h \
210211 sys/types.h \
···752753fi
753754754755756756+AC_MSG_CHECKING([whether to enable the OSS sound driver])
757757+AC_ARG_ENABLE(sound-oss,
758758+ [AS_HELP_STRING([--enable-sound-oss], [Enable the OSS sound driver driver [guessed]])],
759759+ [
760760+ if test "x$enableval" = "xyes" ; then
761761+ PCE_ENABLE_SOUND_OSS=1
762762+ AC_MSG_RESULT([yes])
763763+ else
764764+ PCE_ENABLE_SOUND_OSS=0
765765+ AC_MSG_RESULT([no])
766766+ fi
767767+ ],[
768768+ PCE_ENABLE_SOUND_OSS=1
769769+ test "x$ac_cv_header_fcntl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0
770770+ test "x$ac_cv_header_sys_ioctl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0
771771+ test "x$ac_cv_header_sys_soundcard_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0
772772+ if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then
773773+ AC_MSG_RESULT([yes (guess)])
774774+ else
775775+ AC_MSG_RESULT([no (guess)])
776776+ fi
777777+ ]
778778+)
779779+AC_SUBST(PCE_ENABLE_SOUND_OSS)
780780+if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then
781781+ AC_DEFINE(PCE_ENABLE_SOUND_OSS)
782782+fi
783783+784784+755785AC_MSG_CHECKING([whether to enable readline])
756786AC_ARG_ENABLE(readline,
757787 [AS_HELP_STRING([--enable-readline], [Enable readline [guessed]])],
···925955926956sound1=" null wav"
927957sound2=""
958958+959959+if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then
960960+ sound1="$sound1 oss"
961961+else
962962+ sound2="$sound2 oss"
963963+fi
928964929965930966option1=""
+7
doc/sound-drivers.txt
···32323333wav:
3434 This is another name for the null sound driver.
3535+3636+3737+oss:
3838+ The OSS sound driver.
3939+4040+ dev=<filename>
4141+ Set the OSS device.
···11+/*****************************************************************************
22+ * pce *
33+ *****************************************************************************/
44+55+/*****************************************************************************
66+ * File name: src/drivers/sound/sound-oss.c *
77+ * Created: 2009-10-17 by Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2009-2010 Hampa Hug <hampa@hampa.ch> *
99+ *****************************************************************************/
1010+1111+/*****************************************************************************
1212+ * This program is free software. You can redistribute it and / or modify it *
1313+ * under the terms of the GNU General Public License version 2 as published *
1414+ * by the Free Software Foundation. *
1515+ * *
1616+ * This program is distributed in the hope that it will be useful, but *
1717+ * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919+ * Public License for more details. *
2020+ *****************************************************************************/
2121+2222+2323+#include <stdlib.h>
2424+#include <stdio.h>
2525+#include <string.h>
2626+#include <limits.h>
2727+2828+#include <unistd.h>
2929+#include <fcntl.h>
3030+#include <sys/ioctl.h>
3131+#include <sys/soundcard.h>
3232+3333+#include <drivers/options.h>
3434+#include <drivers/sound/sound.h>
3535+#include <drivers/sound/sound-oss.h>
3636+3737+3838+static
3939+void snd_oss_close (sound_drv_t *sdrv)
4040+{
4141+ sound_oss_t *drv;
4242+4343+ drv = sdrv->ext;
4444+4545+ if (drv->fd >= 0) {
4646+ close (drv->fd);
4747+ }
4848+4949+ if (drv->dev != NULL) {
5050+ free (drv->dev);
5151+ }
5252+5353+ free (drv);
5454+}
5555+5656+static
5757+int snd_oss_write (sound_drv_t *sdrv, const uint16_t *buf, unsigned cnt)
5858+{
5959+ ssize_t r;
6060+ int sign;
6161+ unsigned long bcnt, scnt;
6262+ unsigned char *bbuf;
6363+ sound_oss_t *drv;
6464+6565+ drv = sdrv->ext;
6666+6767+ scnt = (unsigned long) sdrv->channels * (unsigned long) cnt;
6868+ bcnt = 2 * scnt;
6969+7070+ if (bcnt > SSIZE_MAX) {
7171+ return (1);
7272+ }
7373+7474+ bbuf = snd_get_bbuf (sdrv, bcnt);
7575+7676+ if (bbuf == NULL) {
7777+ return (1);
7878+ }
7979+8080+ sign = (sdrv->sample_sign != drv->sign);
8181+8282+ snd_set_buf (bbuf, buf, scnt, sign, drv->big_endian);
8383+8484+ r = write (drv->fd, bbuf, bcnt);
8585+8686+ if (r != (ssize_t) bcnt) {
8787+ return (1);
8888+ }
8989+9090+ return (0);
9191+}
9292+9393+static
9494+int snd_oss_set_format (sound_oss_t *drv, int fmt)
9595+{
9696+ int val;
9797+9898+ val = fmt;
9999+100100+ if (ioctl (drv->fd, SNDCTL_DSP_SETFMT, &val) == -1) {
101101+ return (1);
102102+ }
103103+104104+ if (val != fmt) {
105105+ return (1);
106106+ }
107107+108108+ return (0);
109109+}
110110+111111+static
112112+int snd_oss_set_params (sound_drv_t *sdrv, unsigned chn, unsigned long srate, int sign)
113113+{
114114+ int val;
115115+ sound_oss_t *drv;
116116+117117+ drv = sdrv->ext;
118118+119119+ if (snd_oss_set_format (drv, AFMT_S16_LE) == 0) {
120120+ drv->sign = 1;
121121+ drv->big_endian = 0;
122122+ }
123123+ else if (snd_oss_set_format (drv, AFMT_S16_BE) == 0) {
124124+ drv->sign = 1;
125125+ drv->big_endian = 1;
126126+ }
127127+ else if (snd_oss_set_format (drv, AFMT_U16_LE) == 0) {
128128+ drv->sign = 0;
129129+ drv->big_endian = 0;
130130+ }
131131+ else if (snd_oss_set_format (drv, AFMT_U16_BE) == 0) {
132132+ drv->sign = 0;
133133+ drv->big_endian = 1;
134134+ }
135135+ else {
136136+ return (1);
137137+ }
138138+139139+ val = chn;
140140+ if (ioctl (drv->fd, SNDCTL_DSP_CHANNELS, &val) == -1) {
141141+ return (1);
142142+ }
143143+ if (val != (int) chn) {
144144+ return (1);
145145+ }
146146+147147+ val = srate;
148148+ if (ioctl (drv->fd, SNDCTL_DSP_SPEED, &val) == -1) {
149149+ return (1);
150150+ }
151151+ if (val != (int) srate) {
152152+ return (1);
153153+ }
154154+155155+ return (0);
156156+}
157157+158158+static
159159+int snd_oss_init (sound_oss_t *drv, const char *name)
160160+{
161161+ snd_init (&drv->sdrv, drv);
162162+163163+ drv->sdrv.close = snd_oss_close;
164164+ drv->sdrv.write = snd_oss_write;
165165+ drv->sdrv.set_params = snd_oss_set_params;
166166+167167+ drv->fd = -1;
168168+ drv->dev = drv_get_option (name, "dev");
169169+170170+ if (drv->dev == NULL) {
171171+ return (1);
172172+ }
173173+174174+ drv->fd = open (drv->dev, O_WRONLY, 0);
175175+176176+ if (drv->fd < 0) {
177177+ return (1);
178178+ }
179179+180180+ return (0);
181181+}
182182+183183+sound_drv_t *snd_oss_open (const char *name)
184184+{
185185+ sound_oss_t *drv;
186186+187187+ drv = malloc (sizeof (sound_oss_t));
188188+189189+ if (drv == NULL) {
190190+ return (NULL);
191191+ }
192192+193193+ if (snd_oss_init (drv, name)) {
194194+ snd_oss_close (&drv->sdrv);
195195+ return (NULL);
196196+ }
197197+198198+ return (&drv->sdrv);
199199+}
+41
src/drivers/sound/sound-oss.h
···11+/*****************************************************************************
22+ * pce *
33+ *****************************************************************************/
44+55+/*****************************************************************************
66+ * File name: src/drivers/sound/sound-oss.h *
77+ * Created: 2009-10-17 by Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2009 Hampa Hug <hampa@hampa.ch> *
99+ *****************************************************************************/
1010+1111+/*****************************************************************************
1212+ * This program is free software. You can redistribute it and / or modify it *
1313+ * under the terms of the GNU General Public License version 2 as published *
1414+ * by the Free Software Foundation. *
1515+ * *
1616+ * This program is distributed in the hope that it will be useful, but *
1717+ * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919+ * Public License for more details. *
2020+ *****************************************************************************/
2121+2222+2323+#ifndef PCE_DRIVERS_SOUND_OSS_H
2424+#define PCE_DRIVERS_SOUND_OSS_H 1
2525+2626+2727+#include <drivers/sound/sound.h>
2828+2929+3030+typedef struct sound_oss_t {
3131+ sound_drv_t sdrv;
3232+3333+ int sign;
3434+ int big_endian;
3535+3636+ char *dev;
3737+ int fd;
3838+} sound_oss_t;
3939+4040+4141+#endif