# pulseaudio hook # # clients must connect in two ways: # # connecting to server: tcp:thin_client_ip:4713 # or # importing X11 cookie with: $ pax11publish -i # or # using this env var PULSE_SERVER="thin_client_hostname" if [ ${TCOS_PULSEAUDIO} ] && [ ${TCOS_SOUND} ]; then # check for apps check1=0 [ -x /usr/bin/pulseaudio ] && check1=1 #check2=0 #[ -e /usr/lib/pulse*/modules/module-esound-protocol-tcp.so ] && check2=1 #[ -d ${TCOS_PKG_CACHE}/pulseaudio-esound-compat/usr/lib ] && check2=1 if [ $check1 = 0 ]; then echo " WARNING:" echo " pulseaudio is not installed, disable it from tcos.conf!!!" #elif [ $check2 = 0 ]; then # echo " WARNING:" # echo " pulseaudio-esound-compat is not installed, need some esound modules" # echo " install this package or disable PulseAudio in /etc/tcos/tcos.conf" # echo " You can install a cached package with:" # echo " # gentcos -instpkg pulseaudio-esound-compat" # echo "" # echo " See /usr/share/doc/initramfs-tools-tcos/README.cache" # echo "" else stat_before cpifexists /usr/bin/pulseaudio /usr/bin/ cpifexists /usr/bin/pax11publish /usr/bin/ cpifexists /usr/bin/pactl /usr/bin/ mkdir -p ${DESTDIR}/usr/lib copydir /usr/lib/pulse-* /usr/lib/ mkdir -p ${DESTDIR}/var/lib/pulse # clean unneeded modules rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*.la rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*jack* # rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*rtp* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*lirc* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*evdev* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*sine* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*x11-bell* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*zeroconf* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*avahi* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*gconf* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*hal* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*pipe* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*tunel* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*volume-restore* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*cli* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*http* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*console-kit* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*ladspa* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*bluetooth* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*augment* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*phone* rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*position-event* # don't use suspend-idle (we don't use dbus yet to reload pulseaudio) rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*idle* # don't copy x11 modules rm -f ${DESTDIR}/usr/lib/pulse-*/modules/*x11* # copy channel configuration files if exists if [ -d /usr/share/pulseaudio/ ]; then copydir /usr/share/pulseaudio /usr/share/ fi # needed for pulse -> esound -> OSS [ -e /usr/lib/pulse-*/modules/libsocket-client.so ] && \ cpifexists /usr/lib/pulse-*/modules/libsocket-client.so /usr/lib/pulse-*/modules/ # delete modules and copy again to put linked libs for _lib in $DESTDIR/usr/lib/pulse-*/modules/*so; do librel=$(basename $_lib) rm -f $_lib cpifexists /usr/lib/pulse-*/modules/${librel} /usr/lib/pulse-*/modules/ done echo "pulse:x:111:120:PulseAudio daemon,,,:/var/run/pulse:/bin/false" >> $DESTDIR/etc/passwd echo "pulse:x:120:" >> $DESTDIR/etc/group #copydir /etc/pulse /etc/ mkdir -p $DESTDIR/etc/pulse cp /etc/pulse/client.conf $DESTDIR/etc/pulse/ cp /etc/pulse/daemon.conf $DESTDIR/etc/pulse/ if [ "$TCOS_SOUND_REMOTE_ESD" ]; then _SERVER=";\$(read_server "xdmcp-server")" else _SERVER="" fi #if [ -e /usr/lib/pulse-*/modules/module-udev-detect.so ]; then # _MODULE="module-udev-detect" #else # _MODULE="module-detect" #fi # disable udev-detect by now, (in my system don't find cards) _MODULE="module-detect" cat << EOF >> ${DESTDIR}/sbin/startpulseaudio #!/bin/sh . /scripts/functions . /conf/tcos.conf . /conf/tcos-run-functions # limit PulseAudio SHM memory in low memory systems (<96MiB = 98304) if [ "\$(awk '/MemTotal/ {print \$2}' /proc/meminfo)" -lt 98305 ]; then if grep -q shm-size-bytes /etc/pulse/daemon.conf; then echo "shm-size-bytes = 16" >> /etc/pulse/daemon.conf fi if grep -q enable-shm /etc/pulse/daemon.conf; then echo "enable-shm = no" >> /etc/pulse/daemon.conf fi fi # don't allow to exit_idle (by default 20 seconds) if grep -q exit-idle-time /etc/pulse/daemon.conf; then echo "exit-idle-time = -1" >> /etc/pulse/daemon.conf fi # generate conf rm -f /etc/pulse/default.pa if [ "\$(pidof esd | sed '/^\$/d')" != "" ]; then cat << FIN > /etc/pulse/default.pa #!/usr/bin/pulseaudio -nF load-module module-esound-sink server=127.0.0.1 load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;\$(read_server "xdmcp-server");\$PA_AUTH #.ifexists module-x11-publish.so #.nofail #load-module module-x11-publish #.fail #.endif FIN else cat << FIN > /etc/pulse/default.pa #!/usr/bin/pulseaudio -nF load-module $_MODULE load-module module-esound-protocol-tcp auth-ip-acl=127.0.0.1$_SERVER load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;\$(read_server "xdmcp-server");\$PA_AUTH load-module module-esound-protocol-unix #.ifexists module-x11-publish.so #.nofail #load-module module-x11-publish #.fail #.endif .nofail load-module module-device-restore load-module module-stream-restore load-module module-card-restore load-module module-always-sink .fail FIN fi DISPLAY=:0 export DISPLAY cpu=\$(grep MHz /proc/cpuinfo | tail -1 | awk -F":" '{if(int(\$2) < 1024) printf "low"}') realtime=\$(pulseaudio --help 2>&1 | grep -c realtime) OPTS="--log-target=stderr " if [ \${TCOS_PULSEAUDIO_RESAMPLE_METHOD} ]; then OPTS="\${OPTS} --resample-method=\${TCOS_PULSEAUDIO_RESAMPLE_METHOD}" fi OPTS="--no-cpu-limit \${OPTS}" if [ "\$cpu" = "low" ]; then #OPTS="--no-cpu-limit \${OPTS}" # old versions of pulseaudio don't have realtime switch (Etch) if [ "\$realtime" != "0" ]; then OPTS="\${OPTS} --realtime " fi fi _log "STARTPULSEAUDIO starting pulseaudio server..." pulseaudio \${OPTS} & sleep 4 # # wait for Xorg is started # waitforX sleep 2 # DISPLAY=:0 pax11publish -e # exit 0 EOF chmod +x ${DESTDIR}/sbin/startpulseaudio stat_after "PulseAudio (sound server)" fi # end of else of /usr/bin/pulseaudio else _verbose "(21pulseaudio) TCOS_PULSEAUDIO && sound disabled" fi # end of TCOS_PULSEAUDIO