]> code.delx.au - pulseaudio/commitdiff
split pa_memblockq_flush() into two flush commands, one which fixes up the read ptr...
authorLennart Poettering <lennart@poettering.net>
Wed, 25 Jun 2008 22:39:31 +0000 (00:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 Jun 2008 22:39:31 +0000 (00:39 +0200)
src/modules/module-combine.c
src/pulsecore/memblockq.c
src/pulsecore/memblockq.h
src/pulsecore/protocol-native.c
src/pulsecore/sink-input.c

index cef7a99a22aa9863a4ab1323839d3109ad24b9f4..8c155da002196633977ff3c71a1722e63dc56228 100644 (file)
@@ -525,7 +525,7 @@ static int sink_input_process_msg(pa_msgobject *obj, int code, void *data, int64
             if (PA_SINK_IS_OPENED(o->sink_input->sink->thread_info.state))
                 pa_memblockq_push_align(o->memblockq, chunk);
             else
-                pa_memblockq_flush(o->memblockq);
+                pa_memblockq_flush_write(o->memblockq);
 
             return 0;
     }
@@ -555,7 +555,7 @@ static void enable_output(struct output *o) {
 
     if (output_create_sink_input(o) >= 0) {
 
-        pa_memblockq_flush(o->memblockq);
+        pa_memblockq_flush_write(o->memblockq);
 
         pa_sink_input_put(o->sink_input);
 
index 9ce3372cc96f9767220e3e48295b83f1a63c30dd..841b90753feab20aef242c71bc320416e4a04b0c 100644 (file)
@@ -638,7 +638,7 @@ void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek) {
     bq->missing -= delta;
 }
 
-void pa_memblockq_flush(pa_memblockq *bq) {
+void pa_memblockq_flush_write(pa_memblockq *bq) {
     int64_t old, delta;
     pa_assert(bq);
 
@@ -662,6 +662,21 @@ void pa_memblockq_flush(pa_memblockq *bq) {
     bq->missing -= delta;
 }
 
+void pa_memblockq_flush_read(pa_memblockq *bq) {
+    int64_t old, delta;
+    pa_assert(bq);
+
+    pa_memblockq_silence(bq);
+
+    old = bq->read_index;
+    bq->read_index = bq->write_index;
+
+    pa_memblockq_prebuf_force(bq);
+
+    delta = bq->read_index - old;
+    bq->missing += delta;
+}
+
 size_t pa_memblockq_get_tlength(pa_memblockq *bq) {
     pa_assert(bq);
 
index ad3eea493f54c695cb11a3de4be9b7286a171b98..4b9450f6cc77ee72b5b3709c0193beaa10438b89 100644 (file)
@@ -84,6 +84,9 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *chunk);
  * you know what you do. */
 int pa_memblockq_push_align(pa_memblockq* bq, const pa_memchunk *chunk);
 
+/* Manipulate the write pointer */
+void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek);
+
 /* Return a copy of the next memory chunk in the queue. It is not
  * removed from the queue. There are two reasons this function might
  * fail: 1. prebuffering is active, 2. queue is empty and no silence
@@ -95,6 +98,9 @@ int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk);
 /* Drop the specified bytes from the queue. */
 void pa_memblockq_drop(pa_memblockq *bq, size_t length);
 
+/* Rewind the read index. If the history is shorter than the specified length we'll point to silence afterwards. */
+void pa_memblockq_rewind(pa_memblockq *bq, size_t length);
+
 /* Test if the pa_memblockq is currently readable, that is, more data than base */
 pa_bool_t pa_memblockq_is_readable(pa_memblockq *bq);
 
@@ -111,26 +117,11 @@ size_t pa_memblockq_pop_missing(pa_memblockq *bq);
 /* Directly moves the data from the source memblockq into bq */
 int pa_memblockq_splice(pa_memblockq *bq, pa_memblockq *source);
 
-/* Returns the minimal request value */
-size_t pa_memblockq_get_minreq(pa_memblockq *bq);
-
-/* Manipulate the write pointer */
-void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek);
-
 /* Set the queue to silence, set write index to read index */
-void pa_memblockq_flush(pa_memblockq *bq);
-
-/* Get Target length */
-size_t pa_memblockq_get_tlength(pa_memblockq *bq);
-
-/* Return the current read index */
-int64_t pa_memblockq_get_read_index(pa_memblockq *bq);
-
-/* Return the current write index */
-int64_t pa_memblockq_get_write_index(pa_memblockq *bq);
+void pa_memblockq_flush_write(pa_memblockq *bq);
 
-/* Rewind the read index. If the history is shorter than the specified length we'll point to silence afterwards. */
-void pa_memblockq_rewind(pa_memblockq *bq, size_t length);
+/* Set the queue to silence, set write read index to write index*/
+void pa_memblockq_flush_read(pa_memblockq *bq);
 
 /* Ignore prebuf for now */
 void pa_memblockq_prebuf_disable(pa_memblockq *bq);
@@ -141,9 +132,24 @@ void pa_memblockq_prebuf_force(pa_memblockq *bq);
 /* Return the maximum length of the queue in bytes */
 size_t pa_memblockq_get_maxlength(pa_memblockq *bq);
 
+/* Get Target length */
+size_t pa_memblockq_get_tlength(pa_memblockq *bq);
+
 /* Return the prebuffer length in bytes */
 size_t pa_memblockq_get_prebuf(pa_memblockq *bq);
 
+/* Returns the minimal request value */
+size_t pa_memblockq_get_minreq(pa_memblockq *bq);
+
+/* Return the base unit in bytes */
+size_t pa_memblockq_get_base(pa_memblockq *bq);
+
+/* Return the current read index */
+int64_t pa_memblockq_get_read_index(pa_memblockq *bq);
+
+/* Return the current write index */
+int64_t pa_memblockq_get_write_index(pa_memblockq *bq);
+
 /* Change metrics. Always call in order. */
 void pa_memblockq_set_maxlength(pa_memblockq *memblockq, size_t maxlength); /* might modify tlength, prebuf, minreq too */
 void pa_memblockq_set_tlength(pa_memblockq *memblockq, size_t tlength); /* might modify minreq, too */
@@ -169,6 +175,5 @@ pa_bool_t pa_memblockq_prebuf_active(pa_memblockq *bq);
 /* Return how many items are currently stored in the queue */
 unsigned pa_memblockq_get_nblocks(pa_memblockq *bq);
 
-size_t pa_memblockq_get_base(pa_memblockq *bq);
 
 #endif
index 923a5665d10e5e448c7e030a52c6e997d75dad8d..862b062e9b22594009206be4cd791afbe4425592 100644 (file)
@@ -1196,7 +1196,7 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
 
             switch  (code) {
                 case SINK_INPUT_MESSAGE_FLUSH:
-                    func = pa_memblockq_flush;
+                    func = pa_memblockq_flush_write;
                     break;
 
                 case SINK_INPUT_MESSAGE_PREBUF_FORCE:
@@ -3072,7 +3072,7 @@ static void command_flush_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_U
     s = pa_idxset_get_by_index(c->record_streams, idx);
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY);
 
-    pa_memblockq_flush(s->memblockq);
+    pa_memblockq_flush_read(s->memblockq);
     pa_pstream_send_simple_ack(c->pstream, tag);
 }
 
index 43e7bb21b45a11c71c093c2ac94fbb225276ccfe..be169709c92cd19e698b7bee0b9a9d3bef67204e 100644 (file)
@@ -664,7 +664,7 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam
         /* We were asked to drop all buffered data, and rerequest new
          * data from implementor the next time push() is called */
 
-        pa_memblockq_flush(i->thread_info.render_memblockq);
+        pa_memblockq_flush_write(i->thread_info.render_memblockq);
 
     } else if (i->thread_info.rewrite_nbytes > 0) {
         size_t max_rewrite, amount;