From: Mike Brady Date: Sun, 15 Oct 2017 12:08:21 +0000 (+0100) Subject: Generalise volumeup to any command. X-Git-Tag: 3.2d10~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=415b3f4ba9bbf9b1a5f4896aa292d4662ac23cdb;p=thirdparty%2Fshairport-sync.git Generalise volumeup to any command. --- diff --git a/dbus/src/dbus_service.c b/dbus/src/dbus_service.c index 63ee95df..28103243 100644 --- a/dbus/src/dbus_service.c +++ b/dbus/src/dbus_service.c @@ -47,13 +47,13 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) { return TRUE; } -static gboolean on_handle_vol_up(ShairportSync *skeleton, GDBusMethodInvocation *invocation, gpointer user_data) { - debug(1,"VolUp"); +static gboolean on_handle_remote_command(ShairportSync *skeleton, GDBusMethodInvocation *invocation, const gchar *command, gpointer user_data) { + debug(1,"RemoteCommand with command \"%s\".",command); if (playing_conn) - rtp_send_client_command(playing_conn,"volumeup"); + rtp_send_client_command(playing_conn,command); else - debug(1, "no thread playing -- VolUp ignored."); - shairport_sync_complete_vol_up(skeleton,invocation); + debug(1, "no thread playing -- RemoteCommand ignored."); + shairport_sync_complete_remote_command(skeleton,invocation); return TRUE; } @@ -81,7 +81,7 @@ static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpo g_signal_connect(skeleton, "notify::loudness-threshold", G_CALLBACK(notify_loudness_threshold_callback), NULL); g_signal_connect(skeleton, "notify::volume", G_CALLBACK(notify_volume_callback), NULL); - g_signal_connect(skeleton, "handle-vol-up", G_CALLBACK(on_handle_vol_up), NULL); + g_signal_connect(skeleton, "handle-remote-command", G_CALLBACK(on_handle_remote_command), NULL); } int start_dbus_service() { diff --git a/dbus/src/org.gnome.ShairportSync.xml b/dbus/src/org.gnome.ShairportSync.xml index b9f152b0..8bba3609 100644 --- a/dbus/src/org.gnome.ShairportSync.xml +++ b/dbus/src/org.gnome.ShairportSync.xml @@ -4,7 +4,8 @@ - + + diff --git a/dbus/src/shairport-sync-dbus-client.c b/dbus/src/shairport-sync-dbus-client.c index c118374c..6b576884 100644 --- a/dbus/src/shairport-sync-dbus-client.c +++ b/dbus/src/shairport-sync-dbus-client.c @@ -109,7 +109,7 @@ void main(void) { shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), FALSE); sleep(1); */ - shairport_sync_call_vol_up(SHAIRPORT_SYNC(proxy), NULL,NULL,NULL); + shairport_sync_call_remote_command(SHAIRPORT_SYNC(proxy), "string",NULL,NULL,NULL); g_print("Finished test...\n"); g_main_loop_quit(loop); pthread_join(dbus_thread, NULL); diff --git a/rtp.c b/rtp.c index 7c5cb5a2..5b373dbf 100644 --- a/rtp.c +++ b/rtp.c @@ -759,7 +759,7 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) { } } -void rtp_send_client_command(rtsp_conn_info *conn, char *command) { +void rtp_send_client_command(rtsp_conn_info *conn, const char *command) { if (conn->rtp_running) { if (conn->dacp_port == 0) { debug(1, "Can't request a client pause: no valid active remote."); @@ -768,7 +768,7 @@ void rtp_send_client_command(rtsp_conn_info *conn, char *command) { struct addrinfo hints, *res; int sockfd; - char message[1000], server_reply[2000], portstring[10], server[256]; + char message[20000], server_reply[2000], portstring[10], server[256]; memset(&message, 0, sizeof(message)); memset(&server_reply, 0, sizeof(server_reply)); memset(&portstring, 0, sizeof(portstring)); @@ -814,13 +814,23 @@ void rtp_send_client_command(rtsp_conn_info *conn, char *command) { } // Receive a reply from the server - if (recv(sockfd, server_reply, 2000, 0) < 0) { + ssize_t reply_size = recv(sockfd, server_reply, 2000, 0); + if (reply_size < 0) { debug(1, "recv failed"); } - if (strstr(server_reply, "HTTP/1.1 204 No Content") != server_reply) - debug(1, "Client request to server failed: \"%s\".", server_reply); - + if (strstr(server_reply, "HTTP/1.1 204 No Content") != server_reply) { + debug(1, "Client request to server failed with %d characters starting with this response:", reply_size,server_reply); + int i; + + for (i=0;i