src/audio/alsa/SDL_alsa_audio.c
changeset 0 74212992fb08
child 252 e8157fcb3114
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Thu Apr 26 16:45:43 2001 +0000
     1.3 @@ -0,0 +1,521 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@devolution.com
    1.24 +*/
    1.25 +
    1.26 +
    1.27 +
    1.28 +/* Allow access to a raw mixing buffer */
    1.29 +
    1.30 +#include <stdlib.h>
    1.31 +#include <stdio.h>
    1.32 +#include <string.h>
    1.33 +#include <errno.h>
    1.34 +#include <unistd.h>
    1.35 +#include <fcntl.h>
    1.36 +#include <signal.h>
    1.37 +#include <sys/types.h>
    1.38 +#include <sys/time.h>
    1.39 +
    1.40 +#include "SDL_audio.h"
    1.41 +#include "SDL_error.h"
    1.42 +#include "SDL_audiomem.h"
    1.43 +#include "SDL_audio_c.h"
    1.44 +#include "SDL_timer.h"
    1.45 +#include "SDL_alsa_audio.h"
    1.46 +
    1.47 +/* The tag name used by ALSA audio */
    1.48 +#define DRIVER_NAME         "alsa"
    1.49 +
    1.50 +/* default card and device numbers as listed in dev/snd */
    1.51 +static int card_no = 0;
    1.52 +static int device_no = 0;
    1.53 +
    1.54 +/* default channel communication parameters */
    1.55 +#define DEFAULT_CPARAMS_RATE 22050
    1.56 +#define DEFAULT_CPARAMS_VOICES 1
    1.57 +#define DEFAULT_CPARAMS_FRAG_SIZE 512
    1.58 +#define DEFAULT_CPARAMS_FRAGS_MIN 1
    1.59 +#define DEFAULT_CPARAMS_FRAGS_MAX -1
    1.60 +
    1.61 +/* Open the audio device for playback, and don't block if busy */
    1.62 +#define OPEN_FLAGS	(SND_PCM_OPEN_PLAYBACK|SND_PCM_OPEN_NONBLOCK)
    1.63 +
    1.64 +/* Audio driver functions */
    1.65 +static int PCM_OpenAudio(_THIS, SDL_AudioSpec *spec);
    1.66 +static void PCM_WaitAudio(_THIS);
    1.67 +static void PCM_PlayAudio(_THIS);
    1.68 +static Uint8 *PCM_GetAudioBuf(_THIS);
    1.69 +static void PCM_CloseAudio(_THIS);
    1.70 +
    1.71 +/* PCM transfer channel parameters initialize function */
    1.72 +static void init_pcm_cparams(snd_pcm_channel_params_t* cparams)
    1.73 +{
    1.74 +	memset(cparams,0,sizeof(snd_pcm_channel_params_t));
    1.75 +
    1.76 +	cparams->channel = SND_PCM_CHANNEL_PLAYBACK;
    1.77 +	cparams->mode = SND_PCM_MODE_BLOCK;
    1.78 +	cparams->start_mode = SND_PCM_START_DATA; //_FULL
    1.79 +	cparams->stop_mode  = SND_PCM_STOP_STOP;
    1.80 +	cparams->format.format = SND_PCM_SFMT_S16_LE;
    1.81 +	cparams->format.interleave = 1;
    1.82 +	cparams->format.rate = DEFAULT_CPARAMS_RATE;
    1.83 +	cparams->format.voices = DEFAULT_CPARAMS_VOICES;
    1.84 +	cparams->buf.block.frag_size = DEFAULT_CPARAMS_FRAG_SIZE;
    1.85 +	cparams->buf.block.frags_min = DEFAULT_CPARAMS_FRAGS_MIN;
    1.86 +	cparams->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
    1.87 +}
    1.88 +
    1.89 +/* Audio driver bootstrap functions */
    1.90 +
    1.91 +static int Audio_Available(void)
    1.92 +/*
    1.93 +	See if we can open a nonblocking channel.
    1.94 +	Return value '1' means we can.
    1.95 +	Return value '0' means we cannot.
    1.96 +*/
    1.97 +{
    1.98 +	int available;
    1.99 +	int rval;
   1.100 +	snd_pcm_t *handle;
   1.101 +	snd_pcm_channel_params_t cparams;
   1.102 +#ifdef DEBUG_AUDIO
   1.103 +	snd_pcm_channel_status_t cstatus;
   1.104 +#endif
   1.105 +
   1.106 +	available = 0;
   1.107 +	handle = NULL;
   1.108 +
   1.109 +	init_pcm_cparams(&cparams);
   1.110 +	
   1.111 +	rval = snd_pcm_open(&handle, card_no, device_no, OPEN_FLAGS);
   1.112 +	if (rval >= 0)
   1.113 +	{
   1.114 +		rval = snd_pcm_plugin_params(handle, &cparams);
   1.115 +
   1.116 +#ifdef DEBUG_AUDIO
   1.117 +		snd_pcm_plugin_status(handle, &cstatus);
   1.118 +		printf("status after snd_pcm_plugin_params call = %d\n",cstatus.status);
   1.119 +#endif
   1.120 +		if (rval >= 0)
   1.121 +		{
   1.122 +			available = 1;
   1.123 +		}
   1.124 +		else
   1.125 +		{
   1.126 +	        	SDL_SetError("snd_pcm_channel_params failed: %s\n", snd_strerror (rval));
   1.127 +		}
   1.128 +
   1.129 +        if ((rval = snd_pcm_close(handle)) < 0)
   1.130 +        {
   1.131 +            SDL_SetError("snd_pcm_close failed: %s\n",snd_strerror(rval));
   1.132 +			available = 0;
   1.133 +        }
   1.134 +	}
   1.135 +	else
   1.136 +	{
   1.137 +       SDL_SetError("snd_pcm_open failed: %s\n", snd_strerror(rval));
   1.138 +	}
   1.139 +
   1.140 +	return(available);
   1.141 +}
   1.142 +
   1.143 +static void Audio_DeleteDevice(SDL_AudioDevice *device)
   1.144 +{
   1.145 +	free(device->hidden);
   1.146 +	free(device);
   1.147 +}
   1.148 +
   1.149 +static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   1.150 +{
   1.151 +	SDL_AudioDevice *this;
   1.152 +
   1.153 +	/* Initialize all variables that we clean on shutdown */
   1.154 +	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   1.155 +	if ( this ) {
   1.156 +		memset(this, 0, (sizeof *this));
   1.157 +		this->hidden = (struct SDL_PrivateAudioData *)
   1.158 +				malloc((sizeof *this->hidden));
   1.159 +	}
   1.160 +	if ( (this == NULL) || (this->hidden == NULL) ) {
   1.161 +		SDL_OutOfMemory();
   1.162 +		if ( this ) {
   1.163 +			free(this);
   1.164 +		}
   1.165 +		return(0);
   1.166 +	}
   1.167 +	memset(this->hidden, 0, (sizeof *this->hidden));
   1.168 +	audio_handle = NULL;
   1.169 +
   1.170 +	/* Set the function pointers */
   1.171 +	this->OpenAudio = PCM_OpenAudio;
   1.172 +	this->WaitAudio = PCM_WaitAudio;
   1.173 +	this->PlayAudio = PCM_PlayAudio;
   1.174 +	this->GetAudioBuf = PCM_GetAudioBuf;
   1.175 +	this->CloseAudio = PCM_CloseAudio;
   1.176 +
   1.177 +	this->free = Audio_DeleteDevice;
   1.178 +
   1.179 +	return this;
   1.180 +}
   1.181 +
   1.182 +AudioBootStrap ALSA_bootstrap = {
   1.183 +	DRIVER_NAME, "ALSA PCM audio",
   1.184 +	Audio_Available, Audio_CreateDevice
   1.185 +};
   1.186 +
   1.187 +/* This function waits until it is possible to write a full sound buffer */
   1.188 +static void PCM_WaitAudio(_THIS)
   1.189 +{
   1.190 +
   1.191 +	/* Check to see if the thread-parent process is still alive */
   1.192 +	{ static int cnt = 0;
   1.193 +		/* Note that this only works with thread implementations 
   1.194 +		   that use a different process id for each thread.
   1.195 +		*/
   1.196 +		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
   1.197 +			if ( kill(parent, 0) < 0 ) {
   1.198 +				this->enabled = 0;
   1.199 +			}
   1.200 +		}
   1.201 +	}
   1.202 +
   1.203 +	/* See if we need to use timed audio synchronization */
   1.204 +	if ( frame_ticks ) 
   1.205 +	{
   1.206 +		/* Use timer for general audio synchronization */
   1.207 +		Sint32 ticks;
   1.208 +
   1.209 +		ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
   1.210 +		if ( ticks > 0 ) 
   1.211 +		{
   1.212 +			SDL_Delay(ticks);
   1.213 +		}
   1.214 +	}
   1.215 +    else 
   1.216 +	{
   1.217 +    	/* Use select() for audio synchronization */
   1.218 +		fd_set fdset;
   1.219 +	    struct timeval timeout;
   1.220 +    	FD_ZERO(&fdset);
   1.221 +	    FD_SET(audio_fd, &fdset);
   1.222 +    	timeout.tv_sec = 10;
   1.223 +	    timeout.tv_usec = 0;
   1.224 +#ifdef DEBUG_AUDIO
   1.225 +    	fprintf(stderr, "Waiting for audio to get ready\n");
   1.226 +#endif
   1.227 +	    if ( select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0 ) 
   1.228 +		{
   1.229 +            const char *message =
   1.230 +            "Audio timeout - buggy audio driver? (disabled)";
   1.231 +	        /* In general we should never print to the screen,
   1.232 +       	       but in this case we have no other way of letting
   1.233 +               the user know what happened.
   1.234 +            */
   1.235 +       	    fprintf(stderr, "SDL: %s\n", message);
   1.236 +   	        this->enabled = 0;
   1.237 +            /* Don't try to close - may hang */
   1.238 +            audio_fd = -1;
   1.239 +#ifdef DEBUG_AUDIO
   1.240 +       	    fprintf(stderr, "Done disabling audio\n");
   1.241 +#endif
   1.242 +    	    }
   1.243 +#ifdef DEBUG_AUDIO
   1.244 +        fprintf(stderr, "Ready!\n");
   1.245 +#endif
   1.246 +    }
   1.247 +}
   1.248 +
   1.249 +static snd_pcm_channel_status_t cstatus;
   1.250 +
   1.251 +static void PCM_PlayAudio(_THIS)
   1.252 +{
   1.253 +    int written, rval;
   1.254 +
   1.255 +    /* Write the audio data, checking for EAGAIN (buffer full) and underrun */
   1.256 +    do {
   1.257 +		written = snd_pcm_plugin_write(audio_handle, pcm_buf, pcm_len);
   1.258 +#ifdef DEBUG_AUDIO
   1.259 +		fprintf(stderr, "written = %d pcm_len = %d\n",written,pcm_len);
   1.260 +#endif
   1.261 +		if (written != pcm_len)
   1.262 +		{
   1.263 +	        if (errno == EAGAIN) 
   1.264 +			{
   1.265 +            	SDL_Delay(1);   /* Let a little CPU time go by and try to write again */
   1.266 +#ifdef DEBUG_AUDIO
   1.267 +				fprintf(stderr, "errno == EAGAIN\n");
   1.268 +#endif
   1.269 +        	}
   1.270 +			else
   1.271 +			{
   1.272 +		        if( (rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0 )
   1.273 +        		{
   1.274 +		            SDL_SetError("snd_pcm_plugin_status failed: %s\n", snd_strerror(rval));
   1.275 +        		    return;
   1.276 +		        }
   1.277 +				if ( (cstatus.status == SND_PCM_STATUS_UNDERRUN)
   1.278 +					||(cstatus.status == SND_PCM_STATUS_READY) )
   1.279 +				{
   1.280 +#ifdef DEBUG_AUDIO
   1.281 +					fprintf(stderr, "buffer underrun\n");
   1.282 +#endif
   1.283 +					if ( (rval = snd_pcm_plugin_prepare (audio_handle,SND_PCM_CHANNEL_PLAYBACK)) < 0 )
   1.284 +					{
   1.285 +						SDL_SetError("snd_pcm_plugin_prepare failed: %s\n",snd_strerror(rval) );
   1.286 +						return;
   1.287 +					}
   1.288 +					/* if we reach here, try to write again */
   1.289 +				}
   1.290 +			}
   1.291 +		}
   1.292 +    } while ( (written < 0) && ((errno == 0) || (errno == EAGAIN)) );
   1.293 +
   1.294 +    /* Set the next write frame */
   1.295 +   if ( frame_ticks ) {
   1.296 +	    next_frame += frame_ticks;
   1.297 +	}
   1.298 +
   1.299 +    /* If we couldn't write, assume fatal error for now */
   1.300 +    if ( written < 0 ) {
   1.301 +        this->enabled = 0;
   1.302 +    }
   1.303 +	return;
   1.304 +}
   1.305 +
   1.306 +static Uint8 *PCM_GetAudioBuf(_THIS)
   1.307 +{
   1.308 +	return(pcm_buf);
   1.309 +}
   1.310 +
   1.311 +static void PCM_CloseAudio(_THIS)
   1.312 +{
   1.313 +	int rval;
   1.314 +
   1.315 +	if ( pcm_buf != NULL ) {
   1.316 +		free(pcm_buf);
   1.317 +		pcm_buf = NULL;
   1.318 +	}
   1.319 +	if ( audio_handle != NULL ) {
   1.320 +		if ((rval = snd_pcm_plugin_flush(audio_handle,SND_PCM_CHANNEL_PLAYBACK)) < 0)
   1.321 +		{
   1.322 +        	SDL_SetError("snd_pcm_plugin_flush failed: %s\n",snd_strerror(rval));
   1.323 +			return;
   1.324 +		}
   1.325 +		if ((rval = snd_pcm_close(audio_handle)) < 0)
   1.326 +		{
   1.327 +			SDL_SetError("snd_pcm_close failed: %s\n",snd_strerror(rval));
   1.328 +			return;
   1.329 +		}
   1.330 +		audio_handle = NULL;
   1.331 +	}
   1.332 +}
   1.333 +
   1.334 +static int PCM_OpenAudio(_THIS, SDL_AudioSpec *spec)
   1.335 +{
   1.336 +	int rval;
   1.337 +	snd_pcm_channel_params_t cparams;
   1.338 +	snd_pcm_channel_setup_t  csetup;
   1.339 +	int format;
   1.340 +	Uint16 test_format;
   1.341 +	int twidth;
   1.342 +
   1.343 +	/* initialize channel transfer parameters to default */
   1.344 +	init_pcm_cparams(&cparams);
   1.345 +
   1.346 +	/* Reset the timer synchronization flag */
   1.347 +	frame_ticks = 0.0;
   1.348 +
   1.349 +	/* Open the audio device */
   1.350 +	
   1.351 +	rval = snd_pcm_open(&audio_handle, card_no, device_no, OPEN_FLAGS);
   1.352 +	if ( rval < 0 ) {
   1.353 +		SDL_SetError("snd_pcm_open failed: %s\n", snd_strerror(rval));
   1.354 +		return(-1);
   1.355 +	}
   1.356 +
   1.357 +#ifdef PLUGIN_DISABLE_MMAP /* This is gone in newer versions of ALSA? */
   1.358 +    /* disable count status parameter */
   1.359 +    if ((rval = snd_plugin_set_disable(audio_handle, PLUGIN_DISABLE_MMAP))<0)
   1.360 +    {
   1.361 +        SDL_SetError("snd_plugin_set_disable failed: %s\n", snd_strerror(rval));
   1.362 +        return(-1);
   1.363 +    }
   1.364 +#endif
   1.365 +
   1.366 +	pcm_buf = NULL;
   1.367 +
   1.368 +	/* Try for a closest match on audio format */
   1.369 +	format = 0;
   1.370 +	for ( test_format = SDL_FirstAudioFormat(spec->format);
   1.371 +						! format && test_format; ) 
   1.372 +	{
   1.373 +#ifdef DEBUG_AUDIO
   1.374 +		fprintf(stderr, "Trying format 0x%4.4x spec->samples %d\n", test_format,spec->samples);
   1.375 +#endif
   1.376 +			/* if match found set format to equivalent ALSA format */
   1.377 +        switch ( test_format ) {
   1.378 +			case AUDIO_U8:
   1.379 +				format = SND_PCM_SFMT_U8;
   1.380 +				cparams.buf.block.frag_size = spec->samples * spec->channels;
   1.381 +				break;
   1.382 +			case AUDIO_S8:
   1.383 +				format = SND_PCM_SFMT_S8;
   1.384 +				cparams.buf.block.frag_size = spec->samples * spec->channels;
   1.385 +				break;
   1.386 +			case AUDIO_S16LSB:
   1.387 +				format = SND_PCM_SFMT_S16_LE;
   1.388 +				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
   1.389 +				break;
   1.390 +			case AUDIO_S16MSB:
   1.391 +				format = SND_PCM_SFMT_S16_BE;
   1.392 +				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
   1.393 +				break;
   1.394 +			case AUDIO_U16LSB:
   1.395 +				format = SND_PCM_SFMT_U16_LE;
   1.396 +				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
   1.397 +				break;
   1.398 +			case AUDIO_U16MSB:
   1.399 +				format = SND_PCM_SFMT_U16_BE;
   1.400 +				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
   1.401 +				break;
   1.402 +			default:
   1.403 +				break;
   1.404 +		}
   1.405 +		if ( ! format ) {
   1.406 +			test_format = SDL_NextAudioFormat();
   1.407 +		}
   1.408 +	}
   1.409 +	if ( format == 0 ) {
   1.410 +		SDL_SetError("Couldn't find any hardware audio formats");
   1.411 +		return(-1);
   1.412 +	}
   1.413 +	spec->format = test_format;
   1.414 +
   1.415 +	/* Set the audio format */
   1.416 +	cparams.format.format = format;
   1.417 +
   1.418 +	/* Set mono or stereo audio (currently only two channels supported) */
   1.419 +	cparams.format.voices = spec->channels;
   1.420 +	
   1.421 +	#ifdef DEBUG_AUDIO
   1.422 +	printf("intializing channels %d\n", cparams.format.voices);
   1.423 +	#endif
   1.424 +	
   1.425 +	/* Set rate */
   1.426 +	cparams.format.rate = spec->freq ;
   1.427 +
   1.428 +	/* Setup the transfer parameters according to cparams */
   1.429 +	rval = snd_pcm_plugin_params(audio_handle, &cparams);
   1.430 +	if (rval < 0) {
   1.431 +		SDL_SetError("snd_pcm_channel_params failed: %s\n", snd_strerror (rval));
   1.432 +		return(-1);
   1.433 +	}
   1.434 +
   1.435 +    /*  Make sure channel is setup right one last time */
   1.436 +    memset( &csetup, 0, sizeof( csetup ) );
   1.437 +    csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
   1.438 +    if ( snd_pcm_plugin_setup( audio_handle, &csetup ) < 0 )
   1.439 +    {
   1.440 +        SDL_SetError("Unable to setup playback channel\n" );
   1.441 +        return(-1);
   1.442 +    }
   1.443 +
   1.444 +#ifdef DEBUG_AUDIO
   1.445 +    else
   1.446 +    {
   1.447 +        fprintf(stderr,"requested format: %d\n",cparams.format.format);
   1.448 +        fprintf(stderr,"requested frag size: %d\n",cparams.buf.block.frag_size);
   1.449 +        fprintf(stderr,"requested max frags: %d\n\n",cparams.buf.block.frags_max);
   1.450 +
   1.451 +        fprintf(stderr,"real format: %d\n", csetup.format.format );
   1.452 +        fprintf(stderr,"real frag size : %d\n", csetup.buf.block.frag_size );
   1.453 +		fprintf(stderr,"real max frags : %d\n", csetup.buf.block.frags_max );
   1.454 +    }
   1.455 +#endif // DEBUG_AUDIO
   1.456 +
   1.457 +    /*  Allocate memory to the audio buffer and initialize with silence
   1.458 +        (Note that buffer size must be a multiple of fragment size, so find closest multiple)
   1.459 +    */
   1.460 +    
   1.461 +    twidth = snd_pcm_format_width(format);
   1.462 +    if (twidth < 0) {
   1.463 +        printf("snd_pcm_format_width failed\n");
   1.464 +        twidth = 0;
   1.465 +    }
   1.466 +#ifdef DEBUG_AUDIO
   1.467 +    printf("format is %d bits wide\n",twidth);
   1.468 +#endif      
   1.469 +    
   1.470 +    pcm_len = csetup.buf.block.frag_size * (twidth/8) * csetup.format.voices ;
   1.471 +    
   1.472 +#ifdef DEBUG_AUDIO    
   1.473 +    printf("pcm_len set to %d\n", pcm_len);
   1.474 +#endif
   1.475 +    
   1.476 +    if (pcm_len == 0)
   1.477 +    {
   1.478 +        pcm_len = csetup.buf.block.frag_size;
   1.479 +    }
   1.480 +    
   1.481 +    pcm_buf = (Uint8*)malloc(pcm_len);
   1.482 +    if (pcm_buf == NULL) {
   1.483 +        SDL_SetError("pcm_buf malloc failed\n");
   1.484 +        return(-1);
   1.485 +    }
   1.486 +    memset(pcm_buf,spec->silence,pcm_len);
   1.487 +
   1.488 +#ifdef DEBUG_AUDIO
   1.489 +	fprintf(stderr,"pcm_buf malloced and silenced.\n");
   1.490 +#endif
   1.491 +
   1.492 +    /* get the file descriptor */
   1.493 +    if( (audio_fd = snd_pcm_file_descriptor(audio_handle, device_no)) < 0)
   1.494 +    {
   1.495 +       fprintf(stderr, "snd_pcm_file_descriptor failed with error code: %d\n", audio_fd);
   1.496 +    }
   1.497 +
   1.498 +	/* Trigger audio playback */
   1.499 +	rval = snd_pcm_plugin_prepare( audio_handle, SND_PCM_CHANNEL_PLAYBACK);
   1.500 +	if (rval < 0) {
   1.501 +       SDL_SetError("snd_pcm_plugin_prepare failed: %s\n", snd_strerror (rval));
   1.502 +       return(-1);
   1.503 +	}
   1.504 +	rval =  snd_pcm_playback_go(audio_handle);
   1.505 +    if (rval < 0) {
   1.506 +       SDL_SetError("snd_pcm_playback_go failed: %s\n", snd_strerror (rval));
   1.507 +       return(-1);
   1.508 +    }
   1.509 +
   1.510 +    /* Check to see if we need to use select() workaround */
   1.511 +    { char *workaround;
   1.512 +        workaround = getenv("SDL_DSP_NOSELECT");
   1.513 +        if ( workaround ) {
   1.514 +            frame_ticks = (float)(spec->samples*1000)/spec->freq;
   1.515 +            next_frame = SDL_GetTicks()+frame_ticks;
   1.516 +        }
   1.517 +    }
   1.518 +
   1.519 +	/* Get the parent process id (we're the parent of the audio thread) */
   1.520 +	parent = getpid();
   1.521 +
   1.522 +	/* We're ready to rock and roll. :-) */
   1.523 +	return(0);
   1.524 +}