Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Audio on Radeon gpu HDMI doesn't work after suspending
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
anthonyk
n00b
n00b


Joined: 21 Nov 2005
Posts: 46

PostPosted: Sun Oct 17, 2021 7:40 pm    Post subject: Audio on Radeon gpu HDMI doesn't work after suspending Reply with quote

I am outputting audio to a monitor through HDMI on a Radeon gpu (Caicos HDMI Audio [Radeon HD 6450 / 7450/8450/8490 OEM / R5 230/235/235X OEM]
), after I suspend and resume the audio stops working.

If I go to the sound settings (`mate-audio-control`), go to Hardware and change Profile for the card to Off and then on again the audio works again. I'm not sure what state the card/drivers has ended up in and what needs to be changed, but i'd like to find a way for audio through the card to work again after resuming.

thanks
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3875

PostPosted: Wed Oct 20, 2021 9:11 pm    Post subject: Reply with quote

Create a post/suspend script like this
https://wiki.gentoo.org/wiki/Elogind#Hook_scripts_to_be_run_when_suspending.2Fhibernating_and.2For_when_resuming.2Fthawing
and in the [post] section add
Code:

pulseaudio -k
pulseaudio -D

?
...provided that you are using elogind and pulseaudio.
_________________
:)
Back to top
View user's profile Send private message
anthonyk
n00b
n00b


Joined: 21 Nov 2005
Posts: 46

PostPosted: Thu Oct 21, 2021 10:14 am    Post subject: Reply with quote

Thanks for the tip. Running
Code:
pulseaudio -k
as user from the command line works to fix the audio after resuming, although the hook script isn't working to do it automatically.
Code:
/etc/init.d/elogind
is active. i'll have a look into the details a bit more
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21498

PostPosted: Thu Oct 21, 2021 3:29 pm    Post subject: Reply with quote

Is the hook script not running, or is it running and not producing the desired result? If the latter, as what user did the hook script run the command?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3875

PostPosted: Thu Oct 21, 2021 3:48 pm    Post subject: Reply with quote

Elaborating a bit on Hu's response
you might need
Code:

sudo -H -u <user> pulseaudio -k
sudo -H -u <user> pulseaudio -D

You might need also some env variables exported either via "export" or "env" commands.
I am not sure which ones you need.
run as your user
Code:

env

and try to figure out what you need.
_________________
:)
Back to top
View user's profile Send private message
anthonyk
n00b
n00b


Joined: 21 Nov 2005
Posts: 46

PostPosted: Thu Oct 21, 2021 11:21 pm    Post subject: Reply with quote

ok I did a bit more digging around and I think this works, although it seems to fail sometimes so i'll need to test it a bit more for reliability

Code:

#!/bin/bash
case $1/$2 in
  pre/*)
    # Put here any commands expected to be run when suspending or hibernating.
    ;;
  post/*)
    # Put here any commands expected to be run when resuming from suspension or thawing from hibernation.
    pulse_users=`ps waux | grep pulseaudio | awk '{print $1;}' | sort | uniq`
    for username in $pulse_users
    do
        uid=`id -u $username`
        #sudo -H -u $username PULSE_RUNTIME_PATH=/run/user/$uid/pulse pasuspender /bin/true
        sudo -H -u $username PULSE_RUNTIME_PATH=/run/user/$uid/pulse pulseaudio -k
    done
    ;;
esac


I was trying to use pasuspender instead as it is a softer reset and slightly preferred over pulseaudio -k, but I have tested it sometimes (manually, with a direct call when the audio was stopped) and not had it fix the audio so i'm not sure. and I think the -k option has failed too. anyway i'll test it a bit more and see how it works

also there is a strange case where the /run/user/1001/pulse directory gets owned by root and then the call fails (but calling pulse commands from a normal xterm works), I did chown on the directory but not sure if it will last a reboot.

thanks for the tips
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21498

PostPosted: Fri Oct 22, 2021 1:13 am    Post subject: Reply with quote

That script could be simpler and cleaner. Untested:
Code:
ps -C pulseaudio -o user=,uid= | sort | uniq -f1 | while read username uid; do
    sudo -H -u "$username" "PULSE_RUNTIME_PATH=/run/user/$uid/pulse" pulseaudio -k
done
  • Use ps's -C to find the target program, instead of using grep, which can trigger hits for unrelated processes. (For example, your command would flag an xterm that was invoked as xterm -e /usr/bin/pulseaudio.)
  • Use ps's -o to print only the needed fields.
  • Use uniq -f1 to filter only on one field.
  • Get the uid from ps, so it does not need to be recomputed in the loop body.
  • Pipe the data directly into a loop so it can begin immediately.
  • The sudo command is unchanged.
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