100 lines
3.2 KiB
Bash
Executable File
100 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Install script for DEP dsoundcard ALSA plugin
|
|
# This sets up the dsoundcard plugin to access DEP audio via ALSA
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
DSOUNDCARD_SO="$SCRIPT_DIR/dep_examples-1.2.2.1_aarch64_Linux/dep_examples/apps/dsoundcard.so"
|
|
ASOUNDRC_SRC="$SCRIPT_DIR/asoundrc.dsoundcard"
|
|
INSTALL_DIR="/opt/dep"
|
|
|
|
echo "=========================================="
|
|
echo "DEP dsoundcard ALSA Plugin Installer"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Check if running as root for /opt/dep installation
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "This script requires root privileges to install to $INSTALL_DIR"
|
|
echo "Please run with: sudo bash $0"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if dsoundcard.so exists
|
|
if [ ! -f "$DSOUNDCARD_SO" ]; then
|
|
echo "ERROR: dsoundcard.so not found at:"
|
|
echo " $DSOUNDCARD_SO"
|
|
echo ""
|
|
echo "Make sure the DEP examples package is extracted in the project directory."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if asoundrc config exists
|
|
if [ ! -f "$ASOUNDRC_SRC" ]; then
|
|
echo "ERROR: asoundrc.dsoundcard not found at:"
|
|
echo " $ASOUNDRC_SRC"
|
|
exit 1
|
|
fi
|
|
|
|
echo "1. Creating installation directory..."
|
|
mkdir -p "$INSTALL_DIR"
|
|
echo " Created: $INSTALL_DIR"
|
|
echo ""
|
|
|
|
echo "2. Installing dsoundcard.so..."
|
|
cp "$DSOUNDCARD_SO" "$INSTALL_DIR/"
|
|
chmod 644 "$INSTALL_DIR/dsoundcard.so"
|
|
echo " Installed: $INSTALL_DIR/dsoundcard.so"
|
|
echo ""
|
|
|
|
echo "3. Configuring ALSA..."
|
|
# Get the actual user (not root when using sudo)
|
|
ACTUAL_USER="${SUDO_USER:-$USER}"
|
|
ACTUAL_HOME=$(getent passwd "$ACTUAL_USER" | cut -d: -f6)
|
|
|
|
if [ -f "$ACTUAL_HOME/.asoundrc" ]; then
|
|
# Check if dsoundcard is already configured
|
|
if grep -q "dsoundcard" "$ACTUAL_HOME/.asoundrc"; then
|
|
echo " dsoundcard already configured in $ACTUAL_HOME/.asoundrc"
|
|
else
|
|
echo " Backing up existing .asoundrc..."
|
|
cp "$ACTUAL_HOME/.asoundrc" "$ACTUAL_HOME/.asoundrc.backup.$(date +%Y%m%d_%H%M%S)"
|
|
echo " Appending dsoundcard configuration..."
|
|
echo "" >> "$ACTUAL_HOME/.asoundrc"
|
|
cat "$ASOUNDRC_SRC" >> "$ACTUAL_HOME/.asoundrc"
|
|
fi
|
|
else
|
|
echo " Creating $ACTUAL_HOME/.asoundrc..."
|
|
cp "$ASOUNDRC_SRC" "$ACTUAL_HOME/.asoundrc"
|
|
chown "$ACTUAL_USER:$ACTUAL_USER" "$ACTUAL_HOME/.asoundrc"
|
|
fi
|
|
echo " ALSA configuration updated"
|
|
echo ""
|
|
|
|
echo "4. Verifying installation..."
|
|
# Switch to actual user to test ALSA
|
|
if su - "$ACTUAL_USER" -c "aplay -L 2>/dev/null | grep -q dsoundcard"; then
|
|
echo " ✓ dsoundcard device is available in ALSA"
|
|
else
|
|
echo " ⚠ dsoundcard device not detected (may need to restart audio services)"
|
|
fi
|
|
echo ""
|
|
|
|
echo "=========================================="
|
|
echo "Installation complete!"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "Usage:"
|
|
echo " # Record from DEP (6 channels, 16-bit, 48kHz)"
|
|
echo " arecord -D dsoundcard -c 6 -f S16_LE -r 48000 output.wav"
|
|
echo ""
|
|
echo " # Play to DEP (requires txChannels > 0 in dante.json)"
|
|
echo " aplay -D dsoundcard -f S16_LE -r 48000 input.wav"
|
|
echo ""
|
|
echo " # Use the test script"
|
|
echo " bash $SCRIPT_DIR/test_dsoundcard.sh"
|
|
echo ""
|
|
echo "Note: DEP must be running before using dsoundcard."
|
|
echo " Start DEP with: sudo bash $SCRIPT_DIR/dep.sh start"
|
|
echo ""
|