diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c
index c574b5dc937442499f557dc9c602c7df6f21e525..4a2fc7175d9dc9e1a7556dd276882f2723a51bd2 100644
--- a/src/xpdev/xpbeep.c
+++ b/src/xpdev/xpbeep.c
@@ -474,6 +474,7 @@ BOOL xptone_open(void)
 				}
 			}
 			else {
+				alsa_api->snd_pcm_hw_params_free(hw_params);
 				handle_type=SOUND_DEVICE_ALSA;
 				return(TRUE);
 			}
@@ -624,7 +625,6 @@ void xp_play_sample_thread(void *data)
 
 	#ifdef USE_ALSA_SOUND
 		if(handle_type==SOUND_DEVICE_ALSA) {
-			alsa_api->snd_pcm_hw_params_free(hw_params);
 			if(playback_handle != NULL) {
 				if(alsa_api->snd_pcm_writei(playback_handle, sample_buffer, sample_size)!=sample_size) {
 					/* Go back and try OSS */
@@ -760,7 +760,6 @@ BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t sample_size, BOO
 
 #ifdef USE_ALSA_SOUND
 	if(handle_type==SOUND_DEVICE_ALSA) {
-		alsa_api->snd_pcm_hw_params_free(hw_params);
 		if(playback_handle != NULL) {
 			if(alsa_api->snd_pcm_writei(playback_handle, sample, sample_size)!=sample_size) {
 				/* Go back and try OSS */