Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
change the default sound output card without restarting X?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Sun Aug 25, 2013 2:40 pm    Post subject: change the default sound output card without restarting X? Reply with quote

Is it possible to choose the HDMI sound card as default without restarting X?

I know Mplayer could choose the HDMI sound card to play a film without restarting X.
An example, if I play a video in youtube or a live stream on my TV, I have to quit X and set .asoundrc to change the default sound card, and go back to X in order to get the sound worked from the TV. I want to know if it is possible to do that without .asoundrc?
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3601
Location: USA

PostPosted: Mon Aug 26, 2013 3:13 am    Post subject: Reply with quote

People say that pulseaudio is useless, well, this is what pulseaudio can do fairly easily. With Pulseaudio, In Gnome you could just go to sound preferences, output, and click on the HDMI, and you're done...

Otherwise you have to somehow change the default output channel. But I'm not sure why you need to quit X to change .asoundrc? You will have to quit Firefox/youtube for sure but I would think quitting X isn't needed unless you already have some sort of sound repeater daemon?
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Mon Aug 26, 2013 4:43 am    Post subject: Reply with quote

It is not necessary to quit X.
_________________
Improve your font rendering and ALSA sound
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Mon Aug 26, 2013 7:16 am    Post subject: Reply with quote

eccerr0r wrote:
People say that pulseaudio is useless, well, this is what pulseaudio can do fairly easily. With Pulseaudio, In Gnome you could just go to sound preferences, output, and click on the HDMI, and you're done...

Otherwise you have to somehow change the default output channel. But I'm not sure why you need to quit X to change .asoundrc? You will have to quit Firefox/youtube for sure but I would think quitting X isn't needed unless you already have some sort of sound repeater daemon?


I am not using pulseaudio, I have only alsa. I will try. Thanks
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Mon Aug 26, 2013 7:18 am    Post subject: Reply with quote

PaulBredbury wrote:
It is not necessary to quit X.


by pulseaudio too?
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3601
Location: USA

PostPosted: Mon Aug 26, 2013 5:39 pm    Post subject: Reply with quote

pd1986 wrote:
PaulBredbury wrote:
It is not necessary to quit X.


by pulseaudio too?

If pulseaudio is setup properly, you don't need to quit X either (I can't think of a reason why you'd need to quit X11 at all, something seems very wrong here). The whole point of PA is to be able to change input/output source/sinks on the fly.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
The Doctor
Veteran
Veteran


Joined: 27 Jul 2010
Posts: 1266

PostPosted: Mon Aug 26, 2013 7:14 pm    Post subject: Reply with quote

Wait, won't alsamixer do this? Just use F6 to set the new card.

I take the OP is using pure alsa without pulseaudio.
_________________
First things first, but not necessarily in that order.
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Mon Aug 26, 2013 8:20 pm    Post subject: Reply with quote

The Doctor wrote:
won't alsamixer do this?

No. Alsamixer does not edit ~/.asoundrc

I use ~/bin/speakers:
Code:
#!/bin/bash

# Posted at https://bbs.archlinux.org/viewtopic.php?pid=1250505#p1250505
function headphones_in {
    # Could also use:
    # amixer -c 0 contents | grep -A2 "Headphone Jack" | tail -n 1 | grep -q "=on"

    if [[ `grep "Pin-ctls: 0x40: OUT VREF_HIZ" < /proc/asound/card0/codec#0 | wc -l` -eq 3 ]] ; then
        # Surround, false
        return 1
    fi

    # Headphones, true
    return 0
}


if headphones_in ; then
    speakers-headphones
else
    # http://forums.gentoo.org/viewtopic-p-7160532.html#7160532
    speakers-surround
fi


And to change the volume - xbindkeys.
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Mon Aug 26, 2013 10:13 pm    Post subject: Reply with quote

eccerr0r wrote:
pd1986 wrote:
PaulBredbury wrote:
It is not necessary to quit X.


by pulseaudio too?

If pulseaudio is setup properly, you don't need to quit X either (I can't think of a reason why you'd need to quit X11 at all, something seems very wrong here). The whole point of PA is to be able to change input/output source/sinks on the fly.


Haha, I didn't install pulseaudio at all. That's why I need to quit X11
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3601
Location: USA

PostPosted: Mon Aug 26, 2013 11:03 pm    Post subject: Reply with quote

pd1986 wrote:
Haha, I didn't install pulseaudio at all. That's why I need to quit X11


Pulseaudio or not, I still don't know why you have to quit X.

Oh wait. I just thought of one. If your mixer or some other program that's started with the window manager, and if that cannot be restarted by itself, then you will have to restart X. It should only affect that instance though... But no, X has no bearing on alsa control.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Tue Aug 27, 2013 8:25 am    Post subject: Reply with quote

eccerr0r wrote:
pd1986 wrote:
Haha, I didn't install pulseaudio at all. That's why I need to quit X11


Pulseaudio or not, I still don't know why you have to quit X.

Oh wait. I just thought of one. If your mixer or some other program that's started with the window manager, and if that cannot be restarted by itself, then you will have to restart X. It should only affect that instance though... But no, X has no bearing on alsa control.


As I don't know how to control it. That's why I posted this thread. Could you please teach me?
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Tue Aug 27, 2013 11:59 am    Post subject: Reply with quote

eccerr0r wrote:
pd1986 wrote:
Haha, I didn't install pulseaudio at all. That's why I need to quit X11


Pulseaudio or not, I still don't know why you have to quit X.

Oh wait. I just thought of one. If your mixer or some other program that's started with the window manager, and if that cannot be restarted by itself, then you will have to restart X. It should only affect that instance though... But no, X has no bearing on alsa control.


I understand now. I can restart alsasound service after changing .asoundrc, and it works without restarting X.
one question, is it possible to switch the channel by command without restarting alsa service?
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Tue Aug 27, 2013 12:01 pm    Post subject: Reply with quote

The Doctor wrote:
Wait, won't alsamixer do this? Just use F6 to set the new card.

I take the OP is using pure alsa without pulseaudio.


just select HDMI card in alsamixer? No, I tried. It changes nothing. don't know why
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Tue Aug 27, 2013 12:04 pm    Post subject: Reply with quote

The Doctor wrote:
Wait, won't alsamixer do this? Just use F6 to set the new card.

I take the OP is using pure alsa without pulseaudio.


Actually, there is nothing in alsamixer for my HDMI card, but only S/PIDF with 00
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Tue Aug 27, 2013 7:16 pm    Post subject: Reply with quote

pd1986 wrote:
restart alsasound service

There is no need for a service. Just restart the apps which have the soundcard open. You can see such apps with:

Code:
fuser -fv /dev/snd/*

_________________
Improve your font rendering and ALSA sound
Back to top
View user's profile Send private message
pd1986
Apprentice
Apprentice


Joined: 19 Feb 2012
Posts: 290
Location: Paris

PostPosted: Tue Aug 27, 2013 8:03 pm    Post subject: Reply with quote

PaulBredbury wrote:
pd1986 wrote:
restart alsasound service

There is no need for a service. Just restart the apps which have the soundcard open. You can see such apps with:

Code:
fuser -fv /dev/snd/*


well Thanks you very much, I didn't know that. It works.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum