fixed indentation
This commit is contained in:
parent
fa8c8136b3
commit
9ec002c216
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
int play_raw_audio(char file_name[]) {
|
int play_raw_audio(char file_name[]) {
|
||||||
int pa_error = 0;
|
int pa_error = 0;
|
||||||
char content[1024] = "";
|
char content[1024] = "";
|
||||||
|
|
||||||
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");
|
perror("Failed to open audio file");
|
||||||
return 1;
|
return 1;
|
||||||
@ -29,26 +29,25 @@ int play_raw_audio(char file_name[]) {
|
|||||||
FILE *original_stderr = stderr;
|
FILE *original_stderr = stderr;
|
||||||
stderr = fopen("/dev/null", "w");
|
stderr = fopen("/dev/null", "w");
|
||||||
|
|
||||||
simple = pa_simple_new(NULL, "Audio Playback", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &pa_error);
|
simple = pa_simple_new(NULL, "Audio Playback", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &pa_error);
|
||||||
|
|
||||||
// Restore stderr
|
// Restore stderr
|
||||||
stderr = original_stderr;
|
stderr = original_stderr;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (read(myfd, content, sizeof(content))) {
|
while (read(myfd, content, sizeof(content))) {
|
||||||
// skip the first 1024 bytes to not play the file header
|
// skip the first 1024 bytes to not play the file header
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
pa_simple_write(simple, content, sizeof(content), &pa_error);
|
pa_simple_write(simple, content, sizeof(content), &pa_error);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_simple_drain(simple, NULL);
|
pa_simple_drain(simple, NULL);
|
||||||
|
|
||||||
pa_simple_free(simple);
|
pa_simple_free(simple);
|
||||||
|
|
||||||
close(myfd);
|
close(myfd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user