2004-12-09 23:34:59 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
|
2004-12-10 21:31:53 +00:00
|
|
|
#include <SDL.h>
|
2004-12-09 23:34:59 +00:00
|
|
|
|
2017-02-21 23:26:13 +00:00
|
|
|
#ifndef HAVE_CDPLAYER
|
|
|
|
//nothing
|
|
|
|
#elif SDL_MAJOR_VERSION >= 2
|
2014-02-07 08:38:40 +00:00
|
|
|
//sdl2 has no cd support. sod off.
|
|
|
|
#include "cd_null.c"
|
|
|
|
#else
|
|
|
|
|
2004-12-09 23:34:59 +00:00
|
|
|
extern cvar_t bgmvolume;
|
|
|
|
|
|
|
|
static qboolean initialized = false;
|
|
|
|
|
|
|
|
static SDL_CD *cddevice;
|
|
|
|
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
void CDAudio_Eject(void)
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
|
|
|
if (SDL_CDEject(cddevice))
|
|
|
|
Con_DPrintf("SDL_CDEject failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
void CDAudio_CloseDoor(void)
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
|
|
|
Con_Printf("SDL does not support this\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
int CDAudio_GetAudioDiskInfo(void)
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
|
|
|
switch (SDL_CDStatus(cddevice))
|
|
|
|
{
|
|
|
|
case CD_ERROR:
|
|
|
|
Con_Printf("SDL_CDStatus returned error\n");
|
2013-10-08 14:28:11 +00:00
|
|
|
return -1;
|
2004-12-09 23:34:59 +00:00
|
|
|
case CD_TRAYEMPTY:
|
2013-10-08 14:28:11 +00:00
|
|
|
return 0;
|
2004-12-09 23:34:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-10-08 14:28:11 +00:00
|
|
|
return cddevice->numtracks;
|
2004-12-09 23:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
void CDAudio_Play(int track)
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
2013-10-08 14:28:11 +00:00
|
|
|
if (SDL_CDPlayTracks(cddevice, track, 0, 1, 0))
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
|
|
|
Con_Printf("CDAudio: track %i is not audio\n", track);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-07 20:57:30 +00:00
|
|
|
if (!bgmvolume.value)
|
2004-12-09 23:34:59 +00:00
|
|
|
CDAudio_Pause ();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDAudio_Stop(void)
|
|
|
|
{
|
|
|
|
if (SDL_CDStop(cddevice))
|
|
|
|
Con_DPrintf("CDAudio: SDL_CDStop failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDAudio_Pause(void)
|
|
|
|
{
|
|
|
|
if (SDL_CDPause(cddevice))
|
|
|
|
Con_DPrintf("CDAudio: SDL_CDPause failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDAudio_Resume(void)
|
|
|
|
{
|
|
|
|
if (SDL_CDResume(cddevice))
|
|
|
|
{
|
|
|
|
Con_DPrintf("CDAudio: SDL_CDResume failed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
void CDAudio_Update(void)
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
|
|
|
}
|
2006-05-07 20:57:30 +00:00
|
|
|
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
void CDAudio_Init(void)
|
2006-05-07 20:57:30 +00:00
|
|
|
{
|
2004-12-09 23:34:59 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
qboolean CDAudio_Startup(void)
|
2004-12-09 23:34:59 +00:00
|
|
|
{
|
2013-10-08 14:28:11 +00:00
|
|
|
if (initialized)
|
|
|
|
return !!cddevice;
|
|
|
|
if (!bgmvolume.value)
|
|
|
|
return false;
|
|
|
|
initialized = true;
|
2004-12-09 23:34:59 +00:00
|
|
|
|
|
|
|
SDL_InitSubSystem(SDL_INIT_CDROM|SDL_INIT_NOPARACHUTE);
|
|
|
|
|
|
|
|
if(!SDL_CDNumDrives())
|
|
|
|
{
|
|
|
|
Con_DPrintf("CDAudio_Init: No CD drives\n");
|
2013-10-08 14:28:11 +00:00
|
|
|
return false;
|
2004-12-09 23:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cddevice = SDL_CDOpen(0);
|
|
|
|
if (!cddevice)
|
|
|
|
{
|
|
|
|
Con_Printf("CDAudio_Init: SDL_CDOpen failed\n");
|
2013-10-08 14:28:11 +00:00
|
|
|
return false;
|
2004-12-09 23:34:59 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 14:28:11 +00:00
|
|
|
return true;
|
2004-12-09 23:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDAudio_Shutdown(void)
|
|
|
|
{
|
|
|
|
if (!initialized)
|
|
|
|
return;
|
|
|
|
CDAudio_Stop();
|
|
|
|
|
|
|
|
SDL_CDClose(cddevice);
|
|
|
|
cddevice = NULL;
|
|
|
|
initialized = false;
|
|
|
|
}
|
2014-02-07 08:38:40 +00:00
|
|
|
#endif
|