]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Make it compile -- untested
authorMike Brady <mikebrady@eircom.net>
Wed, 24 Aug 2016 15:30:02 +0000 (16:30 +0100)
committerMike Brady <mikebrady@eircom.net>
Wed, 24 Aug 2016 15:30:02 +0000 (16:30 +0100)
common.h
player.c

index 625108b06098be063cf7576a873ee1dc8179853f..d67100e78e0f2d6071261c025eee108537a8f94e 100644 (file)
--- a/common.h
+++ b/common.h
@@ -48,6 +48,27 @@ enum playback_mode_type {
   ST_mono,
 } playback_mode_type;
 
+
+// the following enum must _exactly match the snd_pcm_format_t definition in the alsa pcm.h file.
+
+enum   sps_format_t { 
+  SPS_FORMAT_UNKNOWN = -1, SPS_FORMAT_S8 = 0, SPS_FORMAT_U8, SPS_FORMAT_S16_LE, 
+  SPS_FORMAT_S16_BE, SPS_FORMAT_U16_LE, SPS_FORMAT_U16_BE, SPS_FORMAT_S24_LE, 
+  SPS_FORMAT_S24_BE, SPS_FORMAT_U24_LE, SPS_FORMAT_U24_BE, SPS_FORMAT_S32_LE, 
+  SPS_FORMAT_S32_BE, SPS_FORMAT_U32_LE, SPS_FORMAT_U32_BE, SPS_FORMAT_FLOAT_LE, 
+  SPS_FORMAT_FLOAT_BE, SPS_FORMAT_FLOAT64_LE, SPS_FORMAT_FLOAT64_BE, SPS_FORMAT_IEC958_SUBFRAME_LE, 
+  SPS_FORMAT_IEC958_SUBFRAME_BE, SPS_FORMAT_MU_LAW, SPS_FORMAT_A_LAW, SPS_FORMAT_IMA_ADPCM, 
+  SPS_FORMAT_MPEG, SPS_FORMAT_GSM, SPS_FORMAT_SPECIAL = 31, SPS_FORMAT_S24_3LE = 32, 
+  SPS_FORMAT_S24_3BE, SPS_FORMAT_U24_3LE, SPS_FORMAT_U24_3BE, SPS_FORMAT_S20_3LE, 
+  SPS_FORMAT_S20_3BE, SPS_FORMAT_U20_3LE, SPS_FORMAT_U20_3BE, SPS_FORMAT_S18_3LE, 
+  SPS_FORMAT_S18_3BE, SPS_FORMAT_U18_3LE, SPS_FORMAT_U18_3BE, SPS_FORMAT_G723_24, 
+  SPS_FORMAT_G723_24_1B, SPS_FORMAT_G723_40, SPS_FORMAT_G723_40_1B, SPS_FORMAT_DSD_U8, 
+  SPS_FORMAT_DSD_U16_LE, SPS_FORMAT_DSD_U32_LE, SPS_FORMAT_DSD_U16_BE, SPS_FORMAT_DSD_U32_BE, 
+  SPS_FORMAT_LAST = SPS_FORMAT_DSD_U32_BE, SPS_FORMAT_S16 = SPS_FORMAT_S16_LE, SPS_FORMAT_U16 = SPS_FORMAT_U16_LE, SPS_FORMAT_S24 = SPS_FORMAT_S24_LE, 
+  SPS_FORMAT_U24 = SPS_FORMAT_U24_LE, SPS_FORMAT_S32 = SPS_FORMAT_S32_LE, SPS_FORMAT_U32 = SPS_FORMAT_U32_LE, SPS_FORMAT_FLOAT = SPS_FORMAT_FLOAT_LE, 
+  SPS_FORMAT_FLOAT64 = SPS_FORMAT_FLOAT64_LE, SPS_FORMAT_IEC958_SUBFRAME = SPS_FORMAT_IEC958_SUBFRAME_LE 
+} sps_format_t;
+
 typedef struct {
   config_t *cfg;
   char *password;
@@ -100,7 +121,7 @@ typedef struct {
                                             // audio backend buffer -- the DAC buffer for ALSA
   long audio_backend_latency_offset; // this will be the offset to compensate for any fixed latency there might be in the audio path
   uint32_t volume_range_db; // the range, in dB, from max dB to min dB. Zero means use the mixer's native range.
-  int output_format;
+  enum sps_format_t output_format;
   int output_rate;
 } shairport_cfg;
 
index 2083f0055c3431a842c6d8667e36b942322d23e5..da1a312cc0ad973cfb5665c617e48cc050c5ac08 100644 (file)
--- a/player.c
+++ b/player.c
@@ -66,7 +66,6 @@
 #include "rtsp.h"
 
 #include "alac.h"
-#include <alsa/pcm.h>
 
 // parameters from the source
 static unsigned char *aesiv;
@@ -1006,21 +1005,18 @@ static void *player_thread_func(void *arg) {
        if (config.output_rate!=0)
                output_sample_ratio = config.output_rate/44100;
        
-       max_frame_size_change = 1*sample_ratio;
+       max_frame_size_change = 1*output_sample_ratio; // we add or subtract one frame at the nominal rate, multiply it by the frame ratio.
        bytes_per_output_audio_frame = 4;
        
-       
-
        switch (config.output_format) {
-               case SND_PCM_FORMAT_S24_LE:
+               case SPS_FORMAT_S24_LE:
                        bytes_per_output_audio_frame=6;
                        break;
-               case SND_PCM_FORMAT_S32_LE:
+               case SPS_FORMAT_S32_LE:
                        bytes_per_output_audio_frame=8;
                        break;          
        }
-               
-       
+
        // check that there are enough buffers to accommodate the desired latency and the latency offset
        
        int maximum_latency = config.latency+config.audio_backend_latency_offset;
@@ -1270,7 +1266,7 @@ static void *player_thread_func(void *arg) {
             if (config.no_sync!=0)
               amount_to_stuff = 0 ; // no stuffing if it's been disabled
                         
-            if ((amount_to_stuff == 0) && (fix_volume == 0x10000) && ((config.output_rate==0) || (config.output_rate==44100)) && ((config.output_format==0) || (config.output_format==SND_PCM_FORMAT_S16_LE))) {
+            if ((amount_to_stuff == 0) && (fix_volume == 0x10000) && ((config.output_rate==0) || (config.output_rate==44100)) && ((config.output_format==0) || (config.output_format==SPS_FORMAT_S16_LE))) {
               // if no stuffing needed and no volume adjustment, then
               // don't send to stuff_buffer_* and don't copy to outbuf; just send directly to the
               // output device...