#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#define BUFSIZE 1024
static ssize_t loop_write(int fd, const void*data, size_t size) {
ssize_t ret = 0;
while (size > 0) {
ssize_t r;
if ((r = write(fd, data, size)) < 0)
return r;
if (r == 0)
break;
ret += r;
data = (const uint8_t*) data + r;
size -= (size_t) r;
}
return ret;
}
int main(int argc, char*argv[]) {
.rate = 44100,
.channels = 2
};
int ret = 1;
int error;
fprintf(stderr, __FILE__
": pa_simple_new() failed: %s\n",
pa_strerror(error));
goto finish;
}
for (;;) {
uint8_t buf[BUFSIZE];
fprintf(stderr, __FILE__
": pa_simple_read() failed: %s\n",
pa_strerror(error));
goto finish;
}
if (loop_write(STDOUT_FILENO, buf, sizeof(buf)) != sizeof(buf)) {
fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));
goto finish;
}
}
ret = 0;
finish:
if (s)
return ret;
}
@ PA_STREAM_RECORD
Record stream.
Definition: def.h:161
const char * pa_strerror(int error)
Return a human readable error message for the specified numeric error code.
@ PA_SAMPLE_S16LE
Signed 16 Bit PCM, little endian (PC)
Definition: sample.h:144
A simple but limited synchronous playback and recording API.
int pa_simple_read(pa_simple *s, void *data, size_t bytes, int *error)
Read some data from the server.
void pa_simple_free(pa_simple *s)
Close and free the connection to the server.
pa_simple * pa_simple_new(const char *server, const char *name, pa_stream_direction_t dir, const char *dev, const char *stream_name, const pa_sample_spec *ss, const pa_channel_map *map, const pa_buffer_attr *attr, int *error)
Create a new connection to the server.
A sample format and attribute specification.
Definition: sample.h:252
pa_sample_format_t format
The sample format.
Definition: sample.h:253
An opaque simple connection object.