fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sound: Add an OSS sound driver

Hampa Hug a68bd299 4bed876d

+356 -1
+5
Makefile.dep
··· 1913 1913 src/drivers/sound/sound-null.h \ 1914 1914 src/drivers/sound/sound.h 1915 1915 1916 + src/drivers/sound/sound-oss.o: src/drivers/sound/sound-oss.c \ 1917 + src/drivers/options.h \ 1918 + src/drivers/sound/sound-oss.h \ 1919 + src/drivers/sound/sound.h 1920 + 1916 1921 src/drivers/sound/sound-wav.o: src/drivers/sound/sound-wav.c \ 1917 1922 src/drivers/options.h \ 1918 1923 src/drivers/sound/sound-wav.h \
+2
Makefile.inc.in
··· 89 89 PCE_ENABLE_CHAR_TCP := @PCE_ENABLE_CHAR_TCP@ 90 90 PCE_ENABLE_CHAR_TIOS := @PCE_ENABLE_CHAR_TIOS@ 91 91 92 + PCE_ENABLE_SOUND_OSS := @PCE_ENABLE_SOUND_OSS@ 93 + 92 94 distdir := pce-$(PCE_VERSION_STR) 93 95 94 96 # ----------------------------------------------------------------------
+49
configure
··· 598 598 PCE_DIR_ETC 599 599 PCE_READLINE_LIBS 600 600 PCE_ENABLE_READLINE 601 + PCE_ENABLE_SOUND_OSS 601 602 PCE_ENABLE_CHAR_TIOS 602 603 PCE_ENABLE_CHAR_TCP 603 604 PCE_ENABLE_CHAR_SLIP ··· 723 724 enable_char_slip 724 725 enable_char_tcp 725 726 enable_char_termios 727 + enable_sound_oss 726 728 enable_readline 727 729 ' 728 730 ac_precious_vars='build_alias ··· 1369 1371 --enable-char-slip Enable the SLIP character driver [guessed] 1370 1372 --enable-char-tcp Enable the TCP character driver [guessed] 1371 1373 --enable-char-termios Enable the termios character driver [guessed] 1374 + --enable-sound-oss Enable the OSS sound driver driver [guessed] 1372 1375 --enable-readline Enable readline [guessed] 1373 1376 1374 1377 Optional Packages: ··· 4009 4012 sys/ioctl.h \ 4010 4013 sys/poll.h \ 4011 4014 sys/socket.h \ 4015 + sys/soundcard.h \ 4012 4016 sys/stat.h \ 4013 4017 sys/time.h \ 4014 4018 sys/types.h \ ··· 5228 5232 fi 5229 5233 5230 5234 5235 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the OSS sound driver" >&5 5236 + $as_echo_n "checking whether to enable the OSS sound driver... " >&6; } 5237 + # Check whether --enable-sound-oss was given. 5238 + if test "${enable_sound_oss+set}" = set; then : 5239 + enableval=$enable_sound_oss; 5240 + if test "x$enableval" = "xyes" ; then 5241 + PCE_ENABLE_SOUND_OSS=1 5242 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 5243 + $as_echo "yes" >&6; } 5244 + else 5245 + PCE_ENABLE_SOUND_OSS=0 5246 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5247 + $as_echo "no" >&6; } 5248 + fi 5249 + 5250 + else 5251 + 5252 + PCE_ENABLE_SOUND_OSS=1 5253 + test "x$ac_cv_header_fcntl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0 5254 + test "x$ac_cv_header_sys_ioctl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0 5255 + test "x$ac_cv_header_sys_soundcard_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0 5256 + if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then 5257 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (guess)" >&5 5258 + $as_echo "yes (guess)" >&6; } 5259 + else 5260 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (guess)" >&5 5261 + $as_echo "no (guess)" >&6; } 5262 + fi 5263 + 5264 + 5265 + fi 5266 + 5267 + 5268 + if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then 5269 + $as_echo "#define PCE_ENABLE_SOUND_OSS 1" >>confdefs.h 5270 + 5271 + fi 5272 + 5273 + 5231 5274 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable readline" >&5 5232 5275 $as_echo_n "checking whether to enable readline... " >&6; } 5233 5276 # Check whether --enable-readline was given. ··· 5540 5583 5541 5584 sound1=" null wav" 5542 5585 sound2="" 5586 + 5587 + if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then 5588 + sound1="$sound1 oss" 5589 + else 5590 + sound2="$sound2 oss" 5591 + fi 5543 5592 5544 5593 5545 5594 option1=""
+36
configure.in
··· 205 205 sys/ioctl.h \ 206 206 sys/poll.h \ 207 207 sys/socket.h \ 208 + sys/soundcard.h \ 208 209 sys/stat.h \ 209 210 sys/time.h \ 210 211 sys/types.h \ ··· 752 753 fi 753 754 754 755 756 + AC_MSG_CHECKING([whether to enable the OSS sound driver]) 757 + AC_ARG_ENABLE(sound-oss, 758 + [AS_HELP_STRING([--enable-sound-oss], [Enable the OSS sound driver driver [guessed]])], 759 + [ 760 + if test "x$enableval" = "xyes" ; then 761 + PCE_ENABLE_SOUND_OSS=1 762 + AC_MSG_RESULT([yes]) 763 + else 764 + PCE_ENABLE_SOUND_OSS=0 765 + AC_MSG_RESULT([no]) 766 + fi 767 + ],[ 768 + PCE_ENABLE_SOUND_OSS=1 769 + test "x$ac_cv_header_fcntl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0 770 + test "x$ac_cv_header_sys_ioctl_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0 771 + test "x$ac_cv_header_sys_soundcard_h" = "xyes" || PCE_ENABLE_SOUND_OSS=0 772 + if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then 773 + AC_MSG_RESULT([yes (guess)]) 774 + else 775 + AC_MSG_RESULT([no (guess)]) 776 + fi 777 + ] 778 + ) 779 + AC_SUBST(PCE_ENABLE_SOUND_OSS) 780 + if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then 781 + AC_DEFINE(PCE_ENABLE_SOUND_OSS) 782 + fi 783 + 784 + 755 785 AC_MSG_CHECKING([whether to enable readline]) 756 786 AC_ARG_ENABLE(readline, 757 787 [AS_HELP_STRING([--enable-readline], [Enable readline [guessed]])], ··· 925 955 926 956 sound1=" null wav" 927 957 sound2="" 958 + 959 + if test "x$PCE_ENABLE_SOUND_OSS" = "x1" ; then 960 + sound1="$sound1 oss" 961 + else 962 + sound2="$sound2 oss" 963 + fi 928 964 929 965 930 966 option1=""
+7
doc/sound-drivers.txt
··· 32 32 33 33 wav: 34 34 This is another name for the null sound driver. 35 + 36 + 37 + oss: 38 + The OSS sound driver. 39 + 40 + dev=<filename> 41 + Set the OSS device.
+4 -1
src/config.h.in
··· 5 5 /***************************************************************************** 6 6 * File name: src/config.h.in * 7 7 * Created: 2002-12-16 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2002-2009 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2002-2010 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 54 54 #undef HAVE_SYS_IOCTL_H 55 55 #undef HAVE_SYS_POLL_H 56 56 #undef HAVE_SYS_SOCKET_H 57 + #undef HAVE_SYS_SOUNDCARD_H 57 58 #undef HAVE_SYS_TIME_H 58 59 #undef HAVE_SYS_TYPES_H 59 60 ··· 95 96 #undef PCE_ENABLE_CHAR_SLIP 96 97 #undef PCE_ENABLE_CHAR_TCP 97 98 #undef PCE_ENABLE_CHAR_TIOS 99 + 100 + #undef PCE_ENABLE_SOUND_OSS 98 101 99 102 /* directory separator */ 100 103 #define PCE_DIR_SEP '/'
+7
src/drivers/sound/Makefile.inc
··· 8 8 DRV_SND_BAS := sound sound-null sound-wav 9 9 DRV_SND_NBAS := 10 10 11 + ifeq "$(PCE_ENABLE_SOUND_OSS)" "1" 12 + DRV_SND_BAS += sound-oss 13 + else 14 + DRV_SND_NBAS += sound-oss 15 + endif 16 + 11 17 DRV_SND_SRC := $(foreach f,$(DRV_SND_BAS),$(rel)/$(f).c) 12 18 DRV_SND_NSRC := $(foreach f,$(DRV_SND_NBAS),$(rel)/$(f).c) 13 19 DRV_SND_OBJ := $(foreach f,$(DRV_SND_BAS),$(rel)/$(f).o) ··· 21 27 22 28 $(rel)/sound.o: $(rel)/sound.c 23 29 $(rel)/sound-null.o: $(rel)/sound-null.c 30 + $(rel)/sound-oss.o: $(rel)/sound-oss.c 24 31 $(rel)/sound-wav.o: $(rel)/sound-wav.c 25 32 26 33 $(rel)/sound.a: $(DRV_SND_OBJ)
+199
src/drivers/sound/sound-oss.c
··· 1 + /***************************************************************************** 2 + * pce * 3 + *****************************************************************************/ 4 + 5 + /***************************************************************************** 6 + * File name: src/drivers/sound/sound-oss.c * 7 + * Created: 2009-10-17 by Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2009-2010 Hampa Hug <hampa@hampa.ch> * 9 + *****************************************************************************/ 10 + 11 + /***************************************************************************** 12 + * This program is free software. You can redistribute it and / or modify it * 13 + * under the terms of the GNU General Public License version 2 as published * 14 + * by the Free Software Foundation. * 15 + * * 16 + * This program is distributed in the hope that it will be useful, but * 17 + * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 + * Public License for more details. * 20 + *****************************************************************************/ 21 + 22 + 23 + #include <stdlib.h> 24 + #include <stdio.h> 25 + #include <string.h> 26 + #include <limits.h> 27 + 28 + #include <unistd.h> 29 + #include <fcntl.h> 30 + #include <sys/ioctl.h> 31 + #include <sys/soundcard.h> 32 + 33 + #include <drivers/options.h> 34 + #include <drivers/sound/sound.h> 35 + #include <drivers/sound/sound-oss.h> 36 + 37 + 38 + static 39 + void snd_oss_close (sound_drv_t *sdrv) 40 + { 41 + sound_oss_t *drv; 42 + 43 + drv = sdrv->ext; 44 + 45 + if (drv->fd >= 0) { 46 + close (drv->fd); 47 + } 48 + 49 + if (drv->dev != NULL) { 50 + free (drv->dev); 51 + } 52 + 53 + free (drv); 54 + } 55 + 56 + static 57 + int snd_oss_write (sound_drv_t *sdrv, const uint16_t *buf, unsigned cnt) 58 + { 59 + ssize_t r; 60 + int sign; 61 + unsigned long bcnt, scnt; 62 + unsigned char *bbuf; 63 + sound_oss_t *drv; 64 + 65 + drv = sdrv->ext; 66 + 67 + scnt = (unsigned long) sdrv->channels * (unsigned long) cnt; 68 + bcnt = 2 * scnt; 69 + 70 + if (bcnt > SSIZE_MAX) { 71 + return (1); 72 + } 73 + 74 + bbuf = snd_get_bbuf (sdrv, bcnt); 75 + 76 + if (bbuf == NULL) { 77 + return (1); 78 + } 79 + 80 + sign = (sdrv->sample_sign != drv->sign); 81 + 82 + snd_set_buf (bbuf, buf, scnt, sign, drv->big_endian); 83 + 84 + r = write (drv->fd, bbuf, bcnt); 85 + 86 + if (r != (ssize_t) bcnt) { 87 + return (1); 88 + } 89 + 90 + return (0); 91 + } 92 + 93 + static 94 + int snd_oss_set_format (sound_oss_t *drv, int fmt) 95 + { 96 + int val; 97 + 98 + val = fmt; 99 + 100 + if (ioctl (drv->fd, SNDCTL_DSP_SETFMT, &val) == -1) { 101 + return (1); 102 + } 103 + 104 + if (val != fmt) { 105 + return (1); 106 + } 107 + 108 + return (0); 109 + } 110 + 111 + static 112 + int snd_oss_set_params (sound_drv_t *sdrv, unsigned chn, unsigned long srate, int sign) 113 + { 114 + int val; 115 + sound_oss_t *drv; 116 + 117 + drv = sdrv->ext; 118 + 119 + if (snd_oss_set_format (drv, AFMT_S16_LE) == 0) { 120 + drv->sign = 1; 121 + drv->big_endian = 0; 122 + } 123 + else if (snd_oss_set_format (drv, AFMT_S16_BE) == 0) { 124 + drv->sign = 1; 125 + drv->big_endian = 1; 126 + } 127 + else if (snd_oss_set_format (drv, AFMT_U16_LE) == 0) { 128 + drv->sign = 0; 129 + drv->big_endian = 0; 130 + } 131 + else if (snd_oss_set_format (drv, AFMT_U16_BE) == 0) { 132 + drv->sign = 0; 133 + drv->big_endian = 1; 134 + } 135 + else { 136 + return (1); 137 + } 138 + 139 + val = chn; 140 + if (ioctl (drv->fd, SNDCTL_DSP_CHANNELS, &val) == -1) { 141 + return (1); 142 + } 143 + if (val != (int) chn) { 144 + return (1); 145 + } 146 + 147 + val = srate; 148 + if (ioctl (drv->fd, SNDCTL_DSP_SPEED, &val) == -1) { 149 + return (1); 150 + } 151 + if (val != (int) srate) { 152 + return (1); 153 + } 154 + 155 + return (0); 156 + } 157 + 158 + static 159 + int snd_oss_init (sound_oss_t *drv, const char *name) 160 + { 161 + snd_init (&drv->sdrv, drv); 162 + 163 + drv->sdrv.close = snd_oss_close; 164 + drv->sdrv.write = snd_oss_write; 165 + drv->sdrv.set_params = snd_oss_set_params; 166 + 167 + drv->fd = -1; 168 + drv->dev = drv_get_option (name, "dev"); 169 + 170 + if (drv->dev == NULL) { 171 + return (1); 172 + } 173 + 174 + drv->fd = open (drv->dev, O_WRONLY, 0); 175 + 176 + if (drv->fd < 0) { 177 + return (1); 178 + } 179 + 180 + return (0); 181 + } 182 + 183 + sound_drv_t *snd_oss_open (const char *name) 184 + { 185 + sound_oss_t *drv; 186 + 187 + drv = malloc (sizeof (sound_oss_t)); 188 + 189 + if (drv == NULL) { 190 + return (NULL); 191 + } 192 + 193 + if (snd_oss_init (drv, name)) { 194 + snd_oss_close (&drv->sdrv); 195 + return (NULL); 196 + } 197 + 198 + return (&drv->sdrv); 199 + }
+41
src/drivers/sound/sound-oss.h
··· 1 + /***************************************************************************** 2 + * pce * 3 + *****************************************************************************/ 4 + 5 + /***************************************************************************** 6 + * File name: src/drivers/sound/sound-oss.h * 7 + * Created: 2009-10-17 by Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2009 Hampa Hug <hampa@hampa.ch> * 9 + *****************************************************************************/ 10 + 11 + /***************************************************************************** 12 + * This program is free software. You can redistribute it and / or modify it * 13 + * under the terms of the GNU General Public License version 2 as published * 14 + * by the Free Software Foundation. * 15 + * * 16 + * This program is distributed in the hope that it will be useful, but * 17 + * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 + * Public License for more details. * 20 + *****************************************************************************/ 21 + 22 + 23 + #ifndef PCE_DRIVERS_SOUND_OSS_H 24 + #define PCE_DRIVERS_SOUND_OSS_H 1 25 + 26 + 27 + #include <drivers/sound/sound.h> 28 + 29 + 30 + typedef struct sound_oss_t { 31 + sound_drv_t sdrv; 32 + 33 + int sign; 34 + int big_endian; 35 + 36 + char *dev; 37 + int fd; 38 + } sound_oss_t; 39 + 40 + 41 + #endif
+4
src/drivers/sound/sound.c
··· 43 43 struct snd_drv_list drvtab[] = { 44 44 { "null", snd_null_open }, 45 45 { "wav", snd_null_open }, 46 + 47 + #ifdef PCE_ENABLE_SOUND_OSS 48 + { "oss", snd_oss_open }, 49 + #endif 46 50 { NULL, NULL } 47 51 }; 48 52
+2
src/drivers/sound/sound.h
··· 177 177 178 178 sound_drv_t *snd_null_open (const char *name); 179 179 180 + sound_drv_t *snd_oss_open (const char *name); 181 + 180 182 181 183 #endif