[pulseaudio-commits] r1618 - /branches/lennart/src/pulsecore/protocol-native.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Aug 10 08:51:56 PDT 2007


Author: lennart
Date: Fri Aug 10 17:51:55 2007
New Revision: 1618

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1618&root=3Dpulseaudio&vi=
ew=3Drev
Log:
do not acces playback pa_messagq from main thread

Modified:
    branches/lennart/src/pulsecore/protocol-native.c

Modified: branches/lennart/src/pulsecore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
protocol-native.c?rev=3D1618&root=3Dpulseaudio&r1=3D1617&r2=3D1618&view=3Dd=
iff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/protocol-native.c (original)
+++ branches/lennart/src/pulsecore/protocol-native.c Fri Aug 10 17:51:55 20=
07
@@ -104,6 +104,10 @@
 =

     pa_atomic_t missing;
     size_t last_missing;
+
+    /* Only updated after SINK_INPUT_MESSAGE_UPDATE_LATENCY */
+    int64_t read_index, write_index;
+    size_t resampled_chunk_length;
 } playback_stream;
 =

 typedef struct upload_stream {
@@ -175,7 +179,8 @@
     SINK_INPUT_MESSAGE_FLUSH,
     SINK_INPUT_MESSAGE_TRIGGER,
     SINK_INPUT_MESSAGE_SEEK,
-    SINK_INPUT_MESSAGE_PREBUF_FORCE
+    SINK_INPUT_MESSAGE_PREBUF_FORCE,
+    SINK_INPUT_MESSAGE_UPDATE_LATENCY
 };
 =

 enum {
@@ -726,9 +731,9 @@
     pa_xfree(c);
 }
 =

+/* Called from thread context */
 static void request_bytes(playback_stream *s) {
     size_t new_missing, delta, previous_missing;
-
 =

 /*     pa_log("request_bytes()"); */
     playback_stream_assert_ref(s);
@@ -804,8 +809,9 @@
     pa_pstream_send_tagstruct(r->connection->pstream, t);
 }
 =

-/*** sinkinput callbacks ***/
-
+/*** sink input callbacks ***/
+
+/* Called from thread context */
 static int sink_input_process_msg(pa_msgobject *o, int code, void *userdat=
a, int64_t offset, pa_memchunk *chunk) {
     pa_sink_input *i =3D PA_SINK_INPUT(o);
     playback_stream *s;
@@ -897,6 +903,13 @@
             =

             return 0;
         }
+
+        case SINK_INPUT_MESSAGE_UPDATE_LATENCY: =

+
+            s->read_index =3D pa_memblockq_get_read_index(s->memblockq);
+            s->write_index =3D pa_memblockq_get_write_index(s->memblockq);
+            s->resampled_chunk_length =3D s->sink_input->thread_info.resam=
pled_chunk.memblock ? s->sink_input->thread_info.resampled_chunk.length : 0;
+            return 0;
             =

         case PA_SINK_INPUT_MESSAGE_SET_STATE:
 =

@@ -918,6 +931,7 @@
     return pa_sink_input_process_msg(o, code, userdata, offset, chunk);
 }
 =

+/* Called from thread context */
 static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk) {
     playback_stream *s;
 =

@@ -943,6 +957,7 @@
     return 0;
 }
 =

+/* Called from thread context */
 static void sink_input_drop_cb(pa_sink_input *i, size_t length) {
     playback_stream *s;
 =

@@ -976,6 +991,7 @@
 =

 /*** source_output callbacks ***/
 =

+/* Called from thread context */
 static void source_output_push_cb(pa_source_output *o, const pa_memchunk *=
chunk) {
     record_stream *s;
 =

@@ -1472,20 +1488,21 @@
     s =3D pa_idxset_get_by_index(c->output_streams, idx);
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY);
     CHECK_VALIDITY(c->pstream, playback_stream_isinstance(s), tag, PA_ERR_=
NOENTITY);
-
+    CHECK_VALIDITY(c->pstream, pa_asyncmsgq_send(s->sink_input->sink->asyn=
cmsgq, PA_MSGOBJECT(s->sink_input), SINK_INPUT_MESSAGE_UPDATE_LATENCY, s, 0=
, NULL) =3D=3D 0, tag, PA_ERR_NOENTITY)
+    =

     reply =3D reply_new(tag);
-
+    =

     latency =3D pa_sink_get_latency(s->sink_input->sink);
-/*     if (s->sink_input->resampled_chunk.memblock) */  /* FIXME*/ =

-/*         latency +=3D pa_bytes_to_usec(s->sink_input->resampled_chunk.le=
ngth, &s->sink_input->sample_spec); */
+    latency +=3D pa_bytes_to_usec(s->resampled_chunk_length, &s->sink_inpu=
t->sample_spec); =

+    =

     pa_tagstruct_put_usec(reply, latency);
 =

     pa_tagstruct_put_usec(reply, 0);
     pa_tagstruct_put_boolean(reply, pa_sink_input_get_state(s->sink_input)=
 =3D=3D PA_SINK_INPUT_RUNNING);
     pa_tagstruct_put_timeval(reply, &tv);
     pa_tagstruct_put_timeval(reply, pa_gettimeofday(&now));
-    pa_tagstruct_puts64(reply, pa_memblockq_get_write_index(s->memblockq));
-    pa_tagstruct_puts64(reply, pa_memblockq_get_read_index(s->memblockq));
+    pa_tagstruct_puts64(reply, s->write_index);
+    pa_tagstruct_puts64(reply, s->read_index);
     pa_pstream_send_tagstruct(c->pstream, reply);
 }
 =





More information about the pulseaudio-commits mailing list