Convert cd audio libs to plugins. Windows untested, dos and sgi not converted yet.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-06-01 22:55:33 +00:00
parent 02003cf229
commit 85333a9f96
15 changed files with 818 additions and 504 deletions

View file

@ -926,75 +926,62 @@ dnl ==================================================================
dnl Checks for CD-ROM
dnl ==================================================================
CD_LIBS=""
CD_CFLAGS=""
CD_PLUGIN_TARGETS=""
CDTYPE=""
AC_MSG_CHECKING(for CD audio support)
dnl SDL CD audio
AC_ARG_ENABLE(sdl-cd-audio,
[ --enable-sdl-cd-audio use SDL for CD audio output],
if test -z "$CDTYPE" -a "x$HAVE_SDL" = "xyes"; then
AC_MSG_RESULT([yes (SDL)])
CDTYPE=SDL
CD_LIBS="$SDL_LIBS"
fi
)
dnl Linux
if test -z "$CDTYPE"; then
AC_EGREP_CPP([QF_maGiC_VALUE],
[
AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <linux/cdrom.h>
#ifdef CDROMREADTOCENTRY
QF_maGiC_VALUE
#endif
],
AC_MSG_RESULT([yes (Linux)])
CDTYPE=LINUX
)
],
AC_MSG_RESULT([yes (Linux)])
CDTYPE="$CDTYPE LINUX"
CD_PLUGIN_TARGETS="$CD_PLUGIN_TARGETS libcd_linux.la"
)
dnl SDL CD audio
if test "x$HAVE_SDL" = "xyes"; then
AC_MSG_RESULT([yes (SDL)])
CDTYPE="$CDTYPE SDL"
CD_PLUGIN_TARGETS="$CD_PLUGIN_TARGETS libcd_sdl.la"
fi
dnl SGI
if test -z "$CDTYPE"; then
AC_EGREP_CPP([QF_maGiC_VALUE],
[
AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <dmedia/cdaudio.h>
#ifdef CD_READY
QF_maGiC_VALUE
#endif
],
AC_MSG_RESULT([yes (SGI)])
CDTYPE=SGI
CD_LIBS="-lcdaudio -lmediad -lds"
)
fi
],
AC_MSG_RESULT([yes (SGI)])
CDTYPE="$CDTYPE SGI"
CD_PLUGIN_TARGETS="$CD_PLUGIN_TARGETS libcd_sgi.la"
SGI_CD_LIBS="-lcdaudio -lmediad -lds"
)
if test -z "$CDTYPE"; then
AC_EGREP_CPP([QF_maGiC_VALUE],
[
AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <windows.h>
#include <mmsystem.h>
#if defined(MCI_SET_DOOR_OPEN)
QF_maGiC_VALUE
#endif
],
AC_MSG_RESULT([yes (Win32)])
CDTYPE=WIN32
CD_LIBS=""
)
fi
],
AC_MSG_RESULT([yes (Win32)])
CDTYPE="$CDTYPE WIN32"
CD_PLUGIN_TARGETS="$CD_PLUGIN_TARGETS libcd_win.la"
)
test -z "$CDTYPE" && AC_MSG_RESULT([no, using null CD audio driver])
AC_SUBST(CD_LIBS)
AC_SUBST(CD_CFLAGS)
AM_CONDITIONAL(CDTYPE_LINUX, test "$CDTYPE" = "LINUX")
AM_CONDITIONAL(CDTYPE_SDL, test "$CDTYPE" = "SDL")
AM_CONDITIONAL(CDTYPE_SGI, test "$CDTYPE" = "SGI")
AM_CONDITIONAL(CDTYPE_WIN32, test "$CDTYPE" = "WIN32")
AM_CONDITIONAL(CDTYPE_NULL, test "$CDTYPE" != "LINUX" -a "$CDTYPE" != "SDL" -a "$CDTYPE" != "SGI" -a "$CDTYPE" != "WIN32")
dnl ==================================================================
dnl Checks for networking
dnl ==================================================================
@ -1491,6 +1478,7 @@ fi
AC_SUBST(NQ_TARGETS)
AC_SUBST(QW_TARGETS)
AC_SUBST(CD_TARGETS)
AC_SUBST(CD_PLUGIN_TARGETS)
AC_SUBST(SND_TARGETS)
AC_SUBST(SND_PLUGIN_TARGETS)
AC_SUBST(VID_TARGETS)

View file

@ -34,6 +34,7 @@
#define QFPLUGIN
#include <QF/qtypes.h>
#include <QF/plugin/cd.h>
#include <QF/plugin/general.h>
#include <QF/plugin/input.h>
#include <QF/plugin/sound.h>
@ -41,18 +42,21 @@
typedef enum {
qfp_null = 0, // Not real
qfp_input, // Input (pointing devices, joysticks, etc)
qfp_cd, // CD Audio
qfp_sound, // Wave output (OSS, ALSA, Win32)
} plugin_type_t;
typedef struct plugin_funcs_s {
general_funcs_t *general;
input_funcs_t *input;
cd_funcs_t *cd;
sound_funcs_t *sound;
} plugin_funcs_t;
typedef struct plugin_data_s {
general_data_t *general;
input_data_t *input;
// cd_data_t *cd;
sound_data_t *sound;
} plugin_data_t;

56
include/QF/plugin/cd.h Normal file
View file

@ -0,0 +1,56 @@
/*
QF/plugin/cd.h
CDAudio plugin data types
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __QF_plugin_cd_h_
#define __QF_plugin_cd_h_
#include <QF/cdaudio.h>
#include <QF/qtypes.h>
#include <QF/plugin.h>
/*
All CDAudio plugins must export these functions
*/
typedef void (QFPLUGIN *P_CDAudio_CD_f) (void); //
typedef void (QFPLUGIN *P_CDAudio_Pause) (void);
typedef void (QFPLUGIN *P_CDAudio_Play) (byte, qboolean);
typedef void (QFPLUGIN *P_CDAudio_Resume) (void);
typedef void (QFPLUGIN *P_CDAudio_Shutdown) (void);
typedef void (QFPLUGIN *P_CDAudio_Update) (void);
typedef void (QFPLUGIN *P_CDAudio_Init) (void);
typedef struct cd_funcs_s {
P_CDAudio_CD_f pCD_f; //
P_CDAudio_Pause pCDAudio_Pause;
P_CDAudio_Play pCDAudio_Play;
P_CDAudio_Resume pCDAudio_Resume;
P_CDAudio_Shutdown pCDAudio_Shutdown;
P_CDAudio_Update pCDAudio_Update;
P_CDAudio_Init pCDAudio_Init;
} cd_funcs_t;
#endif // __QF_plugin_cd_h_

View file

@ -5,11 +5,16 @@ clean-local:
INCLUDES= -I$(top_srcdir)/include
lib_LTLIBRARIES = libQFsound.la
lib_LTLIBRARIES= libQFsound.la libQFcd.la
libQFsound_la_LDFLAGS= -version-info 1:0:0
libQFsound_la_SOURCES= snd_common.c snd.c
libQFsound_la_LDFLAGS = -version-info 1:0:0
libQFsound.la: $(libQFsound_la_OBJECTS) $(libQFsound_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libQFsound_la_LDFLAGS) $(libQFsound_la_OBJECTS) $(libQFsound_la_LIBADD) $(LIBS)
LIBLIST = libQFsound.la @LIBRARY_SEARCH_PATH@
libQFcd_la_LDFLAGS= -version-info 1:0:0
libQFcd_la_SOURCES= cd.c
libQFcd.la: $(libQFcd_la_OBJECTS) $(libQFcd_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libQFcd_la_LDFLAGS) $(libQFcd_la_OBJECTS) $(libQFcd_la_LIBADD) $(LIBS)
LIBLIST = libQFsound.la libQFcd.la @LIBRARY_SEARCH_PATH@

102
libs/audio/cd.c Normal file
View file

@ -0,0 +1,102 @@
/*
cd_plugin.c
cd plugin wrapper
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 1999,2000 contributors of the QuakeForge project
Please see the file "AUTHORS" for a list of contributors
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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#include "QF/cdaudio.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/plugin.h"
#include "QF/qtypes.h"
cvar_t *cd_plugin;
plugin_t *cdmodule = NULL;
int
CDAudio_Init (void)
{
cd_plugin = Cvar_Get ("cd_plugin", "null", CVAR_ARCHIVE, NULL,
"CD Plugin to use");
cdmodule = PI_LoadPlugin ("cd", cd_plugin->string);
if (!cdmodule) {
Con_Printf ("Loading of cd module: %s failed!\n", cd_plugin->string);
return -1;
} else {
cdmodule->functions->general->p_Init ();
return 0; // FIXME: Assumes success
}
}
void
CDAudio_Pause (void)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Pause ();
}
void
CDAudio_Play (byte track, qboolean looping)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Play (track, looping);
}
void
CDAudio_Resume (void)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Resume ();
}
void
CDAudio_Shutdown (void)
{
if (cdmodule)
cdmodule->functions->general->p_Shutdown ();
}
void
CDAudio_Update (void)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Update ();
}
static void
CD_f (void)
{
if (cdmodule)
cdmodule->functions->cd->pCD_f ();
}

View file

@ -1,30 +1,32 @@
INCLUDES= -I$(top_srcdir)/include
INCLUDES= -I$(top_srcdir)/include $(SDL_CFLAGS)
lib_LTLIBRARIES = @CD_TARGETS@
EXTRA_LTLIBRARIES = libQFcd.la
libQFcd_la_LDFLAGS = -version-info 1:0:0 $(CD_LIBS)
#
# ... CD audio
#
if CDTYPE_LINUX
libQFcd_la_SOURCES= cd_linux.c
endif
if CDTYPE_SDL
libQFcd_la_SOURCES= cd_sdl.c
endif
if CDTYPE_SGI
libQFcd_la_SOURCES= cd_sgi.c
endif
if CDTYPE_WIN32
libQFcd_la_SOURCES= cd_win.c
endif
if CDTYPE_NULL
libQFcd_la_SOURCES= cd_null.c
endif
libQFcd.la: $(libQFcd_la_OBJECTS) $(libQFcd_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libQFcd_la_LDFLAGS) $(libQFcd_la_OBJECTS) $(libQFcd_la_LIBADD) $(LIBS)
pkglib_LTLIBRARIES= @CD_PLUGIN_TARGETS@ libcd_null.la
EXTRA_LTLIBRARIES= libcd_linux.la libcd_sdl.la libcd_sgi.la libcd_win.la
LIBLIST = libQFcd.la @LIBRARY_SEARCH_PATH@
libcd_linux_la_LDFLAGS= -version-info 1:0:0
libcd_linux_la_SOURCES= cd_linux.c
libcd_linux.la: $(libcd_linux_la_OBJECTS) $(libcd_linux_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libcd_linux_la_LDFLAGS) $(libcd_linux_la_OBJECTS) $(libcd_linux_la_LIBADD) $(LIBS)
libcd_sdl_la_LDFLAGS= -version-info 1:0:0 $(SDL_LIBS)
libcd_sdl_la_SOURCES= cd_sdl.c
libcd_sdl.la: $(libcd_sdl_la_OBJECTS) $(libcd_sdl_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libcd_sdl_la_LDFLAGS) $(libcd_sdl_la_OBJECTS) $(libcd_sdl_la_LIBADD) $(LIBS)
libcd_sgi_la_LDFLAGS= -version-info 1:0:0 $(SGI_CD_LIBS)
libcd_sgi_la_SOURCES= cd_sgi.c
libcd_sgi.la: $(libcd_sgi_la_OBJECTS) $(libcd_sgi_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libcd_sgi_la_LDFLAGS) $(libcd_sgi_la_OBJECTS) $(libcd_sgi_la_LIBADD) $(LIBS)
libcd_win_la_LDFLAGS= -version-info 1:0:0
libcd_win_la_SOURCES= cd_win.c
libcd_win.la: $(libcd_win_la_OBJECTS) $(libcd_win_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libcd_win_la_LDFLAGS) $(libcd_win_la_OBJECTS) $(libcd_win_la_LIBADD) $(LIBS)
libcd_null_la_LDFLAGS= -version-info 1:0:0
libcd_null_la_SOURCES= cd_null.c
libcd_null.la: $(libcd_null_la_OBJECTS) $(libcd_null_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libcd_null_la_LDFLAGS) $(libcd_null_la_OBJECTS) $(libcd_null_la_LIBADD) $(LIBS)
LIBLIST = $(pkglib_LTLIBRARIES) @LIBRARY_SEARCH_PATH@

View file

@ -2,6 +2,7 @@
cd_dos.c
support for cd music in dos.
FIXME: Update for plugin API
Copyright (C) 1996-1997 Id Software, Inc.

View file

@ -1,7 +1,7 @@
/*
cd_linux.c
(description)
Linux CD Audio support
Copyright (C) 1996-1997 Id Software, Inc.
@ -48,14 +48,24 @@
#include <time.h>
#include <linux/cdrom.h>
#include "compat.h"
#include "QF/cdaudio.h"
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "compat.h"
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
//cd_data_t plugin_info_cd_data;
cd_funcs_t plugin_info_cd_funcs;
static qboolean cdValid = false;
static qboolean playing = false;
static qboolean wasPlaying = false;
@ -71,18 +81,7 @@ cvar_t *mus_cddevice;
static void
CDAudio_Eject (void)
{
if (cdfile == -1 || !mus_enabled)
return; // no cd init'd
if (ioctl (cdfile, CDROMEJECT) == -1)
Con_DPrintf ("CDAudio: ioctl cdromeject failed\n");
}
static void
CDAudio_CloseDoor (void)
I_CDAudio_CloseDoor (void)
{
if (cdfile == -1 || !mus_enabled)
return; // no cd init'd
@ -92,8 +91,19 @@ CDAudio_CloseDoor (void)
}
static void
I_CDAudio_Eject (void)
{
if (cdfile == -1 || !mus_enabled)
return; // no cd init'd
if (ioctl (cdfile, CDROMEJECT) == -1)
Con_DPrintf ("CDAudio: ioctl cdromeject failed\n");
}
static int
CDAudio_GetAudioDiskInfo (void)
I_CDAudio_GetAudioDiskInfo (void)
{
struct cdrom_tochdr tochdr;
@ -117,7 +127,41 @@ CDAudio_GetAudioDiskInfo (void)
void
CDAudio_Play (byte track, qboolean looping)
I_CDAudio_Pause (void)
{
if (cdfile == -1 || !mus_enabled)
return;
if (!playing)
return;
if (ioctl (cdfile, CDROMPAUSE) == -1)
Con_DPrintf ("CDAudio: ioctl cdrompause failed\n");
wasPlaying = playing;
playing = false;
}
void
I_CDAudio_Stop (void)
{
if (cdfile == -1 || !mus_enabled)
return;
if (!playing)
return;
if (ioctl (cdfile, CDROMSTOP) == -1)
Con_DPrintf ("CDAudio: ioctl cdromstop failed (%d)\n", errno);
wasPlaying = false;
playing = false;
}
void
I_CDAudio_Play (byte track, qboolean looping)
{
struct cdrom_tocentry entry0;
struct cdrom_tocentry entry1;
@ -127,7 +171,7 @@ CDAudio_Play (byte track, qboolean looping)
return;
if (!cdValid) {
CDAudio_GetAudioDiskInfo ();
I_CDAudio_GetAudioDiskInfo ();
if (!cdValid)
return;
}
@ -135,7 +179,7 @@ CDAudio_Play (byte track, qboolean looping)
track = remap[track];
if (track < 1 || track > maxTrack) {
CDAudio_Stop ();
I_CDAudio_Stop ();
return;
}
// don't try to play a non-audio track
@ -162,7 +206,7 @@ CDAudio_Play (byte track, qboolean looping)
if (playing) {
if (playTrack == track)
return;
CDAudio_Stop ();
I_CDAudio_Stop ();
}
msf.cdmsf_min0 = entry0.cdte_addr.msf.minute;
@ -197,41 +241,7 @@ CDAudio_Play (byte track, qboolean looping)
void
CDAudio_Stop (void)
{
if (cdfile == -1 || !mus_enabled)
return;
if (!playing)
return;
if (ioctl (cdfile, CDROMSTOP) == -1)
Con_DPrintf ("CDAudio: ioctl cdromstop failed (%d)\n", errno);
wasPlaying = false;
playing = false;
}
void
CDAudio_Pause (void)
{
if (cdfile == -1 || !mus_enabled)
return;
if (!playing)
return;
if (ioctl (cdfile, CDROMPAUSE) == -1)
Con_DPrintf ("CDAudio: ioctl cdrompause failed\n");
wasPlaying = playing;
playing = false;
}
void
CDAudio_Resume (void)
I_CDAudio_Resume (void)
{
if (cdfile == -1 || !mus_enabled)
return;
@ -248,8 +258,21 @@ CDAudio_Resume (void)
}
static void
CD_f (void)
void
I_CDAudio_Shutdown (void)
{
if (cdfile != -1)
{
I_CDAudio_Stop ();
close (cdfile);
cdfile = -1;
}
mus_enabled = false;
}
void // FIXME: was static
I_CD_f (void)
{
char *command;
int ret;
@ -267,7 +290,7 @@ CD_f (void)
if (strequal (command, "off")) {
if (playing)
CDAudio_Stop ();
I_CDAudio_Stop ();
mus_enabled = false;
return;
}
@ -275,10 +298,10 @@ CD_f (void)
if (strequal (command, "reset")) {
mus_enabled = true;
if (playing)
CDAudio_Stop ();
I_CDAudio_Stop ();
for (n = 0; n < 100; n++)
remap[n] = n;
CDAudio_GetAudioDiskInfo ();
I_CDAudio_GetAudioDiskInfo ();
return;
}
@ -296,12 +319,12 @@ CD_f (void)
}
if (strequal (command, "close")) {
CDAudio_CloseDoor ();
I_CDAudio_CloseDoor ();
return;
}
if (!cdValid) {
CDAudio_GetAudioDiskInfo ();
I_CDAudio_GetAudioDiskInfo ();
if (!cdValid) {
Con_Printf ("No CD in player.\n");
return;
@ -319,7 +342,7 @@ CD_f (void)
}
if (strequal (command, "stop")) {
CDAudio_Stop ();
I_CDAudio_Stop ();
return;
}
@ -335,8 +358,8 @@ CD_f (void)
if (strequal (command, "eject")) {
if (playing)
CDAudio_Stop ();
CDAudio_Eject ();
I_CDAudio_Stop ();
I_CDAudio_Eject ();
cdValid = false;
return;
}
@ -356,7 +379,7 @@ CD_f (void)
void
CDAudio_Update (void)
I_CDAudio_Update (void)
{
struct cdrom_subchnl subchnl;
static time_t lastchk;
@ -413,7 +436,7 @@ Mus_CDChange (cvar_t *mus_cdaudio)
return;
}
if (CDAudio_GetAudioDiskInfo ())
if (I_CDAudio_GetAudioDiskInfo ())
{
Con_Printf ("CDAudio_Init: No CD in player.\n");
cdValid = false;
@ -426,18 +449,13 @@ Mus_CDChange (cvar_t *mus_cdaudio)
}
int
CDAudio_Init (void)
void
I_CDAudio_Init (void)
{
#if 0
if (cls.state == ca_dedicated)
return -1;
#endif
mus_cddevice = Cvar_Get("mus_cddevice", "/dev/cdrom", CVAR_NONE,
Mus_CDChange, "device to use for CD music");
Cmd_AddCommand ("cd", CD_f, "Control the CD player.\n"
Cmd_AddCommand ("cd", I_CD_f, "Control the CD player.\n"
"Commands:\n"
"eject - Eject the CD.\n"
"info - Reports information on the CD.\n"
@ -452,19 +470,39 @@ CDAudio_Init (void)
"stop - Stops the currently playing track.");
Con_Printf ("CD Audio Initialized\n");
return 0;
}
void
CDAudio_Shutdown (void)
plugin_t *
PluginInfo (void)
{
if (cdfile != -1)
{
CDAudio_Stop ();
close (cdfile);
cdfile = -1;
}
mus_enabled = false;
plugin_info.type = qfp_cd;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "Linux CD Audio output"
"Copyright (C) 2001 contributors of the QuakeForge project\n"
"Please see the file \"AUTHORS\" for a list of contributors\n";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;
plugin_info_cd_funcs.pCDAudio_Pause = I_CDAudio_Pause;
plugin_info_cd_funcs.pCDAudio_Play = I_CDAudio_Play;
plugin_info_cd_funcs.pCDAudio_Resume = I_CDAudio_Resume;
plugin_info_cd_funcs.pCDAudio_Update = I_CDAudio_Update;
plugin_info_cd_funcs.pCD_f = I_CD_f;
return &plugin_info;
}

View file

@ -31,46 +31,89 @@
#endif
#include "QF/cdaudio.h"
#include "QF/plugin.h"
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
//cd_data_t plugin_info_cd_data;
cd_funcs_t plugin_info_cd_funcs;
void
CDAudio_Play (byte track, qboolean looping)
I_CDAudio_Pause (void)
{
}
void
CDAudio_Stop (void)
I_CDAudio_Play (byte track, qboolean looping)
{
}
void
CDAudio_Pause (void)
I_CDAudio_Resume (void)
{
}
void
CDAudio_Resume (void)
I_CDAudio_Shutdown (void)
{
}
void
CDAudio_Update (void)
I_CDAudio_Update (void)
{
}
int
CDAudio_Init (void)
{
return 0;
}
void
CDAudio_Shutdown (void)
I_CDAudio_Init (void)
{
}
void
I_CD_f (void)
{
}
plugin_t *
PluginInfo (void)
{
plugin_info.type = qfp_cd;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "Null CD Audio output"
"Copyright (C) 2001 contributors of the QuakeForge project\n"
"Please see the file \"AUTHORS\" for a list of contributors\n";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;
plugin_info_cd_funcs.pCDAudio_Pause = I_CDAudio_Pause;
plugin_info_cd_funcs.pCDAudio_Play = I_CDAudio_Play;
plugin_info_cd_funcs.pCDAudio_Resume = I_CDAudio_Resume;
plugin_info_cd_funcs.pCDAudio_Update = I_CDAudio_Update;
plugin_info_cd_funcs.pCD_f = I_CD_f;
return &plugin_info;
}

View file

@ -41,13 +41,24 @@
#include <SDL.h>
#include "compat.h"
#include "QF/cdaudio.h"
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "compat.h"
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
//cd_data_t plugin_info_cd_data;
cd_funcs_t plugin_info_cd_funcs;
static qboolean cdValid = false;
static qboolean initialized = false;
static qboolean enabled = true;
@ -56,11 +67,9 @@ static qboolean playLooping = false;
static SDL_CD *cd_id;
static float cdvolume = 1.0;
static void CD_f (void);
static void
CDAudio_Eject (void)
void
I_CDAudio_Eject (void)
{
if (!cd_id || !enabled)
return;
@ -69,45 +78,22 @@ CDAudio_Eject (void)
Con_DPrintf ("Unable to eject CD-ROM tray.\n");
}
void
CDAudio_Play (byte track, qboolean looping)
{
/* Initialize cd_stat to avoid warning */
/* XXX - Does this default value make sense? */
CDstatus cd_stat = CD_ERROR;
void
I_CDAudio_Pause (void)
{
if (!cd_id || !enabled)
return;
if (!cdValid) {
if (!CD_INDRIVE (cd_stat = SDL_CDStatus (cd_id)) || (!cd_id->numtracks))
return;
cdValid = true;
}
if ((track < 1) || (track >= cd_id->numtracks)) {
CDAudio_Stop ();
if (SDL_CDStatus (cd_id) != CD_PLAYING)
return;
}
track--; /* Convert track from person to SDL
value */
if (cd_stat == CD_PLAYING) {
if (cd_id->cur_track == track)
return;
CDAudio_Stop ();
}
if (SDL_CDPlay (cd_id, cd_id->track[track].offset,
cd_id->track[track].length)) {
Con_DPrintf ("CDAudio_Play: Unable to play track: %d\n", track + 1);
return;
}
playLooping = looping;
if (SDL_CDPause (cd_id))
Con_DPrintf ("CDAudio_Pause: Failed to pause track.\n");
}
void
CDAudio_Stop (void)
I_CDAudio_Stop (void)
{
int cdstate;
@ -123,20 +109,43 @@ CDAudio_Stop (void)
void
CDAudio_Pause (void)
I_CDAudio_Play (byte track, qboolean looping)
{
/* Initialize cd_stat to avoid warning */
/* XXX - Does this default value make sense? */
CDstatus cd_stat = CD_ERROR;
if (!cd_id || !enabled)
return;
if (SDL_CDStatus (cd_id) != CD_PLAYING)
return;
if (SDL_CDPause (cd_id))
Con_DPrintf ("CDAudio_Pause: Failed to pause track.\n");
if (!cdValid) {
if (!CD_INDRIVE (cd_stat = SDL_CDStatus (cd_id)) || (!cd_id->numtracks))
return;
cdValid = true;
}
if ((track < 1) || (track >= cd_id->numtracks)) {
I_CDAudio_Stop ();
return;
}
track--; // Convert track from person to SDL value
if (cd_stat == CD_PLAYING) {
if (cd_id->cur_track == track)
return;
I_CDAudio_Stop ();
}
if (SDL_CDPlay (cd_id, cd_id->track[track].offset,
cd_id->track[track].length)) {
Con_DPrintf ("CDAudio_Play: Unable to play track: %d\n", track + 1);
return;
}
playLooping = looping;
}
void
CDAudio_Resume (void)
I_CDAudio_Resume (void)
{
if (!cd_id || !enabled)
return;
@ -147,8 +156,20 @@ CDAudio_Resume (void)
Con_DPrintf ("CDAudio_Resume: Failed tp resume track.\n");
}
void
CDAudio_Update (void)
I_CDAudio_Shutdown (void)
{
if (!cd_id)
return;
I_CDAudio_Stop ();
SDL_CDClose (cd_id);
cd_id = NULL;
}
void
I_CDAudio_Update (void)
{
if (!cd_id || !enabled)
return;
@ -169,75 +190,10 @@ CDAudio_Update (void)
}
int
CDAudio_Init (void)
{
#ifdef UQUAKE
if (cls.state == ca_dedicated)
return -1;
#endif
if (COM_CheckParm ("-nocdaudio"))
return -1;
if (SDL_Init (SDL_INIT_CDROM) < 0) {
Con_Printf ("Couldn't initialize SDL CD-AUDIO: %s\n", SDL_GetError ());
return -1;
}
cd_id = SDL_CDOpen (0);
if (!cd_id) {
Con_Printf ("CDAudio_Init: Unable to open default CD-ROM drive: %s\n",
SDL_GetError ());
return -1;
}
initialized = true;
enabled = true;
cdValid = true;
if (!CD_INDRIVE (SDL_CDStatus (cd_id))) {
Con_Printf ("CDAudio_Init: No CD in drive.\n");
cdValid = false;
}
if (!cd_id->numtracks) {
Con_Printf ("CDAudio_Init: CD contains no audio tracks.\n");
cdValid = false;
}
Cmd_AddCommand ("cd", CD_f, "Control the CD player.\n"
"Commands:\n"
"eject - Eject the CD.\n"
"info - Reports information on the CD.\n"
"loop (track number) - Loops the specified track.\n"
"remap (track1) (track2) ... - Remap the current track order.\n"
"reset - Causes the CD audio to re-initialize.\n"
"resume - Will resume playback after pause.\n"
"off - Shuts down the CD audio system..\n"
"on - Re-enables the CD audio system after a cd off command.\n"
"pause - Pause the CD playback.\n"
"play (track number) - Plays the specified track one time.\n"
"stop - Stops the currently playing track.");
Con_Printf ("CD Audio Initialized.\n");
return 0;
}
void
CDAudio_Shutdown (void)
{
if (!cd_id)
return;
CDAudio_Stop ();
SDL_CDClose (cd_id);
cd_id = NULL;
}
#define CD_f_DEFINED
static void
CD_f (void)
void // FIXME: was static void
I_CD_f (void)
{
char *command;
int cdstate;
@ -254,32 +210,32 @@ CD_f (void)
return;
cdstate = SDL_CDStatus (cd_id);
if ((cdstate == CD_PLAYING) || (cdstate == CD_PAUSED))
CDAudio_Stop ();
I_CDAudio_Stop ();
enabled = false;
return;
}
if (strequal (command, "play")) {
CDAudio_Play (atoi (Cmd_Argv (2)), false);
I_CDAudio_Play (atoi (Cmd_Argv (2)), false);
return;
}
if (strequal (command, "loop")) {
CDAudio_Play (atoi (Cmd_Argv (2)), true);
I_CDAudio_Play (atoi (Cmd_Argv (2)), true);
return;
}
if (strequal (command, "stop")) {
CDAudio_Stop ();
I_CDAudio_Stop ();
return;
}
if (strequal (command, "pause")) {
CDAudio_Pause ();
I_CDAudio_Pause ();
return;
}
if (strequal (command, "resume")) {
CDAudio_Resume ();
I_CDAudio_Resume ();
return;
}
if (strequal (command, "eject")) {
CDAudio_Eject ();
I_CDAudio_Eject ();
return;
}
if (strequal (command, "info")) {
@ -298,3 +254,83 @@ CD_f (void)
return;
}
}
void
I_CDAudio_Init (void)
{
if (SDL_Init (SDL_INIT_CDROM) < 0) {
Con_Printf ("Couldn't initialize SDL CD-AUDIO: %s\n", SDL_GetError ());
return; // was -1
}
cd_id = SDL_CDOpen (0);
if (!cd_id) {
Con_Printf ("CDAudio_Init: Unable to open default CD-ROM drive: %s\n",
SDL_GetError ());
return; // was -1
}
initialized = true;
enabled = true;
cdValid = true;
if (!CD_INDRIVE (SDL_CDStatus (cd_id))) {
Con_Printf ("CDAudio_Init: No CD in drive.\n");
cdValid = false;
}
if (!cd_id->numtracks) {
Con_Printf ("CDAudio_Init: CD contains no audio tracks.\n");
cdValid = false;
}
Cmd_AddCommand ("cd", I_CD_f, "Control the CD player.\n"
"Commands:\n"
"eject - Eject the CD.\n"
"info - Reports information on the CD.\n"
"loop (track number) - Loops the specified track.\n"
"remap (track1) (track2) ... - Remap the current track order.\n"
"reset - Causes the CD audio to re-initialize.\n"
"resume - Will resume playback after pause.\n"
"off - Shuts down the CD audio system..\n"
"on - Re-enables the CD audio system after a cd off command.\n"
"pause - Pause the CD playback.\n"
"play (track number) - Plays the specified track one time.\n"
"stop - Stops the currently playing track.");
Con_Printf ("CD Audio Initialized.\n");
}
plugin_t *
PluginInfo (void)
{
plugin_info.type = qfp_cd;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "Linux CD Audio output"
"Copyright (C) 2001 contributors of the QuakeForge project\n"
"Please see the file \"AUTHORS\" for a list of contributors\n";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;
plugin_info_cd_funcs.pCDAudio_Pause = I_CDAudio_Pause;
plugin_info_cd_funcs.pCDAudio_Play = I_CDAudio_Play;
plugin_info_cd_funcs.pCDAudio_Resume = I_CDAudio_Resume;
plugin_info_cd_funcs.pCDAudio_Update = I_CDAudio_Update;
plugin_info_cd_funcs.pCD_f = I_CD_f;
return &plugin_info;
}

View file

@ -2,6 +2,7 @@
cd_sgi.c
audio cd playback support for sgi irix machines
FIXME: Update for plugin API
Copyright (C) 1996-1997 Id Software, Inc.
@ -53,7 +54,7 @@ static CDPLAYER *cdp = NULL;
static void
CDAudio_Eject (void)
pCDAudio_Eject (void)
{
if (cdp == NULL || !enabled)
return; // no cd init'd
@ -64,7 +65,7 @@ CDAudio_Eject (void)
static int
CDAudio_GetState (void)
pCDAudio_GetState (void)
{
CDSTATUS cds;
@ -81,7 +82,7 @@ CDAudio_GetState (void)
static int
CDAudio_MaxTrack (void)
pCDAudio_MaxTrack (void)
{
CDSTATUS cds;
@ -98,7 +99,18 @@ CDAudio_MaxTrack (void)
void
CDAudio_Play (byte track, qboolean looping)
pCDAudio_Pause (void)
{
if (cdp == NULL || !enabled || CDAudio_GetState () != CD_PLAYING)
return;
if (CDtogglepause (cdp) == 0)
Con_DPrintf ("CDAudio_PAUSE: CDtogglepause failed (%d)\n", errno);
}
void
pCDAudio_Play (byte track, qboolean looping)
{
int maxtrack = CDAudio_MaxTrack ();
@ -156,7 +168,31 @@ CDAudio_Play (byte track, qboolean looping)
void
CDAudio_Stop (void)
pCDAudio_Resume (void)
{
if (cdp == NULL || !enabled || CDAudio_GetState () != CD_PAUSED)
return;
if (CDtogglepause (cdp) == 0)
Con_DPrintf ("CDAudio_Resume: CDtogglepause failed (%d)\n", errno);
}
void
pCDAudio_Shutdown (void)
{
if (!initialized)
return;
CDAudio_Stop ();
CDclose (cdp);
cdp = NULL;
initialized = false;
}
void
pCDAudio_Stop (void)
{
if (cdp == NULL || !enabled || CDAudio_GetState () != CD_PLAYING)
return;
@ -167,29 +203,31 @@ CDAudio_Stop (void)
void
CDAudio_Pause (void)
pCDAudio_Update (void)
{
if (cdp == NULL || !enabled || CDAudio_GetState () != CD_PLAYING)
if (!initialized || !enabled)
return;
if (CDtogglepause (cdp) == 0)
Con_DPrintf ("CDAudio_PAUSE: CDtogglepause failed (%d)\n", errno);
}
if (bgmvolume->value != cdvolume) {
if (cdvolume) {
Cvar_SetValue (bgmvolume, 0.0);
cdvolume = bgmvolume->value;
CDAudio_Pause ();
} else {
Cvar_SetValue (bgmvolume, 1.0);
cdvolume = bgmvolume->value;
CDAudio_Resume ();
}
}
void
CDAudio_Resume (void)
{
if (cdp == NULL || !enabled || CDAudio_GetState () != CD_PAUSED)
return;
if (CDtogglepause (cdp) == 0)
Con_DPrintf ("CDAudio_Resume: CDtogglepause failed (%d)\n", errno);
if (CDAudio_GetState () != CD_PLAYING &&
CDAudio_GetState () != CD_PAUSED && playLooping)
CDAudio_Play (playTrack, true);
}
static void
CD_f (void)
pCD_f (void)
{
char *command;
int ret;
@ -283,32 +321,8 @@ CD_f (void)
}
void
CDAudio_Update (void)
{
if (!initialized || !enabled)
return;
if (bgmvolume->value != cdvolume) {
if (cdvolume) {
Cvar_SetValue (bgmvolume, 0.0);
cdvolume = bgmvolume->value;
CDAudio_Pause ();
} else {
Cvar_SetValue (bgmvolume, 1.0);
cdvolume = bgmvolume->value;
CDAudio_Resume ();
}
}
if (CDAudio_GetState () != CD_PLAYING &&
CDAudio_GetState () != CD_PAUSED && playLooping)
CDAudio_Play (playTrack, true);
}
int
CDAudio_Init (void)
pCDAudio_Init (void)
{
int i;
@ -352,16 +366,3 @@ CDAudio_Init (void)
return 0;
}
void
CDAudio_Shutdown (void)
{
if (!initialized)
return;
CDAudio_Stop ();
CDclose (cdp);
cdp = NULL;
initialized = false;
}

View file

@ -34,12 +34,22 @@
#include "QF/cdaudio.h"
#include "QF/cmd.h"
#include "compat.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "compat.h"
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
//cd_data_t plugin_info_cd_data;
cd_funcs_t plugin_info_cd_funcs;
extern HWND mainwindow;
static qboolean cdValid = false;
@ -57,20 +67,7 @@ UINT wDeviceID;
static void
CDAudio_Eject (void)
{
DWORD dwReturn;
dwReturn = mciSendCommand (wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN,
(DWORD) NULL);
if (dwReturn) {
Con_DPrintf ("MCI_SET_DOOR_OPEN failed (%li)\n", dwReturn);
}
}
static void
CDAudio_CloseDoor (void)
I_CDAudio_CloseDoor (void)
{
DWORD dwReturn;
@ -82,8 +79,21 @@ CDAudio_CloseDoor (void)
}
static void
I_CDAudio_Eject (void)
{
DWORD dwReturn;
dwReturn = mciSendCommand (wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN,
(DWORD) NULL);
if (dwReturn) {
Con_DPrintf ("MCI_SET_DOOR_OPEN failed (%li)\n", dwReturn);
}
}
static int
CDAudio_GetAudioDiskInfo (void)
I_CDAudio_GetAudioDiskInfo (void)
{
DWORD dwReturn;
MCI_STATUS_PARMS mciStatusParms;
@ -124,8 +134,67 @@ CDAudio_GetAudioDiskInfo (void)
}
LONG
I_CDAudio_MessageHandler (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (lParam != wDeviceID)
return 1;
switch (wParam) {
case MCI_NOTIFY_SUCCESSFUL:
if (playing) {
playing = false;
if (playLooping)
I_CDAudio_Play (playTrack, true);
}
break;
case MCI_NOTIFY_ABORTED:
case MCI_NOTIFY_SUPERSEDED:
break;
case MCI_NOTIFY_FAILURE:
Con_DPrintf ("MCI_NOTIFY_FAILURE\n");
I_CDAudio_Stop ();
cdValid = false;
break;
default:
Con_DPrintf ("Unexpected MM_MCINOTIFY type (%i)\n", wParam);
return 1;
}
return 0;
}
void
CDAudio_Play (byte track, qboolean looping)
I_CDAudio_Pause (void)
{
DWORD dwReturn;
MCI_GENERIC_PARMS mciGenericParms;
if (!enabled)
return;
if (!playing)
return;
mciGenericParms.dwCallback = (DWORD) mainwindow;
dwReturn =
mciSendCommand (wDeviceID, MCI_PAUSE, 0,
(DWORD) (LPVOID) & mciGenericParms);
if (dwReturn) {
Con_DPrintf ("MCI_PAUSE failed (%li)", dwReturn);
}
wasPlaying = playing;
playing = false;
}
void
I_CDAudio_Play (byte track, qboolean looping)
{
DWORD dwReturn;
MCI_PLAY_PARMS mciPlayParms;
@ -135,7 +204,7 @@ CDAudio_Play (byte track, qboolean looping)
return;
if (!cdValid) {
CDAudio_GetAudioDiskInfo ();
I_CDAudio_GetAudioDiskInfo ();
if (!cdValid)
return;
}
@ -143,7 +212,7 @@ CDAudio_Play (byte track, qboolean looping)
track = remap[track];
if (track < 1 || track > maxTrack) {
CDAudio_Stop ();
I_CDAudio_Stop ();
return;
}
// don't try to play a non-audio track
@ -176,7 +245,7 @@ CDAudio_Play (byte track, qboolean looping)
if (playing) {
if (playTrack == track)
return;
CDAudio_Stop ();
I_CDAudio_Stop ();
}
mciPlayParms.dwFrom = MCI_MAKE_TMSF (track, 0, 0, 0);
@ -195,58 +264,12 @@ CDAudio_Play (byte track, qboolean looping)
playing = true;
if (cdvolume == 0.0)
CDAudio_Pause ();
I_CDAudio_Pause ();
}
void
CDAudio_Stop (void)
{
DWORD dwReturn;
if (!enabled)
return;
if (!playing)
return;
dwReturn = mciSendCommand (wDeviceID, MCI_STOP, 0, (DWORD) NULL);
if (dwReturn) {
Con_DPrintf ("MCI_STOP failed (%li)", dwReturn);
}
wasPlaying = false;
playing = false;
}
void
CDAudio_Pause (void)
{
DWORD dwReturn;
MCI_GENERIC_PARMS mciGenericParms;
if (!enabled)
return;
if (!playing)
return;
mciGenericParms.dwCallback = (DWORD) mainwindow;
dwReturn =
mciSendCommand (wDeviceID, MCI_PAUSE, 0,
(DWORD) (LPVOID) & mciGenericParms);
if (dwReturn) {
Con_DPrintf ("MCI_PAUSE failed (%li)", dwReturn);
}
wasPlaying = playing;
playing = false;
}
void
CDAudio_Resume (void)
I_CDAudio_Resume (void)
{
DWORD dwReturn;
MCI_PLAY_PARMS mciPlayParms;
@ -274,8 +297,60 @@ CDAudio_Resume (void)
}
void
I_CDAudio_Shutdown (void)
{
if (!initialized)
return;
I_CDAudio_Stop ();
if (mciSendCommand (wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD) NULL))
Con_DPrintf ("CDAudio_Shutdown: MCI_CLOSE failed\n");
}
void
I_CDAudio_Stop (void)
{
DWORD dwReturn;
if (!enabled)
return;
if (!playing)
return;
dwReturn = mciSendCommand (wDeviceID, MCI_STOP, 0, (DWORD) NULL);
if (dwReturn) {
Con_DPrintf ("MCI_STOP failed (%li)", dwReturn);
}
wasPlaying = false;
playing = false;
}
void
I_CDAudio_Update (void)
{
if (!enabled)
return;
if (bgmvolume->value != cdvolume) {
if (cdvolume) {
Cvar_SetValue (bgmvolume, 0.0);
cdvolume = bgmvolume->value;
I_CDAudio_Pause ();
} else {
Cvar_SetValue (bgmvolume, 1.0);
cdvolume = bgmvolume->value;
I_CDAudio_Resume ();
}
}
}
static void
CD_f (void)
I_CD_f (void)
{
char *command;
int ret;
@ -295,7 +370,7 @@ CD_f (void)
if (strequal (command, "off")) {
if (playing)
CDAudio_Stop ();
I_CDAudio_Stop ();
enabled = false;
return;
}
@ -303,10 +378,10 @@ CD_f (void)
if (strequal (command, "reset")) {
enabled = true;
if (playing)
CDAudio_Stop ();
I_CDAudio_Stop ();
for (n = 0; n < 100; n++)
remap[n] = n;
CDAudio_GetAudioDiskInfo ();
I_CDAudio_GetAudioDiskInfo ();
return;
}
@ -324,12 +399,12 @@ CD_f (void)
}
if (strequal (command, "close")) {
CDAudio_CloseDoor ();
I_CDAudio_CloseDoor ();
return;
}
if (!cdValid) {
CDAudio_GetAudioDiskInfo ();
I_CDAudio_GetAudioDiskInfo ();
if (!cdValid) {
Con_Printf ("No CD in player.\n");
return;
@ -337,34 +412,34 @@ CD_f (void)
}
if (strequal (command, "play")) {
CDAudio_Play ((byte) atoi (Cmd_Argv (2)), false);
I_CDAudio_Play ((byte) atoi (Cmd_Argv (2)), false);
return;
}
if (strequal (command, "loop")) {
CDAudio_Play ((byte) atoi (Cmd_Argv (2)), true);
I_CDAudio_Play ((byte) atoi (Cmd_Argv (2)), true);
return;
}
if (strequal (command, "stop")) {
CDAudio_Stop ();
I_CDAudio_Stop ();
return;
}
if (strequal (command, "pause")) {
CDAudio_Pause ();
I_CDAudio_Pause ();
return;
}
if (strequal (command, "resume")) {
CDAudio_Resume ();
I_CDAudio_Resume ();
return;
}
if (strequal (command, "eject")) {
if (playing)
CDAudio_Stop ();
CDAudio_Eject ();
I_CDAudio_Stop ();
I_CDAudio_Eject ();
cdValid = false;
return;
}
@ -383,82 +458,21 @@ CD_f (void)
}
LONG
CDAudio_MessageHandler (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (lParam != wDeviceID)
return 1;
switch (wParam) {
case MCI_NOTIFY_SUCCESSFUL:
if (playing) {
playing = false;
if (playLooping)
CDAudio_Play (playTrack, true);
}
break;
case MCI_NOTIFY_ABORTED:
case MCI_NOTIFY_SUPERSEDED:
break;
case MCI_NOTIFY_FAILURE:
Con_DPrintf ("MCI_NOTIFY_FAILURE\n");
CDAudio_Stop ();
cdValid = false;
break;
default:
Con_DPrintf ("Unexpected MM_MCINOTIFY type (%i)\n", wParam);
return 1;
}
return 0;
}
void
CDAudio_Update (void)
{
if (!enabled)
return;
if (bgmvolume->value != cdvolume) {
if (cdvolume) {
Cvar_SetValue (bgmvolume, 0.0);
cdvolume = bgmvolume->value;
CDAudio_Pause ();
} else {
Cvar_SetValue (bgmvolume, 1.0);
cdvolume = bgmvolume->value;
CDAudio_Resume ();
}
}
}
int
CDAudio_Init (void)
I_CDAudio_Init (void)
{
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
MCI_SET_PARMS mciSetParms;
int n;
#if 0 // QW
if (cls.state == ca_dedicated)
return -1;
#endif
if (COM_CheckParm ("-nocdaudio"))
return -1;
mciOpenParms.lpstrDeviceType = "cdaudio";
dwReturn =
mciSendCommand (0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE,
(DWORD) (LPVOID) & mciOpenParms);
if (dwReturn) {
Con_Printf ("CDAudio_Init: MCI_OPEN failed (%li)\n", dwReturn);
return -1;
return; // was -1
}
wDeviceID = mciOpenParms.wDeviceID;
@ -470,7 +484,7 @@ CDAudio_Init (void)
if (dwReturn) {
Con_Printf ("MCI_SET_TIME_FORMAT failed (%li)\n", dwReturn);
mciSendCommand (wDeviceID, MCI_CLOSE, 0, (DWORD) NULL);
return -1;
return; // was -1
}
for (n = 0; n < 100; n++)
@ -478,13 +492,13 @@ CDAudio_Init (void)
initialized = true;
enabled = true;
if (CDAudio_GetAudioDiskInfo ()) {
if (I_CDAudio_GetAudioDiskInfo ()) {
Con_Printf ("CDAudio_Init: No CD in player.\n");
cdValid = false;
enabled = false;
}
Cmd_AddCommand ("cd", CD_f, "Control the CD player.\n"
Cmd_AddCommand ("cd", I_CD_f, "Control the CD player.\n"
"Commands:\n"
"eject - Eject the CD.\n"
"info - Reports information on the CD.\n"
@ -499,17 +513,40 @@ CDAudio_Init (void)
"stop - Stops the currently playing track.");
// Con_Printf("CD Audio Initialized\n");
return 0;
}
void
CDAudio_Shutdown (void)
plugin_t *
PluginInfo (void)
{
if (!initialized)
return;
CDAudio_Stop ();
if (mciSendCommand (wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD) NULL))
Con_DPrintf ("CDAudio_Shutdown: MCI_CLOSE failed\n");
plugin_info.type = qfp_cd;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "Linux CD Audio output"
"Copyright (C) 2001 contributors of the QuakeForge project\n"
"Please see the file \"AUTHORS\" for a list of contributors\n";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;
plugin_info_cd_funcs.pCDAudio_Pause = I_CDAudio_Pause;
plugin_info_cd_funcs.pCDAudio_Play = I_CDAudio_Play;
plugin_info_cd_funcs.pCDAudio_Resume = I_CDAudio_Resume;
plugin_info_cd_funcs.pCDAudio_Update = I_CDAudio_Update;
plugin_info_cd_funcs.pCD_f = I_CD_f;
return &plugin_info;
}

View file

@ -313,7 +313,8 @@ SNDDMA_Submit (void)
plugin_t *
PluginInfo (void) {
PluginInfo (void)
{
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";

View file

@ -63,7 +63,7 @@ EXTRA_libqfnet_a_SOURCES= net_dos.c net_bw.c net_ipx.c net_mp.c net_ser.c \
qf_client_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la \
$(top_builddir)/libs/gamecode/libQFgamecode.la \
$(top_builddir)/libs/gib/libQFgib.la \
$(top_builddir)/libs/audio/cd/libQFcd.la \
$(top_builddir)/libs/audio/libQFcd.la \
$(top_builddir)/libs/audio/libQFsound.la \
$(top_builddir)/libs/util/libQFutil.la

View file

@ -88,7 +88,7 @@ endif
qf_client_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la \
$(top_builddir)/libs/gamecode/libQFgamecode.la \
$(top_builddir)/libs/audio/cd/libQFcd.la \
$(top_builddir)/libs/audio/libQFcd.la \
$(top_builddir)/libs/audio/libQFsound.la \
$(top_builddir)/libs/util/libQFutil.la