summaryrefslogtreecommitdiffstats
path: root/server/main_dispatcher.c
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2013-01-25 09:27:33 -0500
committerYonit Halperin <yhalperi@redhat.com>2013-04-22 16:30:55 -0400
commit073aeec569e2bee3feec8042986b8434db8afad3 (patch)
treeaa4abff930aed959f0981a7b3a197697d40832b5 /server/main_dispatcher.c
parenta9087c4c8a1cf38c9dae331a9255f0dc6823e7b8 (diff)
downloadspice-073aeec569e2bee3feec8042986b8434db8afad3.tar.gz
spice-073aeec569e2bee3feec8042986b8434db8afad3.tar.xz
spice-073aeec569e2bee3feec8042986b8434db8afad3.zip
reds: support mm_time latency adjustments
When there is no audio playback, we set the mm_time in the client to be older than the one in the server by at least the requested latency (the delta is actually bigger, due to the network latency). When there is an audio playback, we adjust the mm_time in the client by adjusting the playback buffer using SPICE_MSG_PLAYBACK_LATENCY.
Diffstat (limited to 'server/main_dispatcher.c')
-rw-r--r--server/main_dispatcher.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/main_dispatcher.c b/server/main_dispatcher.c
index 1126ec06..84024024 100644
--- a/server/main_dispatcher.c
+++ b/server/main_dispatcher.c
@@ -40,6 +40,7 @@ MainDispatcher main_dispatcher;
enum {
MAIN_DISPATCHER_CHANNEL_EVENT = 0,
MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
+ MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
MAIN_DISPATCHER_NUM_MESSAGES
};
@@ -53,6 +54,11 @@ typedef struct MainDispatcherMigrateSeamlessDstCompleteMessage {
RedClient *client;
} MainDispatcherMigrateSeamlessDstCompleteMessage;
+typedef struct MainDispatcherMmTimeLatencyMessage {
+ RedClient *client;
+ uint32_t latency;
+} MainDispatcherMmTimeLatencyMessage;
+
/* channel_event - calls core->channel_event, must be done in main thread */
static void main_dispatcher_self_handle_channel_event(
int event,
@@ -96,6 +102,13 @@ static void main_dispatcher_handle_migrate_complete(void *opaque,
reds_on_client_seamless_migrate_complete(mig_complete->client);
}
+static void main_dispatcher_handle_mm_time_latency(void *opaque,
+ void *payload)
+{
+ MainDispatcherMmTimeLatencyMessage *msg = payload;
+ reds_set_client_mm_time_latency(msg->client, msg->latency);
+}
+
void main_dispatcher_seamless_migrate_dst_complete(RedClient *client)
{
MainDispatcherMigrateSeamlessDstCompleteMessage msg;
@@ -109,6 +122,22 @@ void main_dispatcher_seamless_migrate_dst_complete(RedClient *client)
dispatcher_send_message(&main_dispatcher.base, MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
&msg);
}
+
+void main_dispatcher_set_mm_time_latency(RedClient *client, uint32_t latency)
+{
+ MainDispatcherMmTimeLatencyMessage msg;
+
+ if (pthread_self() == main_dispatcher.base.self) {
+ reds_set_client_mm_time_latency(client, latency);
+ return;
+ }
+
+ msg.client = client;
+ msg.latency = latency;
+ dispatcher_send_message(&main_dispatcher.base, MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
+ &msg);
+}
+
static void dispatcher_handle_read(int fd, int event, void *opaque)
{
Dispatcher *dispatcher = opaque;
@@ -129,4 +158,7 @@ void main_dispatcher_init(SpiceCoreInterface *core)
dispatcher_register_handler(&main_dispatcher.base, MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
main_dispatcher_handle_migrate_complete,
sizeof(MainDispatcherMigrateSeamlessDstCompleteMessage), 0 /* no ack */);
+ dispatcher_register_handler(&main_dispatcher.base, MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
+ main_dispatcher_handle_mm_time_latency,
+ sizeof(MainDispatcherMmTimeLatencyMessage), 0 /* no ack */);
}