13
295
Fork
You've already forked yambar
74

New modules pipewire #224

Manually merged
Ogromny merged 1 commit from :pipewire into master 2022年12月13日 10:39:07 +01:00
Contributor
Copy link

This is the continuity of #215

This is the continuity of https://codeberg.org/dnkl/yambar/pulls/215
Ogromny force-pushed pipewire from 2dc65b17a7
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 71a9924927
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2022年09月03日 17:40:22 +02:00
Compare
Contributor
Copy link

(Responding to @Ogromny in #223 (comment))

@Ogromny, I tried the icon tag, but it is empty for me (both with and without headphones plugged in). Both form_factor and bus are empty as well, unfortunately. Is this something that has to be configured manually in PipeWire?

Hum, can you do a

pw-metadata it should list a source and a sink.

I get this:

$ pw-metadata
Found "default" metadata 36
update: id:0 key:'default.audio.source' value:'{"name":"alsa_input.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON'
update: id:0 key:'default.audio.sink' value:'{"name":"alsa_output.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON'

Now do a pw-cli ls Node, you should see your Sink Node and your Source Node.

Now take note of a Node id, let say that your Sink Node id is 35, do a pw-dump 35 and under the props object (at the top of the output) you see a device.icon-name, that's the icon tag, device.bus is the bus tag and device.form-factor is the form-factor tag.

The device.icon-name and device.bus should be always present and non empty. So maybe it's a misconfigured pipewire (missing wireplumber or pipewire-media-session), missing configuration for pipewire-pulse or simply a bug.

pw-cli ls Node shows me that the sink node has ID 47, and pw-dump 47 gives the following output (I can post the full output if you want):

...
"props": {
 "alsa.card": 1,
 "alsa.card_name": "HDA Intel PCH",
 "alsa.class": "generic",
 "alsa.device": 0,
 "alsa.driver_name": "snd_hda_intel",
 "alsa.id": "ALC283 Analog",
 "alsa.long_card_name": "HDA Intel PCH at 0x7eb1c000 irq 46",
 "alsa.name": "ALC283 Analog",
 "alsa.resolution_bits": 16,
 "alsa.subclass": "generic-mix",
 "alsa.subdevice": 0,
 "alsa.subdevice_name": "subdevice #0",
 "api.alsa.card.longname": "HDA Intel PCH at 0x7eb1c000 irq 46",
 "api.alsa.card.name": "HDA Intel PCH",
 "api.alsa.path": "front:1",
 "api.alsa.pcm.card": 1,
 "api.alsa.pcm.stream": "playback",
 "audio.channels": 2,
 "audio.position": "FL,FR",
 "card.profile.device": 3,
 "device.api": "alsa",
 "device.class": "sound",
 "device.id": 41,
 "device.profile.description": "Analog Stereo",
 "device.profile.name": "analog-stereo",
 "device.routes": 2,
 "factory.name": "api.alsa.pcm.sink",
 "media.class": "Audio/Sink",
 "node.description": "Built-in Audio Analog Stereo",
 "node.name": "alsa_output.pci-0000_00_1b.0.analog-stereo",
 "node.nick": "ALC283 Analog",
 "node.pause-on-idle": false,
 "object.path": "alsa:pcm:1:front:1:playback",
 "priority.driver": 1009,
 "priority.session": 1009,
 "factory.id": 18,
 "clock.quantum-limit": 8192,
 "client.id": 35,
 "node.driver": true,
 "factory.mode": "merge",
 "audio.adapt.follower": "",
 "library.name": "audioconvert/libspa-audioconvert",
 "object.id": 47,
 "object.serial": 48
},
...

As you can see, device.icon-name, device.bus and device.form-factor are all missing. I tried removing ~/.local/state/{pipewire,wireplumber} (with pipewire and wireplumber stopped), but the issue remains.

Any ideas how I can investigate further what's going on here?

(Responding to @Ogromny in https://codeberg.org/dnkl/yambar/pulls/223#issuecomment-615123) > > @Ogromny, I tried the `icon` tag, but it is empty for me (both with and without headphones plugged in). Both `form_factor` and `bus` are empty as well, unfortunately. Is this something that has to be configured manually in PipeWire? > > Hum, can you do a > > `pw-metadata` it should list a source and a sink. I get this: ```console $ pw-metadata Found "default" metadata 36 update: id:0 key:'default.audio.source' value:'{"name":"alsa_input.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON' update: id:0 key:'default.audio.sink' value:'{"name":"alsa_output.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON' ``` > Now do a `pw-cli ls Node`, you should see your Sink Node and your Source Node. > > Now take note of a Node id, let say that your Sink Node id is 35, do a `pw-dump 35` and under the `props` object (at the top of the output) you see a `device.icon-name`, that's the `icon` tag, `device.bus` is the `bus` tag and `device.form-factor` is the `form-factor` tag. > > The `device.icon-name` and `device.bus` should be always present and non empty. So maybe it's a misconfigured pipewire (missing wireplumber or pipewire-media-session), missing configuration for pipewire-pulse or simply a bug. `pw-cli ls Node` shows me that the sink node has ID 47, and `pw-dump 47` gives the following output (I can post the full output if you want): ``` ... "props": { "alsa.card": 1, "alsa.card_name": "HDA Intel PCH", "alsa.class": "generic", "alsa.device": 0, "alsa.driver_name": "snd_hda_intel", "alsa.id": "ALC283 Analog", "alsa.long_card_name": "HDA Intel PCH at 0x7eb1c000 irq 46", "alsa.name": "ALC283 Analog", "alsa.resolution_bits": 16, "alsa.subclass": "generic-mix", "alsa.subdevice": 0, "alsa.subdevice_name": "subdevice #0", "api.alsa.card.longname": "HDA Intel PCH at 0x7eb1c000 irq 46", "api.alsa.card.name": "HDA Intel PCH", "api.alsa.path": "front:1", "api.alsa.pcm.card": 1, "api.alsa.pcm.stream": "playback", "audio.channels": 2, "audio.position": "FL,FR", "card.profile.device": 3, "device.api": "alsa", "device.class": "sound", "device.id": 41, "device.profile.description": "Analog Stereo", "device.profile.name": "analog-stereo", "device.routes": 2, "factory.name": "api.alsa.pcm.sink", "media.class": "Audio/Sink", "node.description": "Built-in Audio Analog Stereo", "node.name": "alsa_output.pci-0000_00_1b.0.analog-stereo", "node.nick": "ALC283 Analog", "node.pause-on-idle": false, "object.path": "alsa:pcm:1:front:1:playback", "priority.driver": 1009, "priority.session": 1009, "factory.id": 18, "clock.quantum-limit": 8192, "client.id": 35, "node.driver": true, "factory.mode": "merge", "audio.adapt.follower": "", "library.name": "audioconvert/libspa-audioconvert", "object.id": 47, "object.serial": 48 }, ... ``` As you can see, `device.icon-name`, `device.bus` and `device.form-factor` are all missing. I tried removing `~/.local/state/{pipewire,wireplumber}` (with `pipewire` and `wireplumber` stopped), but the issue remains. Any ideas how I can investigate further what's going on here?
Author
Contributor
Copy link

(Responding to @Ogromny in #223 (comment))

@Ogromny, I tried the icon tag, but it is empty for me (both with and without headphones plugged in). Both form_factor and bus are empty as well, unfortunately. Is this something that has to be configured manually in PipeWire?

Hum, can you do a

pw-metadata it should list a source and a sink.

I get this:

$ pw-metadata
Found "default" metadata 36
update: id:0 key:'default.audio.source' value:'{"name":"alsa_input.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON'
update: id:0 key:'default.audio.sink' value:'{"name":"alsa_output.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON'

Now do a pw-cli ls Node, you should see your Sink Node and your Source Node.

Now take note of a Node id, let say that your Sink Node id is 35, do a pw-dump 35 and under the props object (at the top of the output) you see a device.icon-name, that's the icon tag, device.bus is the bus tag and device.form-factor is the form-factor tag.

The device.icon-name and device.bus should be always present and non empty. So maybe it's a misconfigured pipewire (missing wireplumber or pipewire-media-session), missing configuration for pipewire-pulse or simply a bug.

pw-cli ls Node shows me that the sink node has ID 47, and pw-dump 47 gives the following output (I can post the full output if you want):

...
"props": {
 "alsa.card": 1,
 "alsa.card_name": "HDA Intel PCH",
 "alsa.class": "generic",
 "alsa.device": 0,
 "alsa.driver_name": "snd_hda_intel",
 "alsa.id": "ALC283 Analog",
 "alsa.long_card_name": "HDA Intel PCH at 0x7eb1c000 irq 46",
 "alsa.name": "ALC283 Analog",
 "alsa.resolution_bits": 16,
 "alsa.subclass": "generic-mix",
 "alsa.subdevice": 0,
 "alsa.subdevice_name": "subdevice #0",
 "api.alsa.card.longname": "HDA Intel PCH at 0x7eb1c000 irq 46",
 "api.alsa.card.name": "HDA Intel PCH",
 "api.alsa.path": "front:1",
 "api.alsa.pcm.card": 1,
 "api.alsa.pcm.stream": "playback",
 "audio.channels": 2,
 "audio.position": "FL,FR",
 "card.profile.device": 3,
 "device.api": "alsa",
 "device.class": "sound",
 "device.id": 41,
 "device.profile.description": "Analog Stereo",
 "device.profile.name": "analog-stereo",
 "device.routes": 2,
 "factory.name": "api.alsa.pcm.sink",
 "media.class": "Audio/Sink",
 "node.description": "Built-in Audio Analog Stereo",
 "node.name": "alsa_output.pci-0000_00_1b.0.analog-stereo",
 "node.nick": "ALC283 Analog",
 "node.pause-on-idle": false,
 "object.path": "alsa:pcm:1:front:1:playback",
 "priority.driver": 1009,
 "priority.session": 1009,
 "factory.id": 18,
 "clock.quantum-limit": 8192,
 "client.id": 35,
 "node.driver": true,
 "factory.mode": "merge",
 "audio.adapt.follower": "",
 "library.name": "audioconvert/libspa-audioconvert",
 "object.id": 47,
 "object.serial": 48
},
...

As you can see, device.icon-name, device.bus and device.form-factor are all missing. I tried removing ~/.local/state/{pipewire,wireplumber} (with pipewire and wireplumber stopped), but the issue remains.

Any ideas how I can investigate further what's going on here?

Thanks for the informations, that's weird... I tried to find similar issues on the pipewire gitlab but no one seems to have thing like that. Hum what's your pipewire/wireplumber version ? And I don't know if pulseaudio provide same informations like icon or form-factor. From memory you can do a pactl info or something similar and it'll show you the corresponding icon for the currently selected profile. Or maybe it's pactl list cards, IIRC it'll show a Selected Profile or thing like that with a icon-name field

> (Responding to @Ogromny in https://codeberg.org/dnkl/yambar/pulls/223#issuecomment-615123) > > > > @Ogromny, I tried the `icon` tag, but it is empty for me (both with and without headphones plugged in). Both `form_factor` and `bus` are empty as well, unfortunately. Is this something that has to be configured manually in PipeWire? > > > > Hum, can you do a > > > > `pw-metadata` it should list a source and a sink. > > I get this: > ```console > $ pw-metadata > Found "default" metadata 36 > update: id:0 key:'default.audio.source' value:'{"name":"alsa_input.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON' > update: id:0 key:'default.audio.sink' value:'{"name":"alsa_output.pci-0000_00_1b.0.analog-stereo"}' type:'Spa:String:JSON' > ``` > > > Now do a `pw-cli ls Node`, you should see your Sink Node and your Source Node. > > > > Now take note of a Node id, let say that your Sink Node id is 35, do a `pw-dump 35` and under the `props` object (at the top of the output) you see a `device.icon-name`, that's the `icon` tag, `device.bus` is the `bus` tag and `device.form-factor` is the `form-factor` tag. > > > > The `device.icon-name` and `device.bus` should be always present and non empty. So maybe it's a misconfigured pipewire (missing wireplumber or pipewire-media-session), missing configuration for pipewire-pulse or simply a bug. > > `pw-cli ls Node` shows me that the sink node has ID 47, and `pw-dump 47` gives the following output (I can post the full output if you want): > > ``` > ... > "props": { > "alsa.card": 1, > "alsa.card_name": "HDA Intel PCH", > "alsa.class": "generic", > "alsa.device": 0, > "alsa.driver_name": "snd_hda_intel", > "alsa.id": "ALC283 Analog", > "alsa.long_card_name": "HDA Intel PCH at 0x7eb1c000 irq 46", > "alsa.name": "ALC283 Analog", > "alsa.resolution_bits": 16, > "alsa.subclass": "generic-mix", > "alsa.subdevice": 0, > "alsa.subdevice_name": "subdevice #0", > "api.alsa.card.longname": "HDA Intel PCH at 0x7eb1c000 irq 46", > "api.alsa.card.name": "HDA Intel PCH", > "api.alsa.path": "front:1", > "api.alsa.pcm.card": 1, > "api.alsa.pcm.stream": "playback", > "audio.channels": 2, > "audio.position": "FL,FR", > "card.profile.device": 3, > "device.api": "alsa", > "device.class": "sound", > "device.id": 41, > "device.profile.description": "Analog Stereo", > "device.profile.name": "analog-stereo", > "device.routes": 2, > "factory.name": "api.alsa.pcm.sink", > "media.class": "Audio/Sink", > "node.description": "Built-in Audio Analog Stereo", > "node.name": "alsa_output.pci-0000_00_1b.0.analog-stereo", > "node.nick": "ALC283 Analog", > "node.pause-on-idle": false, > "object.path": "alsa:pcm:1:front:1:playback", > "priority.driver": 1009, > "priority.session": 1009, > "factory.id": 18, > "clock.quantum-limit": 8192, > "client.id": 35, > "node.driver": true, > "factory.mode": "merge", > "audio.adapt.follower": "", > "library.name": "audioconvert/libspa-audioconvert", > "object.id": 47, > "object.serial": 48 > }, > ... > ``` > > As you can see, `device.icon-name`, `device.bus` and `device.form-factor` are all missing. I tried removing `~/.local/state/{pipewire,wireplumber}` (with `pipewire` and `wireplumber` stopped), but the issue remains. > > Any ideas how I can investigate further what's going on here? Thanks for the informations, that's weird... I tried to find similar issues on the pipewire gitlab but no one seems to have thing like that. Hum what's your pipewire/wireplumber version ? And I don't know if pulseaudio provide same informations like `icon` or `form-factor`. From memory you can do a `pactl info` or something similar and it'll show you the corresponding icon for the currently selected profile. Or maybe it's `pactl list cards`, IIRC it'll show a `Selected Profile` or thing like that with a `icon-name` field
Contributor
Copy link

Yeah, I couldn't find any relevant pipewire/wireplumber issues either.

I'm using pipewire 0.3.57 and wireplumber 0.4.11.

pactl list cards shows the properties device.bus, device.form_factor and device.icon_name for the card, and just device.icon_name for each port; pactl list sinks shows all three properties for the sink.

I have another laptop lying around here that also uses Intel HD Audio; I'll see if it is any different there.

Yeah, I couldn't find any relevant pipewire/wireplumber issues either. I'm using pipewire 0.3.57 and wireplumber 0.4.11. `pactl list cards` shows the properties `device.bus`, `device.form_factor` and `device.icon_name` for the card, and just `device.icon_name` for each port; `pactl list sinks` shows all three properties for the sink. I have another laptop lying around here that also uses Intel HD Audio; I'll see if it is any different there.
Contributor
Copy link

Update: I tried the other laptop, and got the same results.

By the way, I noticed that devices (PipeWire:Interface:Device) do have the properties device.bus, device.form-factor and device.icon-name on my machine.

Update: I tried the other laptop, and got the same results. By the way, I noticed that devices (`PipeWire:Interface:Device`) _do_ have the properties `device.bus`, `device.form-factor` and `device.icon-name` on my machine.
Author
Contributor
Copy link

Hum, okay I think I know how to find/provide theses informations. I will try to do that by tomorrow

Edit: I found how to get icon, form-factor, etc, exactly like pactl does, I'm quite busy right now, I think it will be finished in 2-3 days, just to let you know.

Hum, okay I think I know how to find/provide theses informations. I will try to do that by tomorrow Edit: I found how to get icon, form-factor, etc, exactly like pactl does, I'm quite busy right now, I think it will be finished in 2-3 days, just to let you know.
Ogromny force-pushed pipewire from f65eb02921
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 7bd38909ce
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2022年09月12日 15:27:48 +02:00
Compare
Author
Contributor
Copy link

@wvdk Can you retry please, it should be good

@wvdk Can you retry please, it should be good
Contributor
Copy link

@Ogromny, it seems to work now, nice! For the sink, icon gives me audio-headphones/audio-speakers, form_factor gives me headphones/speaker, and bus is empty. For the source, icon gives me audio-input-microphone and form_factor gives me mic (and bus is empty).

I do have one other issue though: the module causes yambar to hang sometimes (when pressing Ctrl-C). I noticed you don't listen on abort_fd; maybe that's what causes this behavior?

@Ogromny, it seems to work now, nice! For the sink, `icon` gives me `audio-headphones`/`audio-speakers`, `form_factor` gives me `headphones`/`speaker`, and `bus` is empty. For the source, `icon` gives me `audio-input-microphone` and `form_factor` gives me `mic` (and `bus` is empty). I do have one other issue though: the module causes `yambar` to hang sometimes (when pressing Ctrl-C). I noticed you don't listen on `abort_fd`; maybe that's what causes this behavior?
Author
Contributor
Copy link

@wvdk yeah bus for me is almost always empty except for the bluetooth source/sink, do you think we should keep it or we should remove it ?

Concerning the hang issue, I experiences it too, let me some days and it will be fixed too !

Glad to hear that the module now work almost properly for you now.

@wvdk yeah `bus` for me is almost always empty except for the bluetooth source/sink, do you think we should keep it or we should remove it ? Concerning the hang issue, I experiences it too, let me some days and it will be fixed too ! Glad to hear that the module now work almost properly for you now.
Author
Contributor
Copy link

@wvdk Sorry for the delay, should be good, the module listens to abort_fd now

@wvdk Sorry for the delay, should be good, the module listens to `abort_fd` now
Contributor
Copy link

@Ogromny, that seems to have fixed the hangs indeed!

@Ogromny, that seems to have fixed the hangs indeed!
Ogromny force-pushed pipewire from c13dd6bde7
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 1247e7b844
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2022年11月06日 11:08:23 +01:00
Compare
Owner
Copy link

Are there any outstanding issues remaining?

Are there any outstanding issues remaining?
dnkl left a comment
Copy link

Thanks! Looks mostly good. It's missing a changelog entry, and I have a couple of questions (below), but that's just about it.

Thanks! Looks mostly good. It's missing a changelog entry, and I have a couple of questions (below), but that's just about it.
@ -0,0 +167,4 @@
bool is_sink;
};
static struct node_data node_data_sink;
static struct node_data node_data_source;
Owner
Copy link

This isn't multi-thread safe? What if the user instantiates two, or more, pipewire modules?

This isn't multi-thread safe? What if the user instantiates two, or more, pipewire modules?
Author
Contributor
Copy link

I've just tested running 2+ instances of yambar with the pipewire module, seems to run fine, pipewire spawn a new process everytime. I'm not really really sure if this is thread safe tho, I never did multi-thread programming related things. Maybe I can just make these global non static ? What do you think ?

I've just tested running 2+ instances of yambar with the pipewire module, seems to run fine, pipewire spawn a new process everytime. I'm not really really sure if this is thread safe tho, I never did multi-thread programming related things. Maybe I can just make these global non static ? What do you think ?
Owner
Copy link

Removing static wont help. They'll still be globals. The only way to make this thread safe is to move them into one of the module structs. The data struct seems like a good candidate.

I've just tested running 2+ instances of yambar with the pipewire module, seems to run fine, pipewire spawn a new process everytime

Well, multithreading bugs often don't trigger consistently :) Sometimes they can be super hard to trigger. But that doesn't mean they're not there.

In almost all cases, using globals is a very bad idea in a multithreaded environment.

Removing `static` wont help. They'll still be globals. The only way to make this thread safe is to move them into one of the module structs. The `data` struct seems like a good candidate. > I've just tested running 2+ instances of yambar with the pipewire module, seems to run fine, pipewire spawn a new process everytime Well, multithreading bugs often don't trigger consistently :) Sometimes they can be super hard to trigger. But that doesn't mean they're not there. In almost all cases, using globals is a very bad idea in a multithreaded environment.
Author
Contributor
Copy link

Fixed ! Thanks for the infos.

Fixed ! Thanks for the infos.
Ogromny marked this conversation as resolved
@ -0,0 +830,4 @@
mtx_lock(&module->lock);
static struct exposable *exposables[2];
static size_t exposables_length = ARRAY_LENGTH(exposables);
Owner
Copy link

Why are these static?

Why are these static?
Author
Contributor
Copy link

No particular reason, without static it'll work fine too, do you want me to make thoses non static ?

No particular reason, without static it'll work fine too, do you want me to make thoses non static ?
Owner
Copy link

Yes please. As static variables, they are very similar to globals, and are thus not multithread safe.

Yes please. As static variables, they are very similar to globals, and are thus not multithread safe.
Author
Contributor
Copy link

Done

Done
Ogromny marked this conversation as resolved
Ogromny force-pushed pipewire from 1247e7b844
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 17ea959880 2022年12月10日 10:25:01 +01:00
Compare
dnkl left a comment
Copy link

Looks good. Though, I still don't see a changelog entry...

Looks good. Though, I still don't see a changelog entry...
Author
Contributor
Copy link

My bad I forgot, added now

My bad I forgot, added now
dnkl left a comment
Copy link

Looks good! Please clean up the commit list as you see fit (squashing is fine), then I'll merge.

Looks good! Please clean up the commit list as you see fit (squashing is fine), then I'll merge.
Ogromny force-pushed pipewire from bd5da260ba to 19a9f099e2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022年12月13日 10:18:09 +01:00
Compare
Author
Contributor
Copy link

Should be good !

Should be good !
Ogromny manually merged commit 19a9f099e2 into master 2022年12月13日 10:39:07 +01:00
Owner
Copy link

Awesome job, thanks!

Awesome job, thanks!
Ogromny deleted branch pipewire 2022年12月13日 22:54:52 +01:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/yambar!224
Reference in a new issue
dnkl/yambar
No description provided.
Delete branch ":pipewire"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?