Remove useless contrib stuff

This commit is contained in:
Julien BLACHE 2009-06-12 11:18:56 +02:00
parent 79dbf85952
commit bb9d53e959
13 changed files with 2 additions and 1015 deletions

View File

@ -1,6 +1,6 @@
EXTRA_DIST = configure CREDITS
SUBDIRS = src contrib
SUBDIRS = src

View File

@ -93,4 +93,4 @@ dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_OUTPUT(src/Makefile contrib/Makefile contrib/init.d/Makefile Makefile)
AC_OUTPUT(src/Makefile Makefile)

2
contrib/.gitignore vendored
View File

@ -1,2 +0,0 @@
mt-daapd.conf

View File

@ -1,18 +0,0 @@
SUBDIRS = init.d
EXTRA_DIST = README mt-daapd.spec mt-daapd.conf.templ mt-daapd-ssc.sh mt-daapd-ssc.pl
BUILT_SOURCES = mt-daapd.conf
bin_SCRIPTS = mt-daapd-ssc.sh
dbdir="$(localstatedir)/cache/mt-daapd"
mt-daapd.conf: mt-daapd.conf.templ ../config.h
sed -e s,[@]prefix[@],$(prefix), \
-e s,[@]sysconfdir[@],$(sysconfdir), \
-e s,[@]libdir[@],$(libdir), \
-e s,[@]dbdir[@],$(dbdir),g mt-daapd.conf.templ >$@

View File

@ -1,12 +0,0 @@
In here goes stuff that anyone wants to send... add-ons, unsupported patches, etc.
mt-daapd.conf.........: an example config
mt-daapd.playlist.....: an example playlist
mt-daapd..............: an init.d script, suitable for redhat
mt-daapd-gentoo.......: an init.d script, suitable for gentoo
mt-daapd-ssc.pl.......: a transcoding script, using perl
mt-daapd-ssc.sh.......: a transcoding script, using shell

View File

@ -1,4 +0,0 @@
mt-daapd-fedora
mt-daapd-suse
mtdaapd-bsd

View File

@ -1,19 +0,0 @@
EXTRA_DIST=mt-daapd-fedora.templ mt-daapd-suse.templ mtdaapd-bsd.templ
BUILT_SOURCES = mt-daapd-fedora mt-daapd-suse mtdaapd-bsd
mt-daapd-fedora: mt-daapd-fedora.templ ../../config.h
sed -e s,[@]prefix[@],$(prefix),g mt-daapd-fedora.templ >$@; \
chmod +x $@
mt-daapd-suse: mt-daapd-suse.templ ../../config.h
sed -e s,[@]prefix[@],$(prefix),g mt-daapd-suse.templ >$@; \
chmod +x $@
mtdaapd-bsd: mtdaapd-bsd.templ ../../config.h
sed -e s,[@]prefix[@],$(prefix),g mtdaapd-bsd.templ >$@; \
chmod +x $@

View File

@ -1,56 +0,0 @@
#!/bin/sh
#
# chkconfig: 2345 85 15
# description: mt-daapd is a multi-threaded DAAP server for iTunes
# processname: mt-daapd
# pidfile: /var/run/mt-daapd
#
# source function library
. /etc/init.d/functions
[ -e @prefix@/etc/daapd.conf ]
RETVAL=0
start() {
echo -n $"Starting DAAP server: "
daemon @prefix@/sbin/mt-daapd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mt-daapd
}
stop() {
echo -n $"Shutting down DAAP server: "
# This is broken.
killall -INT mt-daapd
# killproc mt-daapd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mt-daapd
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
status)
status mt-daapd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL

View File

@ -1,216 +0,0 @@
# Copyright (c) 1995-2004 SUSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Dylan Muir
#
# /etc/init.d/mt-daapd
# and its symbolic link
# /usr/sbin/mt-daapd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
#
# Note: This template uses functions rc_XXX defined in /etc/rc.status on
# UnitedLinux (UL) based Linux distributions. If you want to base your
# script on this template and ensure that it works on non UL based LSB
# compliant Linux distributions, you either have to provide the rc.status
# functions from UL or change the script to work without them.
#
### BEGIN INIT INFO
# Provides: daap
# Required-Start: $portmap $local_fs $remote_fs rendezvous
# Should-Start:
# Required-Stop: $portmap $local_fs $remote_fs rendezvous
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: mt-daapd daemon providing DAAP serving
# Description: mt-daapd allows iTunes-compatible clients
# to connect, serves streams and allows download of files.
# Also provides a web configuration interface on the DAAP port.
### END INIT INFO
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
MT_DAAPD_BIN=@prefix@/sbin/mt-daapd
test -x $MT_DAAPD_BIN || { echo "$MT_DAAPD_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Check for existence of needed config file and read it
MT_DAAPD_CONFIG=@prefix@/etc/mt-daapd.conf
test -r $MT_DAAPD_CONFIG || { echo "$MT_DAAPD_CONFIG does not exist";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
# Directory to wait for
MUSIC_WATCH_DIR=/media/MUSIC/music-root
# Debug level
MT_DAAPD_DEBUG_LEVEL=1
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v be verbose in local rc status and clear it afterwards
# rc_status -v -r ditto and clear both the local and overall rc status
# rc_status -s display "skipped" and exit with status 3
# rc_status -u display "unused" and exit with status 3
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear both the local and overall rc status
# rc_exit exit appropriate to overall rc status
# rc_active checks whether a service is activated by symlinks
. /etc/rc.status
# Reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - user had insufficient privileges
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting mt-daapd "
## Recycle log file
mv /var/log/mt-daapd.log /var/log/mt-daapd.0.log
## Wait for the music cache to appear
while [ ! -e $MUSIC_WATCH_DIR ]
do
echo "mt-daapd: Waiting for music directory to appear..."
sleep 1
done
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
/sbin/startproc $MT_DAAPD_BIN -c $MT_DAAPD_CONFIG -d $MT_DAAPD_DEBUG_LEVEL
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down mt-daapd "
## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.
killall -INT $MT_DAAPD_BIN
# Remember status and be verbose
rc_status -v
;;
try-restart|condrestart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
sleep 3
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart the service if it
## is running.
echo -n "Reload service mt-daapd "
## if it supports it:
#/sbin/killproc -HUP $MT_DAAPD_BIN
#touch /var/run/mt-daapd.pid
#rc_status -v
## Otherwise:
$0 try-restart
rc_status
;;
reload)
## Like force-reload, but if daemon does not support
## signaling, do nothing (!)
# If it supports signaling:
echo -n "Reload service mt-daapd "
#/sbin/killproc -HUP $MT_DAAPD_BIN
#touch /var/run/mt_daapd.pid
#rc_status -v
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking for service mt-daapd "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Return value is slightly different for the status command:
# 0 - service up and running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running (unused)
# 4 - service status unknown :-(
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
# NOTE: checkproc returns LSB compliant status values.
/sbin/checkproc $MT_DAAPD_BIN
# NOTE: rc_status knows that we called this init script with
# "status" option and adapts its messages accordingly.
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload, print out the
## argument to this init script which is required for a reload.
## Note: probe is not (yet) part of LSB (as of 1.9)
test /etc/mt-daapd.conf -nt /var/run/mt-daapd.pid && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit

View File

@ -1,21 +0,0 @@
#!/bin/sh
#
# PROVIDE: mtdaapd mt-daapd
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# mt-daapd daemon.
#
# Created by Patrick Lemmens for NetBSD and FreeBSD.
. /etc/rc.subr
name="mtdaapd"
realname="mt-daapd"
rcvar=$name
command="@prefix@/bin/${realname}"
pidfile="/var/run/${realname}.pid"
sig_stop="SIGINT"
load_rc_config $name
run_rc_command "$1"

View File

@ -1,572 +0,0 @@
#!/usr/bin/env perl
#
# -*- perl -*-
#
# ----------------------------------------------------------------------
# Server side media format conversion script for mt-daapd.
# ----------------------------------------------------------------------
# Copyright & 2005
# Timo J. Rinne <tri@iki.fi>
# ----------------------------------------------------------------------
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# This is quite rudimentary but handles most cases quite well.
#
# TODO-list:
# - Make the guessing of the wav length reliable.
# - Possibly implement some kind of caching.
#
# I'll probably never have time for above things, but now it should
# be easy for someone to take this over, since basically all you have
# to do is to make the filter program and tweak the configuration.
#
# //tri
#
require 'sys/syscall.ph';
use POSIX ":sys_wait_h";
use IO::Handle;
use IO::File;
use IPC::Open2;
use IPC::Open3;
$SIG{PIPE} = 'IGNORE';
{
umask(0077);
if ($#ARGV < 1) {
usage();
}
my ($fn) = $ARGV[0];
my ($off) = 0 + $ARGV[1];
my ($forgelen) = undef;
if ($#ARGV > 1) {
$forgelen = 0.0 + $ARGV[2];
if ($forgelen < 0.01) {
$forgelen = 0.0;
}
} else {
$forgelen = 0.0;
}
if ($off < 0) {
usage();
}
if ($fn =~ m/^..*\.wav$/i) {
passthru_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.wave$/i) {
passthru_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.flac$/i) {
flac_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.fla$/i) {
flac_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.mp4$/i) {
mpeg4_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.m4a$/i) {
mpeg4_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.m4p$/i) {
mpeg4_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.aac$/i) {
mpeg4_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.shn$/i) {
ffmpeg_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.mp3$/i) {
ffmpeg_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.mpg$/i) {
ffmpeg_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.ogg$/i) {
ffmpeg_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.avi$/i) {
ffmpeg_proc($fn, $off, $forgelen);
} elsif ($fn =~ m/^..*\.au$/i) {
ffmpeg_proc($fn, $off, $forgelen);
} else {
mplayer_proc($fn, $off, $forgelen);
}
exit;
}
sub usage
{
print STDERR "usage: ssc-script file offset\n";
exit -1;
}
sub tmp_file
{
my ($r) = sprintf "/tmp/t-%d.wav", $$;
return $r;
}
sub wav_loop
{
my ($f) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($buf);
my ($buflen);
my ($buftry) = 4096;
my ($hdr);
$hdr = read_wav_hdr($f);
if (! defined $hdr) {
return undef;
}
my ($chunk_data_length,
$format_data_length,
$compression_code,
$channel_count,
$sample_rate,
$sample_bit_length,
$data_length) = parse_wav_hdr($hdr);
if (! defined $chunk_data_length) {
print STDERR "Can't parse WAV header.\n";
return undef;
}
if (defined $forgelen) {
if ($forgelen > 0.00001) {
my ($sec) = int($forgelen);
my ($msec) = ($forgelen - (0.0 + int($forgelen))) * 1000;
my ($bps) = ($sample_rate * $channel_count * int(($sample_bit_length + 7) / 8));
my ($len) = int(($sec * $bps) + (($msec * $bps) / 1000));
my ($blocklen);
my ($residual);
if (($sample_rate == 44100) &&
($channel_count == 2) &&
($sample_bit_length == 16)) {
# It's probably a CD track so let's round it to next cd block limit (2352 bytes).
$blocklen = 2352;
} else {
# Pad it at least to next valid sample border.
$blocklen = ($channel_count * int(($sample_bit_length + 7) / 8))
}
$residual = $len % $blocklen;
if ($residual != 0) {
my ($pad) = $blocklen - $residual;
$len += $pad;
}
$hdr = forge_wav_hdr($hdr, $len);
} else {
$hdr = forge_continuous_wav_hdr($hdr);
}
}
if (($off > 0) && ($off < length($hdr))) {
$hdr = substr($hdr, $off, (length($hdr) - $off));
} elsif ($off == length($hdr)) {
$hdr = undef;
} elsif ($off > length($hdr)) {
$hdr = undef;
$off -= length($hdr);
if (! sysseek($f, $off, 1)) {
# It's not seekable. Then just read until desired offset.
while ($off > 0) {
my ($rl) = $off > $buftry ? $buftry : $off;
$buflen = sysread($f, $buf, $rl);
if ($buflen < 1) {
return undef;
}
$off -= $buflen;
}
}
}
if (defined $hdr) {
if (syswrite (STDOUT, $hdr) != length($hdr)) {
print STDERR "Write failed.\n";
return undef;
}
}
while (1) {
$buflen = sysread($f, $buf, $buftry);
if ($buflen < 1) {
return 1;
}
if (syswrite (STDOUT, $buf) != $buflen) {
print STDERR "Write failed.\n";
return undef;
}
}
}
sub read_wav_hdr
{
my ($f) = shift;
my ($hdr) = undef;
my ($format_data_length);
if (sysread($f, $hdr, 44) != 44) {
print STDERR "Can't read WAV header.\n";
return undef;
}
return undef
if ((substr($hdr, 0, 4) ne "RIFF"));
return undef
if ((substr($hdr, 8, 4) ne "WAVE"));
return undef
if ((substr($hdr, 12, 4) ne "fmt "));
$format_data_length = (((((((ord(substr($hdr, 19, 1))) * 256) +
(ord(substr($hdr, 18, 1)))) * 256) +
(ord(substr($hdr, 17, 1)))) * 256) +
(ord(substr($hdr, 16, 1))));
return undef
if (($format_data_length < 16) || ($format_data_length > 256));
if ($format_data_length > 16) {
my ($hdr_cont);
my ($cont_len) = $format_data_length - 16;
if (sysread($f, $hdr_cont, $cont_len) != $cont_len) {
print STDERR "Can't read WAV header.\n";
return undef;
}
$hdr = $hdr . $hdr_cont;
}
# FFMpeg creates sometimes WAVs with fmt chunk longer than 16 bytes.
# This is weird, since at least iTunes can't play them. Let's chop
# extra bytes away from the fmt chunk and make the WAV header look
# like everything else in the world seems to like it.
if ($format_data_length > 16) {
my ($chunk_data_length,
$format_data_length,
$compression_code,
$channel_count,
$sample_rate,
$sample_bit_length,
$data_length) = parse_wav_hdr($hdr);
$chunk_data_length = $chunk_data_length - ($format_data_length - 16);
$hdr = (substr($hdr, 0, 4) .
chr($chunk_data_len % 256) .
chr((int($chunk_data_len / 256)) % 256) .
chr((int($chunk_data_len / (256 * 256))) % 256) .
chr((int($chunk_data_len / (256 * 256 * 256))) % 256) .
substr($hdr, 8, 8) .
chr(16) .
chr(0) .
chr(0) .
chr(0) .
substr($hdr, 20, 16) .
substr($hdr, 20 + $format_data_length, length($hdr) - (20 + $format_data_length)));
}
return $hdr;
}
sub parse_wav_hdr
{
my ($hdr) = shift;
if (length($hdr) < 44) {
return undef;
}
my ($chunk_data_length);
my ($format_data_length);
my ($compression_code);
my ($channel_count);
my ($sample_rate);
my ($sample_bit_length);
my ($data_length);
return undef
if ((substr($hdr, 0, 4) ne "RIFF"));
$chunk_data_length = (((((((ord(substr($hdr, 7, 1))) * 256) +
(ord(substr($hdr, 6, 1)))) * 256) +
(ord(substr($hdr, 5, 1)))) * 256) +
(ord(substr($hdr, 4, 1))));
return undef
if ((substr($hdr, 8, 4) ne "WAVE"));
return undef
if ((substr($hdr, 12, 4) ne "fmt "));
$format_data_length = (((((((ord(substr($hdr, 19, 1))) * 256) +
(ord(substr($hdr, 18, 1)))) * 256) +
(ord(substr($hdr, 17, 1)))) * 256) +
(ord(substr($hdr, 16, 1))));
return undef
if ($format_data_length < 16);
$compression_code = (((ord(substr($hdr, 21, 1))) * 256) +
(ord(substr($hdr, 20, 1))));
return undef
if ($compression_code != 1);
$channel_count = (((ord(substr($hdr, 23, 1))) * 256) +
(ord(substr($hdr, 22, 1))));
return undef
if ($channel_count < 1);
$sample_rate = (((((((ord(substr($hdr, 27, 1))) * 256) +
(ord(substr($hdr, 26, 1)))) * 256) +
(ord(substr($hdr, 25, 1)))) * 256) +
(ord(substr($hdr, 24, 1))));
$sample_bit_length = (((ord(substr($hdr, 35, 1))) * 256) +
(ord(substr($hdr, 34, 1))));
return undef
if ((substr($hdr, $format_data_length + 20, 4) ne "data"));
$data_length = (((((((ord(substr($hdr, $format_data_length + 24 + 3, 1))) * 256) +
(ord(substr($hdr, $format_data_length + 24 + 2, 1)))) * 256) +
(ord(substr($hdr, $format_data_length + 24 + 1, 1)))) * 256) +
(ord(substr($hdr, $format_data_length + 24 + 0, 1))));
return ($chunk_data_length,
$format_data_length,
$compression_code,
$channel_count,
$sample_rate,
$sample_bit_length,
$data_length);
}
sub forge_wav_hdr
{
my ($hdr) = shift;
my ($data_len) = shift;
my ($chunk_data_len) = $data_len + 36;
return (substr($hdr, 0, 4) .
chr($chunk_data_len % 256) .
chr((int($chunk_data_len / 256)) % 256) .
chr((int($chunk_data_len / (256 * 256))) % 256) .
chr((int($chunk_data_len / (256 * 256 * 256))) % 256) .
substr($hdr, 8, length($hdr) - 8 - 4) .
chr($data_len % 256) .
chr((int($data_len / 256)) % 256) .
chr((int($data_len / (256 * 256))) % 256) .
chr((int($data_len / (256 * 256 * 256))) % 256));
}
sub forge_continuous_wav_hdr
{
my ($hdr) = shift;
return (substr($hdr, 0, 4) .
chr(0xff) .
chr(0xff) .
chr(0xff) .
chr(0xff) .
substr($hdr, 8, length($hdr) - 8 - 4) .
chr(0xff - length($hdr) - 8) .
chr(0xff) .
chr(0xff) .
chr(0xff));
}
sub passthru_proc
{
my ($fn) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($tf) = tmp_file();
my ($f) = undef;
if (! open($f, "< $fn")) {
return undef;
}
wav_loop($f, $off, undef); # Ignore $forgelen
close($f);
}
sub flac_proc
{
my ($fn) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($r) = undef;
my ($w) = undef;
my ($pid);
$pid = open2($r, $w, 'flac', '--silent', '--decode', '--stdout', "$fn");
wav_loop($r, $off, undef); # Ignore $forgelen
close($r);
close($w);
if (waitpid($pid, WNOHANG) <= 0) {
kill(SIGKILL, $pid);
waitpid($pid, 0);
}
}
sub ffmpeg_proc
{
my ($fn) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($r) = undef;
my ($w) = undef;
my ($pid);
$pid = open2($r, $w, 'ffmpeg', '-vn', '-i', "$fn", '-f', 'wav', '-');
wav_loop($r, $off, $forgelen);
close($r);
close($w);
if (waitpid($pid, WNOHANG) <= 0) {
kill(SIGKILL, $pid);
waitpid($pid, 0);
}
}
sub mplayer_proc
{
my ($fn) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($tf) = tmp_file();
my ($w) = undef;
my ($f) = undef;
my ($pid);
my ($i);
my ($started) = undef;
my ($waited) = undef;
my ($ready) = undef;
my ($prebuf) = 2 * 1024 * 1024;
unlink($tf);
$pid = open3('>&STDERR', $w, '>&STDERR',
'mplayer',
'-quiet', '-really-quiet',
'-vo', 'null',
'-nomouseinput', '-nojoystick', '-nolirc',
'-noconsolecontrols', '-nortc',
'-ao', "pcm:file=$tf", "$fn");
# Wait just to see, if the decoding starts.
# If the resulting wav is less than 512 bytes,
# This will fail, but who cares.
foreach $i (0.05, 0.1, 0.2, 0.4, 0.8, 1.6, 3.2) {
my ($s);
my ($wp);
select(undef, undef, undef, $i);
$wp = waitpid($pid, WNOHANG);
($_, $_, $_, $_, $_, $_, $_, $s, $_, $_, $_, $_, $_) = stat("$tf");
if (defined $s && ($s > 512)) {
$started = 1;
}
if ($wp > 0) {
$waited = 1;
}
if ($started || $waited) {
last;
}
}
if (! $started) {
kill(SIGKILL, $pid);
unlink($tf);
}
# Loop here until we got data beyond the offset point
# or the process terminates.
my ($sleep) = 0.025;
while (! $waited) {
my ($s);
my ($wp);
if ($sleep < 0.5) {
$sleep *= 2.0;
}
select(undef, undef, undef, $sleep);
$wp = waitpid($pid, WNOHANG);
($_, $_, $_, $_, $_, $_, $_, $s, $_, $_, $_, $_, $_) = stat("$tf");
if (defined $s && ($s > ($off + $prebuf))) {
$ready = 1;
}
if ($wp > 0) {
$waited = 1;
}
if ($ready || $waited) {
last;
}
}
# Stream.
if (open($f, "< $tf")) {
wav_loop($f, $off, $forgelen);
close($f);
}
if (! $waited) {
waitpid($pid, 0);
}
close($w);
unlink($tf);
}
sub mpeg4_proc
{
my ($fn) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($f) = undef;
my ($hdr) = undef;
my ($r) = undef;
if (open($f, "< $fn")) {
my ($rl) = sysread($f, $hdr, 512);
close($f);
if ($rl != 512) {
return undef;
}
} else {
return undef;
}
#
# This detection is really rudimentary, but seems to
# do the job for now.
#
if (index($hdr, "Halac") >= 0) {
$r = alac_proc($fn, $off, $forgelen);
} else {
$r = ffmpeg_proc($fn, $off, $forgelen);
}
return $r;
}
sub alac_proc
{
my ($fn) = shift;
my ($off) = shift;
my ($forgelen) = shift;
my ($r) = undef;
my ($w) = undef;
my ($pid);
$pid = open2($r, $w, 'alac', "$fn");
wav_loop($r, $off, undef); # Ignore $forgelen
close($r);
close($w);
if (waitpid($pid, WNOHANG) <= 0) {
kill(SIGKILL, $pid);
waitpid($pid, 0);
}
}

View File

@ -1,42 +0,0 @@
#!/bin/sh
#
# script to facilitate server-side transcoding of ogg files
#
#
# Usage: mt-daapd-ssc.sh <filename> <offset> <length in seconds>
#
# You may need to fix these paths:
#
WAVSTREAMER=wavstreamer
OGGDEC=oggdec
FLAC=flac
ogg_file() {
$OGGDEC --quiet -o - "$FILE" | $WAVSTREAMER -o $OFFSET $FORGELEN
}
flac_file() {
$FLAC --silent --decode --stdout "$FILE" | $WAVSTREAMER -o $OFFSET $FORGELEN
}
FILE=$1
OFFSET=${2:-0}
if [ "$3" != "" ]; then
FORGELEN="-l $3"
fi
case "$1" in
*.[oO][gG][gG])
ogg_file
;;
*.[fF][lL][aA][cC])
flac_file
;;
*)
# here you could cat a generic "error" wav...
# cat /path/to/error.wav
;;
esac

View File

@ -1,51 +0,0 @@
# mt-daapd config file
# General settings
general {
# user the server will run as
uid = "mt-daapd"
# path of the log file
logfile = "/var/log/mt-daapd.log"
# active log level
loglevel = info
# password for the web interface
admin_password = "fork-daapd"
}
# Libraries
# You can have several libraries, and you can give them names;
# each library must use a different port.
library "default" {
# name to be displayed: %l library name, %h hostname, %v version
name = "%l on %h"
# port to bind to
port = 3689
# password for this library
# password = ""
# paths to the music files
directories = { "/srv/music" }
# patterns matching compilation directories
# compilations = { "/foo/", "/bar/" }
# formats that must not be transcoded
# no_transcode = { "alac", "flac" }
# formats that must be trancoded
# force_transcode = { "ogg", "mpc" }
}
#library "My other library" {
# # name to be displayed: %l library name, %h hostname, %v version
# name = "%l on %h"
# # port to bind to
# port = 3690
# # password for this library
## password = ""
# # paths to the music files
# directories = { "/srv/music" }
# # patterns matching compilation directories
## compilations = { "/foo/", "/bar/" }
# # formats that must not be transcoded
## no_transcode = { "alac", "flac" }
# # formats that must be trancoded
## force_transcode = { "ogg", "mpc" }
#}