Generalise volumeup to any command.
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
<property name="LoudnessFilterActive" type="b" access="readwrite" />
|
||||
<property name="LoudnessThreshold" type="d" access="readwrite" />
|
||||
<property name="Volume" type="d" access="readwrite" />
|
||||
<method name="VolUp">
|
||||
<method name="RemoteCommand">
|
||||
<arg name="command" type="s" direction="in" />
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<reply_size;i++)
|
||||
if (server_reply[i] < ' ')
|
||||
debug(1,"%d %02x", i, server_reply[i]);
|
||||
else
|
||||
debug(1,"%d %02x '%c'", i, server_reply[i],server_reply[i]);
|
||||
//sprintf((char *)message + 2 * i, "%02x", server_reply[i]);
|
||||
//debug(1,"Content is \"%s\".",message);
|
||||
}
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ void clear_reference_timestamp(rtsp_conn_info *conn);
|
||||
uint64_t static local_to_remote_time_jitters;
|
||||
uint64_t static local_to_remote_time_jitters_count;
|
||||
|
||||
void rtp_send_client_command(rtsp_conn_info *conn,char * command);
|
||||
void rtp_send_client_command(rtsp_conn_info *conn,const char * command);
|
||||
|
||||
#endif // _RTP_H
|
||||
|
||||
Reference in New Issue
Block a user