2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cd_linux.c
|
|
|
|
|
2001-06-01 22:55:33 +00:00
|
|
|
Linux CD Audio support
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
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
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2005-08-04 15:27:09 +00:00
|
|
|
static __attribute__ ((used)) const char rcsid[] =
|
2003-01-15 15:31:36 +00:00
|
|
|
"$Id$";
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-08-27 01:00:03 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-09 21:15:09 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#include <time.h>
|
2001-04-09 21:15:09 +00:00
|
|
|
#include <linux/cdrom.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-04-09 21:15:09 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-06-02 04:36:42 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-06-01 22:55:33 +00:00
|
|
|
#include "QF/plugin.h"
|
2001-03-27 20:33:07 +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"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-01 22:55:33 +00:00
|
|
|
#include "compat.h"
|
|
|
|
|
2001-08-31 00:16:31 +00:00
|
|
|
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-06-01 22:55:33 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
static qboolean cdValid = false;
|
|
|
|
static qboolean playing = false;
|
|
|
|
static qboolean wasPlaying = false;
|
2001-04-10 05:41:21 +00:00
|
|
|
static qboolean mus_enabled = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
static qboolean playLooping = false;
|
|
|
|
static float cdvolume;
|
|
|
|
static byte remap[100];
|
|
|
|
static byte playTrack;
|
|
|
|
static byte maxTrack;
|
|
|
|
static int cdfile = -1;
|
2004-02-07 05:35:15 +00:00
|
|
|
|
2001-08-31 00:16:31 +00:00
|
|
|
static cvar_t *mus_cddevice;
|
2003-01-31 23:16:28 +00:00
|
|
|
static cvar_t *bgmvolume;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-20 20:52:27 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_CloseDoor (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-04-10 05:41:21 +00:00
|
|
|
if (cdfile == -1 || !mus_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return; // no cd init'd
|
|
|
|
|
2001-06-01 22:55:33 +00:00
|
|
|
if (ioctl (cdfile, CDROMCLOSETRAY) == -1)
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromclosetray failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Eject (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-04-10 05:41:21 +00:00
|
|
|
if (cdfile == -1 || !mus_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return; // no cd init'd
|
|
|
|
|
2001-06-01 22:55:33 +00:00
|
|
|
if (ioctl (cdfile, CDROMEJECT) == -1)
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromeject failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_GetAudioDiskInfo (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
struct cdrom_tochdr tochdr;
|
|
|
|
|
|
|
|
cdValid = false;
|
|
|
|
|
|
|
|
if (ioctl (cdfile, CDROMREADTOCHDR, &tochdr) == -1) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromreadtochdr failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tochdr.cdth_trk0 < 1) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: no music tracks\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cdValid = true;
|
|
|
|
maxTrack = tochdr.cdth_trk1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Pause (void)
|
|
|
|
{
|
|
|
|
if (cdfile == -1 || !mus_enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!playing)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ioctl (cdfile, CDROMPAUSE) == -1)
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdrompause failed\n");
|
2001-06-01 22:55:33 +00:00
|
|
|
|
|
|
|
wasPlaying = playing;
|
|
|
|
playing = false;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop (void)
|
|
|
|
{
|
|
|
|
if (cdfile == -1 || !mus_enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!playing)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ioctl (cdfile, CDROMSTOP) == -1)
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromstop failed (%d)\n",
|
2010-11-23 05:09:30 +00:00
|
|
|
errno);
|
2001-06-01 22:55:33 +00:00
|
|
|
|
|
|
|
wasPlaying = false;
|
|
|
|
playing = false;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-10-12 19:26:56 +00:00
|
|
|
I_CDAudio_Play (int track, qboolean looping)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
struct cdrom_tocentry entry0;
|
|
|
|
struct cdrom_tocentry entry1;
|
|
|
|
struct cdrom_msf msf;
|
|
|
|
|
2001-04-10 05:41:21 +00:00
|
|
|
if (cdfile == -1 || !mus_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!cdValid) {
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_GetAudioDiskInfo ();
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cdValid)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
if (track < 0 || track >= (int) sizeof (remap)) {
|
- 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
|
|
|
Sys_Printf ("CDAudio: invalid track number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
track = remap[track];
|
|
|
|
|
|
|
|
if (track < 1 || track > maxTrack) {
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// don't try to play a non-audio track
|
|
|
|
entry0.cdte_track = track;
|
|
|
|
entry0.cdte_format = CDROM_MSF;
|
|
|
|
if (ioctl (cdfile, CDROMREADTOCENTRY, &entry0) == -1) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromreadtocentry failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
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) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromreadtocentry failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (entry0.cdte_ctrl == CDROM_DATA_TRACK) {
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("track %i is not audio\n", track);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (playing) {
|
|
|
|
if (playTrack == track)
|
|
|
|
return;
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msf.cdmsf_min0 = entry0.cdte_addr.msf.minute;
|
|
|
|
msf.cdmsf_sec0 = entry0.cdte_addr.msf.second;
|
|
|
|
msf.cdmsf_frame0 = entry0.cdte_addr.msf.frame;
|
|
|
|
|
|
|
|
msf.cdmsf_min1 = entry1.cdte_addr.msf.minute;
|
|
|
|
msf.cdmsf_sec1 = entry1.cdte_addr.msf.second;
|
|
|
|
msf.cdmsf_frame1 = entry1.cdte_addr.msf.frame;
|
|
|
|
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "%2d:%02d:%02d %2d:%02d:%02d\n",
|
2010-11-23 05:09:30 +00:00
|
|
|
msf.cdmsf_min0,
|
|
|
|
msf.cdmsf_sec0,
|
|
|
|
msf.cdmsf_frame0,
|
|
|
|
msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (ioctl (cdfile, CDROMPLAYMSF, &msf) == -1) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND,
|
2010-11-23 05:09:30 +00:00
|
|
|
"CDAudio: ioctl cdromplaytrkind failed (%s)\n",
|
|
|
|
strerror (errno));
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
playLooping = looping;
|
|
|
|
playTrack = track;
|
|
|
|
playing = true;
|
|
|
|
|
|
|
|
if (cdvolume == 0.0)
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Pause ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Resume (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-04-10 05:41:21 +00:00
|
|
|
if (cdfile == -1 || !mus_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!cdValid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!wasPlaying)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ioctl (cdfile, CDROMRESUME) == -1)
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromresume failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
playing = true;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Shutdown (void)
|
|
|
|
{
|
2004-02-07 05:35:15 +00:00
|
|
|
if (cdfile != -1) {
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
|
|
|
close (cdfile);
|
|
|
|
cdfile = -1;
|
|
|
|
}
|
|
|
|
mus_enabled = false;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CD_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +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-04-10 05:41:21 +00:00
|
|
|
mus_enabled = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "off")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (playing)
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
2001-04-10 05:41:21 +00:00
|
|
|
mus_enabled = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "reset")) {
|
2001-04-10 05:41:21 +00:00
|
|
|
mus_enabled = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (playing)
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
for (n = 0; n < 100; n++)
|
|
|
|
remap[n] = n;
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_GetAudioDiskInfo ();
|
2001-02-19 21:15:25 +00:00
|
|
|
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, "close")) {
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_CloseDoor ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cdValid) {
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_GetAudioDiskInfo ();
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cdValid) {
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("No CD in player.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "play")) {
|
2007-05-31 06:06:52 +00:00
|
|
|
I_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")) {
|
2007-05-31 06:06:52 +00:00
|
|
|
I_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")) {
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "pause")) {
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Pause ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "resume")) {
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Resume ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "eject")) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (playing)
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Stop ();
|
|
|
|
I_CDAudio_Eject ();
|
2001-02-19 21:15:25 +00:00
|
|
|
cdValid = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:26:22 +00:00
|
|
|
if (strequal (command, "info")) {
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("%u tracks\n", maxTrack);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (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);
|
|
|
|
else if (wasPlaying)
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Update (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
struct cdrom_subchnl subchnl;
|
|
|
|
static time_t lastchk;
|
|
|
|
|
2001-04-10 05:41:21 +00:00
|
|
|
if (!mus_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (bgmvolume->value != cdvolume) {
|
|
|
|
if (cdvolume) {
|
|
|
|
Cvar_SetValue (bgmvolume, 0.0);
|
|
|
|
cdvolume = bgmvolume->value;
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Pause ();
|
2001-02-19 21:15:25 +00:00
|
|
|
} else {
|
|
|
|
Cvar_SetValue (bgmvolume, 1.0);
|
|
|
|
cdvolume = bgmvolume->value;
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Resume ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (playing && lastchk < time (NULL)) {
|
|
|
|
lastchk = time (NULL) + 2; // two seconds between chks
|
|
|
|
subchnl.cdsc_format = CDROM_MSF;
|
|
|
|
if (ioctl (cdfile, CDROMSUBCHNL, &subchnl) == -1) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND, "CDAudio: ioctl cdromsubchnl failed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
playing = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
|
|
|
|
subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
|
|
|
|
playing = false;
|
|
|
|
if (playLooping)
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Play (playTrack, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-04-10 05:41:21 +00:00
|
|
|
Mus_CDChange (cvar_t *mus_cdaudio)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-05-31 06:06:52 +00:00
|
|
|
I_CDAudio_Shutdown ();
|
2004-02-07 05:35:15 +00:00
|
|
|
if (strequal (mus_cdaudio->string, "none")) {
|
2001-04-10 05:41:21 +00:00
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-04-10 05:41:21 +00:00
|
|
|
cdfile = open (mus_cdaudio->string, O_RDONLY | O_NONBLOCK);
|
2004-02-07 05:35:15 +00:00
|
|
|
if (cdfile == -1) {
|
2011-08-11 08:20:33 +00:00
|
|
|
Sys_MaskPrintf (SYS_SND,
|
2010-11-23 05:09:30 +00:00
|
|
|
"Mus_CDInit: open device \"%s\" failed (error %i)\n",
|
|
|
|
mus_cdaudio->string, errno);
|
2001-04-10 05:41:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
if (I_CDAudio_GetAudioDiskInfo ()) {
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("CDAudio_Init: No CD in player.\n");
|
2001-04-10 05:41:21 +00:00
|
|
|
cdValid = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++)
|
|
|
|
remap[i] = i;
|
|
|
|
|
2001-04-10 05:41:21 +00:00
|
|
|
mus_enabled = true;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:05:58 +00:00
|
|
|
static void
|
2001-06-01 22:55:33 +00:00
|
|
|
I_CDAudio_Init (void)
|
2001-04-10 05:41:21 +00:00
|
|
|
{
|
2004-02-07 05:35:15 +00:00
|
|
|
mus_cddevice = Cvar_Get ("mus_cddevice", "/dev/cdrom", CVAR_NONE,
|
|
|
|
Mus_CDChange, "device to use for CD music");
|
2003-01-31 23:16:28 +00:00
|
|
|
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
|
|
|
|
"Volume of CD music");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2004-01-20 08:34:57 +00:00
|
|
|
static general_funcs_t plugin_info_general_funcs = {
|
|
|
|
I_CDAudio_Init,
|
|
|
|
I_CDAudio_Shutdown,
|
|
|
|
};
|
|
|
|
|
|
|
|
static cd_funcs_t plugin_info_cd_funcs = {
|
|
|
|
I_CD_f,
|
|
|
|
I_CDAudio_Pause,
|
|
|
|
I_CDAudio_Play,
|
|
|
|
I_CDAudio_Resume,
|
|
|
|
I_CDAudio_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",
|
|
|
|
"Linux 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, linux)
|
|
|
|
{
|
2001-06-01 22:55:33 +00:00
|
|
|
return &plugin_info;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|