Commit 4cc89dea authored by Jack Moffitt's avatar Jack Moffitt

Initial revision


git-svn-id: http://svn.xiph.org/trunk/ao@627 0101bb08-14d6-0310-b084-bc0e0c8e3800
parents
Aaron Holtzman
Stan Seibert <indigo@aztec.asu.edu>
fill this in :)
This diff is collapsed.
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = foreign dist-zip
SUBDIRS = src include doc
EXTRA_DIST = README AUTHORS CHANGES COPYING libao.spec
debug:
$(MAKE) all CFLAGS="@DEBUG@"
profile:
$(MAKE) all CFLAGS="@PROFILE@"
This diff is collapsed.
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# (basically ripped directly from enlightenment's autogen.sh)
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
cd "$srcdir"
DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile libao."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have automake installed to compile libao."
echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
echo "Generating configuration files for libao, please wait...."
echo " aclocal $ACLOCAL_FLAGS"
aclocal $ACLOCAL_FLAGS
echo " autoheader"
autoheader
echo " automake --add-missing"
automake --add-missing
echo " autoconf"
autoconf
$srcdir/configure "$@" && echo
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/audio_out.c)
AM_INIT_AUTOMAKE(libao,1.0.0)
AC_CANONICAL_HOST
dnl ====================================
dnl Check for programs
dnl ====================================
AC_PROG_CC
AM_PROG_LIBTOOL
AC_PROG_CPP
AC_PROG_RANLIB
AC_SUBST(RANLIB)
dnl ====================================
dnl Set some general compile options
dnl ====================================
if test -z "$GCC"; then
case $host in
*-*-irix*)
if test -z "$CC"; then
CC=cc
fi
DEBUG="-g -signed"
CFLAGS="-O2 -w -signed"
PROFILE="-p -g3 -O2 -signed" ;;
sparc-sun-solaris*)
DEBUG="-v -g"
CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;;
*)
DEBUG="-g"
CFLAGS="-O"
PROFILE="-g -p" ;;
esac
else
case $host in
*-*-linux*)
DEBUG="-g -Wall -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
CFLAGS="-O20 -ffast-math -D_REENTRANT -fsigned-char"
PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
sparc-sun-*)
DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char -mv8"
CFLAGS="-O20 -ffast-math -D__NO_MATH_INLINES -fsigned-char -mv8"
PROFILE="-pg -g -O20 -D__NO_MATH_INLINES -fsigned-char -mv8" ;;
*)
DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
CFLAGS="-O20 -D__NO_MATH_INLINES -fsigned-char"
PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
esac
fi
AC_SUBST(CC)
AC_SUBST(DEBUG)
AC_SUBST(PROFILE)
dnl ==============================
dnl Check for libraries
dnl ==============================
dnl --- if we're on irix, check for -laudio ---
case $host in
*-*-irix*)
AC_CHECK_LIB(audio, ALwritesamps)
;;
esac
dnl ==============================
dnl Checks for header files
dnl ==============================
AC_HEADER_STDC
dnl ==============================
dnl Checks for types
dnl ==============================
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
case 2 in
$ac_cv_sizeof_short) SIZE16="short";;
$ac_cv_sizeof_int) SIZE16="int";;
esac
case 4 in
$ac_cv_sizeof_short) SIZE32="short";;
$ac_cv_sizeof_int) SIZE32="int";;
$ac_cv_sizeof_long) SIZE32="long";;
esac
if test -z "$SIZE16"; then
AC_MSG_WARN(No 16 bit type found on this platform!)
fi
if test -z "$SIZE32"; then
AC_MSG_WARN(No 32 bit type found on this platform!)
fi
AC_SUBST(SIZE16)
AC_SUBST(SIZE32)
AC_SUBST(SIZE64)
dnl =========================================
dnl Figure out which ao_* files to compile
dnl =========================================
AC_ARG_ENABLE(oss,,,enable_oss=yes)
AC_ARG_ENABLE(irix,,,enable_irix=yes)
AC_ARG_ENABLE(solaris,,,enable_solaris=yes)
AC_ARG_ENABLE(alsa,,,enable_alsa=yes)
AC_ARG_ENABLE(esd,,,enable_esd=yes)
AC_ARG_ENABLE(default-output,,,enable_default_output=def)
dnl ======================================
dnl Detect possible output devices
dnl ======================================
dnl --- Initialize default variable values ---
has_oss=no
has_irix=no
has_solaris=no
has_esd=no
has_alsa=no
need_libossaudio=no
AC_CHECK_LIB(ossaudio, main, has_libossaudio=yes, has_libossaudio=no)
case $host in
*-*-linux*|*-openbsd*|*-freebsd*)
has_oss=yes;;
*-netbsd*)
if test has_libossaudio = "yes"; then
has_oss=yes
need_libossaudio=yes
fi;;
*-irix*)
has_irix=yes;;
*-solaris*)
has_solaris=yes;;
esac
AC_CHECK_LIB(esd, esd_play_stream, has_esd=yes)
AC_CHECK_LIB(asound, snd_pcm_open, has_alsa=yes, has_alsa=no)
dnl -- Set appropriate variables for each driver --
AC_MSG_CHECKING("whether to compile OSS driver")
if test $enable_oss = "yes" && test $has_oss = "yes"; then
AC_MSG_RESULT("yes")
LIBAO_FILES="$LIBAO_FILES ao_oss.c"
LIBAO_FLAGS="$LIBAO_FLAGS -DAO_COMPILE_OSS"
if test need_libossaudio = yes; then
LIBAO_LIBS="$LIBAO_LIBS -lossaudio"
fi
ao_default=oss
else
AC_MSG_RESULT("no")
fi
AC_MSG_CHECKING("whether to compile IRIX driver")
if test $enable_irix = "yes" && test $has_irix = "yes"; then
AC_MSG_RESULT("yes")
LIBAO_FILES="$LIBAO_FILES ao_irix.c"
LIBAO_FLAGS="$LIBAO_FLAGS -DAO_COMPILE_IRIX"
ao_default=irix
else
AC_MSG_RESULT("no")
fi
AC_MSG_CHECKING("whether to compile Solaris driver")
if test $enable_solaris = "yes" && test $has_solaris = "yes"; then
LIBAO_FILES="$LIBAO_FILES ao_solaris.c"
LIBAO_FLAGS="$LIBAO_FLAGS -DAO_COMPILE_SOLARIS"
ao_default=solaris
else
AC_MSG_RESULT("no")
fi
AC_MSG_CHECKING("whether to compile ESD driver")
if test $enable_esd = "yes" && test $has_esd = "yes"; then
AC_MSG_RESULT("yes")
LIBAO_LIBS="$LIBAO_LIBS -lesd"
LIBAO_FLAGS="$LIBAO_FLAGS -DAO_COMPILE_ESD"
LIBAO_FILES="$LIBAO_FILES ao_esd.c"
else
AC_MSG_RESULT("no")
fi
AC_MSG_CHECKING("whether to compile ALSA driver")
if test $enable_alsa = "yes" && test $has_alsa = "yes"; then
AC_MSG_RESULT("yes")
LIBAO_FLAGS="$LIBAO_FLAGS -DAO_COMPILE_ALSA"
LIBAO_FILES="$LIBAO_FILES ao_alsa.c"
LIBAO_LIBS="$LIBAO_LIBS -lasound"
else
AC_MSG_RESULT("no")
fi
dnl -- Set the default device
if test $enable_default_output != "def"; then
ao_default=$enable_default_output
fi
case $ao_default in
null)
AO_DEFAULT_DEF=AO_NULL;;
oss)
AO_DEFAULT_DEF=AO_OSS;;
irix)
AO_DEFAULT_DEF=AO_IRIX;;
solaris)
AO_DEFAULT_DEF=AO_SOLARIS;;
esd)
AO_DEFAULT_DEF=AO_ESD;;
alsa)
AO_DEFAULT_DEF=AO_ALSA;;
wav)
AO_DEFAULT_DEF=AO_WAV;;
*)
dnl Make the default output device AO_NULL
ao_default=null
AO_DEFAULT_DEF=AO_NULL;;
esac
AC_MSG_RESULT("setting default output device... $ao_default")
LIBAO_FLAGS="$LIBAO_FLAGS -DAO_DEFAULT=$AO_DEFAULT_DEF"
AC_SUBST(LIBAO_FILES)
AC_SUBST(LIBAO_FLAGS)
AC_SUBST(LIBAO_LIBS)
AC_OUTPUT(Makefile src/Makefile doc/Makefile include/Makefile include/ao/Makefile include/ao/os_types.h include/ao/ao_libs.inc)
## Process this with automake to create Makefile.in
AUTOMAKE_OPTIONS = foreign
docdir = $(prefix)/doc/$(PACKAGE)-$(VERSION)
doc_DATA = index.html
EXTRA_DIST = $(doc_DATA)
There is no documentation yet.
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = foreign
SUBDIRS = ao
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = foreign
includedir = $(prefix)/include/ao
include_HEADERS = ao.h os_types.h
/*
*
* ao.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000
*
* This file is part of libao, a cross-platform library. See
* README for a history of this source code.
*
* libao 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, or (at your option)
* any later version.
*
* libao 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __AO_H__
#define __AO_H__
#include <stdlib.h>
/* Type sizes */
#include <ao/os_types.h>
/* --- Structures --- */
typedef struct ao_option_s {
char *key;
char *value;
struct ao_option_s *next;
} ao_option_t;
typedef struct ao_info_s
{
/* driver name (Ex: "OSS Audio driver") */
const char *name;
/* short name (for config strings) (Ex: "oss") */
const char *short_name;
/* author (Ex: "Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
const char *author;
/* any additional comments (Ex: "Needs work.") */
const char *comment;
} ao_info_t;
typedef void ao_internal_t;
typedef struct ao_functions_s
{
ao_info_t* (*get_driver_info) (void);
ao_internal_t* (*open) (uint_32 bits, uint_32 rate,
uint_32 channels, ao_option_t *options);
void (*play) (ao_internal_t *state,
void* output_samples, uint_32 num_bytes);
void (*close) (ao_internal_t *state);
} ao_functions_t;
typedef struct ao_device_s
{
ao_functions_t *funcs;
ao_internal_t *state;
} ao_device_t;
/* --- Driver id numbers --- */
#define AO_NULL 0
#define AO_OSS 1
#define AO_IRIX 2
#define AO_SOLARIS 3
#define AO_WIN32 4
#define AO_BEOS 5
#define AO_ESD 6
#define AO_ALSA 7
#define AO_WAV 10
#define AO_RAW 11
/* Total number of drivers */
#define AO_DRIVERS 12
/* --- Functions --- */
int ao_get_driver_id (const char *short_name);
ao_info_t *ao_get_driver_info (int driver_id);
ao_device_t *ao_open (int driver_id, uint_32 bits, uint_32 rate, uint_32 channels,
ao_option_t *options);
void ao_play (ao_device_t *device, void* output_samples, uint_32 num_bytes);
void ao_close (ao_device_t *device);
/* Returns 1 if options successfully appended, 0 if error */
int ao_append_option (ao_option_t **options, const char* op_str);
void ao_free_options (ao_option_t* options);
#endif /* __AO_H__ */
LIBAO_LIBS= -lesd
LIBAO_LIBS=@LIBAO_LIBS@
/*
*
* config.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000
*
* This file is part of libao, a cross-platform library. See
* README for a history of this source code.
*
* libao 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, or (at your option)
* any later version.
*
* libao 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* Set type sizes for this platform (Requires Autoconf) */
typedef unsigned char uint_8;
typedef unsigned short uint_16;
typedef unsigned int uint_32;
typedef signed char sint_32;
typedef signed short sint_16;
typedef signed int sint_8;
/*
*
* config.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000
*
* This file is part of libao, a cross-platform library. See
* README for a history of this source code.
*
* libao 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, or (at your option)
* any later version.
*
* libao 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* Set type sizes for this platform (Requires Autoconf) */
typedef unsigned char uint_8;
typedef unsigned @SIZE16@ uint_16;
typedef unsigned @SIZE32@ uint_32;
typedef signed char sint_32;
typedef signed @SIZE16@ sint_16;
typedef signed @SIZE32@ sint_8;
%define name libao
%define version 1.0.0
%define release 1
Summary: Cross Platform Audio Output Library
Name: %{name}
Version: %{version}
Release: %{release}
Group: Libraries/Multimedia
Copyright: GPL
URL: http://www.xiph.org/
Vendor: Xiphophorus <team@xiph.org>
Source: ftp://ftp.xiph.org/pub/ao/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-root
%description
Libao is a cross platform audio output library. It currently supports
ESD, OSS, Solaris, and IRIX.
%package devel
Summary: Cross Platform Audio Output Library Development
Group: Development/Libraries
%description devel
The libao-devel package contains the header files and documentation
needed to develop applications with libao.
%prep
%setup -q -n %{name}-%{version}
%build
if [ ! -f configure ]; then
CFLAGS="$RPM_FLAGS" ./autogen.sh --prefix=/usr
else
CFLAGS="$RPM_FLAGS" ./configure --prefix=/usr
fi
make
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%files
%defattr(-,root,root)
%doc AUTHORS
%doc CHANGES
%doc COPYING
%doc README
/usr/lib/libao.so.*
/usr/lib/libao.a
%files devel
%doc doc/index.html
/usr/include/ao/ao.h
/usr/include/ao/os_types.h
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%post
/sbin/ldconfig
%postun
/sbin/ldconfig
%changelog
* Sun Sep 03 2000 Jack Moffitt <jack@icecast.org>
- initial spec file created
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include
lib_LTLIBRARIES = libao.la
libao_la_SOURCES = audio_out.c @LIBAO_FILES@
libao_la_LDFLAGS = -version-info 1:0:0
debug:
$(MAKE) all CFLAGS="@DEBUG@"
profile:
$(MAKE) all CFLAGS="@PROFILE@"
/*
*
* ao_alsa.c
*
* Copyright (C) Stan Seibert - July 2000
*
* This file is part of libao, a cross-platform library. See
* README for a history of this source code.
*
* libao 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, or (at your option)
* any later version.
*
* libao 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/asoundlib.h>
#include <ao/ao.h>
#define AO_ALSA_BUF_SIZE 32768
typedef struct ao_alsa_internal_s
{
snd_pcm_t *pcm_handle;
char *buf;
int buf_size;
int buf_end;
int card;
int dev;
} ao_alsa_internal_t;
static ao_info_t ao_alsa_info =
{
"Advanced Linux Sound Architecture (ALSA) output",
"alsa",
"Stan Seibert <volsung@asu.edu>",
""
};
static void
ao_alsa_parse_options(ao_alsa_internal_t *state, ao_option_t *options)
{
state->card = 0;
state->dev = 0;
state->buf_size = AO_ALSA_BUF_SIZE;
while (options)
{
if (!strcmp(options->key, "card"))
state->card = atoi(options->value);
else if (!strcmp(options->key, "dev"))
state->dev = atoi(options->value);
else if (!strcmp(options->key, "buf_size"))
state->buf_size = atoi(options->value);
options = options->next;
}
}
static ao_internal_t*
ao_alsa_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options)
{
ao_alsa_internal_t *state;
snd_pcm_channel_params_t param;
int err;
memset(&param, 0, sizeof(param));
param.channel = SND_PCM_CHANNEL_PLAYBACK;
param.mode = SND_PCM_MODE_BLOCK;
param.format.interleave = 1;
switch (bits)
{
case 8 : param.format.format = SND_PCM_SFMT_S8;
break;
case 16 : param.format.format = SND_PCM_SFMT_S16_LE;
break;
default : return NULL;
}
if (channels > 0 && channels < 3)
param.format.voices = channels;
else
return NULL;
// Allocate the state structure and parse the options
state = malloc(sizeof(ao_alsa_internal_t));
if (state == NULL)
return NULL;
ao_alsa_parse_options(state, options);
// Finish filling in the parameter structure
param.format.rate = rate;
param.start_mode = SND_PCM_START_FULL;
param.stop_mode = SND_PCM_STOP_STOP;
param.buf.block.frag_size = state->buf_size;
param.buf.block.frags_min = 1;
param.buf.block.frags_max = 8;
err = snd_pcm_open(&(state->pcm_handle),
state->card,
state->dev,
SND_PCM_OPEN_PLAYBACK | SND_PCM_OPEN_NONBLOCK);
if ( err < 0 )
{
free(state);
return NULL;
}
err = snd_pcm_channel_params(state->pcm_handle, &param);
if (err < 0 )
{
snd_pcm_close(state->pcm_handle);
free(state);
return NULL;
}
state->buf = malloc(state->buf_size);
state->buf_end = 0;
snd_pcm_nonblock_mode(state->pcm_handle, 0);
snd_pcm_channel_prepare(state->pcm_handle, SND_PCM_CHANNEL_PLAYBACK);
return state;
}
static void
ao_alsa_close (ao_internal_t *state)
{
ao_alsa_internal_t *s = (ao_alsa_internal_t *) state;
snd_pcm_close(s->pcm_handle);
free(s);
}
static void
ao_alsa_write_buffer (ao_alsa_internal_t *s