dslinux/user/bitchx/dll/wavplay Makefile.in invite.wav kicked.wav llook_join.wav llook_split.wav notify_ZnO.wav unotify_ZnO.wav wavplay.c
stsp
stsp at user.in-berlin.de
Sun Jul 2 15:18:38 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/bitchx/dll/wavplay
In directory antilope:/tmp/cvs-serv9280/dll/wavplay
Added Files:
Makefile.in invite.wav kicked.wav llook_join.wav
llook_split.wav notify_ZnO.wav unotify_ZnO.wav wavplay.c
Log Message:
Adding pristine copy of BitchX so I can branch from it.
--- NEW FILE: wavplay.c ---
#include "irc.h"
#include "struct.h"
#include "ircaux.h"
#include "module.h"
#define INIT_MODULE
#include "modval.h"
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef HAVE_MACHINE_SOUNDCARD_H
#include <machine/soundcard.h>
#elif defined(HAVE_LINUX_SOUNDCARD_H)
#include <linux/soundcard.h>
#elif defined(HAVE_SYS_SOUNDCARD_H)
#include <sys/soundcard.h>
#else
#define NO_SOUNDCARD_H
#endif
#ifndef NO_SOUNDCARD_H
static int dspfd = -1;
#define WAV_RIFF_MAGIC "RIFF"
#define WAV_WAVE_MAGIC "WAVE"
#define WAV_FMT_MAGIC "fmt "
#define WAV_DATA_MAGIC "data"
typedef struct {
unsigned char riffID[4];
unsigned long riffsize;
unsigned char waveID[4];
unsigned char fmtID[4];
unsigned long fmtsize;
unsigned short w_formattag;
unsigned short n_channels;
unsigned long n_samples;
unsigned long avg_bytes;
unsigned short n_blockalign;
unsigned short w_bitssample;
unsigned char dataID[4];
unsigned long n_datalen;
} Wave_Header;
char *validate_wav_header(char *header)
{
Wave_Header *w = (Wave_Header *)header;
if (strncmp(w->riffID, WAV_RIFF_MAGIC, 4))
return NULL;
if (strncmp(w->waveID, WAV_WAVE_MAGIC, 4))
return NULL;
if (strncmp(w->fmtID, WAV_FMT_MAGIC, 4))
return NULL;
if (w->fmtsize != 16)
return NULL;
#if 0
if (w->w_formattag != 1)
return NULL;
if (w->n_channels != 2 && w->n_channels != 1)
return NULL;
#endif
if (strncmp(w->dataID, WAV_DATA_MAGIC, 4))
return(NULL);
return (header + sizeof(Wave_Header));
}
int open_dsp(Wave_Header *wav_info)
{
int arg;
if ((dspfd = open("/dev/dsp",O_WRONLY)) < 0)
return -1;
arg = wav_info->w_bitssample;
if ((ioctl(dspfd, SOUND_PCM_WRITE_BITS, &arg)) == -1)
return -1;
arg = wav_info->n_channels; /* mono or stereo */
if ((ioctl(dspfd, SOUND_PCM_WRITE_CHANNELS, &arg)) == -1)
return -1;
arg = wav_info->n_samples; /* sampling rate */
if ((ioctl(dspfd, SOUND_PCM_WRITE_RATE, &arg)) == -1)
return -1;
return dspfd;
}
int play_buffer(int dspfd, short *start, short *end)
{
int status;
status = write(dspfd,(char *)start,(char *)end - (char *)start);
if (status != (char *)end - (char *)start)
return -1;
return 0;
}
void wave_play_file(int wavfd, int dspfd, short *current, short *audioend, int interval)
{
while (current < audioend)
{
short *endcurrent = current + interval;
if (endcurrent > audioend)
endcurrent = audioend;
if (play_buffer(dspfd,current,endcurrent) == -1)
endcurrent = audioend;
current = endcurrent;
}
}
BUILT_IN_DLL(wav_play)
{
char *filename = NULL;
if (dspfd != -1)
{
put_it("Already playing a .wav file");
return;
}
if ((filename = next_arg(args, &args)))
{
char *inwavbuf;
short *current;
short *audioend;
short *audio;
Wave_Header *wav_info;
int wavfd;
struct stat input_fstat;
size_t interval;
if ((wavfd = open(filename,O_RDONLY)) == -1)
{
put_it("errno %s", strerror(errno));
return;
}
if (fstat(wavfd,&input_fstat) != 0)
return;
if (input_fstat.st_size < sizeof(Wave_Header))
return;
if (!(inwavbuf = mmap(NULL, input_fstat.st_size, PROT_READ, MAP_SHARED, wavfd, 0)))
return;
if (!(audio = (short *)validate_wav_header(inwavbuf)))
{
put_it("Invalid wav file");
return;
}
current = audio;
wav_info = (Wave_Header *)inwavbuf;
audioend = (short *)((char *)audio + wav_info->n_datalen);
if ((dspfd = open_dsp(wav_info)) == -1)
{
close(wavfd);
munmap(inwavbuf, input_fstat.st_size);
return;
}
interval = (size_t )((double )wav_info->n_samples * 0.1 * 2);
if (!fork())
{
wave_play_file(wavfd, dspfd, current, audioend, interval);
munmap(inwavbuf,input_fstat.st_size);
close(wavfd);
close(dspfd);
dspfd = -1;
_exit(1);
}
munmap(inwavbuf,input_fstat.st_size);
close(wavfd);
close(dspfd);
dspfd = -1;
}
}
int Wavplay_Init(IrcCommandDll **intp, Function_ptr *global_table)
{
initialize_module("wavplay");
add_module_proc(COMMAND_PROC, "Wavplay", "wavplay", NULL, 0, 0, wav_play, NULL);
bitchsay("Wavplay Module loaded. /wavplay <filename>");
return 0;
}
#endif
--- NEW FILE: unotify_ZnO.wav ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: llook_split.wav ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: notify_ZnO.wav ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: Makefile.in ---
SHELL = @SHELL@
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
topdir = @topdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = @oldincludedir@
local_dir = $(HOME)
# Where the BitchX binary will be installed.
# "make install" will compile and install the program.
INSTALL_IRC = @INSTALL_IRC@
# Where the BitchX library will be. Generally this is the place that
# you put the scripts, help pages and translation tables. It is
# very important that you set this correctly.
IRCLIB = @IRCLIB@
CC = @CC@
DEFS = @INCLUDES@
LIBS = @LIBS@
# Tcl library.
TCL_LIBS = @TCL_LIBS@
# These are for Tcl support.
TCL_OBJS = @TCL_OBJS@
# You don't have the following, so you'll want to leave this blank.
TCL_SRCS = @TCL_SRCS@
# Set this to -g if you want to be able to debug the client, otherwise
# use -O to have the compiler do some optimization instead.
CFLAGS = @CFLAGS@
# Set this to -s if you want the binary to be stripped.
LDFLAGS = @LDFLAGS@
# These are for the cd device player.
CD_SRCS = @CD_SRCS@
CD_OBJS = @CD_OBJS@
# This is the executable suffix for the target operating system.
EXEEXT = @EXEEXT@
# Extra files.
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
# Full path of the directory for BitchX help files.
HELPDIR = @HELPDIR@
# Full path of the directory for the BitchX scripts.
INSTALL_SCRIPT = @INSTALL_SCRIPT@
# Default setting for IRCPATH where BitchX will look for
# its script files if the environment variable is undefined.
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
# the Makefile, but it can contain multiple path elements
# separated by colons. The path MUST lead to an existing directory,
# because the 'global' script is expected to be found there.
IRCPATH = @IRCPATH@
# Path for TRANSLATION variable.
TRANSLATION_PATH = @TRANSLATION_PATH@
# This command will be used to install the BitchX help files. If you don't
# want to install them, replace with the following:
# INSTALL_HELP_CMD = @echo The help files have not been installed.
INSTALL_HELP_CMD = @INSTALL_HELP_CMD@
# This is where the optional plugins will be copied to.
PLUGINDIR = @PLUGINDIR@
# Plugin flags.
SHLIB_LD = @SHLIB_LD@
SHLIB_CFLAGS = @SHLIB_CFLAGS@
SHLIB_SUFFIX = @SHLIB_SUFFIX@
# This command will be used to install the BitchX files on Win32/OS2EMX
# systems.
WINNT_INSTALL = @WINNT_INSTALL@
# This program allows you to use screen/xterm's to put new BitchX windows
# on new screen/xterm windows.
INSTALL_WSERV = @INSTALL_WSERV@
# This program allows you to screen BitchX and reattach to it later.
INSTALL_SCRBX = @INSTALL_SCRBX@
# Set gzip and bzip2 options.
GZIP_ENV = @GZIP_ENV@
BZIP2 = @BZIP2@
# Standard programs.
RM = @RM@
LN = @LN_S@
CP = @CP@
MV = @MV@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
VERSION = @VERSION@
_VERSION_ = @_VERSION_@
MAKE_BIN = @MAKE@
MAKE = $(MAKE_BIN) $(MFLAGS)
MFLAGS = \
'local_dir=$(HOME)' \
'INSTALL_IRC=$(INSTALL_IRC)' \
'IRCLIB=$(IRCLIB)' \
'CC=$(CC)' \
'CFLAGS=$(CFLAGS)' \
'HELPDIR=$(HELPDIR)' \
'INSTALL_WSERV=$(INSTALL_WSERV)' \
'IRCPATH=$(IRCPATH)' \
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
'LDFLAGS=$(LDFLAGS)' \
'LIBS=$(LIBS)' \
'LN=$(LN)' \
'RM=$(RM)' \
'TCL_SRCS=$(TCL_SRCS)' \
'TCL_OBJS=$(TCL_OBJS)' \
'CD_PLAY=$(CD_PLAY)' \
'CD_SRCS=$(CD_SRCS)' \
'CD_OBJS=$(CD_OBJS)' \
'TCL_LIBS=$(TCL_LIBS)' \
'PLUGINDIR=$(PLUGINDIR)' \
'_VERSION_=$(_VERSION_)' \
'VERSION=$(VERSION)' \
'INSTALL_DATA=$(INSTALL_DATA)' \
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
'EXEEXT=$(EXEEXT)' \
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
## Makefile starts here.
PLUGIN_NAME = wavplay
all: Makefile wavplay$(SHLIB_SUFFIX)
Makefile: Makefile.in
cd $(topdir) \
&& ./config.status
wavplay.o: $(srcdir)/wavplay.c
$(CC) $(DEFS) $(CFLAGS) -c $(srcdir)/wavplay.c
wavplay$(SHLIB_SUFFIX): wavplay.o ../dllinit.o
$(SHLIB_LD) wavplay.o ../dllinit.o $(SHLIB_CFLAGS) -o wavplay$(SHLIB_SUFFIX)
clean:
$(RM) *~ *.o wavplay$(SHLIB_SUFFIX) *.a *.dll *.def .#*
distclean: clean
$(RM) Makefile
install:
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(PLUGINDIR)
--- NEW FILE: invite.wav ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: llook_join.wav ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: kicked.wav ---
(This appears to be a binary file; contents omitted.)
More information about the dslinux-commit
mailing list