Sound shuts off when switching to other virtual console

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
awik
Level 3
Level 3
Posts: 183
Joined: Sun Dec 08, 2019 10:05 am

Sound shuts off when switching to other virtual console

Post by awik »

Hi all,

I listen to Internet radio a lot, while I work. As long as I stay in X-win, the sound works fine, but when I switch to another virtual console, eg. using <Ctrl+Alt+F1> the sound goes silent, until I switch back to the console where X is running. Why is this, and can it be fixed? I've only had this problem on Mint.

-Albert.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
MrEen
Level 23
Level 23
Posts: 18270
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound shuts off when switching to other virtual console

Post by MrEen »

Hi awik,

I believe the accepted answer here will basically answer this for you:
Linux has multiple virtual consoles. Ctrl+Alt+Fn switches between these consoles. When you switch from console 7 to console 2, the input and output peripherals are re-routed from console 7 to console 2. When console 7 is inactive, it has no access to the input/output peripherals: the display isn't shown on the screen, the applications don't receive keyboard input, etc.

For historical reasons, sound input and output uses completely different channels from input devices such as keyboard and mouse and from video displays. Console devices (the abstraction in the operating system) cover keyboard and video but not sound. The most common basic implementation of sound on a Unix system is independent from that system, and permission to use the sound peripherals is granted based on group membership rather than on ownership of the console. This is in fact a design deficiency.

Ubuntu has set things up so that the session logged into the console, and only them, has access to the audio device. If you switch consoles, you lose access to the audio device, unless you also log into that other console. This is what really should have been done from the start, but wasn't because the designers of console interfaces weren't thinking about sound.

When you switch to another console, your programs keep running, because the CPU is not associated with a console but with a machine: anyone with an account on the machine is allowed to use CPU time. The same goes for other resources such as memory and files (subject to permissions). It's only interactions with the user that are governed by console ownership. Your sound stops playing when you switch to a console where you aren't logged in because your programs lose the privilege to access the sound output device.

I believe that Ubuntu implements access control via Polkit, but I don't know exactly how this works.
awik wrote: Sat Aug 22, 2020 10:17 amI've only had this problem on Mint.
On other systems, you may be starting PulseAudio in system mode instead of user mode. The user mode is default on Ubuntu based systems. Using system mode can be done, but it's not something I've done myself. This page might help with that: https://rudd-o.com/linux-and-free-softw ... your-users
awik
Level 3
Level 3
Posts: 183
Joined: Sun Dec 08, 2019 10:05 am

Re: Sound shuts off when switching to other virtual console

Post by awik »

I found that it starts playing again after I log in on a console as the same user as on X. Then I can even su to root without interrupting the music. I can cope with it this way. It's good to know about system mode in case it turns out I need it later.

-aw
User avatar
MrEen
Level 23
Level 23
Posts: 18270
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound shuts off when switching to other virtual console

Post by MrEen »

Sounds good awik. I'm glad you found something that works for you.
Locked

Return to “Software & Applications”