DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
cdaudio.h File Reference
#include "qtypes.h"
#include "cvar.h"
+ Include dependency graph for cdaudio.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

float CDAudio_GetPosition (void)
 
int CDAudio_Init (void)
 
void CDAudio_Pause (void)
 
void CDAudio_Play (int track, qbool looping)
 
void CDAudio_Resume (void)
 
void CDAudio_Shutdown (void)
 
int CDAudio_Startup (void)
 
void CDAudio_Stop (void)
 
void CDAudio_Update (void)
 

Variables

cvar_t cdaudioinitialized
 

Function Documentation

◆ CDAudio_GetPosition()

float CDAudio_GetPosition ( void )

Definition at line 220 of file cd_shared.c.

221{
222 if(faketrack != -1)
224 return -1;
225}
static int faketrack
Definition cd_shared.c:96
float S_GetChannelPosition(unsigned int ch_ind)
Definition snd_main.c:1773

◆ CDAudio_Init()

int CDAudio_Init ( void )

Definition at line 544 of file cd_shared.c.

545{
546 int i;
547
548 if (cls.state == ca_dedicated)
549 return -1;
550
551// COMMANDLINEOPTION: Sound: -nocdaudio disables CD audio support
552 if (Sys_CheckParm("-nocdaudio"))
553 return -1;
554
555#ifdef MAXTRACKS
556 for (i = 0; i < MAXTRACKS; i++)
557 *remap[i] = 0;
558#endif
559
562 enabled = true;
563
565 for (i = 0;i < MAX_PLAYLISTS;i++)
566 {
571 }
572
573 Cmd_AddCommand(CF_CLIENT | CF_CLIENT_FROM_SERVER, "cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage");
574
575 return 0;
576}
static void CD_f(cmd_state_t *cmd)
Definition cd_shared.c:267
cvar_t music_playlist_random[MAX_PLAYLISTS]
Definition cd_shared.c:61
cvar_t music_playlist_index
Definition cd_shared.c:34
cvar_t music_playlist_sampleposition[MAX_PLAYLISTS]
Definition cd_shared.c:74
cvar_t music_playlist_list[MAX_PLAYLISTS]
Definition cd_shared.c:35
#define MAX_PLAYLISTS
Definition cd_shared.c:30
cvar_t cdaudioinitialized
Definition cd_shared.c:28
static qbool enabled
Definition cd_shared.c:90
static filename_t remap[MAXTRACKS]
Definition cd_shared.c:94
cvar_t music_playlist_current[MAX_PLAYLISTS]
Definition cd_shared.c:48
client_static_t cls
Definition cl_main.c:116
@ ca_dedicated
Definition client.h:530
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
#define CF_CLIENT_FROM_SERVER
command that the server is allowed to execute on the client
Definition cmd.h:50
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
int i
#define MAXTRACKS
max CD track index
Definition qdefs.h:142
cactive_t state
Definition client.h:568
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327

References ca_dedicated, CD_f(), cdaudioinitialized, CF_CLIENT, CF_CLIENT_FROM_SERVER, cls, Cmd_AddCommand(), Cvar_RegisterVariable(), Cvar_SetValueQuick(), enabled, i, MAX_PLAYLISTS, MAXTRACKS, music_playlist_current, music_playlist_index, music_playlist_list, music_playlist_random, music_playlist_sampleposition, remap, client_static_t::state, and Sys_CheckParm().

Referenced by S_Init().

◆ CDAudio_Pause()

void CDAudio_Pause ( void )

Definition at line 247 of file cd_shared.c.

248{
249 if (!enabled || !cdPlaying || faketrack == -1)
250 return;
251
254 cdPlaying = false;
255}
static qbool cdPlaying
Definition cd_shared.c:98
static qbool wasPlaying
Definition cd_shared.c:88
qbool S_SetChannelFlag(unsigned int ch_ind, unsigned int flag, qbool value)
Definition snd_main.c:1679
#define CHANNELFLAG_PAUSED
Definition sound.h:41

References cdPlaying, CHANNELFLAG_PAUSED, enabled, faketrack, S_SetChannelFlag(), and wasPlaying.

Referenced by CD_f(), CDAudio_Play_byName(), CDAudio_SetVolume(), and CL_ParseServerMessage().

◆ CDAudio_Play()

void CDAudio_Play ( int track,
qbool looping )

Definition at line 211 of file cd_shared.c.

212{
213 char buf[20];
215 return;
216 dpsnprintf(buf, sizeof(buf), "%d", (int) track);
217 CDAudio_Play_byName(buf, looping, true, 0);
218}
static void CDAudio_Play_byName(const char *trackname, qbool looping, qbool tryreal, float startposition)
Definition cd_shared.c:119
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657
int integer
Definition cvar.h:73

References buf, CDAudio_Play_byName(), dpsnprintf(), cvar_t::integer, and music_playlist_index.

Referenced by CL_ParseServerMessage().

◆ CDAudio_Resume()

void CDAudio_Resume ( void )

Definition at line 258 of file cd_shared.c.

259{
260 if (!enabled || cdPlaying || !wasPlaying || faketrack == -1)
261 return;
262
264 cdPlaying = true;
265}

References cdPlaying, CHANNELFLAG_PAUSED, enabled, faketrack, S_SetChannelFlag(), and wasPlaying.

Referenced by CD_f(), CDAudio_SetVolume(), and CL_ParseServerMessage().

◆ CDAudio_Shutdown()

void CDAudio_Shutdown ( void )

Definition at line 590 of file cd_shared.c.

591{
592 if (!initialized)
593 return;
594
595 CDAudio_Stop();
596 initialized = false;
597}
void CDAudio_Stop(void)
Definition cd_shared.c:229
static qbool initialized
Definition cd_shared.c:89

References CDAudio_Stop(), and initialized.

Referenced by CD_f(), and S_Shutdown().

◆ CDAudio_Startup()

int CDAudio_Startup ( void )

Definition at line 578 of file cd_shared.c.

579{
580 if (Sys_CheckParm("-nocdaudio"))
581 return -1;
582
583 initialized = true;
584
585 Con_Print("CD Audio Initialized\n");
586
587 return 0;
588}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504

References Con_Print(), initialized, and Sys_CheckParm().

Referenced by CD_f(), and S_Startup().

◆ CDAudio_Stop()

void CDAudio_Stop ( void )

Definition at line 229 of file cd_shared.c.

230{
231 if (!enabled)
232 return;
233
234 // save the playlist position
236
237 if (faketrack != -1)
238 {
239 S_StopChannel (faketrack, true, true);
240 faketrack = -1;
241 }
242
243 wasPlaying = false;
244 cdPlaying = false;
245}
static void CDAudio_StopPlaylistTrack(void)
Definition cd_shared.c:435
void S_StopChannel(unsigned int channel_ind, qbool lockmutex, qbool freesfx)
Definition snd_main.c:1648

References CDAudio_StopPlaylistTrack(), cdPlaying, enabled, faketrack, S_StopChannel(), and wasPlaying.

Referenced by CD_f(), CDAudio_Play_byName(), CDAudio_Shutdown(), CDAudio_StartPlaylist(), and S_StopAllSounds().

◆ CDAudio_Update()

void CDAudio_Update ( void )

Definition at line 522 of file cd_shared.c.

523{
524 static int lastplaylist = -1;
525 if (!enabled)
526 return;
527
530 {
531 // this track ended, start a new track from the beginning
533 lastplaylist = music_playlist_index.integer;
534 }
535 else if (lastplaylist != music_playlist_index.integer
537 {
538 // active playlist changed, save position and switch track
540 lastplaylist = music_playlist_index.integer;
541 }
542}
static void CDAudio_StartPlaylist(qbool resume)
Definition cd_shared.c:447
static void CDAudio_SetVolume(float newvol)
Definition cd_shared.c:413
int music_playlist_playing
Definition cd_shared.c:32
float CDAudio_GetPosition(void)
Definition cd_shared.c:220
cvar_t bgmvolume
Definition snd_main.c:165
float value
Definition cvar.h:74

References bgmvolume, CDAudio_GetPosition(), CDAudio_SetVolume(), CDAudio_StartPlaylist(), enabled, cvar_t::integer, music_playlist_index, music_playlist_playing, and cvar_t::value.

Referenced by CL_Frame().

Variable Documentation

◆ cdaudioinitialized

cvar_t cdaudioinitialized
extern

Definition at line 28 of file cd_shared.c.

28{CF_CLIENT | CF_READONLY,"cdaudioinitialized","0","indicates if CD Audio system is active"};
#define CF_READONLY
cvar cannot be changed from the console or the command buffer, and is considered CF_PERSISTENT
Definition cmd.h:54

Referenced by CDAudio_Init(), and M_Options_Draw().