#include <soundio/soundio.h>
-int Fs;
-long long starttime, samples_played;
-
struct SoundIoOutStream *outstream;
struct SoundIo *soundio;
struct SoundIoDevice *device;
char *read_ptr = soundio_ring_buffer_read_ptr(ring_buffer);
int fill_bytes = soundio_ring_buffer_fill_count(ring_buffer);
+ if (outstream->bytes_per_frame == 0)
+ die("soundio: outstream->bytes_per_frame is zero.");
int fill_count = fill_bytes / outstream->bytes_per_frame;
- debug(3, "[--->>] frame_count_min: %d , frame_count_max: %d , fill_bytes: %d , fill_count: %d , "
- "outstream->bytes_per_frame: %d",
+ debug(3,
+ "[--->>] frame_count_min: %d , frame_count_max: %d , fill_bytes: %d , fill_count: %d , "
+ "outstream->bytes_per_frame: %d",
frame_count_min, frame_count_max, fill_bytes, fill_count, outstream->bytes_per_frame);
if (frame_count_min > fill_count) {
soundio_ring_buffer_advance_read_ptr(ring_buffer, read_count * outstream->bytes_per_frame);
}
-static void underflow_callback(struct SoundIoOutStream *outstream) {
+static void underflow_callback(__attribute__((unused)) struct SoundIoOutStream *outstream) {
static int count = 0;
debug(0, "underflow %d\n", ++count);
}
-static int init(int argc, char **argv) {
+static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) {
int err;
config.audio_backend_buffer_desired_length = 2.0;
}
static void start(int sample_rate, int sample_format) {
- Fs = sample_rate;
- starttime = 0;
- samples_played = 0;
int err;
debug(1, "soundion rate: %d, format: %d", sample_rate, sample_format);
debug(1, "libsoundio output started\n");
}
-static void play(short buf[], int samples) {
+static int play(void *buf, int samples, __attribute__((unused)) int sample_type,
+ __attribute__((unused)) uint32_t timestamp,
+ __attribute__((unused)) uint64_t playtime) {
// int err;
int free_bytes = soundio_ring_buffer_free_count(ring_buffer);
int written_bytes = 0;
free_bytes);
if (write_bytes) {
- memcpy(write_ptr, (char *)buf, write_bytes);
+ memcpy(write_ptr, buf, write_bytes);
written_bytes += write_bytes;
soundio_ring_buffer_advance_write_ptr(ring_buffer, write_bytes);
debug(3, "[<<---] Written to buffer : %d\n", written_bytes);
}
+ return 0;
}
static void parameters(audio_parameters *info) {
debug(1, "libsoundio output flushed\n");
}
-static void help(void) { printf(" There are no options for libsoundio.\n"); }
-
audio_output audio_soundio = {.name = "soundio",
- .help = &help,
+ .help = NULL,
.init = &init,
.deinit = &deinit,
+ .prepare = NULL,
.start = &start,
.stop = &stop,
+ .is_running = NULL,
.flush = &flush,
.delay = NULL,
+ .stats = NULL,
.play = &play,
.volume = NULL,
.parameters = ¶meters,