void S_ClearBuffer (void) { int clear; #ifdef _WIN32 if (!sound_started || !shm || (!shm->buffer && !pDSBuf)) #else if (!sound_started || !shm || !shm->buffer) #endif return; if (shm->samplebits == 8) clear = 0x80; else clear = 0; #ifdef _WIN32 if (pDSBuf) { DWORD dwSize; DWORD *pData; int reps; HRESULT hresult; reps = 0; while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, (void**)&pData, &dwSize, NULL, NULL, 0)) != DS_OK) { if (hresult != DSERR_BUFFERLOST) { Con_Printf ("S_ClearBuffer: DS::Lock Sound Buffer Failed\n"); S_Shutdown (); return; } if (++reps > 10000) { Con_Printf ("S_ClearBuffer: DS: couldn't restore buffer\n"); S_Shutdown (); return; } } memset(pData, clear, shm->samples * shm->samplebits/8); pDSBuf->lpVtbl->Unlock(pDSBuf, pData, dwSize, NULL, 0); } else #endif { memset(shm->buffer, clear, shm->samples * shm->samplebits/8); } }
/* ==================== SndSys_LockRenderBuffer Get the exclusive lock on "snd_renderbuffer" ==================== */ qboolean SndSys_LockRenderBuffer (void) { #ifdef SUPPORTDIRECTX int reps; HRESULT hresult; DWORD dwStatus; if (pDSBuf) { // if the buffer was lost or stopped, restore it and/or restart it if (IDirectSoundBuffer_GetStatus (pDSBuf, &dwStatus) != DS_OK) Con_Print("Couldn't get sound buffer status\n"); if (dwStatus & DSBSTATUS_BUFFERLOST) { Con_Print("DSound buffer is lost!!\n"); IDirectSoundBuffer_Restore (pDSBuf); } if (!(dwStatus & DSBSTATUS_PLAYING)) IDirectSoundBuffer_Play(pDSBuf, 0, 0, DSBPLAY_LOOPING); reps = 0; while ((hresult = IDirectSoundBuffer_Lock(pDSBuf, 0, gSndBufSize, (LPVOID*)&dsound_pbuf, &dsound_dwSize, (LPVOID*)&dsound_pbuf2, &dsound_dwSize2, 0)) != DS_OK) { if (hresult != DSERR_BUFFERLOST) { Con_Print("S_LockBuffer: DS: Lock Sound Buffer Failed\n"); S_Shutdown (); S_Startup (); return false; } if (++reps > 10000) { Con_Print("S_LockBuffer: DS: couldn't restore buffer\n"); S_Shutdown (); S_Startup (); return false; } } if ((void*)dsound_pbuf != snd_renderbuffer->ring) Sys_Error("SndSys_LockRenderBuffer: the ring address has changed!!!\n"); return true; } #endif return wav_init; }
/** * @brief Restart the sound subsystem so it can pick up new parameters and flush all sounds * @sa S_Shutdown * @sa S_Init */ static void S_Restart_f (void) { Com_Printf("Restarting sound\n"); S_Shutdown(); S_Init(); S_LoadSamples(); }
/* * Restart the sound subsystem so it can pick up * new parameters and flush all sounds */ void CL_Snd_Restart_f(void) { S_Shutdown(); S_Init(); CL_RegisterSounds(); }
void CL_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; CL_WriteConfiguration(); Key_WriteConsoleHistory(); #ifdef CDA CDAudio_Shutdown(); #endif #ifdef OGG OGG_Stop(); #endif S_Shutdown(); IN_Shutdown(); VID_Shutdown(); }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { MsgDev( D_INFO, "CL_Shutdown()\n" ); if( cls.initialized && !host.crashed ) { Host_WriteOpenGLConfig (); Host_WriteVideoConfig (); } IN_TouchShutdown(); CL_CloseDemoHeader(); IN_Shutdown (); Mobile_Destroy(); SCR_Shutdown (); if( cls.initialized ) { CL_UnloadProgs (); cls.initialized = false; } FS_Delete( "demoheader.tmp" ); // remove tmp file SCR_FreeCinematic (); // release AVI's *after* client.dll because custom renderer may use them S_Shutdown (); R_Shutdown (); }
void CL_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; #ifdef USE_CURL CL_HTTP_Cleanup(true); #endif CL_WriteConfiguration(); Key_WriteConsoleHistory(); OGG_Stop(); S_Shutdown(); IN_Shutdown(); VID_Shutdown(); }
void Host_Shutdown(void) { static bool isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration(); CDAudio_Shutdown(); NET_Shutdown(); S_Shutdown(); IN_Shutdown(); NN_deinit(); TextureManager::clearAllTextures(); Alias::shutdown(); Cmd::shutdown(); CVar::shutdown(); MemoryObj::Flush(MemoryObj::ZONE); if (cls.state != ca_dedicated) { VID_Shutdown(); } if (con_debuglog) { Con_CloseDebugLog(); } }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration (); // jkrige - fmod sound system (music) //CDAudio_Shutdown (); // jkrige - fmod sound system (music) NET_Shutdown (); // jkrige - fmod sound system (system) FMOD_Shutdown(); // jkrige - fmod sound system (system) S_Shutdown(); IN_Shutdown (); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
/** * @brief Saves configuration file and shuts the client systems down * @todo this is a callback from @c Sys_Quit and @c Com_Error. It would be better * to run quit through here before the final handoff to the sys code. * @sa Sys_Quit * @sa CL_Init */ void CL_Shutdown (void) { if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; /* remove cvar feedback */ for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) { if (var->flags & CVAR_R_CONTEXT) Cvar_UnRegisterChangeListener(var->name, CL_RContextCvarChange); if (var->flags & CVAR_R_IMAGES) Cvar_UnRegisterChangeListener(var->name, CL_RImagesCvarChange); } GAME_SetMode(nullptr); GAME_UnloadGame(); CL_HTTP_Cleanup(); Irc_Shutdown(); Con_SaveConsoleHistory(); Key_WriteBindings("keys.cfg"); S_Shutdown(); R_Shutdown(); UI_Shutdown(); CIN_Shutdown(); SEQ_Shutdown(); GAME_Shutdown(); CL_LanguageShutdown(); TOTD_Shutdown(); SCR_Shutdown(); }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration (); #ifdef PROQUAKE_EXTENSION IPLog_WriteLog (); // JPG 1.05 - ip loggging #endif if (con_initialized) History_Shutdown (); CDAudio_Shutdown (); NET_Shutdown (); S_Shutdown(); IN_Shutdown (); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration(); CDAudio_Shutdown(); NET_Shutdown(); BGM_Shutdown(); S_Shutdown(); IN_Shutdown(); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
DWORD * DSOUND_LockBuffer(qboolean lockit) { int reps; static DWORD dwSize; static DWORD dwSize2; static DWORD *pbuf1; static DWORD *pbuf2; HRESULT hresult; if (!pDSBuf) return NULL; if (lockit) { reps = 0; while ((hresult = IDirectSoundBuffer_Lock (pDSBuf, 0, gSndBufSize, (LPVOID *) & pbuf1, &dwSize, (LPVOID *) & pbuf2, &dwSize2,0)) != DS_OK) { if (hresult != DSERR_BUFFERLOST) { Con_Printf ("S_TransferStereo16: DS::Lock Sound Buffer Failed\n"); S_Shutdown (); S_Startup (); return NULL; } if (++reps > 10000) { Con_Printf ("S_TransferStereo16: DS: couldn't restore buffer\n"); S_Shutdown (); S_Startup (); return NULL; } } } else { IDirectSoundBuffer_Unlock (pDSBuf, pbuf1, dwSize, NULL, 0); pbuf1=NULL; pbuf2=NULL; dwSize=0; dwSize2=0; } return(pbuf1); }
void I_Error (char *error, ...) { va_list argptr; if (already_quitting) { fprintf(stderr, "Warning: recursive call to I_Error detected.\n"); exit(-1); } else { already_quitting = true; } // Message first. va_start(argptr, error); fprintf(stderr, "\nError: "); vfprintf(stderr, error, argptr); fprintf(stderr, "\n"); va_end(argptr); fflush(stderr); // Shutdown. Here might be other errors. if (demorecording) { G_CheckDemoStatus(); } D_QuitNetGame (); I_ShutdownGraphics(); S_Shutdown(); #ifdef _WIN32 // On Windows, pop up a dialog box with the error message. { char msgbuf[512]; wchar_t wmsgbuf[512]; va_start(argptr, error); memset(msgbuf, 0, sizeof(msgbuf)); vsnprintf(msgbuf, sizeof(msgbuf) - 1, error, argptr); va_end(argptr); MultiByteToWideChar(CP_ACP, 0, msgbuf, strlen(msgbuf) + 1, wmsgbuf, sizeof(wmsgbuf)); MessageBoxW(NULL, wmsgbuf, L"Error", MB_OK); } #endif // abort(); exit(-1); }
/* ============== SNDDMA_BeginPainting Makes sure dma.buffer is valid =============== */ void SNDDMA_BeginPainting(void) { int reps; DWORD dwSize2; DWORD *pbuf, *pbuf2; HRESULT hresult; DWORD dwStatus; if(!pDSBuf) { return; } // if the buffer was lost or stopped, restore it and/or restart it if(pDSBuf->lpVtbl->GetStatus(pDSBuf, &dwStatus) != DS_OK) { Com_Printf("Couldn't get sound buffer status\n"); } if(dwStatus & DSBSTATUS_BUFFERLOST) { pDSBuf->lpVtbl->Restore(pDSBuf); } if(!(dwStatus & DSBSTATUS_PLAYING)) { pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING); } // lock the dsound buffer reps = 0; dma.buffer = NULL; while((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pbuf, &locksize, &pbuf2, &dwSize2, 0)) != DS_OK) { if(hresult != DSERR_BUFFERLOST) { Com_Printf("SNDDMA_BeginPainting: Lock failed with error '%s'\n", DSoundError(hresult)); S_Shutdown(); return; } else { pDSBuf->lpVtbl->Restore(pDSBuf); } if(++reps > 2) { return; } } dma.buffer = (unsigned char *)pbuf; }
/* * S_Restart_f */ static void S_Restart_f(void) { S_Shutdown(); S_Init(); cls.loading = 1; S_LoadMedia(); cls.loading = 0; }
/* * Restart the sound subsystem so it can pick up * new parameters and flush all sounds */ void CL_Snd_Restart_f(void) { OGG_SaveState(); S_Shutdown(); S_Init(); CL_RegisterSounds(); OGG_InitTrackList(); OGG_RecoverState(); }
/* ================ S_Restart ================ */ void S_Restart (void) { int i; S_Shutdown (); // flush all sounds for (i = 0; i < num_sfx; i++) { if (known_sfx[i].cache.data) Cache_Free (&known_sfx[i].cache); } S_Init (); }
void I_Error (char *error, ...) { va_list argptr; char string[1024]; fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); va_start (argptr,error); vsprintf (string,error,argptr); va_end (argptr); fprintf(stderr, "Error: %s\n", string); S_Shutdown(); VID_Shutdown(); exit(-1); }
static void *ds7_lock(struct SoundCard *sc) { struct dspriv *p = sc->driverprivate; int reps; DWORD dwSize,dwSize2; DWORD *pbuf2; HRESULT hresult; reps = 0; while ((hresult = p->pDSBuf->lpVtbl->Lock(p->pDSBuf, 0, p->gSndBufSize, &sc->buffer, &p->lockedsize, &pbuf2, &dwSize2, 0)) != DS_OK) { if (hresult != DSERR_BUFFERLOST) { Com_Printf("dsound7: Lock Sound Buffer Failed\n"); #if 0 S_Shutdown (); S_Startup (); #endif return NULL; } if (++reps > 10000) { Com_Printf("dsound7: couldn't restore buffer\n"); #if 0 S_Shutdown (); S_Startup (); #endif return NULL; } } return sc->buffer; }
void Sys_Reboot( const char *reason ) { LAUNCH_DATA ld; const char *path = NULL; memset( &ld, 0, sizeof(ld) ); if (!Q_stricmp(reason, "new_account")) { PLD_LAUNCH_DASHBOARD pDash = (PLD_LAUNCH_DASHBOARD) &ld; pDash->dwReason = XLD_LAUNCH_DASHBOARD_NEW_ACCOUNT_SIGNUP; path = NULL; } else if (!Q_stricmp(reason, "net_config")) { PLD_LAUNCH_DASHBOARD pDash = (PLD_LAUNCH_DASHBOARD) &ld; pDash->dwReason = XLD_LAUNCH_DASHBOARD_NETWORK_CONFIGURATION; path = NULL; } else if (!Q_stricmp(reason, "manage_account")) { PLD_LAUNCH_DASHBOARD pDash = (PLD_LAUNCH_DASHBOARD) &ld; pDash->dwReason = XLD_LAUNCH_DASHBOARD_ACCOUNT_MANAGEMENT; path = NULL; } else if (!Q_stricmp(reason, "singleplayer")) { path = "d:\\default.xbe"; strcpy((char *)&ld.Data[0], LAUNCH_MAGIC); } else { Com_Error( ERR_FATAL, "Unknown reboot code %s\n", reason ); } // Title should not be doing ANYTHING in the background. // Shutting down sound ensures that the sound thread is gone S_Shutdown(); // Similarly, kill off the streaming thread extern void Sys_StreamShutdown(void); Sys_StreamShutdown(); XLaunchNewImage(path, &ld); // This function should not return! Com_Error( ERR_FATAL, "ERROR: XLaunchNewImage returned\n" ); }
void S_ClearBuffer (void) { int clear; #ifdef _WIN32 if (!shm || (!shm->buffer && !pDSBuf)) #else if (!shm || !shm->buffer) #endif return; clear = (shm->format.width == 2) ? 0x80 : 0; #ifdef _WIN32 if (pDSBuf) { DWORD dwSize; DWORD *pData; int reps; HRESULT hresult; reps = 0; while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pData, &dwSize, NULL, NULL, 0)) != DS_OK) { if (hresult != DSERR_BUFFERLOST) { Com_Printf ("S_ClearBuffer: Lock failed with error '%s'\n", DSoundError(hresult)); S_Shutdown (); return; } else { pDSBuf->lpVtbl->Restore (pDSBuf); } if (++reps > 2) return; } memset(pData, clear, shm->bufferlength); pDSBuf->lpVtbl->Unlock(pDSBuf, pData, dwSize, NULL, 0); } else #endif { memset(shm->buffer, clear, shm->bufferlength); } }
/* ================= CL_Snd_Restart_f Restart the sound subsystem The cgame and game must also be forced to restart because handles will be invalid ================= */ void CL_Snd_Restart_f( void ) { S_Shutdown(); S_Init(); // CL_Vid_Restart_f(); extern qboolean s_soundMuted; s_soundMuted = qfalse; // we can play again S_RestartMusic(); extern void S_ReloadAllUsedSounds(void); S_ReloadAllUsedSounds(); extern void AS_ParseSets(void); AS_ParseSets(); }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; Host_WriteConfiguration(); CDAudio_Shutdown(); NET_Shutdown(); S_Shutdown(); IN_Shutdown(); if (host_basepal) VID_Shutdown(); }
void S_ClearBuffer(void) { int err; int clear; if (!sound_started || !shm) return; err = SNDDMA_LockBuffer(); if (err) { S_Shutdown(); return; } clear = (shm->samplebits == 8) ? 0x80 : 0; memset(shm->buffer, clear, shm->samples * shm->samplebits / 8); SNDDMA_UnlockBuffer(); }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { static qboolean recursive = qfalse; if ( !com_cl_running || !com_cl_running->integer ) { return; } Com_Printf( "----- CL_Shutdown -----\n" ); if ( recursive ) { printf ("recursive shutdown\n"); return; } recursive = qtrue; CL_ShutdownUI(); CL_Disconnect(); S_Shutdown(); CL_ShutdownRef(); #ifdef _IMMERSION CL_ShutdownFF(); #endif // _IMMERSION Cmd_RemoveCommand ("cmd"); Cmd_RemoveCommand ("configstrings"); Cmd_RemoveCommand ("clientinfo"); Cmd_RemoveCommand ("snd_restart"); Cmd_RemoveCommand ("vid_restart"); Cmd_RemoveCommand ("disconnect"); Cmd_RemoveCommand ("cinematic"); Cmd_RemoveCommand ("ingamecinematic"); Cmd_RemoveCommand ("pause"); Cvar_Set( "cl_running", "0" ); recursive = qfalse; memset( &cls, 0, sizeof( cls ) ); Com_Printf( "-----------------------\n" ); }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { // already freed if( !cls.initialized ) return; cls.initialized = false; MsgDev( D_INFO, "CL_Shutdown()\n" ); Host_WriteOpenGLConfig (); Host_WriteVideoConfig (); CL_CloseDemoHeader(); IN_Shutdown (); SCR_Shutdown (); CL_UnloadProgs (); SCR_FreeCinematic (); // release AVI's *after* client.dll because custom renderer may use them S_Shutdown (); R_Shutdown (); }
void I_Quit (void) { D_QuitNetGame (); G_CheckDemoStatus(); S_Shutdown(); if (!screensaver_mode) { M_SaveDefaults (); } I_ShutdownGraphics(); if (show_endoom && !testcontrols && !screensaver_mode) { I_Endoom(); } exit(0); }
/** * Return to default system state. */ void Sys_Shutdown(void) { // We are now shutting down. appShutdown = true; // Time to unload *everything*. if(App_GameLoaded()) Con_Execute(CMDS_DDAY, "unload", true, false); Net_Shutdown(); // Let's shut down sound first, so Windows' HD-hogging doesn't jam // the MUS player (would produce horrible bursts of notes). S_Shutdown(); #ifdef __CLIENT__ GL_Shutdown(); DD_ClearEvents(); #endif DD_DestroyGames(); }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { static qboolean recursive = qfalse; if ( !com_cl_running || !com_cl_running->integer ) { return; } Com_Printf( "----- CL_Shutdown -----\n" ); if ( recursive ) { Com_Printf( "WARNING: Recursive shutdown\n" ); return; } recursive = qtrue; CL_ShutdownUI(); CL_Disconnect(); S_Shutdown(); CL_ShutdownRef(qfalse); Cmd_RemoveCommand ("cmd"); Cmd_RemoveCommand ("configstrings"); Cmd_RemoveCommand ("clientinfo"); Cmd_RemoveCommand ("snd_restart"); Cmd_RemoveCommand ("vid_restart"); Cmd_RemoveCommand ("disconnect"); Cmd_RemoveCommand ("cinematic"); Cmd_RemoveCommand ("ingamecinematic"); Cmd_RemoveCommand ("uimenu"); Cmd_RemoveCommand ("datapad"); Cmd_RemoveCommand ("endscreendissolve"); Cvar_Set( "cl_running", "0" ); recursive = qfalse; memset( &cls, 0, sizeof( cls ) ); Com_Printf( "-----------------------\n" ); }