Cinnamon audio library
Revision | 39f718a05ca885d83fd0c5d0aee398c8506cbe28 (tree) |
---|---|
Zeit | 2019-09-22 09:35:33 |
Autor | AlaskanEmily <emily@alas...> |
Commiter | AlaskanEmily |
Fix aucat on not-Windows
@@ -10,6 +10,7 @@ | ||
10 | 10 | #include "cinnamon.h" |
11 | 11 | |
12 | 12 | #include <stdio.h> |
13 | +#include <string.h> | |
13 | 14 | #include <stdlib.h> |
14 | 15 | |
15 | 16 | /* |
@@ -30,7 +31,7 @@ | ||
30 | 31 | #include <Windows.h> |
31 | 32 | #define AUCAT_SLEEP Sleep |
32 | 33 | |
33 | -#elif defined __linux__ | |
34 | +#else | |
34 | 35 | /* usleep is missing/deprecated on Linux, use nanosleep instead. */ |
35 | 36 | |
36 | 37 | #include <time.h> |
@@ -38,23 +39,12 @@ | ||
38 | 39 | |
39 | 40 | #define AUCAT_SLEEP(MS) do{\ |
40 | 41 | const unsigned long AUCAT_SLEEP_ms = (MS);\ |
41 | - struct AUCAT_SLEEP_ts;\ | |
42 | - AUCAT_SLEEP_ts.tn_sec = (AUCAT_SLEEP_ms % 1000) * 1000000;\ | |
42 | + struct timespec AUCAT_SLEEP_ts;\ | |
43 | + AUCAT_SLEEP_ts.tv_nsec = (AUCAT_SLEEP_ms % 1000) * 1000000;\ | |
43 | 44 | AUCAT_SLEEP_ts.tv_sec = AUCAT_SLEEP_ms / 1000;\ |
44 | 45 | nanosleep(&AUCAT_SLEEP_ts, NULL);\ |
45 | 46 | } while(0) |
46 | 47 | |
47 | -#else | |
48 | -/* On BSD and OS X (and likely other platforms like Solaris and AIX) we can | |
49 | - * simply use nanosleep. This requires _BSD_SOURCE on some platforms. | |
50 | - */ | |
51 | - | |
52 | -#define _BSD_SOURCE | |
53 | -#include <time.h> | |
54 | -#include <unistd.h> | |
55 | - | |
56 | -#define AUCAT_SLEEP(MS) do{ nanosleep((MS) * 1000); }while(0) | |
57 | - | |
58 | 48 | #endif |
59 | 49 | |
60 | 50 | int main(int argc, char **argv){ |
@@ -141,7 +131,7 @@ int main(int argc, char **argv){ | ||
141 | 131 | return EXIT_FAILURE; |
142 | 132 | } |
143 | 133 | |
144 | - while(num_read = fread(buffer, 1, rate, input)){ | |
134 | + while((num_read = fread(buffer, 1, rate, input)) != 0){ | |
145 | 135 | Cin_LoaderPut(loader, buffer, num_read); |
146 | 136 | total_read += num_read; |
147 | 137 | } |
@@ -173,4 +163,6 @@ int main(int argc, char **argv){ | ||
173 | 163 | |
174 | 164 | free(sound); |
175 | 165 | } |
166 | + | |
167 | + return EXIT_SUCCESS; | |
176 | 168 | } |