diff options
author | Camil Staps | 2015-08-24 09:06:36 +0200 |
---|---|---|
committer | Camil Staps | 2015-08-24 09:06:36 +0200 |
commit | d0c6816d1d217b5391c6d85c21d24615b3e5753c (patch) | |
tree | 9541929bb9f5e1e13fc7b6ad21c6a01dc1681f70 /Linux_C_12 | |
parent | Resizing bitmaps (diff) |
Fixing winPlaySound
There doesn't seem to be a straightforward universal way to play a
wav file on Linux. If someone has pulseaudio installed, this command
now simply does a system() call with `paplay ...`. This fails if the
program is not installed, but in any case a True success bool is re-
turned.
Ideally, we wouldn't need system() (which forces us to include
stdlib.h), and would just use a library for this - but I didn't find
one at the moment.
See: http://unix.stackexchange.com/a/8610/37050
Diffstat (limited to 'Linux_C_12')
-rw-r--r-- | Linux_C_12/cCCallSystem_121.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Linux_C_12/cCCallSystem_121.c b/Linux_C_12/cCCallSystem_121.c index 0489882..a9cb1ea 100644 --- a/Linux_C_12/cCCallSystem_121.c +++ b/Linux_C_12/cCCallSystem_121.c @@ -12,6 +12,8 @@ #include <time.h>
#include <sys/time.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
OS WinBeep (OS ios)
{
@@ -50,9 +52,15 @@ void WinGetTickCount (OS ios, int *tickCount, OS *oos) void WinPlaySound (CLEAN_STRING filename, OS ios, Bool *ook, OS *oos)
{
-/* return PlaySound(filename, NULL, SND_FILENAME | SND_SYNC); */
- rprintf("WinPlaySound -> not implemented");
- *ook = FALSE;
+ char sys[64] = "paplay ";
+
+ rprintf("WinPlaySound\n");
+
+ strcat(sys, cstring(filename));
+
+ rprintf("%s - %d\n", sys, system(sys));
+
+ *ook = TRUE;
*oos = ios;
}
|