From aeb46892e0d187b4dc7373ffecfaff2d298bc48f Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sat, 9 Nov 2019 09:35:04 +0000 Subject: [PATCH 01/14] correct frame size entry for S24 format --- audio_alsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio_alsa.c b/audio_alsa.c index e0a16b9a..27e35ed8 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -371,7 +371,7 @@ unsigned int auto_speed_output_rates[] = { format_record fr[] = { {SND_PCM_FORMAT_UNKNOWN, 0}, // unknown {SND_PCM_FORMAT_S8, 2}, {SND_PCM_FORMAT_U8, 2}, {SND_PCM_FORMAT_S16, 4}, - {SND_PCM_FORMAT_S16_LE, 4}, {SND_PCM_FORMAT_S16_BE, 4}, {SND_PCM_FORMAT_S24, 4}, + {SND_PCM_FORMAT_S16_LE, 4}, {SND_PCM_FORMAT_S16_BE, 4}, {SND_PCM_FORMAT_S24, 8}, {SND_PCM_FORMAT_S24_LE, 8}, {SND_PCM_FORMAT_S24_BE, 8}, {SND_PCM_FORMAT_S24_3LE, 6}, {SND_PCM_FORMAT_S24_3BE, 6}, {SND_PCM_FORMAT_S32, 8}, {SND_PCM_FORMAT_S32_LE, 8}, {SND_PCM_FORMAT_S32_BE, 8}, {SND_PCM_FORMAT_UNKNOWN, 0}, // auto From eca7d61f3a7271a8927ec4b483f290813369bf31 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sat, 9 Nov 2019 09:44:48 +0000 Subject: [PATCH 02/14] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index 3816fe18..927bcc3e 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,3 +1,12 @@ +Version 3.3.5d0 +==== +**Bug Fix** +* Fixed a crashing bug when output format `"S24"` was chosen. Fixes the issue reported by [artenverho](https://github.com/artenverho) in [#927](https://github.com/mikebrady/shairport-sync/issues/927). + +Version 3.3.4 +==== +This version did not appear on the `development` branch -- it fixed a small compilation error. + Version 3.3.3d11 ==== **Bug Fix** From 269a6988a86183efd2bd97a9fd916dad83521058 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sun, 10 Nov 2019 10:02:23 +0000 Subject: [PATCH 03/14] Create UNINSTALLING.md --- UNINSTALLING.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 UNINSTALLING.md diff --git a/UNINSTALLING.md b/UNINSTALLING.md new file mode 100644 index 00000000..33689814 --- /dev/null +++ b/UNINSTALLING.md @@ -0,0 +1,21 @@ + + +Uninstalling Shairport Sync +==== +This is under construction. + + + + + From 2f2442f4aa5e478c9fdea826c3f59b4012cd907d Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sun, 10 Nov 2019 18:05:59 +0000 Subject: [PATCH 04/14] Fix D-Bus loudness switch silencing output. Rename LoudnessFiulterActive to Loudness. Add Convolution, ConvolutionGain and ConvolutionImpulseResponseFile properties to the D-Bus interface. --- FFTConvolver/convolver.cpp | 3 + common.h | 2 +- dbus-service.c | 103 ++++++++++++++++++++++++++++++--- documents/sample dbus commands | 19 ++++++ loudness.c | 2 +- org.gnome.ShairportSync.xml | 5 +- player.c | 4 +- shairport.c | 7 ++- 8 files changed, 129 insertions(+), 16 deletions(-) diff --git a/FFTConvolver/convolver.cpp b/FFTConvolver/convolver.cpp index 3f08f0c6..f8f60179 100644 --- a/FFTConvolver/convolver.cpp +++ b/FFTConvolver/convolver.cpp @@ -33,6 +33,9 @@ void convolver_init(const char* filename, int max_length) size_t l = sf_readf_float(file, buffer, size); assert(l == size); + + convolver_l.reset(); // it is possible that init could be called more than once + convolver_r.reset(); // so it could be necessary to remove all previous settings if (info.channels == 1) { convolver_l.init(352, buffer, size); diff --git a/common.h b/common.h index 58772f8b..d3966a56 100644 --- a/common.h +++ b/common.h @@ -230,7 +230,7 @@ typedef struct { #ifdef CONFIG_CONVOLUTION int convolution; - const char *convolution_ir_file; + char *convolution_ir_file; float convolution_gain; int convolution_max_length; #endif diff --git a/dbus-service.c b/dbus-service.c index 76cc0456..7e9d3586 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -15,6 +15,10 @@ #include "dbus-service.h" +#ifdef CONFIG_CONVOLUTION +#include +#endif + int service_is_running = 0; ShairportSyncDiagnostics *shairportSyncDiagnosticsSkeleton = NULL; @@ -413,14 +417,77 @@ gboolean notify_disable_standby_callback(ShairportSync *skeleton, return TRUE; } -gboolean notify_loudness_filter_active_callback(ShairportSync *skeleton, +#ifdef CONFIG_CONVOLUTION +gboolean notify_convolution_callback(ShairportSync *skeleton, __attribute__((unused)) gpointer user_data) { - // debug(1, "\"notify_loudness_filter_active_callback\" called."); - if (shairport_sync_get_loudness_filter_active(skeleton)) { - debug(1, ">> activating loudness filter"); + // debug(1, "\"notify_convolution_callback\" called."); + if (shairport_sync_get_convolution(skeleton)) { + debug(1, ">> activating convolution"); + config.convolution = 1; + } else { + debug(1, ">> deactivating convolution"); + config.convolution = 0; + } + return TRUE; +} +#else +gboolean notify_convolution_callback(__attribute__((unused)) ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + warn(">> Convolution support is not built in to this build of Shairport Sync."); + return TRUE; +} +#endif + +#ifdef CONFIG_CONVOLUTION +gboolean notify_convolution_gain_callback(ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + + gdouble th = shairport_sync_get_convolution_gain(skeleton); + if ((th <= 0.0) && (th >= -100.0)) { + debug(1, ">> setting convolution gain to %f.", th); + config.convolution_gain = th; + } else { + debug(1, ">> invalid convolution gain: %f. Ignored.", th); + shairport_sync_set_convolution_gain(skeleton, config.convolution_gain); + } + return TRUE; +} +#else +gboolean notify_convolution_gain_callback(__attribute__((unused)) ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + warn(">> Convolution support is not built in to this build of Shairport Sync."); + return TRUE; +} +#endif +#ifdef CONFIG_CONVOLUTION +gboolean notify_convolution_impulse_response_file_callback(ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + char *th = (char *)shairport_sync_get_convolution_impulse_response_file(skeleton); + if (config.convolution_ir_file) + free(config.convolution_ir_file); + config.convolution_ir_file = strdup(th); + debug(1, ">> setting configuration impulse response filter file to \"%s\".", config.convolution_ir_file); + convolver_init(config.convolution_ir_file, config.convolution_max_length); + return TRUE; +} +#else +gboolean notify_convolution_impulse_response_file_callback(__attribute__((unused)) ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + char *th = (char *)shairport_sync_get_convolution_impulse_response_file(skeleton); + return TRUE; +} +#endif + + + +gboolean notify_loudness_callback(ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + // debug(1, "\"notify_loudness_callback\" called."); + if (shairport_sync_get_loudness(skeleton)) { + debug(1, ">> activating loudness"); config.loudness = 1; } else { - debug(1, ">> deactivating loudness filter"); + debug(1, ">> deactivating loudness"); config.loudness = 0; } return TRUE; @@ -687,8 +754,14 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name G_CALLBACK(notify_volume_control_profile_callback), NULL); g_signal_connect(shairportSyncSkeleton, "notify::disable-standby", G_CALLBACK(notify_disable_standby_callback), NULL); - g_signal_connect(shairportSyncSkeleton, "notify::loudness-filter-active", - G_CALLBACK(notify_loudness_filter_active_callback), NULL); + g_signal_connect(shairportSyncSkeleton, "notify::convolution", + G_CALLBACK(notify_convolution_callback), NULL); + g_signal_connect(shairportSyncSkeleton, "notify::convolution-gain", + G_CALLBACK(notify_convolution_gain_callback), NULL); + g_signal_connect(shairportSyncSkeleton, "notify::convolution-impulse-response-file", + G_CALLBACK(notify_convolution_impulse_response_file_callback), NULL); + g_signal_connect(shairportSyncSkeleton, "notify::loudness", + G_CALLBACK(notify_loudness_callback), NULL); g_signal_connect(shairportSyncSkeleton, "notify::loudness-threshold", G_CALLBACK(notify_loudness_threshold_callback), NULL); g_signal_connect(shairportSyncSkeleton, "notify::drift-tolerance", @@ -824,11 +897,23 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name } if (config.loudness == 0) { - shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); + shairport_sync_set_loudness(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); } else { - shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE); + shairport_sync_set_loudness(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE); } +#ifdef CONFIG_CONVOLUTION + if (config.convolution == 0) { + shairport_sync_set_convolution(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); + } else { + shairport_sync_set_convolution(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE); + } + if (config.convolution_ir_file) + shairport_sync_set_convolution_impulse_response_file(SHAIRPORT_SYNC(shairportSyncSkeleton), config.convolution_ir_file); + else + shairport_sync_set_convolution_impulse_response_file(SHAIRPORT_SYNC(shairportSyncSkeleton), NULL); +#endif + shairport_sync_set_version(SHAIRPORT_SYNC(shairportSyncSkeleton), PACKAGE_VERSION); char *vs = get_version_string(); shairport_sync_set_version_string(SHAIRPORT_SYNC(shairportSyncSkeleton), vs); diff --git a/documents/sample dbus commands b/documents/sample dbus commands index 2e88003d..e6251929 100644 --- a/documents/sample dbus commands +++ b/documents/sample dbus commands @@ -31,3 +31,22 @@ dbus-send --system --print-reply --type=method_call --dest=org.gnome.ShairportSy dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:DriftTolerance # Set Drift Tolerance to 1 millisecond dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:DriftTolerance variant:double:0.001 + + +# Enable Loudness Filter + + +# Is Convolution enabled: +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:Convolution + +# Enable Convolution +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:Convolution variant:boolean:true + +# Get Convolution Gain: +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:ConvolutionGain + +# Set Convolution Gain -- the gain applied before convolution is applied -- to -10.0 dB +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionGain variant:double:-10 + +# Get Convolution Impulse Response File: +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile diff --git a/loudness.c b/loudness.c index b4dbc3c3..79862ece 100644 --- a/loudness.c +++ b/loudness.c @@ -44,7 +44,7 @@ void loudness_set_volume(float volume) { if (gain < 0) gain = 0; - inform("Volume: %.1f dB - Loudness gain @10Hz: %.1f dB", volume, gain); + debug(2, "Volume: %.1f dB - Loudness gain @10Hz: %.1f dB", volume, gain); _loudness_set_volume(&loudness_l, volume); _loudness_set_volume(&loudness_r, volume); } diff --git a/org.gnome.ShairportSync.xml b/org.gnome.ShairportSync.xml index e4a7d1e6..15317faa 100644 --- a/org.gnome.ShairportSync.xml +++ b/org.gnome.ShairportSync.xml @@ -5,8 +5,11 @@ - + + + + diff --git a/player.c b/player.c index e98331f4..6f7f6415 100644 --- a/player.c +++ b/player.c @@ -2902,8 +2902,8 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c conn->fix_volume = temp_fix_volume; - if (config.loudness) - loudness_set_volume(software_attenuation / 100); + // if (config.loudness) + loudness_set_volume(software_attenuation / 100); } if (config.logOutputLevel) { diff --git a/shairport.c b/shairport.c index 4216d5bb..9c519122 100644 --- a/shairport.c +++ b/shairport.c @@ -962,12 +962,12 @@ int parse_options(int argc, char **argv) { } if (config_lookup_string(config.cfg, "dsp.convolution_ir_file", &str)) { - config.convolution_ir_file = str; + config.convolution_ir_file = strdup(str); convolver_init(config.convolution_ir_file, config.convolution_max_length); } if (config.convolution && config.convolution_ir_file == NULL) { - die("Convolution enabled but no convolution_ir_file provided"); + warn("Convolution enabled but no convolution_ir_file provided"); } #endif if (config_lookup_string(config.cfg, "dsp.loudness", &str)) { @@ -1339,6 +1339,9 @@ Actually, there is no stop_mpris_service() function. if (config.service_name) free(config.service_name); + + if (config.convolution_ir_file) + free(config.convolution_ir_file); if (config.regtype) free(config.regtype); From f2930387b32e7acff07dfe0da2aa864cdfe0b385 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 11 Nov 2019 21:45:29 +0000 Subject: [PATCH 05/14] Add D-Bus convolution filter controls; enable convolution filters to be turned on and off or changed; enable convolution gain to be checked and changed. --- FFTConvolver/convolver.cpp | 105 ++++++++++++++++++--------------- FFTConvolver/convolver.h | 2 +- common.h | 1 + dbus-service.c | 7 ++- documents/sample dbus commands | 11 ++++ player.c | 26 ++++++-- shairport.c | 2 +- 7 files changed, 98 insertions(+), 56 deletions(-) diff --git a/FFTConvolver/convolver.cpp b/FFTConvolver/convolver.cpp index f8f60179..a2824829 100644 --- a/FFTConvolver/convolver.cpp +++ b/FFTConvolver/convolver.cpp @@ -1,72 +1,85 @@ -#include "convolver.h" +#include #include +#include "convolver.h" #include "FFTConvolver.h" #include "Utilities.h" -extern "C" void _die(const char *filename, const int linenumber, const char *format, ...); +extern "C" void _warn(const char *filename, const int linenumber, const char *format, ...); extern "C" void _debug(const char *filename, const int linenumber, int level, const char *format, ...); -#define die(...) _die(__FILE__, __LINE__, __VA_ARGS__) +#define warn(...) _warn(__FILE__, __LINE__, __VA_ARGS__) #define debug(...) _debug(__FILE__, __LINE__, __VA_ARGS__) -static fftconvolver::FFTConvolver convolver_l; -static fftconvolver::FFTConvolver convolver_r; +fftconvolver::FFTConvolver convolver_l; +fftconvolver::FFTConvolver convolver_r; + +// always lock use this when accessing the playing conn value +pthread_mutex_t convolver_lock = PTHREAD_MUTEX_INITIALIZER; -void convolver_init(const char* filename, int max_length) -{ +int convolver_init(const char* filename, int max_length) { + int success = 0; SF_INFO info; - assert(filename); - SNDFILE* file = sf_open(filename, SFM_READ, &info); - assert(file); + if (filename) { + SNDFILE* file = sf_open(filename, SFM_READ, &info); + if (file) { - if (info.samplerate != 44100) - die("Impulse file \"%s\" sample rate is %d Hz. Only 44100 Hz is supported", filename, info.samplerate); + if (info.samplerate == 44100) { + if ((info.channels == 1) || (info.channels == 2)) { + const size_t size = info.frames > max_length ? max_length : info.frames; + float buffer[size*info.channels]; - if (info.channels != 1 && info.channels != 2) - die("Impulse file \"%s\" contains %d channels. Only 1 or 2 is supported.", filename, info.channels); + size_t l = sf_readf_float(file, buffer, size); + if (l != 0) { + pthread_mutex_lock(&convolver_lock); + convolver_l.reset(); // it is possible that init could be called more than once + convolver_r.reset(); // so it could be necessary to remove all previous settings - const size_t size = info.frames > max_length ? max_length : info.frames; - float buffer[size*info.channels]; - - size_t l = sf_readf_float(file, buffer, size); - assert(l == size); - - convolver_l.reset(); // it is possible that init could be called more than once - convolver_r.reset(); // so it could be necessary to remove all previous settings - - if (info.channels == 1) { - convolver_l.init(352, buffer, size); - convolver_r.init(352, buffer, size); - } else { - // deinterleave - float buffer_l[size]; - float buffer_r[size]; + if (info.channels == 1) { + convolver_l.init(352, buffer, size); + convolver_r.init(352, buffer, size); + } else { + // deinterleave + float buffer_l[size]; + float buffer_r[size]; - unsigned int i; - for (i=0; i> activating convolution"); config.convolution = 1; + config.convolver_valid = convolver_init(config.convolution_ir_file, config.convolution_max_length); } else { debug(1, ">> deactivating convolution"); config.convolution = 0; @@ -467,7 +468,7 @@ gboolean notify_convolution_impulse_response_file_callback(ShairportSync *skelet free(config.convolution_ir_file); config.convolution_ir_file = strdup(th); debug(1, ">> setting configuration impulse response filter file to \"%s\".", config.convolution_ir_file); - convolver_init(config.convolution_ir_file, config.convolution_max_length); + config.convolver_valid = convolver_init(config.convolution_ir_file, config.convolution_max_length); return TRUE; } #else @@ -910,8 +911,8 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name } if (config.convolution_ir_file) shairport_sync_set_convolution_impulse_response_file(SHAIRPORT_SYNC(shairportSyncSkeleton), config.convolution_ir_file); - else - shairport_sync_set_convolution_impulse_response_file(SHAIRPORT_SYNC(shairportSyncSkeleton), NULL); +// else +// shairport_sync_set_convolution_impulse_response_file(SHAIRPORT_SYNC(shairportSyncSkeleton), NULL); #endif shairport_sync_set_version(SHAIRPORT_SYNC(shairportSyncSkeleton), PACKAGE_VERSION); diff --git a/documents/sample dbus commands b/documents/sample dbus commands index e6251929..72581f50 100644 --- a/documents/sample dbus commands +++ b/documents/sample dbus commands @@ -32,9 +32,17 @@ dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/Shair # Set Drift Tolerance to 1 millisecond dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:DriftTolerance variant:double:0.001 +# Is Loudness Enabled: +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:LoudnessThreshold # Enable Loudness Filter +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:Loudness variant:boolean:true +# Get Loudness Threshold +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:LoudnessThreshold + +# Set Loudness Threshold +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:LoudnessThreshold variant:double:-15.0 # Is Convolution enabled: dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:Convolution @@ -50,3 +58,6 @@ dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/Shair # Get Convolution Impulse Response File: dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile + +# Set Convolution Impulse Response File: +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile variant:string:"/etc/shairport-sync/boom.wav" \ No newline at end of file diff --git a/player.c b/player.c index 6f7f6415..94fe3802 100644 --- a/player.c +++ b/player.c @@ -2365,9 +2365,24 @@ void *player_thread_func(void *arg) { amount_to_stuff = 0; // no stuffing if it's been disabled // Apply DSP here - if (config.loudness + + // check the state of loudness and convolution flags here and don't change them for the frame + + int do_loudness = config.loudness; + + int do_convolution = 0; + if ((config.convolution) && (config.convolver_valid)) + do_convolution = 1; + + // we will apply the convolution gain if convolution is enabled, even if there is no valid convolution happening + + int convolution_is_enabled = 0; + if (config.convolution) + convolution_is_enabled = 1; + + if (do_loudness #ifdef CONFIG_CONVOLUTION - || config.convolution + || convolution_is_enabled #endif ) { int32_t *tbuf32 = (int32_t *)conn->tbuf; @@ -2383,10 +2398,11 @@ void *player_thread_func(void *arg) { #ifdef CONFIG_CONVOLUTION // Apply convolution - if (config.convolution) { + if (do_convolution) { convolver_process_l(fbuf_l, inbuflength); convolver_process_r(fbuf_r, inbuflength); - + } + if (convolution_is_enabled) { float gain = pow(10.0, config.convolution_gain / 20.0); for (i = 0; i < inbuflength; ++i) { fbuf_l[i] *= gain; @@ -2395,7 +2411,7 @@ void *player_thread_func(void *arg) { } #endif - if (config.loudness) { + if (do_loudness) { // Apply volume and loudness // Volume must be applied here because the loudness filter will increase the // signal level and it would saturate the int32_t otherwise diff --git a/shairport.c b/shairport.c index 9c519122..c9b5ba1c 100644 --- a/shairport.c +++ b/shairport.c @@ -963,7 +963,7 @@ int parse_options(int argc, char **argv) { if (config_lookup_string(config.cfg, "dsp.convolution_ir_file", &str)) { config.convolution_ir_file = strdup(str); - convolver_init(config.convolution_ir_file, config.convolution_max_length); + config.convolver_valid = convolver_init(config.convolution_ir_file, config.convolution_max_length); } if (config.convolution && config.convolution_ir_file == NULL) { From e55f5c6765fc999a30da8de64aa93bbdf6b6e196 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 11 Nov 2019 21:47:04 +0000 Subject: [PATCH 06/14] Add D-Bus convolution filter controls -- enable convolution filters to be turned on and off or changed; enable convolution gain to be checked and changed; fix loudness control. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 848e9763..a27ec6bc 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.50]) -AC_INIT([shairport-sync], [3.3.5d0], [mikebrady@eircom.net]) +AC_INIT([shairport-sync], [3.3.5d1], [mikebrady@eircom.net]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([shairport.c]) AC_CONFIG_HEADERS([config.h]) From ac7c34bc3b76027f60985d22c86e6cda8301ff61 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 11 Nov 2019 21:55:49 +0000 Subject: [PATCH 07/14] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index 927bcc3e..9f8afce9 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,3 +1,12 @@ +Version 3.3.5d1 +==== +**New Features** +* Added to the D-Bus interface the ability to turn on and off convolution, to set the convolution gain and to change the convolution impulse response files. See examples in [sample dbus commands](https://github.com/mikebrady/shairport-sync/blob/development/documents/sample%20dbus%20commands). Note: for these commands to make sense, Shairport Sync must be built with support for convolution and the native D-Bus interface (`--with-convolution` and `--with-dbus-interface`) and fully installed. + +**Bug Fix** +* Fixed a bug whereby if you enabled the Loudness filter via the D-Bus interface, the output disappeared until you changed the volume. + + Version 3.3.5d0 ==== **Bug Fix** From b88c9255b7566b8008236f64cea1ce5d82b15de2 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 11 Nov 2019 22:06:44 +0000 Subject: [PATCH 08/14] Fix a few compilation bugs. Thanks Travis. --- player.c | 5 ++++- shairport.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/player.c b/player.c index 94fe3802..21eb432f 100644 --- a/player.c +++ b/player.c @@ -2370,15 +2370,18 @@ void *player_thread_func(void *arg) { int do_loudness = config.loudness; + +#ifdef CONFIG_CONVOLUTION int do_convolution = 0; if ((config.convolution) && (config.convolver_valid)) do_convolution = 1; - + // we will apply the convolution gain if convolution is enabled, even if there is no valid convolution happening int convolution_is_enabled = 0; if (config.convolution) convolution_is_enabled = 1; +#endif if (do_loudness #ifdef CONFIG_CONVOLUTION diff --git a/shairport.c b/shairport.c index c9b5ba1c..d2a1a494 100644 --- a/shairport.c +++ b/shairport.c @@ -1339,9 +1339,11 @@ Actually, there is no stop_mpris_service() function. if (config.service_name) free(config.service_name); - + +#ifdef CONFIG_CONVOLUTION if (config.convolution_ir_file) free(config.convolution_ir_file); +#endif if (config.regtype) free(config.regtype); From af98db96ac51d84a9615be3807471dd50b3d431e Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Tue, 12 Nov 2019 08:46:38 +0000 Subject: [PATCH 09/14] Update sample dbus commands --- documents/sample dbus commands | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/documents/sample dbus commands b/documents/sample dbus commands index 72581f50..a07cba6a 100644 --- a/documents/sample dbus commands +++ b/documents/sample dbus commands @@ -24,9 +24,6 @@ dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/Shair dbus-send --system --print-reply --type=method_call --dest=org.gnome.ShairportSync '/org/gnome/ShairportSync' org.gnome.ShairportSync.RemoteControl.Play #Remote Control commands include: Play, Pause, PlayPause, Resume, Stop, Next, Previous, VolumeUp, VolumeDown, ToggleMute, FastForward, Rewind, ShuffleSongs -# Set Volume using Advanced Remote Control -dbus-send --system --print-reply --type=method_call --dest=org.gnome.ShairportSync '/org/gnome/ShairportSync' org.gnome.ShairportSync.AdvancedRemoteControl.SetVolume int32:50 - # Get Drift Tolerance dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:DriftTolerance # Set Drift Tolerance to 1 millisecond @@ -60,4 +57,16 @@ dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/Shair dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile # Set Convolution Impulse Response File: -dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile variant:string:"/etc/shairport-sync/boom.wav" \ No newline at end of file +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile variant:string:"/etc/shairport-sync/boom.wav" + +# Some commands and properties are accessible only through the AdvancedRemoteControl interface at org.gnome.ShairportSync.AdvancedRemoteControl +# Unfortunately, only iTunes provides the functionality to allow the AdvancedRemoteControl stuff to work. +# (The macOS "Music" app replacing iTunes appears to have no remote interface whatever (at least as far as is known).) + +# You can check to see if AdvancedRemoteControl is available using the command: + +dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync.AdvancedRemoteControl string:Available + +# Set Volume using Advanced Remote Control -- only works if the org.gnome.ShairportSync.AdvancedRemoteControl is available. +dbus-send --system --print-reply --type=method_call --dest=org.gnome.ShairportSync '/org/gnome/ShairportSync' org.gnome.ShairportSync.AdvancedRemoteControl.SetVolume int32:50 + From 263f4dd59931d76032e590ffb517c0c310befa17 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Tue, 12 Nov 2019 08:57:09 +0000 Subject: [PATCH 10/14] rename LoudnessFilterActive to Loudness and friends --- shairport-sync-dbus-test-client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shairport-sync-dbus-test-client.c b/shairport-sync-dbus-test-client.c index 96a7de8d..bf968c45 100644 --- a/shairport-sync-dbus-test-client.c +++ b/shairport-sync-dbus-test-client.c @@ -40,11 +40,11 @@ void on_properties_changed(__attribute__((unused)) GDBusProxy *proxy, GVariant * } } -void notify_loudness_filter_active_callback(ShairportSync *proxy, +void notify_loudness_callback(ShairportSync *proxy, __attribute__((unused)) gpointer user_data) { - // printf("\"notify_loudness_filter_active_callback\" called with a gpointer of + // printf("\"notify_loudness_callback\" called with a gpointer of // %lx.\n",(int64_t)user_data); - gboolean ebl = shairport_sync_get_loudness_filter_active(proxy); + gboolean ebl = shairport_sync_get_loudness(proxy); if (ebl == TRUE) printf("Client reports loudness is enabled.\n"); else From 8f47c3631554180b90133442cd833164524d3415 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Tue, 12 Nov 2019 09:03:46 +0000 Subject: [PATCH 11/14] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index 9f8afce9..1cfabc6d 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,5 +1,8 @@ Version 3.3.5d1 ==== +**Pesky Changes You May Not Be Able To Ignore** +* Renamed the `LoudnessFilterActive` property in the D-Bus interface to `Loudness`. Updated [shairport-sync-dbus-test-client.c](https://github.com/mikebrady/shairport-sync/blob/master/shairport-sync-dbus-test-client.c) accordingly. + **New Features** * Added to the D-Bus interface the ability to turn on and off convolution, to set the convolution gain and to change the convolution impulse response files. See examples in [sample dbus commands](https://github.com/mikebrady/shairport-sync/blob/development/documents/sample%20dbus%20commands). Note: for these commands to make sense, Shairport Sync must be built with support for convolution and the native D-Bus interface (`--with-convolution` and `--with-dbus-interface`) and fully installed. From 2003992dedc90bd0869a6575d342f6585ead8b2d Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Tue, 12 Nov 2019 09:04:38 +0000 Subject: [PATCH 12/14] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index 1cfabc6d..775d9c69 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,7 +1,7 @@ Version 3.3.5d1 ==== **Pesky Changes You May Not Be Able To Ignore** -* Renamed the `LoudnessFilterActive` property in the D-Bus interface to `Loudness`. Updated [shairport-sync-dbus-test-client.c](https://github.com/mikebrady/shairport-sync/blob/master/shairport-sync-dbus-test-client.c) accordingly. +* Renamed the `LoudnessFilterActive` property in the D-Bus interface to `Loudness`. Updated [shairport-sync-dbus-test-client.c](https://github.com/mikebrady/shairport-sync/blob/development/shairport-sync-dbus-test-client.c) accordingly. **New Features** * Added to the D-Bus interface the ability to turn on and off convolution, to set the convolution gain and to change the convolution impulse response files. See examples in [sample dbus commands](https://github.com/mikebrady/shairport-sync/blob/development/documents/sample%20dbus%20commands). Note: for these commands to make sense, Shairport Sync must be built with support for convolution and the native D-Bus interface (`--with-convolution` and `--with-dbus-interface`) and fully installed. From 768494dc8656105b2c07446cca5515769306c1d5 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Tue, 12 Nov 2019 09:35:33 +0000 Subject: [PATCH 13/14] Update sample dbus commands --- documents/sample dbus commands | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documents/sample dbus commands b/documents/sample dbus commands index a07cba6a..805480ca 100644 --- a/documents/sample dbus commands +++ b/documents/sample dbus commands @@ -59,8 +59,8 @@ dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/Shair # Set Convolution Impulse Response File: dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile variant:string:"/etc/shairport-sync/boom.wav" -# Some commands and properties are accessible only through the AdvancedRemoteControl interface at org.gnome.ShairportSync.AdvancedRemoteControl -# Unfortunately, only iTunes provides the functionality to allow the AdvancedRemoteControl stuff to work. +# Some commands and properties are accessible only through the AdvancedRemoteControl interface. +# Unfortunately, only iTunes provides the functionality to allow the AdvancedRemoteControl interface to work. # (The macOS "Music" app replacing iTunes appears to have no remote interface whatever (at least as far as is known).) # You can check to see if AdvancedRemoteControl is available using the command: From 1f0246da9ac701a08409489268d376522232f91d Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Wed, 11 Dec 2019 15:29:04 +0000 Subject: [PATCH 14/14] Update sample dbus commands --- documents/sample dbus commands | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documents/sample dbus commands b/documents/sample dbus commands index 805480ca..5b173d4a 100644 --- a/documents/sample dbus commands +++ b/documents/sample dbus commands @@ -60,8 +60,8 @@ dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/Shair dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile variant:string:"/etc/shairport-sync/boom.wav" # Some commands and properties are accessible only through the AdvancedRemoteControl interface. -# Unfortunately, only iTunes provides the functionality to allow the AdvancedRemoteControl interface to work. -# (The macOS "Music" app replacing iTunes appears to have no remote interface whatever (at least as far as is known).) +# However, only iTunes or the macOS Music app from 10.15.2 onwards +# provide the functionality needed for the AdvancedRemoteControl interface to work. # You can check to see if AdvancedRemoteControl is available using the command: