diff options
Diffstat (limited to 'include/xas')
-rw-r--r-- | include/xas/audio.h | 76 | ||||
-rw-r--r-- | include/xas/riff.h | 2 |
2 files changed, 77 insertions, 1 deletions
diff --git a/include/xas/audio.h b/include/xas/audio.h new file mode 100644 index 0000000..4ffc430 --- /dev/null +++ b/include/xas/audio.h @@ -0,0 +1,76 @@ +#ifndef _XAS_AUDIO_H +#define _XAS_AUDIO_H + +#include <stdint.h> +#include <sys/types.h> + +enum xas_audio_stream_type { + XAS_AUDIO_STREAM_SINK, + XAS_AUDIO_STREAM_SOURCE +}; + +typedef struct _xas_audio_stream xas_audio_stream; + +typedef int (*xas_audio_drain)(void *ctx, + void *samples, + size_t count, + xas_audio_stream *stream); + +typedef ssize_t (*xas_audio_fill)(void *ctx, + void *samples, + size_t count, + xas_audio_stream *stream); + +typedef void (*xas_audio_cleanup)(void *ctx, + xas_audio_stream *stream); + +struct _xas_audio_stream { + enum xas_audio_stream_type type; + + size_t sample_size, + sample_rate, + channels; + + size_t buffer_size, + buffer_count; + + union { + void *callback; + xas_audio_drain drain; + xas_audio_fill fill; + }; + + xas_audio_cleanup cleanup; + + void *ctx; +}; + +xas_audio_stream *xas_audio_stream_new_sink(xas_audio_drain drain, + xas_audio_cleanup cleanup, + void *ctx, + size_t sample_size, + size_t sample_rate, + size_t channels, + size_t buffer_size); + +xas_audio_stream *xas_audio_stream_new_source(xas_audio_fill fill, + xas_audio_cleanup cleanup, + void *ctx, + size_t sample_size, + size_t sample_rate, + size_t channels, + size_t buffer_size); + +void xas_audio_stream_destroy(xas_audio_stream *stream); + +ssize_t xas_audio_stream_write(xas_audio_stream *stream, + void *samples, + size_t count); + +ssize_t xas_audio_stream_read(xas_audio_stream *stream, + void *samples, + size_t count); + +int xas_audio_stream_flush(xas_audio_stream *stream); + +#endif /* _XAS_AUDIO_H */ diff --git a/include/xas/riff.h b/include/xas/riff.h index bf438cc..07ed0f2 100644 --- a/include/xas/riff.h +++ b/include/xas/riff.h @@ -39,7 +39,7 @@ typedef struct _xas_riff_wave_header { typedef struct _xas_riff xas_riff; -xas_audio_stream *xas_riff_open_file(const char *path, +xas_audio_stream *xas_riff_file_open(const char *path, size_t sample_size, size_t sample_rate, size_t channels, |