Add a few new elements ot the native dbus interface
This commit is contained in:
@@ -1004,3 +1004,71 @@ int ss_pthread_mutex_timedlock(pthread_mutex_t *mutex, useconds_t dally_time,
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
char *get_version_string() {
|
||||
char *version_string = malloc(200);
|
||||
if (version_string) {
|
||||
strcpy(version_string, PACKAGE_VERSION);
|
||||
#ifdef HAVE_LIBMBEDTLS
|
||||
strcat(version_string, "-mbedTLS");
|
||||
#endif
|
||||
#ifdef HAVE_LIBPOLARSSL
|
||||
strcat(version_string, "-PolarSSL");
|
||||
#endif
|
||||
#ifdef HAVE_LIBSSL
|
||||
strcat(version_string, "-OpenSSL");
|
||||
#endif
|
||||
#ifdef CONFIG_TINYSVCMDNS
|
||||
strcat(version_string, "-tinysvcmdns");
|
||||
#endif
|
||||
#ifdef CONFIG_AVAHI
|
||||
strcat(version_string, "-Avahi");
|
||||
#endif
|
||||
#ifdef CONFIG_DNS_SD
|
||||
strcat(version_string, "-dns_sd");
|
||||
#endif
|
||||
#ifdef CONFIG_ALSA
|
||||
strcat(version_string, "-ALSA");
|
||||
#endif
|
||||
#ifdef CONFIG_SNDIO
|
||||
strcat(version_string, "-sndio");
|
||||
#endif
|
||||
#ifdef CONFIG_AO
|
||||
strcat(version_string, "-ao");
|
||||
#endif
|
||||
#ifdef CONFIG_PA
|
||||
strcat(version_string, "-pa");
|
||||
#endif
|
||||
#ifdef CONFIG_SOUNDIO
|
||||
strcat(version_string, "-soundio");
|
||||
#endif
|
||||
#ifdef CONFIG_DUMMY
|
||||
strcat(version_string, "-dummy");
|
||||
#endif
|
||||
#ifdef CONFIG_STDOUT
|
||||
strcat(version_string, "-stdout");
|
||||
#endif
|
||||
#ifdef CONFIG_PIPE
|
||||
strcat(version_string, "-pipe");
|
||||
#endif
|
||||
#ifdef HAVE_LIBSOXR
|
||||
strcat(version_string, "-soxr");
|
||||
#endif
|
||||
#ifdef CONFIG_CONVOLUTION
|
||||
strcat(version_string, "-convolution");
|
||||
#endif
|
||||
#ifdef CONFIG_METADATA
|
||||
strcat(version_string, "-metadata");
|
||||
#endif
|
||||
#ifdef HAVE_DBUS
|
||||
strcat(version_string, "-dbus");
|
||||
#endif
|
||||
#ifdef HAVE_MPRIS
|
||||
strcat(version_string, "-mpris");
|
||||
#endif
|
||||
strcat(version_string, "-sysconfdir:");
|
||||
strcat(version_string, SYSCONFDIR);
|
||||
}
|
||||
return version_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -254,4 +254,6 @@ extern sigset_t pselect_sigset;
|
||||
int ss_pthread_mutex_timedlock(pthread_mutex_t *mutex, useconds_t dally_time,
|
||||
const char *debugmessage, int debuglevel);
|
||||
|
||||
char *get_version_string(); // mallocs a string space -- remember to free it afterwards
|
||||
|
||||
#endif // _COMMON_H
|
||||
|
||||
@@ -340,6 +340,16 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
|
||||
pthread_mutex_unlock(&dacp_server_information_lock);
|
||||
// debug(1, "DACP Server ID \"%u\" at \"%s:%u\", scan %d.", dacp_server.active_remote_id,
|
||||
// dacp_server.ip_string, dacp_server.port, scan_index);
|
||||
|
||||
int adv = (result == 200);
|
||||
// a result of 200 means the advanced features of, e.g., iTunes, are available
|
||||
// so, turn the advanced_dacp_server flag on or off and flag if it's changed.
|
||||
metadata_hub_modify_prolog();
|
||||
int diff = metadata_store.advanced_dacp_server_active != adv;
|
||||
if (diff)
|
||||
metadata_store.advanced_dacp_server_active = adv;
|
||||
metadata_hub_modify_epilog(diff);
|
||||
|
||||
if (result == 200) {
|
||||
ssize_t le;
|
||||
char *response = NULL;
|
||||
|
||||
+123
-12
@@ -1,3 +1,4 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -30,10 +31,19 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
shairport_sync_remote_control_set_airplay_volume(shairportSyncRemoteControlSkeleton,
|
||||
argc->airplay_volume);
|
||||
|
||||
if (argc->dacp_server_active)
|
||||
shairport_sync_remote_control_set_server(shairportSyncRemoteControlSkeleton, argc->client_ip);
|
||||
else
|
||||
shairport_sync_remote_control_set_server(shairportSyncRemoteControlSkeleton, "");
|
||||
shairport_sync_remote_control_set_server(shairportSyncRemoteControlSkeleton, argc->client_ip);
|
||||
|
||||
if (argc->dacp_server_active) {
|
||||
shairport_sync_remote_control_set_available(shairportSyncRemoteControlSkeleton, TRUE);
|
||||
} else {
|
||||
shairport_sync_remote_control_set_available(shairportSyncRemoteControlSkeleton, FALSE);
|
||||
}
|
||||
|
||||
if (argc->advanced_dacp_server_active) {
|
||||
shairport_sync_advanced_remote_control_set_available(shairportSyncAdvancedRemoteControlSkeleton, TRUE);
|
||||
} else {
|
||||
shairport_sync_advanced_remote_control_set_available(shairportSyncAdvancedRemoteControlSkeleton, FALSE);
|
||||
}
|
||||
|
||||
GVariantBuilder *dict_builder, *aa;
|
||||
|
||||
@@ -293,6 +303,63 @@ gboolean notify_loudness_threshold_callback(ShairportSync *skeleton,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean notify_alacdecoder_callback(ShairportSync *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
char* th = (char *)shairport_sync_get_alacdecoder(skeleton);
|
||||
#ifdef HAVE_APPLE_ALAC
|
||||
if (strcasecmp(th,"hammerton")==0)
|
||||
config.use_apple_decoder = 0;
|
||||
else if (strcasecmp(th,"apple")==0)
|
||||
config.use_apple_decoder = 1;
|
||||
else
|
||||
warn("Unrecognised ALAC decoder: \"%s\".",th);
|
||||
// debug(1,"Using the %s ALAC decoder.", ((config.use_apple_decoder==0) ? "Hammerton" : "Apple"));
|
||||
#else
|
||||
if (strcasecmp(th,"hammerton")==0) {
|
||||
config.use_apple_decoder = 0;
|
||||
// debug(1,"Using the Hammerton ALAC decoder.");
|
||||
} else
|
||||
warn("Unrecognised ALAC decoder: \"%s\" (or else support for this decoder was not compiled into this version of Shairport Sync).",th);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean notify_interpolation_callback(ShairportSync *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
char* th = (char *)shairport_sync_get_interpolation(skeleton);
|
||||
#ifdef HAVE_LIBSOXR
|
||||
if (strcasecmp(th,"basic")==0)
|
||||
config.packet_stuffing = ST_basic;
|
||||
else if (strcasecmp(th,"soxr")==0)
|
||||
config.packet_stuffing = ST_soxr;
|
||||
else
|
||||
warn("Unrecognised interpolation: \"%s\".",th);
|
||||
#else
|
||||
if (strcasecmp(th,"basic")==0)
|
||||
config.packet_stuffing = ST_basic;
|
||||
} else
|
||||
warn("Unrecognised interpolation method: \"%s\" (or else support for this interolation method was not compiled into this version of Shairport Sync).",th);
|
||||
#endif
|
||||
debug(1,"Using %s interpolation (aka \"stuffing\").", ((config.packet_stuffing==ST_basic) ? "basic" : "soxr"));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean notify_volume_control_profile_callback(ShairportSync *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
char* th = (char *)shairport_sync_get_volume_control_profile(skeleton);
|
||||
enum volume_control_profile_type previous_volume_control_profile = config.volume_control_profile;
|
||||
if (strcasecmp(th,"standard")==0)
|
||||
config.volume_control_profile = VCP_standard;
|
||||
else if (strcasecmp(th,"flat")==0)
|
||||
config.volume_control_profile = VCP_flat;
|
||||
else
|
||||
warn("Unrecognised Volume Control Profile: \"%s\".",th);
|
||||
debug(1,"Using the %s Volume Control Profile.", ((config.volume_control_profile==VCP_standard) ? "Standard" : "Flat"));
|
||||
if (previous_volume_control_profile!=config.volume_control_profile)
|
||||
debug(1,"Should really reset volume now, maybe?");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_remote_command(ShairportSync *skeleton, GDBusMethodInvocation *invocation,
|
||||
const gchar *command,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
@@ -308,26 +375,74 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
|
||||
// debug(1, "Shairport Sync native D-Bus interface \"%s\" acquired on the %s bus.", name,
|
||||
// (config.dbus_service_bus_type == DBT_session) ? "session" : "system");
|
||||
shairportSyncSkeleton = shairport_sync_skeleton_new();
|
||||
|
||||
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncSkeleton), connection,
|
||||
"/org/gnome/ShairportSync", NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
shairport_sync_set_loudness_threshold(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
config.loudness_reference_volume_db);
|
||||
debug(1, "Loudness threshold is %f.", config.loudness_reference_volume_db);
|
||||
|
||||
#ifdef HAVE_APPLE_ALAC
|
||||
if (config.use_apple_decoder==0)
|
||||
shairport_sync_set_alacdecoder(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"hammerton");
|
||||
else
|
||||
shairport_sync_set_alacdecoder(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"apple");
|
||||
#else
|
||||
shairport_sync_set_alacdecoder(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"hammerton");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SOXR
|
||||
if (config.packet_stuffing == ST_basic)
|
||||
shairport_sync_set_interpolation(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"basic");
|
||||
else
|
||||
shairport_sync_set_interpolation(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"soxr");
|
||||
#else
|
||||
shairport_sync_set_interpolation(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"basic");
|
||||
#endif
|
||||
|
||||
if (config.volume_control_profile==VCP_standard)
|
||||
shairport_sync_set_volume_control_profile(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"standard");
|
||||
else
|
||||
shairport_sync_set_volume_control_profile(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
"flat");
|
||||
|
||||
if (config.loudness == 0) {
|
||||
shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE);
|
||||
debug(1, "Loudness is off");
|
||||
} else {
|
||||
shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE);
|
||||
debug(1, "Loudness is on");
|
||||
}
|
||||
|
||||
shairport_sync_set_version(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
PACKAGE_VERSION);
|
||||
char * vs = get_version_string();
|
||||
shairport_sync_set_version_string(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
vs);
|
||||
if (vs)
|
||||
free(vs);
|
||||
|
||||
g_signal_connect(shairportSyncSkeleton, "notify::interpolation",
|
||||
G_CALLBACK(notify_interpolation_callback), NULL);
|
||||
g_signal_connect(shairportSyncSkeleton, "notify::alacdecoder",
|
||||
G_CALLBACK(notify_alacdecoder_callback), NULL);
|
||||
g_signal_connect(shairportSyncSkeleton, "notify::volume-control-profile",
|
||||
G_CALLBACK(notify_volume_control_profile_callback), NULL);
|
||||
g_signal_connect(shairportSyncSkeleton, "notify::loudness-filter-active",
|
||||
G_CALLBACK(notify_loudness_filter_active_callback), NULL);
|
||||
g_signal_connect(shairportSyncSkeleton, "notify::loudness-threshold",
|
||||
G_CALLBACK(notify_loudness_threshold_callback), NULL);
|
||||
|
||||
g_signal_connect(shairportSyncSkeleton, "handle-remote-command",
|
||||
G_CALLBACK(on_handle_remote_command), NULL);
|
||||
|
||||
@@ -428,10 +543,6 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
|
||||
|
||||
add_metadata_watcher(dbus_metadata_watcher, NULL);
|
||||
|
||||
#ifdef HAVE_DBUS_REMOTE_CONTROL
|
||||
dbus_remote_control_on_dbus_name_acquired(connection, name, user_data);
|
||||
#endif
|
||||
|
||||
debug(1, "Shairport Sync native D-Bus service started at \"%s\" on the %s bus.", name,
|
||||
(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ typedef struct metadata_bundle {
|
||||
|
||||
int dacp_server_active; // true if there's a reachable DACP server (assumed to be the Airplay
|
||||
// client) ; false otherwise
|
||||
int advanced_dacp_server_active; // true if there's a reachable DACP server with iTunes capabilitiues
|
||||
// ; false otherwise
|
||||
|
||||
int changed; // normally 0, nonzero if a field has been changed
|
||||
int playerstatusupdates_are_received; // false if it's "traditional" metadata
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
<method name="RemoteCommand">
|
||||
<arg name="command" type="s" direction="in" />
|
||||
</method>
|
||||
<property name="VolumeControlProfile" type="s" access="readwrite" />
|
||||
<property name="Interpolation" type="s" access="readwrite" />
|
||||
<property name="ALACDecoder" type="s" access="readwrite" />
|
||||
<property name="Version" type="s" access="read" />
|
||||
<property name="VersionString" type="s" access="read" />
|
||||
</interface>
|
||||
<interface name="org.gnome.ShairportSync.Diagnostics">
|
||||
<property name="Verbosity" type="i" access="readwrite" />
|
||||
@@ -33,8 +38,11 @@
|
||||
<property name='Metadata' type='a{sv}' access='read'>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
|
||||
</property>
|
||||
<property name='Available' type='b' access='read'/>
|
||||
</interface>
|
||||
<interface name="org.gnome.ShairportSync.Advanced.Remote.Control">
|
||||
<property name='Available' type='b' access='read'/>
|
||||
<property name='PlaybackStatus' type='s' access='read'/>
|
||||
<property name="Volume" type="i" access="read" />
|
||||
<method name="SetVolume">
|
||||
<arg name="volume" type="i" direction="in" />
|
||||
|
||||
@@ -1573,12 +1573,13 @@ static void *player_thread_func(void *arg) {
|
||||
if (tbuf == NULL)
|
||||
die("Failed to allocate memory for the transition buffer.");
|
||||
sbuf = 0;
|
||||
if (config.packet_stuffing == ST_soxr) { // needed for stuffing
|
||||
// initialise this, because soxr stuffing might be chosen later
|
||||
// if (config.packet_stuffing == ST_soxr) { // needed for stuffing
|
||||
sbuf = malloc(sizeof(int32_t) * 2 * (conn->max_frames_per_packet * conn->output_sample_ratio +
|
||||
conn->max_frame_size_change));
|
||||
if (sbuf == NULL)
|
||||
debug(1, "Failed to allocate memory for the sbuf buffer.");
|
||||
}
|
||||
// }
|
||||
// We might need an output buffer and a buffer of silence.
|
||||
// The size of these dependents on the number of frames, the size of each frame and the maximum
|
||||
// size change
|
||||
|
||||
-67
@@ -140,73 +140,6 @@ static void sig_connect_audio_output(__attribute__((unused)) int foo,
|
||||
set_requested_connection_state_to_output(1);
|
||||
}
|
||||
|
||||
char *get_version_string() {
|
||||
char *version_string = malloc(200);
|
||||
if (version_string) {
|
||||
strcpy(version_string, PACKAGE_VERSION);
|
||||
#ifdef HAVE_LIBMBEDTLS
|
||||
strcat(version_string, "-mbedTLS");
|
||||
#endif
|
||||
#ifdef HAVE_LIBPOLARSSL
|
||||
strcat(version_string, "-PolarSSL");
|
||||
#endif
|
||||
#ifdef HAVE_LIBSSL
|
||||
strcat(version_string, "-OpenSSL");
|
||||
#endif
|
||||
#ifdef CONFIG_TINYSVCMDNS
|
||||
strcat(version_string, "-tinysvcmdns");
|
||||
#endif
|
||||
#ifdef CONFIG_AVAHI
|
||||
strcat(version_string, "-Avahi");
|
||||
#endif
|
||||
#ifdef CONFIG_DNS_SD
|
||||
strcat(version_string, "-dns_sd");
|
||||
#endif
|
||||
#ifdef CONFIG_ALSA
|
||||
strcat(version_string, "-ALSA");
|
||||
#endif
|
||||
#ifdef CONFIG_SNDIO
|
||||
strcat(version_string, "-sndio");
|
||||
#endif
|
||||
#ifdef CONFIG_AO
|
||||
strcat(version_string, "-ao");
|
||||
#endif
|
||||
#ifdef CONFIG_PA
|
||||
strcat(version_string, "-pa");
|
||||
#endif
|
||||
#ifdef CONFIG_SOUNDIO
|
||||
strcat(version_string, "-soundio");
|
||||
#endif
|
||||
#ifdef CONFIG_DUMMY
|
||||
strcat(version_string, "-dummy");
|
||||
#endif
|
||||
#ifdef CONFIG_STDOUT
|
||||
strcat(version_string, "-stdout");
|
||||
#endif
|
||||
#ifdef CONFIG_PIPE
|
||||
strcat(version_string, "-pipe");
|
||||
#endif
|
||||
#ifdef HAVE_LIBSOXR
|
||||
strcat(version_string, "-soxr");
|
||||
#endif
|
||||
#ifdef CONFIG_CONVOLUTION
|
||||
strcat(version_string, "-convolution");
|
||||
#endif
|
||||
#ifdef CONFIG_METADATA
|
||||
strcat(version_string, "-metadata");
|
||||
#endif
|
||||
#ifdef HAVE_DBUS
|
||||
strcat(version_string, "-dbus");
|
||||
#endif
|
||||
#ifdef HAVE_MPRIS
|
||||
strcat(version_string, "-mpris");
|
||||
#endif
|
||||
strcat(version_string, "-sysconfdir:");
|
||||
strcat(version_string, SYSCONFDIR);
|
||||
}
|
||||
return version_string;
|
||||
}
|
||||
|
||||
void print_version(void) {
|
||||
char *version_string = get_version_string();
|
||||
if (version_string) {
|
||||
|
||||
Reference in New Issue
Block a user