fixed bug that changed the HOME env var inside the program
This commit is contained in:
parent
de70866e1f
commit
ba37d057fb
8
main.c
8
main.c
@ -12,10 +12,12 @@
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int countdown_min_total;
|
||||
|
||||
char *HOME = getenv("HOME");
|
||||
char *audio_file = "";
|
||||
char audio_file_path[256] = "";
|
||||
if (HOME != NULL) {
|
||||
audio_file = strcat(HOME, "/music/alarm-clock-elapsed.wav");
|
||||
strcpy(audio_file_path, HOME);
|
||||
strcat(audio_file_path, "/music/alarm-clock-elapsed.wav");
|
||||
} else {
|
||||
printf ("Can't find environment variable HOME!\n");
|
||||
return 1;
|
||||
@ -59,7 +61,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
printf ("THE TIME IS UP!\n");
|
||||
play_raw_audio(audio_file);
|
||||
play_raw_audio(audio_file_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,16 +21,8 @@ int play_raw_audio(char file_name[]) {
|
||||
ss.rate = 48000;
|
||||
ss.channels = 2;
|
||||
|
||||
// Temporarily redirect stderr to /dev/null
|
||||
// because pulseaudio prints to stderr even though it does not set any error codes
|
||||
FILE *original_stderr = stderr;
|
||||
stderr = fopen("/dev/null", "w");
|
||||
|
||||
simple = pa_simple_new(NULL, "Audio Playback", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &pa_error);
|
||||
|
||||
// Restore stderr
|
||||
stderr = original_stderr;
|
||||
|
||||
int i = 0;
|
||||
while (read(myfd, content, sizeof(content))) {
|
||||
// skip the first 1024 bytes to not play the file header
|
||||
|
Loading…
Reference in New Issue
Block a user