#!/bin/sh

# stop/continue processes using sound devices.

set -e

devices=$(find /dev -type c | xargs stat -c '%t %n' | sed -n 's/^e //p; s/^74 //p')
if [ "$1" = suspend ]; then
    if [ -d /proc/asound ]; then
	fuser -k -STOP $devices
    fi
    sleep 1
elif [ "$1" = resume ]; then
    if [ -d /proc/asound ]; then
	fuser -k -CONT $devices
    fi
fi

