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.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
#include "quakedef.h"
+// used by menu to ghost CD audio slider
+qboolean cdaudioinitialized = false;
static qboolean cdValid = false;
-static qboolean playing = false;
-static qboolean wasPlaying = false;
-static qboolean initialized = false;
-static qboolean enabled = true;
+static qboolean playing = false;
+static qboolean wasPlaying = false;
+static qboolean initialized = false;
+static qboolean enabled = true;
static qboolean playLooping = false;
-static float cdvolume;
-static byte remap[100];
-static byte playTrack;
-static byte maxTrack;
+static float cdvolume;
+static qbyte remap[100];
+static qbyte playTrack;
+static qbyte maxTrack;
static int cdfile = -1;
static char cd_dev[64] = "/dev/cdrom";
if (cdfile == -1 || !enabled)
return; // no cd init'd
- if ( ioctl(cdfile, CDROMEJECT) == -1 )
+ if ( ioctl(cdfile, CDROMEJECT) == -1 )
Con_DPrintf("ioctl cdromeject failed\n");
}
if (cdfile == -1 || !enabled)
return; // no cd init'd
- if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
+ if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
Con_DPrintf("ioctl cdromclosetray failed\n");
}
cdValid = false;
- if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
+ if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
{
Con_DPrintf("ioctl cdromreadtochdr failed\n");
return -1;
}
-void CDAudio_Play(byte track, qboolean looping)
+void CDAudio_Play(qbyte track, qboolean looping)
{
struct cdrom_tocentry entry;
struct cdrom_ti ti;
if (cdfile == -1 || !enabled)
return;
-
+
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
ti.cdti_ind0 = 1;
ti.cdti_ind1 = 99;
- if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
+ if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
{
Con_DPrintf("ioctl cdromplaytrkind failed\n");
return;
}
- if ( ioctl(cdfile, CDROMRESUME) == -1 )
+ if ( ioctl(cdfile, CDROMRESUME) == -1 )
Con_DPrintf("ioctl cdromresume failed\n");
playLooping = looping;
{
if (cdfile == -1 || !enabled)
return;
-
+
if (!playing)
return;
if (!playing)
return;
- if ( ioctl(cdfile, CDROMPAUSE) == -1 )
+ if ( ioctl(cdfile, CDROMPAUSE) == -1 )
Con_DPrintf("ioctl cdrompause failed\n");
wasPlaying = playing;
{
if (cdfile == -1 || !enabled)
return;
-
+
if (!cdValid)
return;
if (!wasPlaying)
return;
-
- if ( ioctl(cdfile, CDROMRESUME) == -1 )
+
+ if ( ioctl(cdfile, CDROMRESUME) == -1 )
Con_DPrintf("ioctl cdromresume failed\n");
playing = true;
}
static void CD_f (void)
{
- char *command;
- int ret;
- int n;
+ const char *command;
+ int ret;
+ int n;
if (Cmd_Argc() < 2)
return;
command = Cmd_Argv (1);
- if (Q_strcasecmp(command, "on") == 0)
+ if (strcasecmp(command, "on") == 0)
{
enabled = true;
return;
}
- if (Q_strcasecmp(command, "off") == 0)
+ if (strcasecmp(command, "off") == 0)
{
if (playing)
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "reset") == 0)
+ if (strcasecmp(command, "reset") == 0)
{
enabled = true;
if (playing)
return;
}
- if (Q_strcasecmp(command, "remap") == 0)
+ if (strcasecmp(command, "remap") == 0)
{
ret = Cmd_Argc() - 2;
if (ret <= 0)
return;
}
- if (Q_strcasecmp(command, "close") == 0)
+ if (strcasecmp(command, "close") == 0)
{
CDAudio_CloseDoor();
return;
}
}
- if (Q_strcasecmp(command, "play") == 0)
+ if (strcasecmp(command, "play") == 0)
{
- CDAudio_Play((byte)atoi(Cmd_Argv (2)), false);
+ CDAudio_Play((qbyte)atoi(Cmd_Argv (2)), false);
return;
}
- if (Q_strcasecmp(command, "loop") == 0)
+ if (strcasecmp(command, "loop") == 0)
{
- CDAudio_Play((byte)atoi(Cmd_Argv (2)), true);
+ CDAudio_Play((qbyte)atoi(Cmd_Argv (2)), true);
return;
}
- if (Q_strcasecmp(command, "stop") == 0)
+ if (strcasecmp(command, "stop") == 0)
{
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "pause") == 0)
+ if (strcasecmp(command, "pause") == 0)
{
CDAudio_Pause();
return;
}
- if (Q_strcasecmp(command, "resume") == 0)
+ if (strcasecmp(command, "resume") == 0)
{
CDAudio_Resume();
return;
}
- if (Q_strcasecmp(command, "eject") == 0)
+ if (strcasecmp(command, "eject") == 0)
{
if (playing)
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "info") == 0)
+ if (strcasecmp(command, "info") == 0)
{
Con_Printf("%u tracks\n", maxTrack);
if (playing)
{
if (cdvolume)
{
- Cvar_SetValue ("bgmvolume", 0.0);
+ Cvar_SetValueQuick (&bgmvolume, 0.0);
cdvolume = bgmvolume.value;
CDAudio_Pause ();
}
else
{
- Cvar_SetValue ("bgmvolume", 1.0);
+ Cvar_SetValueQuick (&bgmvolume, 1.0);
cdvolume = bgmvolume.value;
CDAudio_Resume ();
}
if (cls.state == ca_dedicated)
return -1;
- if (COM_CheckParm("-nocdaudio"))
+ if (COM_CheckParm("-nocdaudio") || COM_CheckParm("-safe"))
return -1;
if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1) {
- strncpy(cd_dev, com_argv[i + 1], sizeof(cd_dev));
+ strlcpy (cd_dev, com_argv[i + 1], sizeof (cd_dev));
cd_dev[sizeof(cd_dev) - 1] = 0;
}
if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
- Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
+ Con_DPrintf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
cdfile = -1;
return -1;
}
for (i = 0; i < 100; i++)
remap[i] = i;
+ cdaudioinitialized = true;
initialized = true;
enabled = true;
if (CDAudio_GetAudioDiskInfo())
{
- Con_Printf("CDAudio_Init: No CD in player.\n");
+ Con_DPrintf("CDAudio_Init: No CD in player.\n");
cdValid = false;
}
Cmd_AddCommand ("cd", CD_f);
- Con_Printf("CD Audio Initialized\n");
+ Con_DPrintf("CD Audio Initialized\n");
return 0;
}
close(cdfile);
cdfile = -1;
}
+
+void CDAudio_Open(void)
+{
+}
+
+void CDAudio_Close(void)
+{
+}