Fix D-Bus loudness switch silencing output. Rename LoudnessFiulterActive to Loudness. Add Convolution, ConvolutionGain and ConvolutionImpulseResponseFile properties to the D-Bus interface.

This commit is contained in:
Mike Brady
2019-11-10 18:05:59 +00:00
parent aeb46892e0
commit 2f2442f4aa
8 changed files with 129 additions and 16 deletions
+3
View File
@@ -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);
+1 -1
View File
@@ -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
+94 -9
View File
@@ -15,6 +15,10 @@
#include "dbus-service.h"
#ifdef CONFIG_CONVOLUTION
#include <FFTConvolver/convolver.h>
#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);
+19
View File
@@ -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
+1 -1
View File
@@ -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);
}
+4 -1
View File
@@ -5,8 +5,11 @@
<property name='Active' type='b' access='read'/>
<property name="DisableStandby" type="b" access="readwrite" />
<property name="DisableStandbyMode" type="s" access="readwrite" />
<property name="LoudnessFilterActive" type="b" access="readwrite" />
<property name="Loudness" type="b" access="readwrite" />
<property name="LoudnessThreshold" type="d" access="readwrite" />
<property name="Convolution" type="b" access="readwrite" />
<property name="ConvolutionGain" type="d" access="readwrite" />
<property name="ConvolutionImpulseResponseFile" type="s" access="readwrite" />
<property name="DriftTolerance" type="d" access="readwrite" />
<method name="RemoteCommand">
<arg name="command" type="s" direction="in" />
+2 -2
View File
@@ -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) {
+5 -2
View File
@@ -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);