Bluetooth : Support AVC target feature
[platform/upstream/pulseaudio.git] / src / pulsecore / sink-input.c
index f0bcf4f..fcde714 100644 (file)
@@ -1086,6 +1086,10 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
     size_t ilength;
     size_t ilength_full;
 
+#ifdef __TIZEN__
+    pa_sink_avc_mode_t avc_mode = PA_SINK_AVC_OFF;
+#endif
+
     pa_sink_input_assert_ref(i);
     pa_sink_input_assert_io_context(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->thread_info.state));
@@ -1137,6 +1141,16 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
     volume_is_norm = pa_cvolume_is_norm(&i->thread_info.soft_volume) && !i->thread_info.muted;
     need_volume_factor_sink = !pa_cvolume_is_norm(&i->volume_factor_sink);
 
+#ifdef __TIZEN__
+    avc_mode = pa_sink_get_avc_mode(i->sink);
+#ifdef SINK_INPUT_DEBUG
+    pa_log("idx(%u), avc mode(%d), do(%d), norm(%d), nvfs(%d), muted(%d), resampler(%p)",
+            i->index, avc_mode,
+            do_volume_adj_here, volume_is_norm, need_volume_factor_sink,
+            i->thread_info.muted, i->thread_info.resampler);
+#endif
+#endif
+
     while (!pa_memblockq_is_readable(i->thread_info.render_memblockq)) {
         pa_memchunk tchunk;
 
@@ -1179,10 +1193,18 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
                 wchunk.length = block_size_max_sink_input;
 
             /* It might be necessary to adjust the volume here */
+#ifdef __TIZEN__
+            if (do_volume_adj_here && !volume_is_norm && avc_mode != PA_SINK_AVC_NORM) {
+#else
             if (do_volume_adj_here && !volume_is_norm) {
+#endif
                 pa_memchunk_make_writable(&wchunk, 0);
 
+#ifdef __TIZEN__
+                if (i->thread_info.muted || avc_mode == PA_SINK_AVC_SILENT) {
+#else
                 if (i->thread_info.muted) {
+#endif
                     pa_silence_memchunk(&wchunk, &i->thread_info.sample_spec);
                     nvfs = false;
 
@@ -1202,7 +1224,6 @@ 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) {
@@ -1263,10 +1284,18 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
     /* Let's see if we had to apply the volume adjustment ourselves,
      * or if this can be done by the sink for us */
 
+#ifdef __TIZEN__
+    if (do_volume_adj_here || avc_mode == PA_SINK_AVC_NORM)
+#else
     if (do_volume_adj_here)
+#endif
         /* We had different channel maps, so we already did the adjustment */
         pa_cvolume_reset(volume, i->sink->sample_spec.channels);
+#ifdef __TIZEN__
+    else if (i->thread_info.muted || avc_mode == PA_SINK_AVC_SILENT)
+#else
     else if (i->thread_info.muted)
+#endif
         /* We've both the same channel map, so let's have the sink do the adjustment for us*/
         pa_cvolume_mute(volume, i->sink->sample_spec.channels);
     else