replace perror with strerror to be able to print the file name

This commit is contained in:
2025-11-14 07:50:44 +01:00
parent 50f115c710
commit 132a7c0788

View File

@@ -1,9 +1,11 @@
#include "play_raw_audio.h" #include "play_raw_audio.h"
#include <stdio.h> #include <errno.h>
#include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <pulse/simple.h>
#include <pulse/error.h> #include <pulse/error.h>
#include <pulse/simple.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int play_raw_audio(char file_name[]) { int play_raw_audio(char file_name[]) {
int pa_error = 0; int pa_error = 0;
@@ -11,7 +13,7 @@ int play_raw_audio(char file_name[]) {
int myfd = open(file_name, O_RDONLY); int myfd = open(file_name, O_RDONLY);
if (myfd == -1) { if (myfd == -1) {
perror("Failed to open audio file"); fprintf(stderr, "Failed to open audio file %s: %s.\n", file_name, strerror(errno));
return 1; return 1;
} }