Re: [pulseaudio-discuss] [PATCH v3 4/4] Add A2DP LDAC codec source support

2019-01-13 Thread Huang-Huang Bao
My bad, noticed before, but I forgot it when adding copyrights.

On 1/13/19 10:14 AM, Pali Rohár wrote:
> On Saturday 29 December 2018 23:48:08 Huang-Huang Bao wrote:
>> diff --git a/src/modules/bluetooth/a2dp/a2dp_ldac.c 
>> b/src/modules/bluetooth/a2dp/a2dp_ldac.c
>> new file mode 100644
>> index 0..8095d2435
>> --- /dev/null
>> +++ b/src/modules/bluetooth/a2dp/a2dp_ldac.c
>> @@ -0,0 +1,605 @@
>> +/***
>> +  This file is part of PulseAudio.
>> +
>> +  Copyright 2018 Huang-Huang Bao
>> +
>> +  PulseAudio is free software; you can redistribute it and/or modify
>> +  it under the terms of the GNU Lesser General Public License as
>> +  published by the Free Software Foundation; either version 2.1 of the
>> +  License, or (at your option) any later version.
>> +
>> +  PulseAudio is distributed in the hope that it will be useful, but
>> +  WITHOUT ANY WARRANTY; without even the implied warranty of
>> +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> +  General Public License for more details.
>> +
>> +  You should have received a copy of the GNU Lesser General Public
>> +  License along with PulseAudio; if not, see .
>> +***/
>> +
>> +#include 
>> +#include 
>> +
>> +#ifdef HAVE_CONFIG_H
>> +
>> +#include 
>> +
>> +#endif
>> +
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
> This looks like an another license problem. This Sony's LDAC encoder
> library is licensed under Apache License Version 2.0 which is not
> compatible with above LGPL 2.1.
>
> IIRC Apache License Version 2.0 can be used in GPLv3 projects, so
> without relicensing pulseaudio to (L)GPLv3 this looks like a problem.
>
Could we relicense bluez modules or AAC/LDAC staffs to LGPLv3?

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


signature.asc
Description: OpenPGP digital signature
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 0/2] Handle two Headphone Jacks with the same name

2019-01-13 Thread Hui Wang
Although the patchset tries to add index support, the objective is 100%
compatible with the past. If there is no kcontrols with "index != 0", we
don't need to change any conf files, the pulseaudio will work as before.

The name of "Front Headphone Surround" and "Front Headphone Front" are
not good, I plan to submit a patch to the kernel to change the name to
"Front Headphone" with index 0 and "Front Headphone" with index 1, since
the patch for the kernel is not submitted yet, here I don't send the patch
to change ${path}.conf, but to be easy to review, I paste an example of
changing the ${path}.conf after the kernel patch is merged:


--- a/src/modules/alsa/mixer/paths/analog-output-headphones-2.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-headphones-2.conf
@@ -40,6 +40,18 @@ override-map.2 = all-left,all-right
 switch = off
 volume = off
 
+[Jack Front Headphone@1]
+required-any = any
+index = 1
+
+[Element Headphone@1]
+required-any = any
+index = 1
+switch = mute
+volume = merge
+override-map.1 = all
+override-map.2 = all-left,all-right
+
 ; This profile path is intended to control the second headphones, not
 ; the first headphones. But it should not hurt if we leave the
 ; headphone jack enabled nonetheless.
@@ -56,7 +68,7 @@ switch = off
 volume = off
 
 [Element Headphone2]
-required = any
+required-any = any
 switch = mute
 volume = merge
 override-map.1 = all


--- a/src/modules/alsa/mixer/paths/analog-output-speaker.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
@@ -32,6 +32,11 @@ state.unplugged = unknown
 state.plugged = no
 state.unplugged = unknown
 
+[Jack Front Headphone@1]
+index = 1
+state.plugged = no
+state.unplugged = unknown
+
 [Jack Front Headphone]
 state.plugged = no
 state.unplugged = unknown


Hui Wang (2):
  alsa-mixer: Add alsa index number support for Element and Jack
  alsa-mixer: set different strings to name and alsa-name for jack and
element

 src/modules/alsa/alsa-mixer.c | 99 +++
 src/modules/alsa/alsa-mixer.h |  6 +-
 src/modules/alsa/alsa-ucm.c   |  2 +-
 src/modules/alsa/alsa-util.c  |  4 +-
 src/modules/alsa/alsa-util.h  |  2 +-
 .../mixer/paths/analog-output.conf.common |  6 ++
 src/modules/alsa/module-alsa-card.c   |  4 +-
 7 files changed, 95 insertions(+), 28 deletions(-)

-- 
2.17.1

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


[pulseaudio-discuss] [PATCH v2 1/2] alsa-mixer: Add alsa index number support for Element and Jack

2019-01-13 Thread Hui Wang
We have met a couple of machines which have two Kcontrols with the
exact same names and with the different index numbers, for example:
  (1 physical headphone jack + 1 physical headset jack on front panel)
  - Simple mixer control 'Headphone',0 (volume and switch)
  - Simple mixer control 'Headphone',1 (volume and switch)
  (1 physical mic jack + 1 physical headset jack on front panel)
  - iface=CARD,name='Mic Jack' index 0
  - iface=CARD,name='Mic Jack' index 1

To let pulseaudio treat them as different Jacks or differnt Elements,
we introduce index to the pa_alsa_jack and pa_alsa_element.

When probing jacks or elements, we add index as a parameter.

Signed-off-by: Hui Wang 
---
 src/modules/alsa/alsa-mixer.c | 59 ++-
 src/modules/alsa/alsa-mixer.h |  2 +
 src/modules/alsa/alsa-ucm.c   |  2 +-
 src/modules/alsa/alsa-util.c  |  4 +-
 src/modules/alsa/alsa-util.h  |  2 +-
 .../mixer/paths/analog-output.conf.common |  5 ++
 src/modules/alsa/module-alsa-card.c   |  4 +-
 7 files changed, 59 insertions(+), 19 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 91dfc66ee..e32ec5cd7 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -718,11 +718,11 @@ static pa_volume_t from_alsa_volume(long v, long min, 
long max) {
 return (pa_volume_t) round(((double) (v - min) * PA_VOLUME_NORM) / 
(double) (max - min));
 }
 
-#define SELEM_INIT(sid, name)   \
+#define SELEM_INIT(sid, name, index)   \
 do {\
 snd_mixer_selem_id_alloca(&(sid));  \
 snd_mixer_selem_id_set_name((sid), (name)); \
-snd_mixer_selem_id_set_index((sid), 0); \
+snd_mixer_selem_id_set_index((sid), index); \
 } while(false)
 
 static int element_get_volume(pa_alsa_element *e, snd_mixer_t *m, const 
pa_channel_map *cm, pa_cvolume *v) {
@@ -737,7 +737,7 @@ static int element_get_volume(pa_alsa_element *e, 
snd_mixer_t *m, const pa_chann
 pa_assert(cm);
 pa_assert(v);
 
-SELEM_INIT(sid, e->alsa_name);
+SELEM_INIT(sid, e->alsa_name, e->index);
 if (!(me = snd_mixer_find_selem(m, sid))) {
 pa_log_warn("Element %s seems to have disappeared.", e->alsa_name);
 return -1;
@@ -902,7 +902,7 @@ static int element_get_switch(pa_alsa_element *e, 
snd_mixer_t *m, bool *b) {
 pa_assert(e);
 pa_assert(b);
 
-SELEM_INIT(sid, e->alsa_name);
+SELEM_INIT(sid, e->alsa_name, e->index);
 if (!(me = snd_mixer_find_selem(m, sid))) {
 pa_log_warn("Element %s seems to have disappeared.", e->alsa_name);
 return -1;
@@ -1066,7 +1066,7 @@ static int element_set_volume(pa_alsa_element *e, 
snd_mixer_t *m, const pa_chann
 pa_assert(v);
 pa_assert(pa_cvolume_compatible_with_channel_map(v, cm));
 
-SELEM_INIT(sid, e->alsa_name);
+SELEM_INIT(sid, e->alsa_name, e->index);
 if (!(me = snd_mixer_find_selem(m, sid))) {
 pa_log_warn("Element %s seems to have disappeared.", e->alsa_name);
 return -1;
@@ -1256,7 +1256,7 @@ static int element_set_switch(pa_alsa_element *e, 
snd_mixer_t *m, bool b) {
 pa_assert(m);
 pa_assert(e);
 
-SELEM_INIT(sid, e->alsa_name);
+SELEM_INIT(sid, e->alsa_name, e->index);
 if (!(me = snd_mixer_find_selem(m, sid))) {
 pa_log_warn("Element %s seems to have disappeared.", e->alsa_name);
 return -1;
@@ -1307,7 +1307,7 @@ static int element_set_constant_volume(pa_alsa_element 
*e, snd_mixer_t *m) {
 pa_assert(m);
 pa_assert(e);
 
-SELEM_INIT(sid, e->alsa_name);
+SELEM_INIT(sid, e->alsa_name, e->index);
 if (!(me = snd_mixer_find_selem(m, sid))) {
 pa_log_warn("Element %s seems to have disappeared.", e->alsa_name);
 return -1;
@@ -1734,7 +1734,7 @@ static int element_probe(pa_alsa_element *e, snd_mixer_t 
*m) {
 pa_assert(e);
 pa_assert(e->path);
 
-SELEM_INIT(sid, e->alsa_name);
+SELEM_INIT(sid, e->alsa_name, e->index);
 
 if (!(me = snd_mixer_find_selem(m, sid))) {
 
@@ -1837,7 +1837,7 @@ static int jack_probe(pa_alsa_jack *j, pa_alsa_mapping 
*mapping, snd_mixer_t *m)
 j->append_pcm_to_name = false;
 }
 
-has_control = pa_alsa_mixer_find(m, j->alsa_name, 0) != NULL;
+has_control = pa_alsa_mixer_find(m, j->alsa_name, 0, j->index) != NULL;
 pa_alsa_jack_set_has_control(j, has_control);
 
 if (j->has_control) {
@@ -1959,6 +1959,36 @@ finish:
 return o;
 }
 
+static int element_parse_index(pa_config_parser_state *state) {
+pa_alsa_path *p;
+pa_alsa_element *e;
+pa_alsa_jack *j;
+uint32_t ind;
+
+pa_assert(state);
+
+p = state->userdata;
+
+e = element_get(p, state->section, true);
+j = jack_get(p, state->section);
+if (!e && !j)
+   goto error;
+
+if 

[pulseaudio-discuss] [PATCH v2 2/2] alsa-mixer: set different strings to name and alsa-name for jack and element

2019-01-13 Thread Hui Wang
It is possible that we set more than one jacks or elements with the same name
and different index in a {path}.conf, the current code will only generate
one pa_alsa_jack or pa_alsa_element for them regardless of the difference
of index number.

To fix it, we change the rule of naming an element or a jack, let us use
the element as an example, if the index of this element is 0, we don't
set index for it in the {path}.conf and set the element name to 
as before, if the index number is 1, we should set the "index = 1" for
this element in the {path}.conf and set the element name to @1, then
in the alsa-mixer.c, the "@1" will be set to the element->name, and
the "" will be set to the element->alsa_name, we generated the new
element based on the element->name, then this issue is fixed.

Signed-off-by: Hui Wang 
---
 src/modules/alsa/alsa-mixer.c | 40 +++
 src/modules/alsa/alsa-mixer.h |  4 +-
 .../mixer/paths/analog-output.conf.common |  3 +-
 3 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index e32ec5cd7..b4933e07f 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -100,6 +100,8 @@ static inline int 
vgfix_get_playback_dB_range(snd_mixer_elem_t *a, long *b, long
 
 #endif
 
+#define SEC_NAME_INDEX_DELIMITER "@"
+
 static int setting_select(pa_alsa_setting *s, snd_mixer_t *m);
 
 struct description_map {
@@ -109,13 +111,17 @@ struct description_map {
 
 pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name) {
 pa_alsa_jack *jack;
+char *tmp_name;
+const char *split_state = NULL;
 
 pa_assert(name);
 
 jack = pa_xnew0(pa_alsa_jack, 1);
 jack->path = path;
 jack->name = pa_xstrdup(name);
-jack->alsa_name = pa_sprintf_malloc("%s Jack", name);
+tmp_name = pa_split(name, SEC_NAME_INDEX_DELIMITER, _state);
+jack->alsa_name = pa_sprintf_malloc("%s Jack", tmp_name);
+pa_xfree(tmp_name);
 jack->state_unplugged = PA_AVAILABLE_NO;
 jack->state_plugged = PA_AVAILABLE_YES;
 jack->ucm_devices = pa_dynarray_new(NULL);
@@ -657,6 +663,7 @@ static void element_free(pa_alsa_element *e) {
 if (e->db_fix)
 decibel_fix_free(e->db_fix);
 
+pa_xfree(e->name);
 pa_xfree(e->alsa_name);
 pa_xfree(e);
 }
@@ -1820,6 +1827,8 @@ static int jack_probe(pa_alsa_jack *j, pa_alsa_mapping 
*mapping, snd_mixer_t *m)
 
 if (j->append_pcm_to_name) {
 char *new_name;
+char *tmp_name;
+const char *split_state = NULL;
 
 if (!mapping) {
 /* This could also be an assertion, because this should never
@@ -1831,7 +1840,9 @@ static int jack_probe(pa_alsa_jack *j, pa_alsa_mapping 
*mapping, snd_mixer_t *m)
 return -1;
 }
 
-new_name = pa_sprintf_malloc("%s,pcm=%i Jack", j->name, 
mapping->hw_device_index);
+tmp_name = pa_split(j->name, SEC_NAME_INDEX_DELIMITER, _state);
+new_name = pa_sprintf_malloc("%s,pcm=%i Jack", tmp_name, 
mapping->hw_device_index);
+pa_xfree(tmp_name);
 pa_xfree(j->alsa_name);
 j->alsa_name = new_name;
 j->append_pcm_to_name = false;
@@ -1855,6 +1866,8 @@ static int jack_probe(pa_alsa_jack *j, pa_alsa_mapping 
*mapping, snd_mixer_t *m)
 
 static pa_alsa_element* element_get(pa_alsa_path *p, const char *section, bool 
prefixed) {
 pa_alsa_element *e;
+char *tmp_name;
+const char *split_state = NULL;
 
 pa_assert(p);
 pa_assert(section);
@@ -1870,16 +1883,19 @@ static pa_alsa_element* element_get(pa_alsa_path *p, 
const char *section, bool p
 if (strchr(section, ':'))
 return NULL;
 
-if (p->last_element && pa_streq(p->last_element->alsa_name, section))
+if (p->last_element && pa_streq(p->last_element->name, section))
 return p->last_element;
 
 PA_LLIST_FOREACH(e, p->elements)
-if (pa_streq(e->alsa_name, section))
+if (pa_streq(e->name, section))
 goto finish;
 
 e = pa_xnew0(pa_alsa_element, 1);
 e->path = p;
-e->alsa_name = pa_xstrdup(section);
+e->name = pa_xstrdup(section);
+tmp_name = pa_split(section, SEC_NAME_INDEX_DELIMITER, _state);
+e->alsa_name = pa_xstrdup(tmp_name);
+pa_xfree(tmp_name);
 e->direction = p->direction;
 e->volume_limit = -1;
 
@@ -2692,6 +2708,8 @@ fail:
 pa_alsa_path *pa_alsa_path_synthesize(const char *element, pa_alsa_direction_t 
direction) {
 pa_alsa_path *p;
 pa_alsa_element *e;
+char *tmp_name;
+const char *split_state = NULL;
 
 pa_assert(element);
 
@@ -2702,7 +2720,10 @@ pa_alsa_path *pa_alsa_path_synthesize(const char 
*element, pa_alsa_direction_t d
 
 e = pa_xnew0(pa_alsa_element, 1);
 e->path = p;
-e->alsa_name = pa_xstrdup(element);
+e->name = pa_xstrdup(element);
+tmp_name = pa_split(element, SEC_NAME_INDEX_DELIMITER, _state);
+e->alsa_name =