Dear Elimar,

On 12/18/16 20:52, Paul Menzel wrote:

On 2016-12-18 11:50, Elimar Riesebieter wrote:
* Paul Menzel <pmen...@molgen.mpg.de> [2016-12-17 16:01 +0100]:

On 2016-12-17 14:10, Elimar Riesebieter wrote:
> Control: tags -1 +moreinfo
>
> * Paul Menzel <pmen...@molgen.mpg.de> [2016-12-17 11:03 +0100]:
>
[...]
The manual page of alsactl says.

> init tries to initialize all devices to a default state. If device is
> not known, error code 99 is returned.

[...]

> > Is the udev rule still needed?
>
> yes

Interesting. Sorry, for being ignorant, just to be clear, it does the
same
thing, what the systemd service unit does?

Sysvinit systems don't have "systemd device units"

That wasn’t my question. So reading both files again, the udev rule and
the systemd service unit do the same thing, that means, they run
`alsactl restore …`.

But you argue, that the udev rule is needed on a system using SysV.

Unfortunely, I don’t understand that argument, as there is also the SysV
init script `/etc/init.d/alsa-utils`. That contains the code below.

```
[…]
# $1 <card ID> | "all"
restore_levels()
{
    [ -f /var/lib/alsa/asound.state ] || return 1
    CARD="$1"
    [ "$1" = all ] && CARD=""
    # Assume that if alsactl prints a message on stderr
    # then it failed somehow.  This works around the fact
    # that alsactl doesn't return nonzero status when it
    # can't restore settings for the card
    if MSG="$(alsactl -E HOME="$ALSACTLHOME" restore $CARD 2>&1
/dev/null)" && [ ! "$MSG" ] ; then
        return 0
    else
        # Retry with the "force" option.  This restores more levels
        # but it results in much longer error messages.
        alsactl -F restore $CARD >/dev/null 2>&1
        log_action_cont_msg "warning: 'alsactl -E HOME="$ALSACTLHOME"
restore${CARD:+ $CARD}' failed with error message '$MSG'"
        return 1
    fi
}
[…]
  start)
    EXITSTATUS=0
    TARGET_CARD="$2"
    case "$TARGET_CARD" in
      ""|all) TARGET_CARD=all ; log_action_begin_msg "Setting up ALSA" ;;
      *) log_action_begin_msg "Setting up ALSA card ${TARGET_CARD}" ;;
    esac
    card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ]
; echo $? ; )" "none loaded"
    preinit_levels "$TARGET_CARD" || EXITSTATUS=1
    if ! restore_levels "$TARGET_CARD" ; then
        sanify_levels "$TARGET_CARD" || EXITSTATUS=1
        restore_levels "$TARGET_CARD" >/dev/null 2>&1 || :
    fi
    log_action_end_msg_and_exit "$EXITSTATUS"
    ;;
```

So doesn’t that cover systems using SysV as init system?

Michael Biebl explained to me, that the udev rule is needed for hotplugging sound cards. I didn’t think of that.

[…]


Kind regards,

Paul

Reply via email to