mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
add support for reading audio data from a file instead of plain STDIN in pacat-simple.c
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@830 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
bb6c45dee8
commit
5f9bbf005a
1 changed files with 18 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <polyp/simple.h>
|
||||
#include <polyp/error.h>
|
||||
|
|
@ -47,6 +48,23 @@ int main(PA_GCC_UNUSED int argc, char*argv[]) {
|
|||
int ret = 1;
|
||||
int error;
|
||||
|
||||
/* replace STDIN with the specified file if needed */
|
||||
if (argc > 1) {
|
||||
int fd;
|
||||
|
||||
if ((fd = open(argv[1], O_RDONLY)) < 0) {
|
||||
fprintf(stderr, __FILE__": open() failed: %s\n", strerror(errno));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (dup2(fd, STDIN_FILENO) < 0) {
|
||||
fprintf(stderr, __FILE__": dup2() failed: %s\n", strerror(errno));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* Create a new playback stream */
|
||||
if (!(s = pa_simple_new(NULL, argv[0], PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, &error))) {
|
||||
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue