Updates for package distribution.

This commit is contained in:
Jaroslav Kysela 2001-08-20 15:17:09 +00:00
parent 903f63aea2
commit 2c87d88158
12 changed files with 64 additions and 395 deletions

View file

@ -12,8 +12,12 @@ ac3dec_SOURCES = ac3dec.c output.c ac3spdif.c
ac3dec_DEPENDENCIES = libac3/libac3.a
EXTRA_DIST = README Changelog TODO plot_spectrum.m autogen.sh\
output_linux.c output_irix.c output_solaris.c
EXTRA_DIST = README Changelog TODO plot_spectrum.m autogen.sh
SUBDIRS = libac3 tools test .
alsa-dist: distdir
@rm -rf ../distdir/ac3dec
@mkdir -p ../distdir/ac3dec
@cp -RLpv $(distdir)/* ../distdir/ac3dec
@rm -rf $(distdir)

View file

@ -1,154 +0,0 @@
/*
*
* output_irix.c
*
* Copyright (C) Aaron Holtzman - May 1999
* Port to IRIX by Jim Miller, SGI - Nov 1999
*
* This file is part of ac3dec, a free Dolby AC-3 stream decoder.
*
* ac3dec 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.
*
* ac3dec 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.
*
*
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include <audio.h>
typedef signed short sint_16;
typedef unsigned int uint_32;
#include "output.h"
static int init = 0;
static ALport alport = 0;
static ALconfig alconfig = 0;
static int bytesPerWord = 1;
static int nChannels = 2;
/*
* open the audio device for writing to
*/
int output_open(int bits, int rate, int channels)
{
ALpv params[2];
int dev = AL_DEFAULT_OUTPUT;
int wsize = AL_SAMPLE_16;
nChannels = channels;
if (!init) {
init = 1;
alconfig = alNewConfig();
if (alSetQueueSize(alconfig, BUFFER_SIZE) < 0) {
fprintf(stderr, "alSetQueueSize failed: %s\n",
alGetErrorString(oserror()));
return 0;
}
if (alSetChannels(alconfig, channels) < 0) {
fprintf(stderr, "alSetChannels(%d) failed: %s\n",
channels, alGetErrorString(oserror()));
return 0;
}
if (alSetDevice(alconfig, dev) < 0) {
fprintf(stderr, "alSetDevice failed: %s\n",
alGetErrorString(oserror()));
return 0;
}
if (alSetSampFmt(alconfig, AL_SAMPFMT_TWOSCOMP) < 0) {
fprintf(stderr, "alSetSampFmt failed: %s\n",
alGetErrorString(oserror()));
return 0;
}
alport = alOpenPort("AC3Decode", "w", 0);
if (!alport) {
fprintf(stderr, "alOpenPort failed: %s\n",
alGetErrorString(oserror()));
return 0;
}
switch (bits) {
case 8:
bytesPerWord = 1;
wsize = AL_SAMPLE_8;
break;
case 16:
bytesPerWord = 2;
wsize = AL_SAMPLE_16;
break;
case 24:
bytesPerWord = 4;
wsize = AL_SAMPLE_24;
break;
default:
printf("Irix audio: unsupported bit with %d\n", bits);
break;
}
if (alSetWidth(alconfig, wsize) < 0) {
fprintf(stderr, "alSetWidth failed: %s\n", alGetErrorString(oserror()));
return 0;
}
params[0].param = AL_RATE;
params[0].value.ll = alDoubleToFixed((double)rate);
params[1].param = AL_MASTER_CLOCK;
params[1].value.i = AL_CRYSTAL_MCLK_TYPE;
if ( alSetParams(dev, params, 1) < 0) {
printf("alSetParams() failed: %s\n", alGetErrorString(oserror()));
return 0;
}
}
printf("I've synced the IRIX code with the mainline blindly.\n Let me know if it works.\n");
return 1;
}
/*
* play the sample to the already opened file descriptor
*/
void output_play(sint_16* output_samples, uint_32 num_bytes)
{
alWriteFrames(alport, output_samples, 6 * 256);
}
void
output_close(void)
{
alClosePort(alport);
alFreeConfig(alconfig);
alport = 0;
alconfig = 0;
init = 0;
}

View file

@ -1,113 +0,0 @@
/*
*
* output_linux.c
*
* Copyright (C) Aaron Holtzman - May 1999
*
* This file is part of ac3dec, a free Dolby AC-3 stream decoder.
*
* ac3dec 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.
*
* ac3dec 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.
*
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#if defined(__OpenBSD__)
#include <soundcard.h>
#elif defined(__FreeBSD__)
#include <machine/soundcard.h>
#else
#include <sys/soundcard.h>
#endif
#include <sys/ioctl.h>
//this sux...types should go in config.h methinks
typedef signed short sint_16;
typedef unsigned int uint_32;
#include "output.h"
static char dev[] = "/dev/dsp";
static int fd;
/*
* open the audio device for writing to
*/
int output_open(int bits, int rate, int channels)
{
int tmp;
/*
* Open the device driver
*/
fd=open(dev,O_WRONLY);
if(fd < 0)
{
fprintf(stderr,"%s: Opening audio device %s\n",
strerror(errno), dev);
goto ERR;
}
tmp = channels == 2 ? 1 : 0;
ioctl(fd,SNDCTL_DSP_STEREO,&tmp);
tmp = bits;
ioctl(fd,SNDCTL_DSP_SAMPLESIZE,&tmp);
tmp = rate;
ioctl(fd,SNDCTL_DSP_SPEED, &tmp);
//this is cheating
tmp = 256;
// ioctl(fd,SNDCTL_DSP_SETFRAGMENT,&tmp);
return 1;
ERR:
if(fd >= 0) { close(fd); }
return 0;
}
/*
* play the sample to the already opened file descriptor
*/
void output_play(sint_16* output_samples, uint_32 num_bytes)
{
// if(fd < 0)
// return;
write(fd,output_samples,1024 * 6);
}
void
output_close(void)
{
close(fd);
}

View file

@ -1,124 +0,0 @@
/*
*
* output_solaris.c
*
* Copyright (C) Aaron Holtzman - May 1999
*
* This file is part of ac3dec, a free Dolby AC-3 stream decoder.
*
* ac3dec 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.
*
* ac3dec 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.
*
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/audioio.h>
#include <sys/ioctl.h>
#include <stropts.h>
#include <signal.h>
#include <math.h>
//FIXME broken solaris headers!
int usleep(unsigned int useconds);
//this sux...types should go in config.h methinks
typedef signed short sint_16;
typedef unsigned int uint_32;
#include "output.h"
/* Global to keep track of old state */
static audio_info_t info;
static char dev[] = "/dev/audio";
static int fd;
/*
* open the audio device for writing to
*/
int output_open(int bits, int rate, int channels)
{
/*
* Open the device driver
*/
fd=open(dev,O_WRONLY);
if(fd < 0)
{
fprintf(stderr,"%s: Opening audio device %s\n",
strerror(errno), dev);
goto ERR;
}
fprintf(stderr,"Opened audio device \"%s\"\n",dev);
/* Setup our parameters */
AUDIO_INITINFO(&info);
info.play.sample_rate = rate;
info.play.precision = bits;
info.play.channels = channels;
info.play.buffer_size = 1024;
info.play.encoding = AUDIO_ENCODING_LINEAR;
//info.play.port = AUDIO_SPEAKER;
//info.play.gain = 110;
/* Write our configuration */
/* An implicit GETINFO is also performed so we can get
* the buffer_size */
if(ioctl(fd, AUDIO_SETINFO, &info) < 0)
{
fprintf(stderr, "%s: Writing audio config block\n",strerror(errno));
goto ERR;
}
return 1;
ERR:
if(fd >= 0) { close(fd); }
return 0;
}
unsigned long j= 0 ;
/*
* play the sample to the already opened file descriptor
*/
void output_play(sint_16* output_samples, uint_32 num_bytes)
{
write(fd,&output_samples[0 * 512],1024);
write(fd,&output_samples[1 * 512],1024);
write(fd,&output_samples[2 * 512],1024);
write(fd,&output_samples[3 * 512],1024);
write(fd,&output_samples[4 * 512],1024);
write(fd,&output_samples[5 * 512],1024);
}
void
output_close(void)
{
close(fd);
}