Recoomendation from Lennart Poettering: SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 19 Oct 2009 02:36:02 +0000
branchSDL-1.2
changeset 43594b582c04ec1d
parent 4358 df306a61a61d
child 4360 be2dff2f79c0
Recoomendation from Lennart Poettering:

I guess I don't have to mention that, but ALSA_WaitAudio() is
pure evil, and just broken. getpid() returns pids, not tids. You get
those via gettid(). But I'd recommend dropping that entirely. It's
just broken.
src/audio/alsa/SDL_alsa_audio.c
src/audio/alsa/SDL_alsa_audio.h
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Mon Oct 19 02:33:07 2009 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Mon Oct 19 02:36:02 2009 +0000
     1.3 @@ -251,17 +251,7 @@
     1.4  /* This function waits until it is possible to write a full sound buffer */
     1.5  static void ALSA_WaitAudio(_THIS)
     1.6  {
     1.7 -	/* Check to see if the thread-parent process is still alive */
     1.8 -	{ static int cnt = 0;
     1.9 -		/* Note that this only works with thread implementations 
    1.10 -		   that use a different process id for each thread.
    1.11 -		*/
    1.12 -		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
    1.13 -			if ( kill(parent, 0) < 0 ) {
    1.14 -				this->enabled = 0;
    1.15 -			}
    1.16 -		}
    1.17 -	}
    1.18 +	/* We're in blocking mode, so there's nothing to do here */
    1.19  }
    1.20  
    1.21  
    1.22 @@ -601,9 +591,6 @@
    1.23  	}
    1.24  	SDL_memset(mixbuf, spec->silence, spec->size);
    1.25  
    1.26 -	/* Get the parent process id (we're the parent of the audio thread) */
    1.27 -	parent = getpid();
    1.28 -
    1.29  	/* Switch to blocking mode for playback */
    1.30  	SDL_NAME(snd_pcm_nonblock)(pcm_handle, 0);
    1.31  
     2.1 --- a/src/audio/alsa/SDL_alsa_audio.h	Mon Oct 19 02:33:07 2009 +0000
     2.2 +++ b/src/audio/alsa/SDL_alsa_audio.h	Mon Oct 19 02:36:02 2009 +0000
     2.3 @@ -35,9 +35,6 @@
     2.4  	/* The audio device handle */
     2.5  	snd_pcm_t *pcm_handle;
     2.6  
     2.7 -	/* The parent process id, to detect when application quits */
     2.8 -	pid_t parent;
     2.9 -
    2.10  	/* Raw mixing buffer */
    2.11  	Uint8 *mixbuf;
    2.12  	int    mixlen;
    2.13 @@ -45,7 +42,6 @@
    2.14  
    2.15  /* Old variable names */
    2.16  #define pcm_handle		(this->hidden->pcm_handle)
    2.17 -#define parent			(this->hidden->parent)
    2.18  #define mixbuf			(this->hidden->mixbuf)
    2.19  #define mixlen			(this->hidden->mixlen)
    2.20