[Clam-devel] PATCH: remove vestigal snprintfs

Zach Welch zach-clam-devel at splitstring.com
Wed Apr 11 17:47:20 PDT 2007


Pau Arumi wrote:
> En/na Zach Welch ha escrit:
>> Hi all,
>>
>> This patch removes a couple of instances where snprintf is used.  For 
>> some reason, I get an error saying that snprintf is not a member of 
>> the std namespace, so this patch avoids the whole issue.
> 
> committed revision 9984.

I moved to a new machine today and discovered my old patch doesn't work.
The problems are fixed with the attached patch.  Sorry for the churn.

Cheers,

Zach

-------------- next part --------------
Index: CLAM/src/Tools/AudioIO/Linux/ALSAAudioDevice.cxx
===================================================================
--- CLAM/src/Tools/AudioIO/Linux/ALSAAudioDevice.cxx	(revision 9985)
+++ CLAM/src/Tools/AudioIO/Linux/ALSAAudioDevice.cxx	(working copy)
@@ -278,7 +278,6 @@
 		ALSAAudioDeviceList()
 			:AudioDeviceList(std::string("alsa"))
 		{
-			std::stringstream name;
 			int card, dev;
 			snd_ctl_t *handle;
 			snd_ctl_card_info_t *info;
@@ -288,8 +287,10 @@
 			if (snd_card_next(&card) < 0 || card < 0)
 				return; // No cards found
 			while (card >= 0) {
-				name << "hw:" << card;
-				if (snd_ctl_open(&handle, name.str().c_str(), 0) < 0)
+				std::stringstream namestr;
+				namestr << "hw:" << card;
+				std::string name(namestr.str());
+				if (snd_ctl_open(&handle, name.c_str(), 0) < 0)
 					continue; // Card control open error!
 				if (snd_ctl_card_info(handle, info) < 0) {
 					snd_ctl_close(handle); // Card control read error!
@@ -300,12 +301,14 @@
 					snd_ctl_pcm_next_device(handle, &dev);
 					if (dev < 0)
 						break;
-					name << "," << dev;
-					mAvailableDevices.push_back(name.str());
+					std::stringstream dnamestr;
+					dnamestr << name << "," << dev;
+					std::string dname(dnamestr.str());
+					mAvailableDevices.push_back(dname.c_str());
 
-					name.clear();
-					name << "plughw:" << card << "," << dev;
-					mAvailableDevices.push_back(name.str());
+					std::stringstream plug;
+					plug << "plug" << dname;
+					mAvailableDevices.push_back(plug.str());
 				}
 				snd_ctl_close(handle);
 				if (snd_card_next(&card) < 0)
Index: CLAM/src/Tools/MIDIIO/Linux/ALSAMIDIDevice.cxx
===================================================================
--- CLAM/src/Tools/MIDIIO/Linux/ALSAMIDIDevice.cxx	(revision 9985)
+++ CLAM/src/Tools/MIDIIO/Linux/ALSAMIDIDevice.cxx	(working copy)
@@ -122,7 +122,6 @@
 		ALSAMIDIDeviceList()
 			:MIDIDeviceList(std::string("alsa"))
 		{
-			std::stringstream name;
 			int card, dev;
 			snd_ctl_t *handle;
 			snd_ctl_card_info_t *info;
@@ -132,9 +131,12 @@
 			if (snd_card_next(&card) < 0 || card < 0)
 				return; // No cards found
 			while (card >= 0) {
-				name << "hw:" << card;	
-				if (snd_ctl_open(&handle, name.str().c_str(), 0) < 0)
+				std::stringstream namestr;
+				namestr << "hw:" << card;	
+				std::string name(namestr.str());
+				if (snd_ctl_open(&handle, name.c_str(), 0) < 0)
 					continue; // Card control open error!
+
 				if (snd_ctl_card_info(handle, info) < 0) {
 					snd_ctl_close(handle); // Card control read error!
 					continue;
@@ -144,8 +146,9 @@
 					snd_ctl_rawmidi_next_device(handle, &dev);
 					if (dev < 0)
 						break;
-					name << "," << dev;
-					mAvailableDevices.push_back(name.str());
+					std::stringstream dname;
+					dname << name << "," << dev;
+					mAvailableDevices.push_back(dname.str());
 				}
 				snd_ctl_close(handle);
 				if (snd_card_next(&card) < 0)


More information about the clam-devel mailing list