summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Toso <victortoso@redhat.com>2015-03-06 18:15:35 +0100
committerVictor Toso <victortoso@redhat.com>2015-04-24 17:31:20 +0200
commit9b0eb8b1246ccb422ccecc3679b0bb6b477ba6cb (patch)
tree6fb3a34a01b98f004eb13408176c4ff17574525b
parent010dc21f35fb3997ade6717e10c6a3b52a1737ba (diff)
downloadvd_agent-9b0eb8b1246ccb422ccecc3679b0bb6b477ba6cb.tar.gz
vd_agent-9b0eb8b1246ccb422ccecc3679b0bb6b477ba6cb.tar.xz
vd_agent-9b0eb8b1246ccb422ccecc3679b0bb6b477ba6cb.zip
vdagent: volume synchronization from client.
Include the capability of volume sync to set volume or mute to default sink-input/source-output of guest.
-rw-r--r--src/vdagent.c11
-rw-r--r--src/vdagentd-proto.h1
-rw-r--r--src/vdagentd.c21
3 files changed, 33 insertions, 0 deletions
diff --git a/src/vdagent.c b/src/vdagent.c
index 9d130d5..348dfbd 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -40,6 +40,7 @@
#include "udscs.h"
#include "vdagentd-proto.h"
#include "vdagentd-proto-strings.h"
+#include "vdagent-audio.h"
#include "vdagent-x11.h"
#include "vdagent-file-xfers.h"
@@ -109,6 +110,16 @@ void daemon_read_complete(struct udscs_connection **connp,
}
free(data);
break;
+ case VDAGENTD_AUDIO_VOLUME_SYNC: {
+ VDAgentAudioVolumeSync *avs = (VDAgentAudioVolumeSync *)data;
+ if (avs->is_playback) {
+ vdagent_audio_playback_sync(avs->mute, avs->nchannels, avs->volume);
+ } else {
+ vdagent_audio_record_sync(avs->mute, avs->nchannels, avs->volume);
+ }
+ free(data);
+ break;
+ }
case VDAGENTD_FILE_XFER_DATA:
if (vdagent_file_xfers != NULL) {
vdagent_file_xfers_data(vdagent_file_xfers,
diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h
index 25e6a36..0dbaaea 100644
--- a/src/vdagentd-proto.h
+++ b/src/vdagentd-proto.h
@@ -36,6 +36,7 @@ enum {
VDAGENTD_CLIPBOARD_DATA, /* arg1: sel, arg 2: type, data: data */
VDAGENTD_CLIPBOARD_RELEASE, /* arg1: selection */
VDAGENTD_VERSION, /* daemon -> client, data: version string */
+ VDAGENTD_AUDIO_VOLUME_SYNC,
VDAGENTD_FILE_XFER_START,
VDAGENTD_FILE_XFER_STATUS,
VDAGENTD_FILE_XFER_DATA,
diff --git a/src/vdagentd.c b/src/vdagentd.c
index b5c7d14..14c5be1 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -101,6 +101,7 @@ static void send_capabilities(struct vdagent_virtio_port *vport,
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_SPARSE_MONITORS_CONFIG);
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_GUEST_LINEEND_LF);
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MAX_CLIPBOARD);
+ VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_AUDIO_VOLUME_SYNC);
vdagent_virtio_port_write(vport, VDP_CLIENT_PORT,
VD_AGENT_ANNOUNCE_CAPABILITIES, 0,
@@ -156,6 +157,19 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr,
(uint8_t *)&reply, sizeof(reply));
}
+static void do_client_volume_sync(struct vdagent_virtio_port *vport, int port_nr,
+ VDAgentMessage *message_header,
+ VDAgentAudioVolumeSync *avs)
+{
+ if (active_session_conn == NULL) {
+ syslog(LOG_DEBUG, "No active session - Can't volume-sync");
+ return;
+ }
+
+ udscs_write(active_session_conn, VDAGENTD_AUDIO_VOLUME_SYNC, 0, 0,
+ (uint8_t *)avs, message_header->size);
+}
+
static void do_client_capabilities(struct vdagent_virtio_port *vport,
VDAgentMessage *message_header,
VDAgentAnnounceCapabilities *caps)
@@ -379,6 +393,13 @@ int virtio_port_read_complete(
syslog(LOG_DEBUG, "Set max clipboard: %d", msg->max);
max_clipboard = msg->max;
break;
+ case VD_AGENT_AUDIO_VOLUME_SYNC:
+ if (message_header->size < sizeof(VDAgentAudioVolumeSync))
+ goto size_error;
+
+ do_client_volume_sync(vport, port_nr, message_header,
+ (VDAgentAudioVolumeSync *)data);
+ break;
default:
syslog(LOG_WARNING, "unknown message type %d, ignoring",
message_header->type);