comparison src/audio/openbsd/SDL_openbsdaudio.c @ 1565:57431b199aed

Fixed bug #52 Integrated most of the NetBSD and DragonFly patches at: ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/devel/SDL/patches/ Thanks to Thomas Klausner for defailed information on the patches
author Sam Lantinga <slouken@libsdl.org>
date Tue, 21 Mar 2006 08:54:50 +0000
parents d910939febfa
children
comparison
equal deleted inserted replaced
1564:4950a25bd91e 1565:57431b199aed
40 #include "../SDL_audiomem.h" 40 #include "../SDL_audiomem.h"
41 #include "../SDL_audio_c.h" 41 #include "../SDL_audio_c.h"
42 #include "../SDL_audiodev_c.h" 42 #include "../SDL_audiodev_c.h"
43 #include "SDL_openbsdaudio.h" 43 #include "SDL_openbsdaudio.h"
44 44
45 /* The tag name used by OpenBSD audio */ 45 /* The tag name used by NetBSD/OpenBSD audio */
46 #ifdef __NETBSD__
47 #define OBSD_DRIVER_NAME "netbsd"
48 #else
46 #define OBSD_DRIVER_NAME "openbsd" 49 #define OBSD_DRIVER_NAME "openbsd"
50 #endif
47 51
48 /* Open the audio device for playback, and don't block if busy */ 52 /* Open the audio device for playback, and don't block if busy */
49 /* #define USE_BLOCKING_WRITES */ 53 /* #define USE_BLOCKING_WRITES */
50 54
51 /* Use timer for synchronization */ 55 /* Use timer for synchronization */
126 130
127 return this; 131 return this;
128 } 132 }
129 133
130 AudioBootStrap OPENBSD_AUDIO_bootstrap = { 134 AudioBootStrap OPENBSD_AUDIO_bootstrap = {
135 #ifdef __NETBSD__
136 OBSD_DRIVER_NAME, "Native NetBSD audio",
137 #else
131 OBSD_DRIVER_NAME, "Native OpenBSD audio", 138 OBSD_DRIVER_NAME, "Native OpenBSD audio",
139 #endif
132 Audio_Available, Audio_CreateDevice 140 Audio_Available, Audio_CreateDevice
133 }; 141 };
134 142
135 /* This function waits until it is possible to write a full sound buffer */ 143 /* This function waits until it is possible to write a full sound buffer */
136 static void 144 static void
137 OBSD_WaitAudio(_THIS) 145 OBSD_WaitAudio(_THIS)
138 { 146 {
139 /* Check to see if the thread-parent process is still alive */
140 { static int cnt = 0;
141 /* Note that this only works with thread implementations
142 that use a different process id for each thread.
143 */
144 if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
145 if ( kill(parent, 0) < 0 ) {
146 this->enabled = 0;
147 }
148 }
149 }
150
151 #ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */ 147 #ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */
152 /* See if we need to use timed audio synchronization */ 148 /* See if we need to use timed audio synchronization */
153 if ( frame_ticks ) { 149 if ( frame_ticks ) {
154 /* Use timer for general audio synchronization */ 150 /* Use timer for general audio synchronization */
155 Sint32 ticks; 151 Sint32 ticks;
382 info.play.channels = spec->channels; 378 info.play.channels = spec->channels;
383 if (ioctl(audio_fd, AUDIO_SETINFO, &info) == -1) 379 if (ioctl(audio_fd, AUDIO_SETINFO, &info) == -1)
384 spec->channels = 1; 380 spec->channels = 1;
385 AUDIO_INITINFO(&info); 381 AUDIO_INITINFO(&info);
386 info.play.sample_rate = spec->freq; 382 info.play.sample_rate = spec->freq;
383 info.blocksize = spec->size;
384 info.hiwat = 5;
385 info.lowat = 3;
387 (void)ioctl(audio_fd, AUDIO_SETINFO, &info); 386 (void)ioctl(audio_fd, AUDIO_SETINFO, &info);
388 (void)ioctl(audio_fd, AUDIO_GETINFO, &info); 387 (void)ioctl(audio_fd, AUDIO_GETINFO, &info);
389 spec->freq = info.play.sample_rate; 388 spec->freq = info.play.sample_rate;
390 /* Allocate mixing buffer */ 389 /* Allocate mixing buffer */
391 mixlen = spec->size; 390 mixlen = spec->size;