#
# Copyright (C) by Stefano Falsetto
# e-mail contact ....: mailto:stefko5@inwind.it
#
#    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
#
#
# Config plugin for madplay
#

cat_variables_madplay () {

  cat <<EOF 
# Complete path for mp3 decoder
madplay_DECODER="$madplay_DECODER"

# Program to only show a time line
MADTIME="$MADTIME"

# Array of output supported formats files
OUTPUT_FORMATS_madplay=( $OUTPUT_FORMATS_madplay )

# Parameters to output to file in wav format
TO_wav="$TO_wav"

# Parameters to output to file in cdda format
TO_cdr="$TO_cdr"

# Parameters to output to file in aiff format
TO_aiff="$TO_aiff"

# Parameters to output to file in snd format
TO_snd="$TO_snd"

# Parameters to output to file in snd format
TO_raw="$TO_raw"

# default output file format
TOFMT="$TOFMT"

# Default conversion file extension
MPGCMD="$MPGCMD"

# Bound and criteria to check file type using magic file
# Layer 3
MPEGS1_1=$MPEGS1_1
MPEGS2_1=$MPEGS2_1
MPEGCRITERIA="$MPEGCRITERIA"
# Layer 2
MPEGS1_2=$MPEGS1_2
MPEGS2_2=$MPEGS2_2
MPEGCRITERIA_2="$MPEGCRITERIA_2"

EOF

}

. $PLUGINDIR/config/general/mp3funcs.inc

###################
# MAIN
###################

if [ $(expr "$SUPPORTED_FORMATS" : ".*mp3.*") -ne ${#SUPPORTED_FORMATS} ]; then
  begin_check madplay
  find_prg madplay
  madplay_DECODER=$FOUND_PRG
  find_prg madtime
  MADTIME=$FOUND_PRG
  if [ -z "$madplay_DECODER" ] || [ -z "$MADTIME" ]; then
    missing madplay "http://www.mars.org/home/rob/proj/mpeg/"
    echoc GREEN "You must remember that 'madtime' program must be also compiled and installed"
    end_check
  else
    QueryVersion $($madplay_DECODER --version 2>&1|head -n 1|cut -d' ' -f4) madplay "0.14.2"
    shared_mp3_desc
    EXTENSIONS="mp3"
    OUTPUT_FORMATS_madplay="wav cdr aiff snd raw"
    TO_wav="wave"
    TO_cdr="cdda"
    TO_aiff="aiff"
    TO_snd="snd"
    TO_raw="raw"
    TOFMT=$TO_wav
    MPGCMD="wav"
    AUDIO_PLUGINS="$AUDIO_PLUGINS madplay"
    shared_summary_strings "$madplay_DECODER"
    end_check
    SUPPORTED_FORMATS="$SUPPORTED_FORMATS $EXTENSIONS"
  fi
fi

