#include <string.h>
#include <errno.h>
-#include "polyplib-simple.h"
-#include "polyplib-error.h"
+#include <polyp/polyplib-simple.h>
+#include <polyp/polyplib-error.h>
#define BUFSIZE 1024
+/* A simple routine calling UNIX write() in a loop */
static ssize_t loop_write(int fd, const void*data, size_t size) {
ssize_t ret = 0;
}
int main(int argc, char*argv[]) {
+ /* The sample type to use */
static const struct pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
int ret = 1;
int error;
+ /* Create the recording stream */
if (!(s = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, NULL, "record", &ss, NULL, &error))) {
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
goto finish;
uint8_t buf[BUFSIZE];
ssize_t r;
+ /* Record some data ... */
if (pa_simple_read(s, buf, sizeof(buf), &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_read() failed: %s\n", pa_strerror(error));
goto finish;
}
-
+
+ /* And write it to STDOUT */
if ((r = loop_write(STDOUT_FILENO, buf, sizeof(buf))) <= 0) {
fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));
goto finish;