Hide music playback from CD behind CDA

This commit is contained in:
Yamagi Burmeister 2012-04-25 08:53:25 +00:00
parent 9d60a5de6a
commit 03015a686b
11 changed files with 58 additions and 4 deletions

View File

@ -59,7 +59,7 @@ CC := gcc
#
# -MMD to generate header dependencies.
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -MMD
-Wall -pipe -g -MMD -DCDA -DOGG
# ----------

View File

@ -451,8 +451,10 @@ SCR_PlayCinematic(char *arg) {
byte *palette;
char name[MAX_OSPATH], *dot;
/* make sure CD isn't playing music */
/* make sure background music is not playing */
#ifdef CDA
CDAudio_Stop();
#endif
#ifdef OGG
OGG_Stop();
#endif

View File

@ -738,7 +738,9 @@ void CL_Frame (int msec)
/* update audio */
S_Update (cl.refdef.vieworg, cl.v_forward, cl.v_right, cl.v_up);
#ifdef CDA
CDAudio_Update();
#endif
/* advance local effects for next frame */
CL_RunDLights ();
@ -800,7 +802,9 @@ void CL_Init (void)
cls.disable_screen = true; /* don't draw yet */
#ifdef CDA
CDAudio_Init ();
#endif
CL_InitLocal ();
@ -824,7 +828,9 @@ void CL_Shutdown(void)
CL_WriteConfiguration ();
#ifdef CDA
CDAudio_Shutdown ();
#endif
#ifdef OGG
OGG_Stop();
#endif

View File

@ -294,7 +294,9 @@ void CL_Disconnect (void)
#ifdef OGG
OGG_Stop();
#endif
#ifdef CDA
CDAudio_Stop();
#endif
if (cls.demorecording)
CL_Stop_f ();

View File

@ -837,7 +837,9 @@ void CL_ParseConfigString (void) {
else if (i == CS_CDTRACK) {
if (cl.refresh_prepped) {
#ifdef CDA
CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
#endif
#ifdef OGG
/* OGG/Vorbis */

View File

@ -443,7 +443,9 @@ void SCR_DrawConsole (void) {
void SCR_BeginLoadingPlaque (void) {
S_StopAllSounds ();
cl.sound_prepped = false; /* don't play ambients */
#ifdef CDA
CDAudio_Stop ();
#endif
#ifdef OGG
OGG_Stop();
#endif

View File

@ -302,12 +302,16 @@ void CL_PrepRefresh (void) {
cl.refresh_prepped = true;
cl.force_refdef = true; /* make sure we have a valid refdef */
#if defined(OGG) || defined(CDA)
/* start the cd track */
if (Cvar_VariableValue("cd_shuffle")) {
#ifdef CDA
CDAudio_RandomPlay();
#endif
} else {
#ifdef CDA
CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
#endif
#ifdef OGG
/* OGG/Vorbis */
@ -320,6 +324,7 @@ void CL_PrepRefresh (void) {
}
#endif
}
#endif
}
float CalcFov (float fov_x, float width, float height) {

View File

@ -998,8 +998,12 @@ static menulist_s s_options_lookspring_box;
static menulist_s s_options_lookstrafe_box;
static menulist_s s_options_crosshair_box;
static menuslider_s s_options_sfxvolume_slider;
#ifdef CDA
static menulist_s s_options_cdvolume_box;
#endif
#if defined(OGG) || defined(CDA)
static menulist_s s_options_cdshuffle_box;
#endif
#ifdef OGG
static menulist_s s_options_oggvolume_box;
#endif
@ -1036,7 +1040,9 @@ static float ClampCvar( float min, float max, float value ) {
static void ControlsSetMenuItemValues( void ) {
s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10;
#ifdef CDA
s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd");
#endif
#ifdef OGG
s_options_oggvolume_box.curvalue = Cvar_VariableValue("ogg_enable");
@ -1095,6 +1101,7 @@ static void UpdateVolumeFunc( void *unused ) {
Cvar_SetValue( "s_volume", s_options_sfxvolume_slider.curvalue / 10 );
}
#if defined(OGG) || defined(CDA)
static void CDShuffleFunc(void *unused) {
Cvar_SetValue("cd_shuffle", s_options_cdshuffle_box.curvalue);
@ -1125,7 +1132,9 @@ static void CDShuffleFunc(void *unused) {
}
#endif
}
#endif
#ifdef CDA
static void UpdateCDVolumeFunc( void *unused ) {
Cvar_SetValue( "cd_nocd", (float)!s_options_cdvolume_box.curvalue );
#ifdef OGG
@ -1149,14 +1158,19 @@ static void UpdateCDVolumeFunc( void *unused ) {
CDAudio_Stop();
}
}
#endif
#ifdef OGG
static void UpdateOGGVolumeFunc( void *unused ) {
Cvar_SetValue( "ogg_enable", (float)s_options_oggvolume_box.curvalue );
#ifdef CDA
Cvar_SetValue( "cd_nocd", 1 );
#endif
if (s_options_oggvolume_box.curvalue) {
#ifdef CDA
CDAudio_Stop();
#endif
OGG_Init();
OGG_Stop();
@ -1211,11 +1225,13 @@ static void UpdateSoundQualityFunc( void *unused ) {
}
static void Options_MenuInit( void ) {
#ifdef CDA
static const char *cd_music_items[] = {
"disabled",
"enabled",
0
};
#endif
#ifdef OGG
static const char *ogg_music_items[] = {
@ -1225,11 +1241,13 @@ static void Options_MenuInit( void ) {
};
#endif
#if defined(OGG) || defined(CDA)
static const char *cd_shuffle[] = {
"disabled",
"enabled",
0
};
#endif
static const char *quality_items[] = {
"normal", "high", 0
@ -1262,7 +1280,8 @@ static void Options_MenuInit( void ) {
s_options_sfxvolume_slider.minvalue = 0;
s_options_sfxvolume_slider.maxvalue = 10;
s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10.0f;
#ifdef CDA
s_options_cdvolume_box.generic.type = MTYPE_SPINCONTROL;
s_options_cdvolume_box.generic.x = 0;
s_options_cdvolume_box.generic.y = 10;
@ -1270,6 +1289,7 @@ static void Options_MenuInit( void ) {
s_options_cdvolume_box.generic.callback = UpdateCDVolumeFunc;
s_options_cdvolume_box.itemnames = cd_music_items;
s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd");
#endif
#ifdef OGG
s_options_oggvolume_box.generic.type = MTYPE_SPINCONTROL;
@ -1281,6 +1301,7 @@ static void Options_MenuInit( void ) {
s_options_oggvolume_box.curvalue = Cvar_VariableValue("ogg_enable");
#endif
#if defined(OGG) || defined(CDA)
s_options_cdshuffle_box.generic.type = MTYPE_SPINCONTROL;
s_options_cdshuffle_box.generic.x = 0;
s_options_cdshuffle_box.generic.y = 30;
@ -1288,6 +1309,7 @@ static void Options_MenuInit( void ) {
s_options_cdshuffle_box.generic.callback = CDShuffleFunc;
s_options_cdshuffle_box.itemnames = cd_shuffle;
s_options_cdshuffle_box.curvalue = Cvar_VariableValue("cd_shuffle");;
#endif
s_options_quality_list.generic.type = MTYPE_SPINCONTROL;
s_options_quality_list.generic.x = 0;
@ -1368,11 +1390,15 @@ static void Options_MenuInit( void ) {
ControlsSetMenuItemValues();
Menu_AddItem( &s_options_menu, ( void * ) &s_options_sfxvolume_slider );
#ifdef CDA
Menu_AddItem( &s_options_menu, ( void * ) &s_options_cdvolume_box );
#endif
#ifdef OGG
Menu_AddItem( &s_options_menu, ( void * ) &s_options_oggvolume_box );
#endif
#if defined(OGG) || defined(CDA)
Menu_AddItem( &s_options_menu, ( void * ) &s_options_cdshuffle_box );
#endif
Menu_AddItem( &s_options_menu, ( void * ) &s_options_quality_list );
Menu_AddItem( &s_options_menu, ( void * ) &s_options_sensitivity_slider );
Menu_AddItem( &s_options_menu, ( void * ) &s_options_alwaysrun_box );

View File

@ -24,6 +24,8 @@
* =======================================================================
*/
#ifdef CDA
#ifndef CL_SOUND_CDAUDIO_H
#define CL_SOUND_CDAUDIO_H
@ -36,4 +38,5 @@ void CDAudio_Activate (qboolean active);
void CDAudio_RandomPlay(void);
#endif
#endif

View File

@ -202,8 +202,10 @@ S_Shutdown ( void )
Cmd_RemoveCommand( "soundinfo" );
Cmd_RemoveCommand( "play" );
Cmd_RemoveCommand( "stopsound" );
#ifdef OGG
Cmd_RemoveCommand( "ogg_init" );
Cmd_RemoveCommand( "ogg_shutdown" );
#endif
}
/*

View File

@ -25,6 +25,8 @@
* =======================================================================
*/
#ifdef CDA
#include <stdio.h>
#include "SDL.h"
#include "../client/header/client.h"
@ -514,3 +516,5 @@ CDAudio_Activate ( qboolean active )
}
}
#endif /* CDA */