Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-13 Thread rong deng
2012/8/14 Tanu Kaskinen :
> On Mon, 2012-08-13 at 15:44 +0800, rong deng wrote:
>> 2012/8/13 Tanu Kaskinen :
>> > On Fri, 2012-08-03 at 15:12 +0800, Deng Zhengrong wrote:
>> >> @@ -336,7 +351,10 @@ static void subscribe_callback(pa_core *c, 
>> >> pa_subscription_event_type_t t, uint3
>> >>  dirty = true;
>> >>  break;
>> >>  }
>> >> -
>> >> +if (p_info->max_volume != old_p_info->max_volume) {
>> >> +dirty = true;
>> >> +break;
>> >> +}
>> >>  } else {
>> >>  dirty = true;
>> >>  break;
>> >
>> > Later in the function there's this:
>> >
>> > if (card->save_profile)
>> > pa_log_info("Storing profile and port latency offsets for card 
>> > %s.", card->name);
>> > else
>> > pa_log_info("Storing port latency offsets for card %s.", 
>> > card->name);
>> >
>> > That code is now out of date.
>>
>> Hi Tanu,
>>
>> Thanks for your review, I've updated and sent out another patch.
>> However, I've checked that the above code is still in pulseaudio's
>> master repository. Why it's out dated? So I don't add the message "max
>> volume" into the messages.
>
> Sorry for being unclear. I meant that with your patch the messages are
> outdated, because they don't mention the volume limit.

Ah, got it. I'll update it with another patch.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-13 Thread Tanu Kaskinen
On Mon, 2012-08-13 at 15:44 +0800, rong deng wrote:
> 2012/8/13 Tanu Kaskinen :
> > On Fri, 2012-08-03 at 15:12 +0800, Deng Zhengrong wrote:
> >> @@ -336,7 +351,10 @@ static void subscribe_callback(pa_core *c, 
> >> pa_subscription_event_type_t t, uint3
> >>  dirty = true;
> >>  break;
> >>  }
> >> -
> >> +if (p_info->max_volume != old_p_info->max_volume) {
> >> +dirty = true;
> >> +break;
> >> +}
> >>  } else {
> >>  dirty = true;
> >>  break;
> >
> > Later in the function there's this:
> >
> > if (card->save_profile)
> > pa_log_info("Storing profile and port latency offsets for card 
> > %s.", card->name);
> > else
> > pa_log_info("Storing port latency offsets for card %s.", 
> > card->name);
> >
> > That code is now out of date.
> 
> Hi Tanu,
> 
> Thanks for your review, I've updated and sent out another patch.
> However, I've checked that the above code is still in pulseaudio's
> master repository. Why it's out dated? So I don't add the message "max
> volume" into the messages.

Sorry for being unclear. I meant that with your patch the messages are
outdated, because they don't mention the volume limit.

-- 
Tanu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-13 Thread rong deng
2012/8/13 Tanu Kaskinen :
> On Fri, 2012-08-03 at 15:12 +0800, Deng Zhengrong wrote:
>> module-card-restore now saves the maximum volume.
>>
>> This change includes a entry version bump.
>> ---
>>  src/modules/module-card-restore.c |   26 +++---
>>  1 files changed, 23 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/modules/module-card-restore.c 
>> b/src/modules/module-card-restore.c
>> index 7d101c5..689381d 100644
>> --- a/src/modules/module-card-restore.c
>> +++ b/src/modules/module-card-restore.c
>> @@ -68,11 +68,12 @@ struct userdata {
>>  pa_database *database;
>>  };
>>
>> -#define ENTRY_VERSION 2
>> +#define ENTRY_VERSION 3
>>
>>  struct port_info {
>>  char *name;
>>  int64_t offset;
>> +pa_volume_t max_volume;
>>  };
>>
>>  struct entry {
>> @@ -145,6 +146,7 @@ static pa_bool_t entry_write(struct userdata *u, const 
>> char *name, const struct
>>  PA_HASHMAP_FOREACH(p_info, e->ports, state) {
>>  pa_tagstruct_puts(t, p_info->name);
>>  pa_tagstruct_puts64(t, p_info->offset);
>> +pa_tagstruct_put_volume(t, p_info->max_volume);
>>  }
>>
>>  key.data = (char *) name;
>> @@ -249,6 +251,18 @@ static struct entry* entry_read(struct userdata *u, 
>> const char *name) {
>>  p_info->name = pa_xstrdup(port_name);
>>  p_info->offset = port_offset;
>>
>> +if (e->version >= 3) {
>> +pa_volume_t max_volume = PA_VOLUME_INVALID;
>> +
>> +if (pa_tagstruct_get_volume(t, &max_volume) < 0) {
>> +pa_xfree(p_info->name);
>> +pa_xfree(p_info);
>> +goto fail;
>> +}
>> +
>> +p_info->max_volume = max_volume;
>> +}
>
> p_info->max_volume needs to be initialized even when e->version is less
> than 3. Also, the local max_volume variable is redundant: you can give
> p_info->max_volume directly to pa_tagstruct_get_volume().
>
>> +
>>  pa_assert_se(pa_hashmap_put(e->ports, p_info->name, p_info) >= 
>> 0);
>>  }
>>  }
>> @@ -313,6 +327,7 @@ static void subscribe_callback(pa_core *c, 
>> pa_subscription_event_type_t t, uint3
>>  p_info = pa_xnew(struct port_info, 1);
>>  p_info->name = pa_xstrdup(p->name);
>>  p_info->offset = p->latency_offset;
>> +p_info->max_volume = p->maximum_volume;
>>
>>  pa_assert_se(pa_hashmap_put(entry->ports, p_info->name, p_info) >= 
>> 0);
>>  }
>> @@ -336,7 +351,10 @@ static void subscribe_callback(pa_core *c, 
>> pa_subscription_event_type_t t, uint3
>>  dirty = true;
>>  break;
>>  }
>> -
>> +if (p_info->max_volume != old_p_info->max_volume) {
>> +dirty = true;
>> +break;
>> +}
>>  } else {
>>  dirty = true;
>>  break;
>
> Later in the function there's this:
>
> if (card->save_profile)
> pa_log_info("Storing profile and port latency offsets for card %s.", 
> card->name);
> else
> pa_log_info("Storing port latency offsets for card %s.", card->name);
>
> That code is now out of date.

Hi Tanu,

Thanks for your review, I've updated and sent out another patch.
However, I've checked that the above code is still in pulseaudio's
master repository. Why it's out dated? So I don't add the message "max
volume" into the messages.

>
>> @@ -391,8 +409,10 @@ static pa_hook_result_t card_new_hook_callback(pa_core 
>> *c, pa_card_new_data *new
>>  pa_log_info("Restoring port latency offsets for card %s.", 
>> new_data->name);
>
> There should be a mention of restoring the maximum volume too.
>
>>
>>  PA_HASHMAP_FOREACH(p_info, e->ports, state)
>> -if ((p = pa_hashmap_get(new_data->ports, p_info->name)))
>> +if ((p = pa_hashmap_get(new_data->ports, p_info->name))) {
>>  p->latency_offset = p_info->offset;
>> +p->maximum_volume = p_info->max_volume;
>> +}
>>
>>  entry_free(e);
>
> --
> Tanu
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-13 Thread Tanu Kaskinen
On Fri, 2012-08-03 at 15:12 +0800, Deng Zhengrong wrote:
> module-card-restore now saves the maximum volume.
> 
> This change includes a entry version bump.
> ---
>  src/modules/module-card-restore.c |   26 +++---
>  1 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/src/modules/module-card-restore.c 
> b/src/modules/module-card-restore.c
> index 7d101c5..689381d 100644
> --- a/src/modules/module-card-restore.c
> +++ b/src/modules/module-card-restore.c
> @@ -68,11 +68,12 @@ struct userdata {
>  pa_database *database;
>  };
>  
> -#define ENTRY_VERSION 2
> +#define ENTRY_VERSION 3
>  
>  struct port_info {
>  char *name;
>  int64_t offset;
> +pa_volume_t max_volume;
>  };
>  
>  struct entry {
> @@ -145,6 +146,7 @@ static pa_bool_t entry_write(struct userdata *u, const 
> char *name, const struct
>  PA_HASHMAP_FOREACH(p_info, e->ports, state) {
>  pa_tagstruct_puts(t, p_info->name);
>  pa_tagstruct_puts64(t, p_info->offset);
> +pa_tagstruct_put_volume(t, p_info->max_volume);
>  }
>  
>  key.data = (char *) name;
> @@ -249,6 +251,18 @@ static struct entry* entry_read(struct userdata *u, 
> const char *name) {
>  p_info->name = pa_xstrdup(port_name);
>  p_info->offset = port_offset;
>  
> +if (e->version >= 3) {
> +pa_volume_t max_volume = PA_VOLUME_INVALID;
> +
> +if (pa_tagstruct_get_volume(t, &max_volume) < 0) {
> +pa_xfree(p_info->name);
> +pa_xfree(p_info);
> +goto fail;
> +}
> +
> +p_info->max_volume = max_volume;
> +}

p_info->max_volume needs to be initialized even when e->version is less
than 3. Also, the local max_volume variable is redundant: you can give
p_info->max_volume directly to pa_tagstruct_get_volume().

> +
>  pa_assert_se(pa_hashmap_put(e->ports, p_info->name, p_info) >= 
> 0);
>  }
>  }
> @@ -313,6 +327,7 @@ static void subscribe_callback(pa_core *c, 
> pa_subscription_event_type_t t, uint3
>  p_info = pa_xnew(struct port_info, 1);
>  p_info->name = pa_xstrdup(p->name);
>  p_info->offset = p->latency_offset;
> +p_info->max_volume = p->maximum_volume;
>  
>  pa_assert_se(pa_hashmap_put(entry->ports, p_info->name, p_info) >= 
> 0);
>  }
> @@ -336,7 +351,10 @@ static void subscribe_callback(pa_core *c, 
> pa_subscription_event_type_t t, uint3
>  dirty = true;
>  break;
>  }
> -
> +if (p_info->max_volume != old_p_info->max_volume) {
> +dirty = true;
> +break;
> +}
>  } else {
>  dirty = true;
>  break;

Later in the function there's this:

if (card->save_profile)
pa_log_info("Storing profile and port latency offsets for card %s.", 
card->name);
else
pa_log_info("Storing port latency offsets for card %s.", card->name);

That code is now out of date.

> @@ -391,8 +409,10 @@ static pa_hook_result_t card_new_hook_callback(pa_core 
> *c, pa_card_new_data *new
>  pa_log_info("Restoring port latency offsets for card %s.", 
> new_data->name);

There should be a mention of restoring the maximum volume too.

>  
>  PA_HASHMAP_FOREACH(p_info, e->ports, state)
> -if ((p = pa_hashmap_get(new_data->ports, p_info->name)))
> +if ((p = pa_hashmap_get(new_data->ports, p_info->name))) {
>  p->latency_offset = p_info->offset;
> +p->maximum_volume = p_info->max_volume;
> +}
>  
>  entry_free(e);

-- 
Tanu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-05 Thread rong deng
2012/8/3 poljar (Damir Jelić) :
> On Fri, Aug 03, 2012 at 08:25:18PM +0800, rong deng wrote:
>> Hi Poljar,
>>
>> Sorry for top posting.
>>
>> This patch is based on your github's commit. Of course, it doesn't
>> work yet because not everything is weaved together... However I'd like
>> to give others a chance to see what i'm doing and whether i'm on the
>> right track.
>>
>
> Hi.
>
> I've changed the variable from maximum_volume to max_volume (for
> consistency sake).

I've update it accordingly here:
https://github.com/dzrongg/pulseaudio-1/tree/volume

>
> I've gave the patch a glimpse and for now it looks fine to me.

Thanks for your quick review!
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-03 Thread poljar (Damir Jelić)
On Fri, Aug 03, 2012 at 08:25:18PM +0800, rong deng wrote:
> Hi Poljar,
> 
> Sorry for top posting.
> 
> This patch is based on your github's commit. Of course, it doesn't
> work yet because not everything is weaved together... However I'd like
> to give others a chance to see what i'm doing and whether i'm on the
> right track.
> 

Hi.

I've changed the variable from maximum_volume to max_volume (for
consistency sake).

I've gave the patch a glimpse and for now it looks fine to me.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the maximum volume

2012-08-03 Thread rong deng
Hi Poljar,

Sorry for top posting.

This patch is based on your github's commit. Of course, it doesn't
work yet because not everything is weaved together... However I'd like
to give others a chance to see what i'm doing and whether i'm on the
right track.

2012/8/3 Deng Zhengrong :
> module-card-restore now saves the maximum volume.
>
> This change includes a entry version bump.
> ---
>  src/modules/module-card-restore.c |   26 +++---
>  1 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/src/modules/module-card-restore.c 
> b/src/modules/module-card-restore.c
> index 7d101c5..689381d 100644
> --- a/src/modules/module-card-restore.c
> +++ b/src/modules/module-card-restore.c
> @@ -68,11 +68,12 @@ struct userdata {
>  pa_database *database;
>  };
>
> -#define ENTRY_VERSION 2
> +#define ENTRY_VERSION 3
>
>  struct port_info {
>  char *name;
>  int64_t offset;
> +pa_volume_t max_volume;
>  };
>
>  struct entry {
> @@ -145,6 +146,7 @@ static pa_bool_t entry_write(struct userdata *u, const 
> char *name, const struct
>  PA_HASHMAP_FOREACH(p_info, e->ports, state) {
>  pa_tagstruct_puts(t, p_info->name);
>  pa_tagstruct_puts64(t, p_info->offset);
> +pa_tagstruct_put_volume(t, p_info->max_volume);
>  }
>
>  key.data = (char *) name;
> @@ -249,6 +251,18 @@ static struct entry* entry_read(struct userdata *u, 
> const char *name) {
>  p_info->name = pa_xstrdup(port_name);
>  p_info->offset = port_offset;
>
> +if (e->version >= 3) {
> +pa_volume_t max_volume = PA_VOLUME_INVALID;
> +
> +if (pa_tagstruct_get_volume(t, &max_volume) < 0) {
> +pa_xfree(p_info->name);
> +pa_xfree(p_info);
> +goto fail;
> +}
> +
> +p_info->max_volume = max_volume;
> +}
> +
>  pa_assert_se(pa_hashmap_put(e->ports, p_info->name, p_info) >= 
> 0);
>  }
>  }
> @@ -313,6 +327,7 @@ static void subscribe_callback(pa_core *c, 
> pa_subscription_event_type_t t, uint3
>  p_info = pa_xnew(struct port_info, 1);
>  p_info->name = pa_xstrdup(p->name);
>  p_info->offset = p->latency_offset;
> +p_info->max_volume = p->maximum_volume;
>
>  pa_assert_se(pa_hashmap_put(entry->ports, p_info->name, p_info) >= 
> 0);
>  }
> @@ -336,7 +351,10 @@ static void subscribe_callback(pa_core *c, 
> pa_subscription_event_type_t t, uint3
>  dirty = true;
>  break;
>  }
> -
> +if (p_info->max_volume != old_p_info->max_volume) {
> +dirty = true;
> +break;
> +}
>  } else {
>  dirty = true;
>  break;
> @@ -391,8 +409,10 @@ static pa_hook_result_t card_new_hook_callback(pa_core 
> *c, pa_card_new_data *new
>  pa_log_info("Restoring port latency offsets for card %s.", 
> new_data->name);
>
>  PA_HASHMAP_FOREACH(p_info, e->ports, state)
> -if ((p = pa_hashmap_get(new_data->ports, p_info->name)))
> +if ((p = pa_hashmap_get(new_data->ports, p_info->name))) {
>  p->latency_offset = p_info->offset;
> +p->maximum_volume = p_info->max_volume;
> +}
>
>  entry_free(e);
>
> --
> 1.7.7.6
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss