]>
code.delx.au - pulseaudio/blob - src/parec-simple.c
6 #include "polyplib-simple.h"
7 #include "polyplib-error.h"
11 static ssize_t
loop_write(int fd
, const void*data
, size_t size
) {
17 if ((r
= write(fd
, data
, size
)) < 0)
31 int main(int argc
, char*argv
[]) {
32 static const struct pa_sample_spec ss
= {
33 .format
= PA_SAMPLE_S16LE
,
37 struct pa_simple
*s
= NULL
;
41 if (!(s
= pa_simple_new(NULL
, argv
[0], PA_STREAM_RECORD
, NULL
, "record", &ss
, NULL
, &error
))) {
42 fprintf(stderr
, __FILE__
": pa_simple_new() failed: %s\n", pa_strerror(error
));
50 if (pa_simple_read(s
, buf
, sizeof(buf
), &error
) < 0) {
51 fprintf(stderr
, __FILE__
": pa_simple_read() failed: %s\n", pa_strerror(error
));
55 if ((r
= loop_write(STDOUT_FILENO
, buf
, sizeof(buf
))) <= 0) {
56 fprintf(stderr
, __FILE__
": write() failed: %s\n", strerror(errno
));