sink-input: Enhance PCM dump 19/125419/3
authorJungsup Lee <jungsup4.lee@samsung.com>
Mon, 17 Apr 2017 07:08:04 +0000 (16:08 +0900)
committerJungsup Lee <jungsup4.lee@samsung.com>
Thu, 11 May 2017 04:39:42 +0000 (13:39 +0900)
PCM dump is not correct if one or more sink-input hasn't pcm data enough when sink request pcm data
In this case, PCM dump file should be rewound when pa_sink_input_drop is called

[Version] 5.0.117
[Profile] Common
[Issue Type] Enhancement

Signed-off-by: Jungsup Lee <jungsup4.lee@samsung.com>
Change-Id: I42cb75c6e058a186d0b761583b87bcd46361bdfb

packaging/pulseaudio.spec
src/pulsecore/sink-input.c
src/pulsecore/sink-input.h

index d2bcb94..7165abb 100644 (file)
@@ -12,7 +12,7 @@
 Name:             pulseaudio
 Summary:          Improved Linux sound server
 Version:          5.0
-Release:          116
+Release:          117
 Group:            Multimedia/Audio
 License:          LGPL-2.1
 URL:              http://pulseaudio.org
index f2260f0..c01d2d8 100644 (file)
@@ -116,10 +116,13 @@ static void pa_sink_input_write_pcm_dump(pa_sink_input *i, pa_memchunk *chunk)
         void *ptr = NULL;
 
         ptr = pa_memblock_acquire(chunk->memblock);
-        if (ptr)
+        if (ptr) {
+            i->dump_length = chunk->length;
             fwrite((uint8_t *)ptr + chunk->index, 1, chunk->length, i->pcm_dump_fp);
-        else
+        } else {
+            i->dump_length = 0;
             pa_log_warn("pa_memblock_acquire is failed. ptr is NULL");
+        }
         pa_memblock_release(chunk->memblock);
     }
 }
@@ -641,6 +644,7 @@ int pa_sink_input_new(
 #ifdef ENABLE_PCM_DUMP
     i->pcm_dump_fp = NULL;
     i->dump_path = NULL;
+    i->dump_length = 0;
 #endif
 #endif
     if (data->flags & PA_SINK_INPUT_START_RAMP_MUTED)
@@ -1234,7 +1238,18 @@ void pa_sink_input_drop(pa_sink_input *i, size_t nbytes /* in sink sample spec *
 #ifdef SINK_INPUT_DEBUG
     pa_log_debug("dropping %lu", (unsigned long) nbytes);
 #endif
+#ifdef __TIZEN__
+    if (i->pcm_dump_fp && i->dump_length) {
+        int64_t seek_length;
 
+        seek_length = (int64_t) (nbytes - i->dump_length);
+
+        if (seek_length < 0)
+            fseeko(i->pcm_dump_fp, (off_t)seek_length, SEEK_CUR);
+
+        i->dump_length = 0;
+    }
+#endif
     pa_memblockq_drop(i->thread_info.render_memblockq, nbytes);
 }
 
index 2e993d4..ac910f2 100644 (file)
@@ -275,6 +275,7 @@ struct pa_sink_input {
     bool is_virtual;
     FILE *pcm_dump_fp;
     char *dump_path;
+    uint32_t dump_length;
 #endif
 
     void *userdata;