alsa: backport SDL2 commit c87efb30 - removes noticable lag during quit. SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Thu, 15 Aug 2019 20:34:32 +0300
branchSDL-1.2
changeset 13012a8557f8c3c01
parent 13011 edf8cb7ce974
child 13014 35a99e8ae9c4
alsa: backport SDL2 commit c87efb30 - removes noticable lag during quit.
src/audio/alsa/SDL_alsa_audio.c
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Thu Aug 15 20:32:32 2019 +0300
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Thu Aug 15 20:34:32 2019 +0300
     1.3 @@ -61,7 +61,6 @@
     1.4  static snd_pcm_sframes_t (*SDL_NAME(snd_pcm_writei))(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
     1.5  static int (*SDL_NAME(snd_pcm_resume))(snd_pcm_t *pcm);
     1.6  static int (*SDL_NAME(snd_pcm_prepare))(snd_pcm_t *pcm);
     1.7 -static int (*SDL_NAME(snd_pcm_drain))(snd_pcm_t *pcm);
     1.8  static const char *(*SDL_NAME(snd_strerror))(int errnum);
     1.9  static size_t (*SDL_NAME(snd_pcm_hw_params_sizeof))(void);
    1.10  static size_t (*SDL_NAME(snd_pcm_sw_params_sizeof))(void);
    1.11 @@ -100,7 +99,6 @@
    1.12  	{ "snd_pcm_writei",	(void**)(char*)&SDL_NAME(snd_pcm_writei)	},
    1.13  	{ "snd_pcm_resume",	(void**)(char*)&SDL_NAME(snd_pcm_resume)	},
    1.14  	{ "snd_pcm_prepare",	(void**)(char*)&SDL_NAME(snd_pcm_prepare)	},
    1.15 -	{ "snd_pcm_drain",	(void**)(char*)&SDL_NAME(snd_pcm_drain)	},
    1.16  	{ "snd_strerror",	(void**)(char*)&SDL_NAME(snd_strerror)		},
    1.17  	{ "snd_pcm_hw_params_sizeof",		(void**)(char*)&SDL_NAME(snd_pcm_hw_params_sizeof)		},
    1.18  	{ "snd_pcm_sw_params_sizeof",		(void**)(char*)&SDL_NAME(snd_pcm_sw_params_sizeof)		},
    1.19 @@ -366,7 +364,11 @@
    1.20  		mixbuf = NULL;
    1.21  	}
    1.22  	if ( pcm_handle ) {
    1.23 -		SDL_NAME(snd_pcm_drain)(pcm_handle);
    1.24 +		/* Wait for the submitted audio to drain
    1.25 +		   snd_pcm_drop() can hang, so don't use that.
    1.26 +		 */
    1.27 +		Uint32 delay = ((this->spec.samples * 1000) / this->spec.freq) * 2;
    1.28 +		SDL_Delay(delay);
    1.29  		SDL_NAME(snd_pcm_close)(pcm_handle);
    1.30  		pcm_handle = NULL;
    1.31  	}