audio-output-switcher icon indicating copy to clipboard operation
audio-output-switcher copied to clipboard

Feature/Regression Request: Allow selection of active device

Open Bujiraso opened this issue 10 years ago • 18 comments

In a previous version of the audio-output-switcher, the active output device could be selected from the drop-down, but now it is a label which cannot be selected. This had the benefit of moving all streams which have been "left behind" on another device before the system was rebooted over to the current stream.

This feature can be achieved by regressing to the old drop-down style, or by adding an option to Reset All Streams to the current audio device.

Another way to achieve this effect is to monitor for new streams and move them automatically over to the current device, but this seems perhaps an overstep of what a user may desire, and more difficult to implement

Use case (a.k.a. the long reason why this would be nice) The use case for this feature is as follows. When I move my desktop over to my television, the HDMI audio stream becomes the stream which I want all my programs to move to. I use the audio-output-switcher to achieve this. I often shut-down the PC while the TV is the active display, and the HDMI audio output as the active audio output stream. This means that, when I power my computer on again, and my audio and video output streams are both reverted-to-default to my main monitor and speakers, any programs that were running "last night" are outputting their audio to the TV, which I cannot hear. In prior versions of the audio-output-switcher, I would just click the drop-down and select the active audio device. Currently, I have to select another audio device, and then open the panel again and select the current audio device. This means I have to suspend any videos that I'm watching so that I don't miss segments of audio. Hence why I'd appreciate the feature/regression!

Bujiraso avatar Jun 03 '14 23:06 Bujiraso

So just to make sure I understand that correctly; you want to "re-select" the currently selected device, right ?

anduchs avatar Jun 05 '14 04:06 anduchs

Hi there...

I did some redesign of how the extension works and recently also made it more stable for suspend/resume. Would you mind testing the branch ports2 ? It might show the correct output-device for you now...

anduchs avatar Jun 08 '14 12:06 anduchs

Yep. I want to re-select the current device. I'll try the redesign.

Bujiraso avatar Jun 09 '14 10:06 Bujiraso

The redesign works for me. The output devices are different (more of them), but re-select is still not possible.

Bujiraso avatar Jun 09 '14 11:06 Bujiraso

hmmmm... my hope was, that "re-selection" would not be necessary now... a pitty... :-(

I created a branch for you called reselection... But I'm afraid, I won"t mainline it... Maybe I'll make it a config-option at some point, but I guess your case is 1 in a million... ;)

anduchs avatar Jun 09 '14 14:06 anduchs

I have the reselection branch checked out and installed. I'll let you know if it works next time I reboot.

I'd like to add a bit of clarity to what's going on as it doesn't seem I've explained very well. The reason I need to reselect is not because the device isn't showing, it's because applications remember which audio output stream they were last using if the PC is shut-down on a non-default audio output stream. Here's a more bug-like report:

Steps to reproduce: Ensure the default audio output stream is selected (the one that is selected at boot) and open a music player or some application which makes easily producible sounds. Switch the current audio device using the audio-output-switcher. Ensure that the audio is now playing out of a non-default audio output stream. Reboot the PC and open the same application used earlier and produce some more sounds. Note: Make sure that the default audio stream has been reselected on reboot. If it has not been reselected on reboot, repeat the above steps with an audio device that may be detached from the system so it is not selectable on boot, and the default audio device gets reselected. My television remains off during the day and, without it being on, the system is unable to detect its audio output stream and falls back to the default output stream. Expected behaviour: Sound plays from the default audio device Actual behaviour: Sound plays from the device which was selected before the reboot EXCEPT: This is not a problem with the gnome-extension. This is likely a problem with either gnome or pulseaudio or something deeper. I should most likely report it to them, too! Quick-fix Solution: Allow reselect of current audio device (like in an older version for gnome 3.10). That is what the new branch does, so I'll try it out and see if it works by tomorrow!

Bujiraso avatar Jun 11 '14 15:06 Bujiraso

I think I have another idea; since the reselection of the currently already selected (non-default) device solves your problem, my idea would be that my extension could just select the currently selected device on initialize. I guess I'd have to jump through some loops for this, but it should work for you case, right ?

anduchs avatar Jun 11 '14 18:06 anduchs

I just want to clarify on what you said a bit. I never reselect the non-default device, I only reselect the default device on reboot. Here's an example of the workflow in a linear state-diagram-like format. States are labelled with numbers in order of their occurrence, events come between each states to move from one state to another, and there are three audio devices which will be referred to: DEFAULT, which is the default audio output stream; HDMI, which is the alternate device; and OTHER, which is some random other device for explanation purposes only -- any other output stream that isn't the other two.

State 1: DEFAULT: Available. Selected. In this example, currently playing YouTube videos in Firefox HDMI: Not available. Not selected. Not playing any streams.

Event 1_to_2 : Turn television on. (Go to next state)

State 2: DEFAULT: Available. Selected. Playing YouTube videos HDMI: Available. Unselected. Not playing any streams.

Event 2_to_3 : Switch active device from DEFAULT to HDMI

State 3: DEFAULT: Available. Unselected. Not playing any streams. HDMI: Available. Selected. Playing all streams that were moved from the DEFAULT device, including the YouTube videos.

Event 3_to_4: Turn off TV and then reboot the PC

State 4: DEFAULT: Available. Selected. Playing nothing yet since PC has been rebooted. HDMI: Unavailable. Unselected. Not playing any streams since PC has been rebooted

Event 4_to_5: Play some sounds, for instance, more YouTube videos

State 5: DEFAULT: Available. Selected. Not playing any streams. HDMI: Unavailable. Unselected. But the YouTube stream is assumedly playing here, because the system remembers that it was last played here, persisting beyond a reboot

Event 5_to_6: Switch audio device from DEFAULT to OTHER (a new device, not HDMI). Switch back from OTHER to DEFAULT

State 6: DEFAULT: Available Selected. Playing Youtube videos now that the streams have been all redirected towards OTHER, and then towards DEFAULT HDMI: Unavailable. Unselected. Not playing any streams.

So the difference here is that I would prefer to reselect the current device so I can skip having to open the menu twice. I hope this work-flow has helped clear up what's occurring.

Bujiraso avatar Jun 11 '14 19:06 Bujiraso

Now, to answer your question: I will also test in the next couple days (my PC needs to be on today so I can't do it right now) whether or not simply changing the device from my default to another and then back fixes it, or using the reselect feature in the branch you kindly opened for me. I can't tell whether or not it would work without Firefox already being opened, because I worry that the stream would not be redirected and that Firefox would still open up on the wrong stream. So I'll let you know if it works on reboot before Firefox has been opened, or if it doesn't since the stream is not active at login

Bujiraso avatar Jun 11 '14 19:06 Bujiraso

Ok, I coded up my idea in reselection2. Maybe that latest commit explains my idea better then my text. My hope is that with the latest change, you would actually not have to select anything on startup, since it will select the currently anyways selected device once more (which seems to be what you do manually).

anduchs avatar Jun 11 '14 20:06 anduchs

Ok cool, I'll try out reselection2 later. Right now I don't see the branch, I only see ports, ports2 and reselection. Also, I have some bad news! For some reason -- the reselection branch doesn't work. I try to reselect the current audio device and it does nothing. However, if I select another audio device, and then the current audio device, the streams come back. That is to say, I do the exact same thing as on the master branch.

I want to be super clear here that an older version of this exact extension did allow reselection and it worked. If it helps you figure out which commit it was: at the time, the options box did not have an outer-level non-clickable label. That is, it wasn't really a drop-down, it kind of expanded and every choice was an option. I would go back and try and find the version, but I believe it only ran on Gnome 3.10 so it wouldn't do me much good right now.

Bujiraso avatar Jun 12 '14 13:06 Bujiraso

Ok, that's interesting... With ports2 and reselection branches, I changed the way I handle device choice from set_sink to some UIDevice API... I guess this makes some internal changes as well...

Anyways for the quick fix, pick up the master branch and remove these lines from function _updateSinkList(): if (sink === defsink) continue;

I'll prepare a new reselection2 branch, that uses the old "set_sink" once on startup for reselection but the newer logics for actual output-selection afterwards... I hope this might solve your issues...

anduchs avatar Jun 12 '14 14:06 anduchs

Alright. I'll clone master and remove those two lines and let you know what happens next time I reboot Thanks!

Bujiraso avatar Jun 13 '14 13:06 Bujiraso

Hi again. Yeah, removing those two lines from master is exactly what I was looking for in terms of "re-enabling reselection". The functionality works like it did before and I don't need to open the menu twice -- I can just reselect the current device to redirect the missing streams

Bujiraso avatar Jun 16 '14 15:06 Bujiraso

Should I still attempt to adjust the new layout or wouldn't you care testing that ?

anduchs avatar Jun 17 '14 15:06 anduchs

Definitely. This works if we can't find another solution but if we can make some change to master so that I don't have to modify the new versions each time, that'd be great.

Bujiraso avatar Jun 17 '14 18:06 Bujiraso

Ok, I'll keep this on my todo list then... ;-)

anduchs avatar Jun 18 '14 14:06 anduchs

Thanks : 3

Bujiraso avatar Jun 19 '14 00:06 Bujiraso