2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cd_sgi.c
|
|
|
|
|
|
|
|
audio cd playback support for sgi irix machines
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <errno.h>
|
2001-08-27 01:00:03 +00:00
|
|
|
#include <sys/types.h>
|
2002-03-03 06:03:51 +00:00
|
|
|
#include <dmedia/cdaudio.h>
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-04-09 21:15:09 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-03-27 23:36:02 +00:00
|
|
|
#include "QF/cmd.h"
|
2004-02-07 05:35:15 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-03-27 23:36:02 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-04-09 21:15:09 +00:00
|
|
|
#include "QF/sound.h"
|
2001-09-21 04:22:46 +00:00
|
|
|
#include "QF/sys.h"
|
2012-02-13 12:58:34 +00:00
|
|
|
|
|
|
|
#include "QF/plugin/general.h"
|
|
|
|
#include "QF/plugin/cd.h"
|
2004-02-07 05:35:15 +00:00
|
|
|
|
2002-03-03 06:03:51 +00:00
|
|
|
#include "compat.h"
|
|
|
|
|
|
|
|
static plugin_t plugin_info;
|
|
|
|
static plugin_data_t plugin_info_data;
|
|
|
|
static plugin_funcs_t plugin_info_funcs;
|
|
|
|
static general_data_t plugin_info_general_data;
|
|
|
|
static general_funcs_t plugin_info_general_funcs;
|
|
|
|
|
|
|
|
static cd_funcs_t plugin_info_cd_funcs;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool initialized = false;
|
|
|
|
static bool enabled = true;
|
|
|
|
static bool playLooping = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
static float cdvolume;
|
|
|
|
static byte remap[100];
|
|
|
|
static byte playTrack;
|
|
|
|
|
2003-05-08 23:24:02 +00:00
|
|
|
static char cd_dev[] = "/dev/cdrom";
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
static CDPLAYER *cdp = NULL;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
static float bgmvolume;
|
|
|
|
static cvar_t bgmvolume_cvar = {
|
|
|
|
.name = "bgmvolume",
|
|
|
|
.description =
|
|
|
|
"Volume of CD music",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &bgmvolume },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
static void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Eject (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (cdp == NULL || !enabled)
|
|
|
|
return; // no cd init'd
|
|
|
|
|
|
|
|
if (CDeject (cdp) == 0)
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "I_SGI_Eject: CDeject failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_GetState (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-20 20:52:27 +00:00
|
|
|
CDSTATUS cds;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cdp == NULL || !enabled)
|
|
|
|
return -1; // no cd init'd
|
|
|
|
|
|
|
|
if (CDgetstatus (cdp, &cds) == 0) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "CDAudio_GetStatus: CDgetstatus failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cds.state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_MaxTrack (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-20 20:52:27 +00:00
|
|
|
CDSTATUS cds;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cdp == NULL || !enabled)
|
|
|
|
return -1; // no cd init'd
|
|
|
|
|
|
|
|
if (CDgetstatus (cdp, &cds) == 0) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "I_SGI_MaxTrack: CDgetstatus failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cds.last;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Pause (void)
|
2001-06-01 22:55:33 +00:00
|
|
|
{
|
2002-03-03 06:03:51 +00:00
|
|
|
if (cdp == NULL || !enabled || I_SGI_GetState () != CD_PLAYING)
|
2001-06-01 22:55:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (CDtogglepause (cdp) == 0)
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "CDAudio_PAUSE: CDtogglepause failed (%d)\n", errno);
|
2001-06-01 22:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-06-13 09:06:11 +00:00
|
|
|
I_SGI_Play (int track, bool looping)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-03-03 06:03:51 +00:00
|
|
|
int maxtrack = I_SGI_MaxTrack ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!initialized || !enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* cd == audio cd? */
|
2002-03-03 06:03:51 +00:00
|
|
|
if (I_SGI_GetState () != CD_READY) {
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("CDAudio_Play: CD in player not an audio CD.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxtrack < 0) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd,
|
2010-11-23 05:09:30 +00:00
|
|
|
"CDAudio_Play: Error getting maximum track number\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
- add some missing boundschecking to CDAudio_Play's track remap (in
specific plugins only)
- convert updateping, updatepl, updateentertime, updatestat,
updatestatlong, cdtrack intermission, finale, muzzleflashchokecount,
maxspeed, entgravity, and setpause on the client. Can you say all
that in one breath? :)
2001-11-05 16:17:45 +00:00
|
|
|
if (track < 0 || track >= sizeof (remap)) {
|
|
|
|
Sys_Printf ("CDAudio: invalid track number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
track = remap[track];
|
|
|
|
|
|
|
|
if (track < 1 || track > maxtrack) {
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// don't try to play a non-audio track
|
2001-05-20 20:52:27 +00:00
|
|
|
/* mw: how to do this on irix? entry0.cdte_track = track;
|
2001-02-19 21:15:25 +00:00
|
|
|
entry0.cdte_format = CDROM_MSF; if ( ioctl(cdfile, CDROMREADTOCENTRY,
|
2001-09-21 04:22:46 +00:00
|
|
|
&entry0) == -1 ) { Sys_DPrintf("CDAudio: ioctl cdromreadtocentry
|
2001-02-19 21:15:25 +00:00
|
|
|
failed\n"); return; }
|
|
|
|
|
|
|
|
entry1.cdte_track = track + 1; entry1.cdte_format = CDROM_MSF; if
|
|
|
|
(entry1.cdte_track > maxTrack) { entry1.cdte_track = CDROM_LEADOUT; }
|
|
|
|
|
|
|
|
if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry1) == -1 ) {
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_DPrintf("CDAudio: ioctl cdromreadtocentry failed\n"); return; }
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-21 04:22:46 +00:00
|
|
|
if (entry0.cdte_ctrl == CDROM_DATA_TRACK) { Sys_Printf("track %i is
|
2001-05-20 20:52:27 +00:00
|
|
|
not audio\n", track); return; }
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-03-03 06:03:51 +00:00
|
|
|
if (I_SGI_GetState () == CD_PLAYING) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (playTrack == track)
|
|
|
|
return;
|
|
|
|
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (CDplaytrack (cdp, track, cdvolume == 0.0 ? 0 : 1) == 0) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "CDAudio_Play: CDplay failed (%d)\n", errno);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
playLooping = looping;
|
|
|
|
playTrack = track;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Resume (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-03-03 06:03:51 +00:00
|
|
|
if (cdp == NULL || !enabled || I_SGI_GetState () != CD_PAUSED)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2001-06-01 22:55:33 +00:00
|
|
|
if (CDtogglepause (cdp) == 0)
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "CDAudio_Resume: CDtogglepause failed (%d)\n",
|
2010-11-23 05:09:30 +00:00
|
|
|
errno);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Shutdown (void)
|
2001-06-01 22:55:33 +00:00
|
|
|
{
|
|
|
|
if (!initialized)
|
|
|
|
return;
|
|
|
|
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
2001-06-01 22:55:33 +00:00
|
|
|
CDclose (cdp);
|
|
|
|
cdp = NULL;
|
|
|
|
initialized = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-03-03 06:03:51 +00:00
|
|
|
if (cdp == NULL || !enabled || I_SGI_GetState () != CD_PLAYING)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2001-06-01 22:55:33 +00:00
|
|
|
if (CDstop (cdp) == 0)
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "I_SGI_Stop: CDStop failed (%d)\n", errno);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Update (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-06-01 22:55:33 +00:00
|
|
|
if (!initialized || !enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (bgmvolume != cdvolume) {
|
2001-06-01 22:55:33 +00:00
|
|
|
if (cdvolume) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
bgmvolume = 0.0;
|
|
|
|
cdvolume = bgmvolume;
|
2001-06-01 22:55:33 +00:00
|
|
|
CDAudio_Pause ();
|
|
|
|
} else {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
bgmvolume = 1.0;
|
|
|
|
cdvolume = bgmvolume;
|
2001-06-01 22:55:33 +00:00
|
|
|
CDAudio_Resume ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
if (I_SGI_GetState () != CD_PLAYING
|
|
|
|
&& I_SGI_GetState () != CD_PAUSED && playLooping)
|
|
|
|
CDAudio_Play (playTrack, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-03-03 06:03:51 +00:00
|
|
|
const char *command;
|
2004-02-07 05:35:15 +00:00
|
|
|
int ret, n;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
command = Cmd_Argv (1);
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "on")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
enabled = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "off")) {
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
enabled = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "reset")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
enabled = true;
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
for (n = 0; n < 100; n++)
|
|
|
|
remap[n] = n;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "remap")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
ret = Cmd_Argc () - 2;
|
|
|
|
|
|
|
|
if (ret <= 0) {
|
|
|
|
for (n = 1; n < 100; n++)
|
|
|
|
if (remap[n] != n)
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf (" %u -> %u\n", n, remap[n]);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 1; n <= ret; n++)
|
|
|
|
remap[n] = atoi (Cmd_Argv (n + 1));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "play")) {
|
2001-10-12 23:14:59 +00:00
|
|
|
CDAudio_Play (atoi (Cmd_Argv (2)), false);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "loop")) {
|
2001-10-12 23:14:59 +00:00
|
|
|
CDAudio_Play (atoi (Cmd_Argv (2)), true);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "stop")) {
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "pause")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
CDAudio_Pause ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "resume")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
CDAudio_Resume ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "eject")) {
|
2002-03-03 06:03:51 +00:00
|
|
|
I_SGI_Stop ();
|
|
|
|
I_SGI_Eject ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "info")) {
|
2002-03-03 06:03:51 +00:00
|
|
|
Sys_Printf ("%u tracks\n", I_SGI_MaxTrack ());
|
|
|
|
if (I_SGI_GetState () == CD_PLAYING)
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("Currently %s track %u\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
playLooping ? "looping" : "playing", playTrack);
|
2002-03-03 06:03:51 +00:00
|
|
|
else if (I_SGI_GetState () == CD_PAUSED)
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("Paused %s track %u\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
playLooping ? "looping" : "playing", playTrack);
|
|
|
|
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("Volume is %g\n", cdvolume);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-03 06:03:51 +00:00
|
|
|
static void
|
|
|
|
I_SGI_Init (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&bgmvolume_cvar, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
if ((i = COM_CheckParm ("-cddev")) != 0 && i < com_argc - 1) {
|
|
|
|
strncpy (cd_dev, com_argv[i + 1], sizeof (cd_dev));
|
|
|
|
cd_dev[sizeof (cd_dev) - 1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cdp = CDopen (cd_dev, "r");
|
|
|
|
|
|
|
|
if (cdp == NULL) {
|
2004-02-07 05:35:15 +00:00
|
|
|
Sys_Printf ("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev,
|
|
|
|
errno);
|
2002-03-03 06:03:51 +00:00
|
|
|
return ;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++)
|
|
|
|
remap[i] = i;
|
|
|
|
|
|
|
|
initialized = true;
|
|
|
|
enabled = true;
|
|
|
|
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("CD Audio Initialized\n");
|
2002-03-03 06:03:51 +00:00
|
|
|
}
|
|
|
|
|
2004-01-20 08:34:57 +00:00
|
|
|
static general_funcs_t plugin_info_general_funcs = {
|
|
|
|
I_SGI_Init,
|
|
|
|
I_SGI_Shutdown,
|
|
|
|
};
|
|
|
|
|
|
|
|
static cd_funcs_t plugin_info_cd_funcs = {
|
2021-06-26 06:43:17 +00:00
|
|
|
0,
|
2004-01-20 08:34:57 +00:00
|
|
|
I_SGI_f,
|
|
|
|
I_SGI_Pause,
|
|
|
|
I_SGI_Play,
|
|
|
|
I_SGI_Resume,
|
|
|
|
I_SGI_Update,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_funcs_t plugin_info_funcs = {
|
|
|
|
&plugin_info_general_funcs,
|
|
|
|
0,
|
|
|
|
&plugin_info_cd_funcs,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_data_t plugin_info_data = {
|
|
|
|
&plugin_info_general_data,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_t plugin_info = {
|
|
|
|
qfp_cd,
|
|
|
|
0,
|
|
|
|
QFPLUGIN_VERSION,
|
|
|
|
"0.1",
|
|
|
|
"SGI CD Audio output\n",
|
2004-02-07 05:35:15 +00:00
|
|
|
"Copyright (C) 2001 contributors of the QuakeForge project\n"
|
|
|
|
"Please see the file \"AUTHORS\" for a list of contributors\n",
|
2004-01-20 08:34:57 +00:00
|
|
|
&plugin_info_funcs,
|
|
|
|
&plugin_info_data,
|
|
|
|
};
|
|
|
|
|
|
|
|
PLUGIN_INFO (cd, sgi)
|
2002-03-03 06:03:51 +00:00
|
|
|
{
|
2004-01-20 08:34:57 +00:00
|
|
|
return &plugin_info;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|