changeset 1725:f9856ca98943

Pass literal values to snd_strerror(), as passing -err will cause an invalid dereference in any modern ALSA.
author William Pitcock <nenolod@atheme.org>
date Tue, 18 Sep 2007 09:25:56 -0500
parents c3375df9efd5
children 0a689ca43d7a
files src/alsa/audio.c src/alsa/configure.c
diffstat 2 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/alsa/audio.c	Mon Sep 17 09:05:53 2007 -0500
+++ b/src/alsa/audio.c	Tue Sep 18 09:25:56 2007 -0500
@@ -193,7 +193,7 @@
 		if (ret < 0)
 		{
 			g_warning("alsa_get_avail(): snd_pcm_avail_update() failed: %s",
-				  snd_strerror(-ret));
+				  snd_strerror(ret));
 			return 0;
 		}
 	}
@@ -248,7 +248,7 @@
 		snd_pcm_drop(alsa_pcm);
 		if ((err = snd_pcm_close(alsa_pcm)) < 0)
 			g_warning("alsa_pcm_close() failed: %s",
-				  snd_strerror(-err));
+				  snd_strerror(err));
 		alsa_pcm = NULL;
 	}
 }
@@ -349,7 +349,7 @@
 	if ((err = snd_mixer_open(mixer, 0)) < 0)
 	{
 		g_warning("alsa_get_mixer(): Failed to open empty mixer: %s",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		mixer = NULL;
 		return -1;
 	}
@@ -358,7 +358,7 @@
 	if ((err = snd_mixer_attach(*mixer, dev)) < 0)
 	{
 		g_warning("alsa_get_mixer(): Attaching to mixer %s failed: %s",
-			  dev, snd_strerror(-err));
+			  dev, snd_strerror(err));
 		g_free(dev);
 		return -1;
 	}
@@ -367,13 +367,13 @@
 	if ((err = snd_mixer_selem_register(*mixer, NULL, NULL)) < 0)
 	{
 		g_warning("alsa_get_mixer(): Failed to register mixer: %s",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 	if ((err = snd_mixer_load(*mixer)) < 0)
 	{
 		g_warning("alsa_get_mixer(): Failed to load mixer: %s",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 
@@ -768,7 +768,7 @@
 			if (err < 0)
 			{
 				g_warning("alsa_write_audio(): write error: %s",
-					  snd_strerror(-err));
+					  snd_strerror(err));
 				break;
 			}
 		}
@@ -963,7 +963,7 @@
 				SND_PCM_NONBLOCK)) < 0)
 	{
 		g_warning("alsa_setup(): Failed to open pcm device (%s): %s",
-			  alsa_cfg.pcm_device, snd_strerror(-err));
+			  alsa_cfg.pcm_device, snd_strerror(err));
 		alsa_pcm = NULL;
 		g_free(outputf);
 		outputf = NULL;
@@ -992,7 +992,7 @@
 	if ((err = snd_pcm_hw_params_any(alsa_pcm, hwparams)) < 0)
 	{
 		g_warning("alsa_setup(): No configuration available for "
-			  "playback: %s", snd_strerror(-err));
+			  "playback: %s", snd_strerror(err));
 		return -1;
 	}
 
@@ -1000,7 +1000,7 @@
 						SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
 	{
 		g_warning("alsa_setup(): Cannot set direct write mode: %s",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 
@@ -1040,7 +1040,7 @@
 		{
 			g_warning("alsa_setup(): Sample format not "
 				  "available for playback: %s",
-				  snd_strerror(-err));
+				  snd_strerror(err));
 			return -1;
 		}
 	}
@@ -1083,7 +1083,7 @@
 							  &alsa_buffer_time, 0)) < 0)
 	{
 		g_warning("alsa_setup(): Set buffer time failed: %s.",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 
@@ -1092,7 +1092,7 @@
 							  &alsa_period_time, 0)) < 0)
 	{
 		g_warning("alsa_setup(): Set period time failed: %s.",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 
@@ -1108,7 +1108,7 @@
 	{
 		g_warning("alsa_setup(): snd_pcm_hw_params_get_buffer_size() "
 			  "failed: %s",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 
@@ -1116,7 +1116,7 @@
 	{
 		g_warning("alsa_setup(): snd_pcm_hw_params_get_period_size() "
 			  "failed: %s",
-			  snd_strerror(-err));
+			  snd_strerror(err));
 		return -1;
 	}
 
@@ -1129,7 +1129,7 @@
 	if ((err = snd_pcm_sw_params_set_start_threshold(alsa_pcm,
 			swparams, alsa_buffer_size - alsa_period_size) < 0))
 		g_warning("alsa_setup(): setting start "
-			  "threshold failed: %s", snd_strerror(-err));
+			  "threshold failed: %s", snd_strerror(err));
 	if (snd_pcm_sw_params(alsa_pcm, swparams) < 0)
 	{
 		g_warning("alsa_setup(): Unable to install sw params");
--- a/src/alsa/configure.c	Mon Sep 17 09:05:53 2007 -0500
+++ b/src/alsa/configure.c	Tue Sep 18 09:25:56 2007 -0500
@@ -69,7 +69,7 @@
 
 	menu = gtk_menu_new();
 	if ((err = snd_card_next(&card)) != 0)
-		g_warning("snd_next_card() failed: %s", snd_strerror(-err));
+		g_warning("snd_next_card() failed: %s", snd_strerror(err));
 
 	while (card > -1)
 	{
@@ -81,7 +81,7 @@
 		if ((err = snd_card_get_name(card, &label)) != 0)
 		{
 			g_warning("snd_carg_get_name() failed: %s",
-				  snd_strerror(-err));
+				  snd_strerror(err));
 			break;
 		}
 
@@ -93,7 +93,7 @@
 		if ((err = snd_card_next(&card)) != 0)
 		{
 			g_warning("snd_next_card() failed: %s",
-				  snd_strerror(-err));
+				  snd_strerror(err));
 			break;
 		}
 	}
@@ -140,13 +140,13 @@
 
 	if ((err = snd_ctl_open(&ctl, dev, 0)) < 0)
 	{
-		printf("snd_ctl_open() failed: %s", snd_strerror(-err));
+		printf("snd_ctl_open() failed: %s", snd_strerror(err));
 		return;
 	}
 
 	if ((err = snd_card_get_name(card, &card_name)) != 0)
 	{
-		g_warning("snd_card_get_name() failed: %s", snd_strerror(-err));
+		g_warning("snd_card_get_name() failed: %s", snd_strerror(err));
 		card_name = _("Unknown soundcard");
 	}
 
@@ -158,7 +158,7 @@
 		if ((err = snd_ctl_pcm_next_device(ctl, &pcm_device)) < 0)
 		{
 			g_warning("snd_ctl_pcm_next_device() failed: %s",
-				  snd_strerror(-err));
+				  snd_strerror(err));
 			pcm_device = -1;
 		}
 		if (pcm_device < 0)
@@ -174,7 +174,7 @@
 				g_warning("get_devices_for_card(): "
 					  "snd_ctl_pcm_info() "
 					  "failed (%d:%d): %s.", card,
-					  pcm_device, snd_strerror(-err));
+					  pcm_device, snd_strerror(err));
 			continue;
 		}
 
@@ -211,7 +211,7 @@
 
 	if ((err = snd_card_next(&card)) != 0)
 	{
-		g_warning("snd_next_card() failed: %s", snd_strerror(-err));
+		g_warning("snd_next_card() failed: %s", snd_strerror(err));
 		return;
 	}
 
@@ -221,7 +221,7 @@
 		if ((err = snd_card_next(&card)) != 0)
 		{
 			g_warning("snd_next_card() failed: %s",
-				  snd_strerror(-err));
+				  snd_strerror(err));
 			break;
 		}
 	}