From b7d9c22de9effda99d2a77849de9b25739e5e1d4 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:01:38 +0100 Subject: [PATCH] format adjustments --- audio_alsa.c | 3 ++- audio_jack.c | 2 +- common.c | 27 ++++++++++++++++----------- common.h | 12 +++++++----- dacp.c | 10 +++++----- metadata_hub.c | 2 +- rtp.c | 6 ++++-- 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/audio_alsa.c b/audio_alsa.c index bf8d6ada..78780804 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -176,7 +176,8 @@ void handle_unfixable_error(int errorCode) { command_execute(config.cmd_unfixable, messageString, 1); } else { die("An unrecoverable error, \"output_device_error_%d\", has been " - "detected. Doing an emergency exit, as no run_this_if_an_unfixable_error_is_detected program.", + "detected. Doing an emergency exit, as no run_this_if_an_unfixable_error_is_detected " + "program.", errorCode); } } diff --git a/audio_jack.c b/audio_jack.c index abdf09d9..911fada7 100644 --- a/audio_jack.c +++ b/audio_jack.c @@ -299,7 +299,7 @@ static int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) c while (port_list[i++] != NULL) { inform( "Additional matching port %s found. Check that the connections are what you intended.", - port_list[i-1]); + port_list[i - 1]); } jack_free(port_list); } diff --git a/common.c b/common.c index bed243ba..618293ae 100644 --- a/common.c +++ b/common.c @@ -72,8 +72,8 @@ #endif #ifdef CONFIG_OPENSSL -#include // needed for BIO_new_mem_buf #include // needed for older AES stuff +#include // needed for BIO_new_mem_buf #include // needed for ERR_error_string, ERR_get_error #include // needed for EVP_PKEY_CTX_new, EVP_PKEY_sign_init, EVP_PKEY_sign #include // needed for PEM_read_bio_RSAPrivateKey, EVP_PKEY_CTX_set_rsa_padding @@ -1203,14 +1203,14 @@ uint32_t uatoi(const char *nptr) { // clang-format on double flat_vol2attn(double vol, long max_db, long min_db) { -// clang-format off + // clang-format off // This "flat" volume control profile has the property that a given change in the AirPlay volume // always results in the same change in output dB. For example, if a change of AirPlay volume // from 0 to -4 resulted in a 7 dB change, then a change in AirPlay volume from -20 to -24 // would also result in a 7 dB change. -// clang-format on + // clang-format on double vol_setting = min_db; // if all else fails, set this, for safety if ((vol <= 0.0) && (vol >= -30.0)) { @@ -1219,15 +1219,15 @@ double flat_vol2attn(double vol, long max_db, long min_db) { // max_db); } else if (vol != -144.0) { debug(1, - "flat_vol2attn volume request value %f is out of range: should be from 0.0 to -30.0 or -144.0.", + "flat_vol2attn volume request value %f is out of range: should be from 0.0 to -30.0 or " + "-144.0.", vol); } return vol_setting; } - double dasl_tapered_vol2attn(double vol, long max_db, long min_db) { -// clang-format off + // clang-format off // The "dasl_tapered" volume control profile has the property that halving the AirPlay volume (the "vol" parameter) // reduces the output level by 10 dB, which corresponds to roughly halving the perceived volume. @@ -1251,7 +1251,7 @@ double dasl_tapered_vol2attn(double vol, long max_db, long min_db) { // If the device's attenuation range is over about 50 dB, // the flat output level will hardly be needed at all. -// clang-format on + // clang-format on double vol_setting = min_db; // if all else fails, set this, for safety if ((vol <= 0.0) && (vol >= -30.0)) { @@ -1259,11 +1259,15 @@ double dasl_tapered_vol2attn(double vol, long max_db, long min_db) { if (vol_pct <= 0) { return min_db; } - + double flat_setting = min_db + (max_db - min_db) * vol_pct; - vol_setting = max_db + 1000 * log10(vol_pct) / log10(2); // This will be in the range [-inf, max_db] + vol_setting = + max_db + 1000 * log10(vol_pct) / log10(2); // This will be in the range [-inf, max_db] if (vol_setting < flat_setting) { - debug(3, "dasl_tapered_vol2attn returning a flat setting of %f for AirPlay volume %f instead of a tapered setting of %f in a range from %f to %f.", flat_setting, vol, vol_setting, 1.0 * min_db, 1.0 * max_db); + debug(3, + "dasl_tapered_vol2attn returning a flat setting of %f for AirPlay volume %f instead of " + "a tapered setting of %f in a range from %f to %f.", + flat_setting, vol, vol_setting, 1.0 * min_db, 1.0 * max_db); return flat_setting; } if (vol_setting > max_db) { @@ -1272,7 +1276,8 @@ double dasl_tapered_vol2attn(double vol, long max_db, long min_db) { return vol_setting; } else if (vol != -144.0) { debug(1, - "dasl_tapered volume request value %f is out of range: should be from 0.0 to -30.0 or -144.0.", + "dasl_tapered volume request value %f is out of range: should be from 0.0 to -30.0 or " + "-144.0.", vol); } return vol_setting; diff --git a/common.h b/common.h index c8e8915b..edd48fa8 100644 --- a/common.h +++ b/common.h @@ -391,11 +391,13 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode); // dB), return an attenuation depending on a linear interpolation along the range double flat_vol2attn(double vol, long max_db, long min_db); -// The intention behind dasl_tapered is that a given percentage change in volume should result in the same percentage change in -// perceived loudness. For instance, doubling the volume level should result in doubling the perceived loudness. -// With the range of AirPlay volume being from -30 to 0, doubling the volume from -22.5 to -15 results in an increase of 10 dB. -// Similarly, doubling the volume from -15 to 0 results in an increase of 10 dB. -// For compatibility with mixers having a restricted attenuation range (e.g. 30 dB), "dasl_tapered" will switch to a flat profile at low AirPlay volumes. +// The intention behind dasl_tapered is that a given percentage change in volume should result in +// the same percentage change in perceived loudness. For instance, doubling the volume level should +// result in doubling the perceived loudness. With the range of AirPlay volume being from -30 to 0, +// doubling the volume from -22.5 to -15 results in an increase of 10 dB. Similarly, doubling the +// volume from -15 to 0 results in an increase of 10 dB. For compatibility with mixers having a +// restricted attenuation range (e.g. 30 dB), "dasl_tapered" will switch to a flat profile at low +// AirPlay volumes. double dasl_tapered_vol2attn(double vol, long max_db, long min_db); // given a volume (0 to -30) and high and low attenuations in dB*100 (e.g. 0 to -6000 for 0 to -60 // dB), return an attenuation depending on the transfer function diff --git a/dacp.c b/dacp.c index 14154263..52535cc5 100644 --- a/dacp.c +++ b/dacp.c @@ -411,14 +411,14 @@ void set_dacp_server_information(rtsp_conn_info *conn) { debug(2, "set_dacp_server_information set IP to \"%s\" and DACP id to \"%s\".", dacp_server.ip_string, dacp_server.dacp_id); -/* + /* -"long polling" is not implemented by Shairport Sync, whereby by sending the client the -last-received revision number, the link will hang until a change occurs. + "long polling" is not implemented by Shairport Sync, whereby by sending the client the + last-received revision number, the link will hang until a change occurs. -Instead, at present, Shairport Sync always uses a revision number of 1. + Instead, at present, Shairport Sync always uses a revision number of 1. -*/ + */ // always use revision number 1 dacp_server.always_use_revision_number_1 = 1; diff --git a/metadata_hub.c b/metadata_hub.c index 27176058..235b6fe5 100644 --- a/metadata_hub.c +++ b/metadata_hub.c @@ -211,7 +211,7 @@ char *metadata_write_image_file(const char *buf, int len) { #ifdef CONFIG_OPENSSL EVP_MD_CTX *ctx; unsigned int img_md5_len = EVP_MD_size(EVP_md5()); - + ctx = EVP_MD_CTX_new(); EVP_DigestInit_ex(ctx, EVP_md5(), NULL); EVP_DigestUpdate(ctx, buf, len); diff --git a/rtp.c b/rtp.c index ed64ea74..c7c8efa3 100644 --- a/rtp.c +++ b/rtp.c @@ -2917,7 +2917,8 @@ void *rtp_buffered_audio_processor(void *arg) { debug(1, "error %d during decoding", ret); } else { #if LIBAVUTIL_VERSION_MAJOR >= 57 - av_samples_alloc(&pcm_audio, &dst_linesize, codec_context->ch_layout.nb_channels, + av_samples_alloc(&pcm_audio, &dst_linesize, + codec_context->ch_layout.nb_channels, decoded_frame->nb_samples, av_format, 1); #else av_samples_alloc(&pcm_audio, &dst_linesize, codec_context->channels, @@ -2929,7 +2930,8 @@ void *rtp_buffered_audio_processor(void *arg) { decoded_frame->nb_samples); #if LIBAVUTIL_VERSION_MAJOR >= 57 dst_bufsize = av_samples_get_buffer_size( - &dst_linesize, codec_context->ch_layout.nb_channels, ret, av_format, 1); + &dst_linesize, codec_context->ch_layout.nb_channels, ret, av_format, + 1); #else dst_bufsize = av_samples_get_buffer_size( &dst_linesize, codec_context->channels, ret, av_format, 1); -- 2.47.3