Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Sound in linux (Lack of standards in Linux is a problem but there are some near-standards)
Re: Sound in linux [message #44100 is a reply to message #44098] Wed, 24 December 2014 16:30 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Mirek,

It seems that "Sys" works perfect...

static String FindPlayer()
{
	static String player;
	if (player.IsEmpty()) {
		const char *players[] = { "play", "ogg123", "gst123" };
		for (int i = 0; i < __countof(players); i++) {
			String out;
			if (Sys("which " + String(players[i]), out) == 0 && !out.IsEmpty()) {
				player = players[i];
				break;
			}
		}
	}
	return player;
}

static void LinuxBeep(const char *name)
{
	String player = FindPlayer();
	if (!player.IsEmpty()) {
		String fn = "/usr/share/sounds/" + CurrentSoundTheme + "/stereo/dialog-" + name;
		system(player + " -q " + fn + (FileExists(fn + ".ogg") ? ".ogg" :
        	                           FileExists(fn + ".oga") ? ".oga" :
        	                           FileExists(fn + ".wav") ? ".wav" :
        	                           ".*")
	    	   + " >/dev/null 2>/dev/null&");
	}
}


I enclose also diff...

----------------------------
But, all this applications needs user installation. So, sound out of the box (without installation any package) seems to be hard. We can also make additional dependency for example with "sox" package (Debian base distribution).
----------------------------
Next problem is GCC warning, because we ignore system return value. What should we do?

int status = system(...)
if (status == -1) return; // <- Throw exception???


Sincerely,
Klugier
  • Attachment: Sound.diff
    (Size: 1.41KB, Downloaded 245 times)


U++ - one framework to rule them all.

[Updated on: Wed, 24 December 2014 20:03]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Raster::Line segfaults ... sometimes.
Next Topic: Adding network proxy support to U++
Goto Forum:
  


Current Time: Sat May 11 07:36:07 CEST 2024

Total time taken to generate the page: 0.04426 seconds