Wednesday 29 August 2007

Installing Music Player and usb sound card on the ASUS WL-500g wireless client

Following the wiki, I installed the appropriate kernel modules for an nfs client -
ipkg install kmod-fs-nfs
and then attempted to mount the filesystem export from the fileserver -
mkdir /tmp/music
mount -t nfs 192.168.1.77:/home/share/music /tmp/music -o nolock
then
ls /tmp/music
indeed shows the music directory from the fileserver -
root@OpenWrt:~# ls /tmp/music
2 Many DJ's
Acid House Kings
Al Green
Babyshambles
Barenaked Ladies
Buena Vista Social Club
Bugz in the Attic
Following the Usb Storage and Usb Audio wiki entries, I installed the appropriate kernel modules to enable my usb soundcard -
ipkg install kmod-usb-ohci kmod-soundcore kmod-usb-audio
Then, on plugging the soundcard in, dmesg gives -
hub.c: new USB device 00:04.0-1, assigned address 2
usbaudio: device 2 audiocontrol interface 0 has 0 input and 1 output AudioStreaming interfaces
usbaudio: device 2 interface 1 altsetting 0 does not have an endpoint
usbaudio: device 2 interface 1 altsetting 1 channels 2 framesize 2 configured
usbaudio: valid output sample rate 44100
usbaudio: valid output sample rate 48000
usbaudio: device 2 interface 1 altsetting 1: format 0x01000010 sratelo 44100 sratehi 48000 attributes 0x01
usbaudio: registered dsp 14,3
usbaudio: constructing mixer for Terminal 3 type 0x0301
usbaudio: registered mixer 14,0
usb_audio_parsecontrol: usb_audio_state at 807f8860
I then installed the Music Player application -
ipkg install mpd
and some other dependences that weren't properly flagged when mpd was installed -
ipkg install alsa-lib libpthread
editted the config file -

# MPD CONFIG FILE
# For a full description of all config parameters,
# Check the mpd man page, "man mpd".

##################### REQUIRED ###########################
music_directory "/tmp/music"
playlist_directory "/tmp/music"
db_file "/tmp/music/mpd.db"
log_file "/tmp/mpd.log"
error_file "/tmp/mpd.error"
pid_file "/tmp/mpd.pid"
##########################################################

##########################################################
# EVERYTHING ELSE IS OPTIONAL
##########################################################

################## AUDIO OUTPUT ##########################
#
# use this if you want to use OSS audio output
audio_output {
type "oss"
name "my OSS sound card"
device "/dev/sound/dsp" # optional
format "44100:16:2" #optional
}
#
# OSS Mixer
mixer_type "oss"
mixer_device "/dev/sound/mixer"
mixer_control "PCM"
#

################# SECURITY SETTINGS ######################
#
# It is encouraged to run MPD as
# non-superuser. If you start mpd as root
# (for example, in an init script), set
# this value, then mpd will drop root priveleges
# and runs as the user specified.
#
user "share"
#

################ MISCELLANEOUS OPTIONS ###################
#
port "6600"

added 'share' user and group (by editting /etc/passwd and /etc/group) so that we can properly read and write to the nfs share on the fileserver which is owned by user 'share'. Since we will be running mpd as user 'share', we need to open the permissions of /dev/sound/dsp and /dev/sound/mixer which were created by root
chmod 777 /dev/sound -R
Then try it ! First start the music player -
mpd
There may be a long wait while it builds the database before daemon starts up. Then can use the command-line controller to add all the files in the database to a playlist, shuffle it, then play -
mpc listall mpc add
mpc shuffle
mpc play
and lovely music!

In order for it all to start up properly on power-up of the router, create /etc/init.d/mpd -
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=70

start() {
mkdir /tmp/music
mount -t nfs 192.168.1.77:/home/share/music /tmp/music -o nolock
chmod 777 /dev/sound -R
mpd
mpc listall mpc add
mpc shuffle
mpc volume 10
mpc update
}

stop() {
killall mpd
umount /tmp/music
}
and then to set it up to run on router restart -
/etc/init.d/mpd enable

No comments: