mix, sink-input: Add to invoke hook fire when ramping is finished 37/201337/4
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 8 Mar 2019 06:06:08 +0000 (15:06 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 15 Mar 2019 02:16:53 +0000 (11:16 +0900)
[Version] 11.1-63
[Issue Type] New feature

Change-Id: Id7e826389dc69082d45271644e10987e0de83f48
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio.spec
src/pulsecore/core.h
src/pulsecore/mix.c
src/pulsecore/mix.h
src/pulsecore/sink-input.c

index 60ae9b3..374e9f1 100644 (file)
@@ -3,7 +3,7 @@
 Name:             pulseaudio
 Summary:          Improved Linux sound server
 Version:          11.1
-Release:          62
+Release:          63
 Group:            Multimedia/Audio
 License:          LGPL-2.1
 URL:              http://pulseaudio.org
index e33df95..4c2fb90 100644 (file)
@@ -142,6 +142,9 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SAMPLE_CACHE_NEW,
     PA_CORE_HOOK_SAMPLE_CACHE_CHANGED,
     PA_CORE_HOOK_SAMPLE_CACHE_UNLINK,
+#ifdef __TIZEN__
+    PA_CORE_HOOK_SINK_INPUT_RAMP_FINISH,
+#endif
     PA_CORE_HOOK_MAX
 } pa_core_hook_t;
 
index 319c4d8..c3d3d2f 100644 (file)
@@ -837,6 +837,7 @@ static void calc_volume_ramps(pa_cvolume_ramp_int *ramp, float *vol)
             if (ramp->ramps[i].target == PA_VOLUME_NORM) {
                 vol[i] = 1.0;
             }
+            ramp->finished = true;
         } else {
             vol[i] = ramp->ramps[i].curr = calc_volume_ramp_table[ramp->ramps[i].type] (&ramp->ramps[i]);
             ramp->ramps[i].left--;
@@ -927,6 +928,8 @@ pa_cvolume_ramp_int* pa_cvolume_ramp_convert(const pa_cvolume_ramp *src, pa_cvol
         dst->ramps[j].end = dst->ramps[i].end;
     }
 
+    dst->finished = false;
+
     return dst;
 }
 
index e36541d..ae26bde 100644 (file)
@@ -73,6 +73,7 @@ typedef struct pa_volume_ramp_int_t {
 typedef struct pa_cvolume_ramp_int {
     uint8_t channels;
     pa_volume_ramp_int ramps[PA_CHANNELS_MAX];
+    bool finished;
 } pa_cvolume_ramp_int;
 
 pa_cvolume_ramp_int* pa_cvolume_ramp_convert(const pa_cvolume_ramp *src, pa_cvolume_ramp_int *dst, int sample_rate);
index 1115950..032907e 100644 (file)
@@ -1067,6 +1067,9 @@ static void check_and_apply_ramp(pa_cvolume_ramp_int *ramp, const pa_sample_spec
 void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa_memchunk *chunk, pa_cvolume *volume) {
     bool do_volume_adj_here, need_volume_factor_sink;
     bool volume_is_norm;
+#ifdef TIZEN_VOLUME_RAMP
+    bool prev_ramp_finished = false;
+#endif
     size_t block_size_max_sink, block_size_max_sink_input;
     size_t ilength;
     size_t ilength_full;
@@ -1187,6 +1190,8 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
 
 #ifdef TIZEN_VOLUME_RAMP
             check_and_apply_silence(i);
+
+            prev_ramp_finished = i->thread_info.ramp.finished;
 #endif
             if (!i->thread_info.resampler) {
 
@@ -1257,6 +1262,14 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
 #ifdef TIZEN_PCM_DUMP
     pa_sink_input_write_pcm_dump(i, chunk);
 #endif
+#ifdef TIZEN_VOLUME_RAMP
+    /* Hook fire only if ramp is finished. Note that it does not mean all the ramped data
+     * is written to the device, hence it needs to be improved later on. */
+    if (!prev_ramp_finished && i->thread_info.ramp.finished) {
+        pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_RAMP_FINISH], i);
+        i->thread_info.ramp.finished = false;
+    }
+#endif
 }
 
 /* Called from thread context */