[Spice-devel] [vdagent-linux PATCH 2/2] vdagent: volume synchronization from client.
Victor Toso
victortoso at redhat.com
Tue Apr 14 05:18:53 PDT 2015
Include the capability of volume sync to set volume or mute to default
sink-input/source-output of guest.
---
src/vdagent.c | 11 +++++++++++
src/vdagentd-proto.h | 1 +
src/vdagentd.c | 21 +++++++++++++++++++++
3 files changed, 33 insertions(+)
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);
--
2.1.0
More information about the Spice-devel
mailing list