From d0c6816d1d217b5391c6d85c21d24615b3e5753c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 24 Aug 2015 09:06:36 +0200 Subject: 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 --- Linux_C_12/cCCallSystem_121.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Linux_C_12') 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 #include #include +#include +#include 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; } -- cgit v1.2.3