[pulseaudio-discuss] [PATCH] device-restore: When restoring volume, print the restored volume to the log.

Colin Guthrie gmane at colin.guthr.ie
Sat Nov 3 09:11:27 PDT 2012


'Twas brillig, and Tanu Kaskinen at 23/10/12 17:55 did gyre and gimble:
> ---
>  src/modules/module-device-restore.c |   16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
> index b9bd498..c9ffbb1 100644
> --- a/src/modules/module-device-restore.c
> +++ b/src/modules/module-device-restore.c
> @@ -779,12 +779,13 @@ static pa_hook_result_t sink_fixate_hook_callback(pa_core *c, pa_sink_new_data *
>  
>              if (!new_data->volume_is_set) {
>                  pa_cvolume v;
> +                char buf[PA_CVOLUME_SNPRINT_MAX];
>  
>                  pa_log_info("Restoring volume for sink %s.", new_data->name);
> -
>                  v = e->volume;
>                  pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map);
>                  pa_sink_new_data_set_volume(new_data, &v);
> +                pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &new_data->volume));
>  
>                  new_data->save_volume = TRUE;
>              } else
> @@ -823,14 +824,15 @@ static pa_hook_result_t sink_port_hook_callback(pa_core *c, pa_sink *sink, struc
>      if ((e = perportentry_read(u, name, (sink->active_port ? sink->active_port->name : NULL)))) {
>  
>          if (u->restore_volume && e->volume_valid) {
> -
> +            char buf[PA_CVOLUME_SNPRINT_MAX];
>              pa_cvolume v;
>  
>              pa_log_info("Restoring volume for sink %s.", sink->name);
> -
>              v = e->volume;
>              pa_cvolume_remap(&v, &e->channel_map, &sink->channel_map);
>              pa_sink_set_volume(sink, &v, TRUE, FALSE);
> +            pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &sink->reference_volume));
> +
>              sink->save_volume = TRUE;
>          }
>  
> @@ -919,13 +921,14 @@ static pa_hook_result_t source_fixate_hook_callback(pa_core *c, pa_source_new_da
>          if (u->restore_volume && e->volume_valid) {
>  
>              if (!new_data->volume_is_set) {
> +                char buf[PA_CVOLUME_SNPRINT_MAX];
>                  pa_cvolume v;
>  
>                  pa_log_info("Restoring volume for source %s.", new_data->name);
> -
>                  v = e->volume;
>                  pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map);
>                  pa_source_new_data_set_volume(new_data, &v);
> +                pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &new_data->volume));
>  
>                  new_data->save_volume = TRUE;
>              } else
> @@ -964,14 +967,15 @@ static pa_hook_result_t source_port_hook_callback(pa_core *c, pa_source *source,
>      if ((e = perportentry_read(u, name, (source->active_port ? source->active_port->name : NULL)))) {
>  
>          if (u->restore_volume && e->volume_valid) {
> -
> +            char buf[PA_CVOLUME_SNPRINT_MAX];
>              pa_cvolume v;
>  
>              pa_log_info("Restoring volume for source %s.", source->name);
> -
>              v = e->volume;
>              pa_cvolume_remap(&v, &e->channel_map, &source->channel_map);
>              pa_source_set_volume(source, &v, TRUE, FALSE);
> +            pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &source->reference_volume));
> +
>              source->save_volume = TRUE;
>          }
>  
> 

Looks sensible to me. Applied to my tree but with the very anal change
that I move char buf declaration to be second (i.e. after v) in all
cases rather than the inconsistent order here. Makes me feel mildly
important by making such a trivial change :D


In my tree now!

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/



More information about the pulseaudio-discuss mailing list