]> git.ipfire.org Git - thirdparty/shairport-sync.git/blobdiff - audio_soundio.c
Updates to the Issues template.
[thirdparty/shairport-sync.git] / audio_soundio.c
index 03ec5e6e5a3279bacfd69b8a792e27bfa33f6946..a34851c6ac829c655bf1c99be235ef695c893f73 100644 (file)
@@ -7,9 +7,6 @@
 
 #include <soundio/soundio.h>
 
-int Fs;
-long long starttime, samples_played;
-
 struct SoundIoOutStream *outstream;
 struct SoundIo *soundio;
 struct SoundIoDevice *device;
@@ -25,10 +22,13 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
 
   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) {
@@ -77,12 +77,12 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
   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;
@@ -129,9 +129,6 @@ static void deinit(void) {
 }
 
 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);
@@ -167,7 +164,9 @@ static void start(int sample_rate, int 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;
@@ -181,11 +180,12 @@ static void play(short buf[], int samples) {
         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) {
@@ -208,16 +208,17 @@ static void flush(void) {
   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 = &parameters,