[Spice-commits] 5 commits - client/smartcard_channel.cpp configure.ac python_modules/codegen.py server/Makefile.am server/tests

Alon Levy alon at kemper.freedesktop.org
Tue Mar 22 03:47:19 PDT 2011


 client/smartcard_channel.cpp |    8 +--
 configure.ac                 |    2 
 python_modules/codegen.py    |    2 
 server/Makefile.am           |    1 
 server/tests/Makefile.am     |    5 +-
 server/tests/test_playback.c |   99 +++++++++++++++++++++++++++++++++++++++++++
 server/tests/test_util.h     |    2 
 7 files changed, 112 insertions(+), 7 deletions(-)

New commits:
commit 02c3f54deb780d01f89edd52a2be05cdaa3556a8
Author: Alon Levy <alevy at redhat.com>
Date:   Tue Mar 8 21:17:56 2011 +0200

    server/tests: add test_playback

diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index 3494e5c..9d20264 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -9,7 +9,7 @@ INCLUDES =                          \
 
 AM_LDFLAGS = -L../.libs -lspice-server
 
-noinst_PROGRAMS = test_just_sockets_no_ssl test_empty_success test_fail_on_null_core_interface test_display_no_ssl test_display_streaming
+noinst_PROGRAMS = test_just_sockets_no_ssl test_empty_success test_fail_on_null_core_interface test_display_no_ssl test_display_streaming test_playback
 
 test_display_streaming_SOURCES = test_display_streaming.c test_display_base.c basic_event_loop.c basic_event_loop.h test_util.h
 
@@ -29,4 +29,7 @@ test_fail_on_null_core_interface_SOURCES = test_fail_on_null_core_interface.c
 
 test_fail_on_null_core_interface_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS)
 
+test_playback_SOURCES = test_playback.c basic_event_loop.c basic_event_loop.h test_util.h
+
+test_playback_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS)
 
diff --git a/server/tests/test_playback.c b/server/tests/test_playback.c
new file mode 100644
index 0000000..18220ea
--- /dev/null
+++ b/server/tests/test_playback.c
@@ -0,0 +1,99 @@
+#include <stdio.h>
+#include <strings.h>
+#include <sys/select.h>
+#include <math.h>
+
+#include <spice.h>
+#include "test_util.h"
+#include "basic_event_loop.h"
+
+/* test the audio playback interface. Really basic no frils test - create
+ * a single tone sinus sound (easy to hear clicks if it is generated badly
+ * or is transmitted badly).
+ *
+ * TODO: Was going to do white noise to test compression too.
+ *
+ * TODO: gstreamer based test (could be used to play music files so
+ * it has actual merit. Also possibly to simulate network effects?)
+ * */
+
+SpicePlaybackInstance playback_instance;
+
+static const SpicePlaybackInterface playback_sif = {
+    .base.type          = SPICE_INTERFACE_PLAYBACK,
+    .base.description   = "test playback",
+    .base.major_version = SPICE_INTERFACE_PLAYBACK_MAJOR,
+    .base.minor_version = SPICE_INTERFACE_PLAYBACK_MINOR,
+};
+
+uint32_t *frame;
+uint32_t num_samples;
+SpiceTimer *playback_timer;
+int playback_timer_ms;
+SpiceCoreInterface *core;
+
+void playback_timer_cb(void *opaque)
+{
+    static int t = 0;
+    static uint64_t last_sent_usec = 0;
+    static uint64_t samples_to_send;
+    int i;
+    struct timeval cur;
+    uint64_t cur_usec;
+    uint32_t batches;
+
+    if (!frame) {
+        spice_server_playback_get_buffer(&playback_instance, &frame, &num_samples);
+        if (frame) {
+            playback_timer_ms = num_samples ? 1000*num_samples/SPICE_INTERFACE_PLAYBACK_FREQ : 100;
+        } else {
+            /* continue waiting until there is a channel */
+            core->timer_start(playback_timer, playback_timer_ms);
+            return;
+        }
+    }
+    /* we have a channel */
+    gettimeofday(&cur, NULL);
+    cur_usec = cur.tv_usec + cur.tv_sec * 1e6;
+    if (last_sent_usec == 0) {
+        samples_to_send = num_samples;
+    } else {
+        samples_to_send += (cur_usec - last_sent_usec) * SPICE_INTERFACE_PLAYBACK_FREQ / 1e6;
+    }
+    last_sent_usec = cur_usec;
+    batches = samples_to_send / num_samples;
+#if 0
+    printf("samples_to_send = %d, batches = %d\n", samples_to_send, batches);
+#endif
+    samples_to_send -= num_samples * batches;
+    for (;batches > 0 ; --batches) {
+        for (i = 0 ; i < num_samples; ++i) {
+            frame[i] = (((uint16_t)((1<<14)*sin((t+i)/10))) << 16) + (((uint16_t)((1<<14)*sin((t+i)/10))));
+        }
+        t += num_samples;
+        spice_server_playback_put_samples(&playback_instance, frame);
+    }
+    core->timer_start(playback_timer, playback_timer_ms);
+}
+
+int main()
+{
+    SpiceServer *server = spice_server_new();
+    core = basic_event_loop_init();
+
+    spice_server_set_port(server, 5701);
+    spice_server_set_noauth(server);
+    spice_server_init(server, core);
+
+    playback_instance.base.sif = &playback_sif.base;
+    spice_server_add_interface(server, &playback_instance.base);
+    spice_server_playback_start(&playback_instance);
+
+    playback_timer_ms = 100;
+    playback_timer = core->timer_add(playback_timer_cb, NULL);
+    core->timer_start(playback_timer, playback_timer_ms);
+
+    basic_event_loop_mainloop();
+
+    return 0;
+}
diff --git a/server/tests/test_util.h b/server/tests/test_util.h
index ac1442d..5344a4f 100644
--- a/server/tests/test_util.h
+++ b/server/tests/test_util.h
@@ -9,4 +9,6 @@
     abort();                                                \
 }
 
+#define MIN(a,b) ((a) > (b) ? (b) : (a))
+
 #endif // __TEST_UTIL_H__
commit 5fc7fb68aebb884c4a99e85c71ffd88e119c73dc
Author: Alon Levy <alevy at redhat.com>
Date:   Wed Mar 9 23:14:01 2011 +0200

    configure.ac: fix message when missing SASL lib

diff --git a/configure.ac b/configure.ac
index 31e832b..5580a5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -337,7 +337,7 @@ if test "x$with_sasl" != "xno"; then
   elif test "x$with_sasl" = "xyes"; then
     SASL_LIBS="$SASL_LIBS -lsasl"
   else
-    AC_MSG_ERROR([You must install the Cyrus SASL development package in order to compile GTK-VNC])
+    AC_MSG_ERROR([Missing required Cyrus SASL development package])
   fi
   CFLAGS="$old_cflags"
   LIBS="$old_libs"
commit 43c5b4f97334f0f4ca61bdd679b68d079575deac
Author: Alon Levy <alevy at redhat.com>
Date:   Mon Dec 13 01:54:12 2010 +0200

    server: use -std=c99
    
    Finds some bugs.

diff --git a/server/Makefile.am b/server/Makefile.am
index 5a5106e..7ab8c3d 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -19,6 +19,7 @@ INCLUDES = \
 	$(WARN_CFLAGS)                          \
 	$(VISIBILITY_HIDDEN_CFLAGS)		\
 	$(SMARTCARD_CFLAGS)				\
+	-std=gnu99 \
 	$(NULL)
 
 spice_built_sources = generated_marshallers.c generated_marshallers.h generated_demarshallers.c
commit 127f83afc22a651efdee40b63aeadebfae4b5bec
Author: Alon Levy <alevy at redhat.com>
Date:   Sat Dec 11 15:55:19 2010 +0200

    python_modules/codegen.py: fix indent error in an unused function

diff --git a/python_modules/codegen.py b/python_modules/codegen.py
index 03c67e6..75033dc 100644
--- a/python_modules/codegen.py
+++ b/python_modules/codegen.py
@@ -11,7 +11,7 @@ def camel_to_underscores(s, upper = False):
             res = res + c.upper()
         else:
             res = res + c.lower()
-        return res
+    return res
 
 def underscores_to_camel(s):
     res = ""
commit 644b7271845cdb870e3a598c566b76932343b9ac
Author: Alon Levy <alevy at redhat.com>
Date:   Mon Dec 13 02:17:19 2010 +0200

    client/smartcard: use proper include delemiters

diff --git a/client/smartcard_channel.cpp b/client/smartcard_channel.cpp
index 98f24a8..272d29d 100644
--- a/client/smartcard_channel.cpp
+++ b/client/smartcard_channel.cpp
@@ -4,10 +4,10 @@
 #include "mutex.h"
 
 extern "C" {
-#include "vscard_common.h"
-#include "vreader.h"
-#include "vcard_emul.h"
-#include "vevent.h"
+#include <vscard_common.h>
+#include <vreader.h>
+#include <vcard_emul.h>
+#include <vevent.h>
 }
 
 #include "smartcard_channel.h"


More information about the Spice-commits mailing list