After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689359 - Add support for dynamic port creation/deletion
Add support for dynamic port creation/deletion
Status: RESOLVED INVALID
Product: gnome-control-center
Classification: Core
Component: Sound
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Control center sound maintainer(s)
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-11-30 16:50 UTC by David Henningsson
Modified: 2013-04-15 10:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
1/3 (4.05 KB, patch)
2012-11-30 16:51 UTC, David Henningsson
none Details | Review
2/3 (8.70 KB, patch)
2012-11-30 16:51 UTC, David Henningsson
none Details | Review
3/3 (14.17 KB, patch)
2012-11-30 16:52 UTC, David Henningsson
none Details | Review
1/3 (4.05 KB, patch)
2012-12-13 09:58 UTC, David Henningsson
needs-work Details | Review
2/3 (8.80 KB, patch)
2012-12-13 09:58 UTC, David Henningsson
needs-work Details | Review
3/3 (14.17 KB, patch)
2012-12-13 09:59 UTC, David Henningsson
needs-work Details | Review

Description David Henningsson 2012-11-30 16:50:40 UTC
With PulseAudio 3.0, Bluetooth ports can sometimes appear after a card has been created. Therefore catch new ports as they appear.
Comment 1 David Henningsson 2012-11-30 16:51:10 UTC
Created attachment 230300 [details] [review]
1/3
Comment 2 David Henningsson 2012-11-30 16:51:33 UTC
Created attachment 230301 [details] [review]
2/3
Comment 3 David Henningsson 2012-11-30 16:52:01 UTC
Created attachment 230302 [details] [review]
3/3
Comment 4 David Henningsson 2012-11-30 16:54:17 UTC
I believe I cleaned up a little and fixed a few memory leaks in the process, hopefully without causing new ones :-)

(And hopefully there aren't too many coding style problems either, despite the fact that I almost forgot them while working on PulseAudio & kernel the latest months)
Comment 5 David Henningsson 2012-12-03 15:42:48 UTC
Hmm, I discovered some problems with the existing version of the patches. Please wait a little with committing them.
Comment 6 David Henningsson 2012-12-13 09:58:10 UTC
Created attachment 231457 [details] [review]
1/3
Comment 7 David Henningsson 2012-12-13 09:58:36 UTC
Created attachment 231458 [details] [review]
2/3
Comment 8 David Henningsson 2012-12-13 09:59:00 UTC
Created attachment 231459 [details] [review]
3/3
Comment 9 David Henningsson 2012-12-13 10:01:38 UTC
So it turns out that the patch that was to dynamically add ports was not merged for 3.0, but planned for 4.0 instead. 

Anyway, posting updated patches here but no rush in merging them. I should probably test them with something real too before merging.
Comment 10 Bastien Nocera 2013-01-08 11:41:01 UTC
Review of attachment 231457 [details] [review]:

::: gvc-mixer-card.c
@@ +357,3 @@
 
+static gint
+find_port_by_name (const GvcMixerCardPort *p, const char *n)

That's not a great name. I would expect the function that ran g_list_find_custom() to be called that.

port_compare()?

@@ +375,3 @@
+ * Adds or updates a port.
+ * @port: (transfer full): Template for port to add or update.
+ * Return value: (transfer none) The port added or updated, or NULL if the function

Missing ":" after the parenthesis

@@ +379,3 @@
+ * one passed.
+ */
+const GvcMixerCardPort * gvc_mixer_card_ensure_port       (GvcMixerCard     *card,

Line feed after the return type.

@@ +403,3 @@
+
+        memcpy (p, port, sizeof (GvcMixerCardPort));
+        g_free (port);

free_port (link->data);
link->data = g_memdup (port, sizeof(GvcMixerCardPort));
return link->data;

@@ +412,3 @@
+ * @port_name: Delete the port with this name from the list.
+ */
+gboolean                 gvc_mixer_card_free_port         (GvcMixerCard     *card,

Missing line feed too.

_free_port_by_name() (to not confuse with free_port)

@@ +425,3 @@
+        free_port (link->data);
+        card->priv->ports = g_list_delete_link (card->priv->ports, link);
+        return TRUE;

Line feed before the return.
Comment 11 Bastien Nocera 2013-01-08 11:46:54 UTC
Review of attachment 231458 [details] [review]:

::: gvc-mixer-control.c
@@ +1231,3 @@
+        data.port_name = port_name;
+
+        dlist = g_hash_table_get_values (control->priv->ui_outputs);

Would adding new hashtables be useful to look this up? Instead of the current lookup mechanism.

If not, using g_hash_table_find() looks like it would be cleaner.
Comment 12 Bastien Nocera 2013-01-08 11:51:21 UTC
Review of attachment 231459 [details] [review]:

::: gvc-mixer-control.c
@@ +1867,3 @@
         gint i;
         GList *supported_profiles = NULL;
+        const GList *p;

Looks like a separate bug fix. Can you please split it out?

@@ +1989,3 @@
+        g_debug ("Card removal remove device %s",
+                 gvc_mixer_ui_device_get_description (device));
+        g_hash_table_remove (gvc_mixer_ui_device_is_output (device) ? control->priv->ui_outputs : control->priv->ui_inputs,

Run _device_is_output() once in the function please.

@@ +2002,3 @@
+{
+        /* Currently we only update the availability, since that's
+           the only thing that can change (as of PulseAudio 3.0). */

Put the comment above the code that exits out lower down in the code.

@@ +2006,3 @@
+        guint    signal;
+
+        new_avail = port->available != PA_PORT_AVAILABLE_NO;

brackets around the comparison.

@@ +2029,3 @@
+
+/**
+ * If should_exist == TRUE, this function adds or updates a UI device.

Given the code in the function, a separate "remove_ui_device" would be cleaner.

@@ +2129,3 @@
+
+        for (i = 0; i < info->n_ports; i++) {
+                GvcMixerCardPort *port;

line feed here

@@ +2173,3 @@
+        }
+
+        while (ports_to_delete) {

I prefer for() loops for iterating over lists.
Comment 13 Bastien Nocera 2013-04-15 10:43:48 UTC
(In reply to comment #0)
> With PulseAudio 3.0, Bluetooth ports can sometimes appear after a card has been
> created. Therefore catch new ports as they appear.

Is that the functionality you told me was going to be removed from PA 4.0?

Looks like bug 697545 is the same problem.
Comment 14 David Henningsson 2013-04-15 10:49:49 UTC
The functionality (dynamic port creation/deletion) is not present in either 3.0, nor will it be in 4.0.