]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/sink-input.c
dbus: first restart timer, then dispatch it
[pulseaudio] / src / pulsecore / sink-input.c
index 216edd412da4657b39b5f2e537f6ec09ca072909..395110b7fe412656dc35c52f622ab8ec4cfd833c 100644 (file)
@@ -740,14 +740,15 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p
                 pa_memchunk rchunk;
                 pa_resampler_run(i->thread_info.resampler, &wchunk, &rchunk);
 
-                if (nvfs) {
-                    pa_memchunk_make_writable(&rchunk, 0);
-                    pa_volume_memchunk(&rchunk, &i->sink->sample_spec, &i->volume_factor_sink);
-                }
-
 /*                 pa_log_debug("pushing %lu", (unsigned long) rchunk.length); */
 
                 if (rchunk.memblock) {
+
+                    if (nvfs) {
+                        pa_memchunk_make_writable(&rchunk, 0);
+                        pa_volume_memchunk(&rchunk, &i->sink->sample_spec, &i->volume_factor_sink);
+                    }
+
                     pa_memblockq_push_align(i->thread_info.render_memblockq, &rchunk);
                     pa_memblock_unref(rchunk.memblock);
                 }
@@ -778,11 +779,11 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p
 
     if (!i->thread_info.ramp_info.envelope_dead) {
         i->thread_info.ramp_info.envelope_dying += chunk->length;
-        pa_log_debug("Envelope dying is %d, chunk length is %d, dead thresholder is %d\n", i->thread_info.ramp_info.envelope_dying,
+        pa_log_debug("Envelope dying is %d, chunk length is %zu, dead thresholder is %lu\n", i->thread_info.ramp_info.envelope_dying,
                 chunk->length,
                 i->sink->thread_info.max_rewind + pa_envelope_length(i->thread_info.ramp_info.envelope));
 
-        if (i->thread_info.ramp_info.envelope_dying >= (i->sink->thread_info.max_rewind + pa_envelope_length(i->thread_info.ramp_info.envelope))) {
+        if (i->thread_info.ramp_info.envelope_dying >= (int32_t) (i->sink->thread_info.max_rewind + pa_envelope_length(i->thread_info.ramp_info.envelope))) {
             pa_log_debug("RELEASE Envelop");
             i->thread_info.ramp_info.envelope_dead = TRUE;
             sink_input_release_envelope(i);
@@ -841,7 +842,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_write(i->thread_info.render_memblockq);
+        pa_memblockq_flush_write(i->thread_info.render_memblockq, TRUE);
 
     } else if (i->thread_info.rewrite_nbytes > 0) {
         size_t max_rewrite, amount;
@@ -1060,7 +1061,7 @@ void pa_sink_input_update_proplist(pa_sink_input *i, pa_update_mode_t mode, pa_p
     if (p)
         pa_proplist_update(i->proplist, mode, p);
 
-    if (PA_SINK_IS_LINKED(i->state)) {
+    if (PA_SINK_INPUT_IS_LINKED(i->state)) {
         pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED], i);
         pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
     }
@@ -1766,18 +1767,20 @@ static void sink_input_rewind_ramp_info(pa_sink_input *i, size_t nbytes) {
     pa_assert(i);
 
     if (!i->thread_info.ramp_info.envelope_dead) {
+        int32_t envelope_length;
+
         pa_assert(i->thread_info.ramp_info.envelope);
 
-        int32_t envelope_length = pa_envelope_length(i->thread_info.ramp_info.envelope);
+        envelope_length = pa_envelope_length(i->thread_info.ramp_info.envelope);
 
         if (i->thread_info.ramp_info.envelope_dying > envelope_length) {
-            if ((i->thread_info.ramp_info.envelope_dying - nbytes) < envelope_length) {
+            if ((int32_t) (i->thread_info.ramp_info.envelope_dying - nbytes) < envelope_length) {
                 pa_log_debug("Envelope Become Alive");
                 pa_envelope_rewind(i->thread_info.ramp_info.envelope, envelope_length - (i->thread_info.ramp_info.envelope_dying - nbytes));
                 i->thread_info.ramp_info.is_ramping = TRUE;
             }
         } else if (i->thread_info.ramp_info.envelope_dying < envelope_length) {
-            if ((i->thread_info.ramp_info.envelope_dying - nbytes) <= 0) {
+            if ((i->thread_info.ramp_info.envelope_dying - (ssize_t) nbytes) <= 0) {
                 pa_log_debug("Envelope Restart");
                 pa_envelope_restart(i->thread_info.ramp_info.envelope);
             }
@@ -1813,6 +1816,7 @@ void pa_sink_input_set_volume_with_ramping(pa_sink_input *i, const pa_cvolume *v
         else
             volume = pa_sw_cvolume_multiply_scalar(&v, &v, pa_cvolume_max(volume));
     } else {
+
         if (!pa_cvolume_compatible(volume, &i->sample_spec)) {
             v = i->volume;
             volume = pa_cvolume_scale(&v, pa_cvolume_max(volume));
@@ -1866,15 +1870,18 @@ void pa_sink_input_set_volume_with_ramping(pa_sink_input *i, const pa_cvolume *v
 
 void pa_sink_input_set_mute_with_ramping(pa_sink_input *i, pa_bool_t mute, pa_bool_t save, pa_usec_t t){
 
-    pa_assert(i);
     pa_sink_input_assert_ref(i);
+    pa_assert_ctl_context();
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
 
-    if (!i->muted == !mute)
+    if (!i->muted == !mute) {
+        i->save_muted = i->save_muted || mute;
         return;
+    }
 
     i->muted = mute;
     i->save_muted = save;
+
     /* Set this flag before the following code modify i->thread_info.muted, otherwise distortion will be heard */
     if (t > 0)
         pa_atomic_store(&i->before_ramping_m, 1);
@@ -1884,5 +1891,9 @@ void pa_sink_input_set_mute_with_ramping(pa_sink_input *i, pa_bool_t mute, pa_bo
     if (t > 0)
         sink_input_set_ramping_info_for_mute(i, mute, t);
 
+    /* The mute status changed, let's tell people so */
+    if (i->mute_changed)
+        i->mute_changed(i);
+
     pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
 }