[polypaudio-commits] r618 - in /trunk/src: Makefile.am polyp/def.h polyp/internal.h polyp/stream.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Mar 2 08:32:37 PST 2006


Author: ossman
Date: Thu Mar  2 17:32:36 2006
New Revision: 618

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=618&root=polypaudio&view=rev
Log:
Handle the new latency protocol. This is just a quick fix and does not
handle the new memblockq system.

Modified:
    trunk/src/Makefile.am
    trunk/src/polyp/def.h
    trunk/src/polyp/internal.h
    trunk/src/polyp/stream.c

Modified: trunk/src/Makefile.am
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/Makefile.am?rev=618&root=polypaudio&r1=617&r2=618&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Thu Mar  2 17:32:36 2006
@@ -346,6 +346,7 @@
 		polypcore/conf-parser.c polypcore/conf-parser.h \
 		polypcore/dynarray.c polypcore/dynarray.h \
 		polypcore/gccmacro.h \
+		polypcore/hashmap.c polypcore/hashmap.h \
 		polypcore/idxset.c polypcore/idxset.h \
 		polypcore/iochannel.c polypcore/iochannel.h \
 		polypcore/log.c polypcore/log.h \

Modified: trunk/src/polyp/def.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/def.h?rev=618&root=polypaudio&r1=617&r2=618&view=diff
==============================================================================
--- trunk/src/polyp/def.h (original)
+++ trunk/src/polyp/def.h Thu Mar  2 17:32:36 2006
@@ -195,6 +195,8 @@
                                * 0.5 */
     struct timeval timestamp; /**< The time when this latency info was current */
     uint64_t counter;         /**< The byte counter current when the latency info was requested. \since 0.6 */
+    int64_t write_index;      /**< Current absolute write index in the buffer. \since 0.8 */
+    int64_t read_index;       /**< Current absolute read index in the buffer. \since 0.8 */
 } pa_latency_info;
 
 /** A structure for the spawn api. This may be used to integrate auto

Modified: trunk/src/polyp/internal.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/internal.h?rev=618&root=polypaudio&r1=617&r2=618&view=diff
==============================================================================
--- trunk/src/polyp/internal.h (original)
+++ trunk/src/polyp/internal.h Thu Mar  2 17:32:36 2006
@@ -37,6 +37,7 @@
 #include <polypcore/strlist.h>
 #include <polypcore/mcalign.h>
 #include <polypcore/memblockq.h>
+#include <polypcore/hashmap.h>
 
 #include "client-conf.h"
 
@@ -103,6 +104,8 @@
     pa_stream_state_t state;
     pa_memchunk peek_memchunk;
     pa_memblockq *record_memblockq;
+
+    pa_hashmap *counter_hashmap;
 
     int interpolate;
     int corked;

Modified: trunk/src/polyp/stream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/stream.c?rev=618&root=polypaudio&r1=617&r2=618&view=diff
==============================================================================
--- trunk/src/polyp/stream.c (original)
+++ trunk/src/polyp/stream.c Thu Mar  2 17:32:36 2006
@@ -33,10 +33,12 @@
 #include <polypcore/pstream-util.h>
 #include <polypcore/util.h>
 #include <polypcore/log.h>
+#include <polypcore/hashmap.h>
 
 #include "internal.h"
 
 #define LATENCY_IPOL_INTERVAL_USEC (10000L)
+#define COUNTER_HASHMAP_MAXSIZE (5)
 
 pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map) {
     pa_stream *s;
@@ -85,6 +87,8 @@
 
     s->record_memblockq = NULL;
 
+    s->counter_hashmap = pa_hashmap_new(NULL, NULL);
+
     s->counter = 0;
     s->previous_time = 0;
     s->previous_ipol_time = 0;
@@ -102,6 +106,10 @@
     return pa_stream_ref(s);
 }
 
+static void hashmap_free_func(void *p, void *userdata) {
+    pa_xfree(p);
+}
+
 static void stream_free(pa_stream *s) {
     assert(s);
 
@@ -115,6 +123,9 @@
 
     if (s->record_memblockq)
         pa_memblockq_free(s->record_memblockq);
+
+    if (s->counter_hashmap)
+        pa_hashmap_free(s->counter_hashmap, hashmap_free_func, NULL);
 
     pa_xfree(s->name);
     pa_xfree(s);
@@ -618,6 +629,9 @@
     assert(o->stream);
     assert(o->context);
 
+    i.counter = *(uint64_t*)pa_hashmap_get(o->stream->counter_hashmap, (void*)tag);
+    pa_xfree(pa_hashmap_remove(o->stream->counter_hashmap, (void*)tag));
+
     if (command != PA_COMMAND_REPLY) {
         if (pa_context_handle_error(o->context, command, t) < 0)
             goto finish;
@@ -629,7 +643,8 @@
                pa_tagstruct_getu32(t, &i.queue_length) < 0 ||
                pa_tagstruct_get_timeval(t, &local) < 0 ||
                pa_tagstruct_get_timeval(t, &remote) < 0 ||
-               pa_tagstruct_getu64(t, &i.counter) < 0 ||
+               pa_tagstruct_gets64(t, &i.write_index) < 0 ||
+               pa_tagstruct_gets64(t, &i.read_index) < 0 ||
                !pa_tagstruct_eof(t)) {
         pa_context_fail(o->context, PA_ERR_PROTOCOL);
         goto finish;
@@ -679,12 +694,14 @@
     pa_operation *o;
     pa_tagstruct *t;
     struct timeval now;
+    uint64_t *counter;
     
     assert(s);
     assert(s->ref >= 1);
 
     PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
     PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY_RETURN_NULL(s->context, pa_hashmap_size(s->counter_hashmap) < COUNTER_HASHMAP_MAXSIZE, PA_ERR_INTERNAL);
     
     o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
 
@@ -696,10 +713,13 @@
 
     pa_gettimeofday(&now);
     pa_tagstruct_put_timeval(t, &now);
-    pa_tagstruct_putu64(t, s->counter);
     
     pa_pstream_send_tagstruct(s->context->pstream, t);
     pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, stream_get_latency_info_callback, o);
+
+    counter = pa_xmalloc(sizeof(uint64_t));
+    *counter = s->counter;
+    pa_hashmap_put(s->counter_hashmap, (void*)tag, counter);
 
     return pa_operation_ref(o);
 }




More information about the pulseaudio-commits mailing list