]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
NOP: remove commented-out code segments that were re-implemented
authorJörn Nettingsmeier <nettings@luchtbeweging.nl>
Fri, 15 Feb 2019 17:58:50 +0000 (17:58 +0000)
committerJörn Nettingsmeier <nettings@luchtbeweging.nl>
Fri, 15 Feb 2019 17:58:50 +0000 (17:58 +0000)
audio_jack.c

index 544255a8631dcee732cff3f2702764144a8801f5..3d3faddadc03ef398c8df534191df345bc29ec85 100644 (file)
@@ -106,49 +106,9 @@ int play(void *buf, int samples) {
   if (bytes_transferred < bytes_to_transfer) {
     debug(1, "JACK ringbuffer overrun. Only wrote %d of %d bytes.", bytes_transferred, bytes_to_transfer);
   }
-/*
-  size_t space_to_end_of_buffer = audio_umb - audio_eoq;
-  if (space_to_end_of_buffer >= bytes_to_transfer) {
-    memcpy(audio_eoq, buf, bytes_to_transfer);
-    pthread_mutex_lock(&buffer_mutex);
-    audio_occupancy += samples;
-    audio_eoq += bytes_to_transfer;
-    pthread_mutex_unlock(&buffer_mutex);
-  } else {
-    memcpy(audio_eoq, buf, space_to_end_of_buffer);
-    buf += space_to_end_of_buffer;
-    memcpy(audio_lmb, buf, bytes_to_transfer - space_to_end_of_buffer);
-    pthread_mutex_lock(&buffer_mutex);
-    audio_occupancy += samples;
-    audio_eoq = audio_lmb + bytes_to_transfer - space_to_end_of_buffer;
-    pthread_mutex_unlock(&buffer_mutex);
-  }
-*/
   return 0;
 }
 
-void deinterleave_and_convert_stream(const char *interleaved_frames,
-                                     const jack_default_audio_sample_t *jack_frame_buffer,
-                                     jack_nframes_t number_of_frames, enum ift_type side) {
-  jack_nframes_t i;
-  short *ifp = (short *)interleaved_frames;
-  jack_default_audio_sample_t *fp = (jack_default_audio_sample_t *)jack_frame_buffer;
-  if (side == IFT_frame_right_sample)
-    ifp++;
-  for (i = 0; i < number_of_frames; i++) {
-    short sample = *ifp;
-    jack_default_audio_sample_t converted_value;
-    if (sample >= 0)
-      converted_value = (1.0 * sample) / SHRT_MAX;
-    else
-      converted_value = -(1.0 * sample) / SHRT_MIN;
-    *fp = converted_value;
-    ifp++;
-    ifp++;
-    fp++;
-  }
-}
-
 static inline jack_default_audio_sample_t sample_conv(short sample) {
   return ((sample < 0) ? (-1.0 * sample / SHRT_MIN) : (1.0 * sample / SHRT_MAX));
 }
@@ -212,50 +172,6 @@ int jack_stream_write_cb(jack_nframes_t nframes, __attribute__((unused)) void *a
     frames_written++;
     nframes--;
   }
-
-/*
-  size_t frames_we_can_transfer = nframes;
-  // lock
-  pthread_mutex_lock(&buffer_mutex);
-  if (audio_occupancy < frames_we_can_transfer) {
-    frames_we_can_transfer = audio_occupancy;
-    // This means we effectively have underflow from the Shairport Sync source.
-    // In fact, it may be that there is nothing at all coming from the source,
-    // but the Shairport Sync client is open and active, so it must continue to output something.
-  }
-
-  if (frames_we_can_transfer * 2 * 2 <= (size_t)(audio_umb - audio_toq)) {
-    // the bytes are all in a row in the audio buffer
-    deinterleave_and_convert_stream(audio_toq, &left_buffer[0], frames_we_can_transfer,
-                                    IFT_frame_left_sample);
-    deinterleave_and_convert_stream(audio_toq, &right_buffer[0], frames_we_can_transfer,
-                                    IFT_frame_right_sample);
-    audio_toq += frames_we_can_transfer * 2 * 2;
-  } else {
-    // the bytes are in two places in the audio buffer
-    size_t first_portion_to_write = (audio_umb - audio_toq) / (2 * 2);
-    if (first_portion_to_write != 0) {
-      deinterleave_and_convert_stream(audio_toq, &left_buffer[0], first_portion_to_write,
-                                      IFT_frame_left_sample);
-      deinterleave_and_convert_stream(audio_toq, &right_buffer[0], first_portion_to_write,
-                                      IFT_frame_right_sample);
-    }
-    deinterleave_and_convert_stream(audio_lmb, &left_buffer[first_portion_to_write],
-                                    frames_we_can_transfer - first_portion_to_write,
-                                    IFT_frame_left_sample);
-    deinterleave_and_convert_stream(audio_lmb, &right_buffer[first_portion_to_write],
-                                    frames_we_can_transfer - first_portion_to_write,
-                                    IFT_frame_right_sample);
-    audio_toq = audio_lmb + (frames_we_can_transfer - first_portion_to_write) * 2 * 2;
-  }
-  audio_occupancy -= frames_we_can_transfer;
-  jack_port_get_latency_range(left_port, JackPlaybackLatency, &latest_left_latency_range);
-  jack_port_get_latency_range(right_port, JackPlaybackLatency, &latest_right_latency_range);
-  time_of_latest_transfer = get_absolute_time_in_fp();
-  pthread_mutex_unlock(&buffer_mutex);
-  // unlock
-
-*/
   return 0;
 }
 
@@ -265,26 +181,6 @@ void default_jack_error_callback(const char *desc) { debug(2, "jackd error: \"%s
 
 void default_jack_info_callback(const char *desc) { inform("jackd information: \"%s\"", desc); }
 
-/*
-void default_jack_set_latency_callback(jack_latency_callback_mode_t mode,
-                                       __attribute__((unused)) void *arg) {
-  if (mode == JackPlaybackLatency) {
-    jack_latency_range_t left_latency_range, right_latency_range;
-    jack_port_get_latency_range(left_port, JackPlaybackLatency, &left_latency_range);
-    jack_port_get_latency_range(right_port, JackPlaybackLatency, &right_latency_range);
-
-    jack_nframes_t b_latency = (left_latency_range.min + left_latency_range.max) / 2;
-    if (b_latency == 0)
-      b_latency = (right_latency_range.min + right_latency_range.max) / 2;
-    // jack_latency = b_latency; // actually, we are not interested in the latency of the jack
-    // devices connected...
-    // FIXME: yes, we are.
-    jack_latency = 0;
-    debug(1, "playback latency callback: %" PRIu32 ".", jack_latency);
-  }
-}
-*/
-
 int jack_is_running() {
   int reply = -1; // meaning jack is not running
   if (client_is_open) {
@@ -329,19 +225,12 @@ int jack_client_open_if_needed(void) {
       sample_rate = jack_get_sample_rate(client);
       // debug(1, "jackaudio sample rate = %" PRId32 ".", sample_rate);
       if (sample_rate == 44100) {
-        // FIXME: shairport-sync has no need for a latency callback, it's a leaf node with only outputs.
-        // If in the future some jack video player wants to resync to shairplay-sync audio, then yes, but
-        // the current usage seems to suggest a misunderstanding.
-//      if (jack_set_latency_callback(client, default_jack_set_latency_callback, NULL) == 0) {
           if (jack_activate(client)) {
             debug(1, "jackaudio cannot activate client");
           } else {
             debug(2, "jackaudio client opened.");
             client_is_open = 1;
           }
-//      } else {
-//        debug(1, "jackaudio cannot set latency callback");
-//      }
       } else {
         inform(
             "jackaudio is running at the wrong speed (%d) for Shairport Sync, which must be 44100",
@@ -453,16 +342,6 @@ int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) char **a
   jack_set_error_function(default_jack_error_callback);
   jack_set_info_function(default_jack_info_callback);
 
-/*
-  // allocate space for the audio buffer
-  audio_lmb = malloc(buffer_size);
-  if (audio_lmb == NULL)
-    die("Can't allocate %d bytes for jackaudio buffer.", buffer_size);
-  audio_toq = audio_eoq = audio_lmb;
-  audio_umb = audio_lmb + buffer_size;
-  audio_occupancy = 0; // frames
-*/
-
   client_is_open = 0;
 
   // now, if selected, start a thread to automatically open a client when there is a server.
@@ -534,12 +413,6 @@ int jack_delay(long *the_delay) {
 void jack_flush() {
   debug(1, "Only the consumer can safely flush a lock-free ringbuffer. Asking the process callback to do it...");
   flush_please = 1;
-/*
-  //  debug(1,"jack flush");
-  audio_toq = audio_eoq = audio_lmb;
-  audio_umb = audio_lmb + buffer_size;
-  audio_occupancy = 0; // frames
-*/
 }
 
 void jack_stop(void) {