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 |
|
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
|
|
|
|
|
Sound in linux
|
|
|
Re: Sound in linux
By: mirek on Wed, 17 December 2014 11:30
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: mirek on Wed, 17 December 2014 19:56
|
|
|
Re: Sound in linux (& generic launchers)
|
|
|
Re: Sound in linux (& generic launchers)
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: Klugier on Tue, 23 December 2014 14:49
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: mirek on Wed, 24 December 2014 12:27
|
|
|
Re: Sound in linux
By: Klugier on Wed, 24 December 2014 13:18
|
|
|
Re: Sound in linux
By: mirek on Wed, 24 December 2014 15:46
|
|
|
Re: Sound in linux
By: Klugier on Wed, 24 December 2014 16:30
|
|
|
Re: Sound in linux
By: mirek on Thu, 25 December 2014 10:48
|
|
|
Re: Sound in linux
By: Klugier on Thu, 25 December 2014 13:56
|
|
|
Re: Sound in linux
By: mirek on Thu, 25 December 2014 21:01
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: Klugier on Thu, 25 December 2014 14:23
|
Goto Forum:
Current Time: Sat May 11 07:36:07 CEST 2024
Total time taken to generate the page: 0.04426 seconds
|