changeset 19887:1259d6add8e6

When one of the PCM configuration function in init() fails, abort immediately instead of continuing with the remaining calls that would fail anyway because the device or some variable wasn't properly initialized in this case.
author cladisch
date Mon, 18 Sep 2006 16:29:27 +0000
parents 49ebd9c51a99
children 2ce14efa8917
files libao2/ao_alsa.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_alsa.c	Mon Sep 18 16:24:16 2006 +0000
+++ b/libao2/ao_alsa.c	Mon Sep 18 16:29:27 2006 +0000
@@ -577,6 +577,7 @@
 	  {
 	    mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set period time: %s\n",
 		   snd_strerror(err));
+	    return 0;
 	  }
 	mp_msg(MSGT_AO,MSGL_INFO,"alsa-init: buffer_time: %d, period_time :%d\n",
 	       alsa_buffer_time, err);
@@ -591,6 +592,7 @@
 	  {
 	    mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set periodsize(%ld): %s\n",
 			    chunk_size, snd_strerror(err));
+	    return 0;
 	  }
 	else {
 	  mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set to %li\n", chunk_size);
@@ -599,6 +601,7 @@
 						      &alsa_fragcount, NULL)) < 0) {
 	  mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set periods: %s\n", 
 		 snd_strerror(err));
+	  return 0;
 	}
 	else {
 	  mp_msg(MSGT_AO,MSGL_V,"alsa-init: fragcount=%i\n", alsa_fragcount);
@@ -611,6 +614,7 @@
 	{
 	  mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set hw-parameters: %s\n",
 		 snd_strerror(err));
+	  return 0;
 	}
       // end setting hw-params
 
@@ -619,6 +623,7 @@
       if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize)) < 0)
 	{
 	  mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to get buffersize: %s\n", snd_strerror(err));
+	  return 0;
 	}
       else {
 	ao_data.buffersize = bufsize * bytes_per_sample;
@@ -627,6 +632,7 @@
 
       if ((err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &chunk_size, NULL)) < 0) {
 	mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to get period size: %s\n", snd_strerror(err));
+	return 0;
       } else {
 	mp_msg(MSGT_AO,MSGL_V,"alsa-init: got period size %li\n", chunk_size);
       }