/* * @brief Ensures music playback continues by selecting a new track when one * completes. */ void S_FrameMusic(void) { extern cl_static_t cls; static cl_state_t last_state = CL_UNINITIALIZED; // revert to the default music when the client disconnects if (last_state == CL_ACTIVE && cls.state != CL_ACTIVE) { S_ClearPlaylist(); S_StopMusic(); } last_state = cls.state; if (s_music_volume->modified) { s_music_volume->value = Clamp(s_music_volume->value, 0.0, 1.0); if (s_music_volume->value) Mix_VolumeMusic(s_music_volume->value * 255); else S_StopMusic(); } // if music is enabled but not playing, play that funky music if (s_music_volume->value && !Mix_PlayingMusic()) S_NextTrack_f(); }
void S_ChangeMusic(int music_id, int looping) { musicinfo_t *music; int music_file_failed; // cournia - if true load the default MIDI music char* music_filename; // cournia //jff 1/22/98 return if music is not enabled if (!mus_card || nomusicparm) return; if (music_id <= mus_None || music_id >= NUMMUSIC) I_Error("S_ChangeMusic: Bad music number %d", music_id); music = &S_music[music_id]; if (mus_playing == music) return; // shutdown old music S_StopMusic(); // get lumpnum if neccessary if (!music->lumpnum) { char namebuf[9]; sprintf(namebuf, "d_%s", music->name); music->lumpnum = W_GetNumForName(namebuf); } printf("mus: d_%s\n", music->name); music->data = W_CacheLumpNum(music->lumpnum); mus_play_music(music->data); mus_playing = music; }
static void Title_Stop(void) { menuactive = false; //WIPE_FadeScreen(8); S_StopMusic(); }
void S_MusicShutdown(void) { S_StopMusic(); if (MUSIC_Shutdown() != MUSIC_Ok) initprintf("%s\n", MUSIC_ErrorString(MUSIC_ErrorCode)); }
void MIDIDeviceChanged(int newdev, bool force) { static int oldmididev = INT_MIN; // If a song is playing, move it to the new device. if (oldmididev != newdev || force) { if (currSong != NULL && currSong->IsMIDI()) { MusInfo *song = currSong; if (song->m_Status == MusInfo::STATE_Playing) { if (song->GetDeviceType() == MDEV_FLUIDSYNTH && force) { // FluidSynth must reload the song to change the patch set. auto mi = mus_playing; S_StopMusic(true); S_ChangeMusic(mi.name, mi.baseorder, mi.loop); } else { song->Stop(); song->Start(song->m_Looping); } } } else { S_MIDIDeviceChanged(); } } // 'force' if (!force) oldmididev = newdev; }
int32_t S_PlayMusic(const char *fn) { if (!ud.config.MusicToggle || fn == NULL) return 0; int32_t fp = S_OpenAudio(fn, 0, 1); if (EDUKE32_PREDICT_FALSE(fp < 0)) { OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open \"%s\" for playback!\n",fn); return 0; } S_StopMusic(); int32_t MusicLen = kfilelength(fp); if (EDUKE32_PREDICT_FALSE(MusicLen < 4)) { OSD_Printf(OSD_ERROR "S_PlayMusic(): error: empty music file \"%s\"\n", fn); kclose(fp); return 0; } ALIGNED_FREE_AND_NULL(MusicPtr); // in case the following allocation was never freed MusicPtr = (char *)Xaligned_alloc(16, MusicLen); g_musicSize = kread(fp, (char *)MusicPtr, MusicLen); if (EDUKE32_PREDICT_FALSE(g_musicSize != MusicLen)) { OSD_Printf(OSD_ERROR "S_PlayMusic(): error: read %d bytes from \"%s\", expected %d\n", g_musicSize, fn, MusicLen); kclose(fp); g_musicSize = 0; return 0; } kclose(fp); if (!Bmemcmp(MusicPtr, "MThd", 4)) { MUSIC_PlaySong(MusicPtr, MUSIC_LoopSong); MusicIsWaveform = 0; } else { int32_t const mvol = MASTER_VOLUME(ud.config.MusicVolume); MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0, 0, mvol, mvol, mvol, FX_MUSIC_PRIORITY, MUSIC_ID); if (MusicVoice > FX_Ok) MusicIsWaveform = 1; } return 0; }
// // End the frontend. // static void FE_Shutdown(void) { frontend_running = false; FE_DisableLobbyListener(); // cannot join any games now S_StopMusic(); // stop music I_ResetBaseTime(); // don't screw with in-game timing I_SetShowVisualCursor(false); FE_DestroyBackgrounds(); FE_FreeSlider(); }
void S_Exit() { Result ret; if (!audio_initialized) { return; } S_StopMusic(); S_Stop(); MIX_exit(); mus_exit(); //flush csnd command buffers csndExecCmds(true); csndExit(); //svcSleepThread(5000000000LL); }
void G_SkipDemoStart(void) { saved_fastdemo = fastdemo; saved_nodrawers = nodrawers; saved_nosfxparm = nosfxparm; saved_nomusicparm = nomusicparm; paused = false; doSkip = true; S_StopMusic(); fastdemo = true; nodrawers = true; nosfxparm = true; nomusicparm = true; I_Init2(); }
void G_SkipDemoStart(void) { saved_fastdemo = fastdemo; saved_nodrawers = nodrawers; saved_nosfxparm = nosfxparm; saved_nomusicparm = nomusicparm; saved_render_precise = render_precise; paused = false; doSkip = true; S_StopMusic(); fastdemo = true; nodrawers = true; nosfxparm = true; nomusicparm = true; render_precise = false; M_ChangeRenderPrecise(); I_Init2(); }
void I_PlaySong(byte* data, size_t length, bool loop) { if (!musicsystem) return; MusicSystemType newtype = I_SelectMusicSystem(data, length); if (newtype != current_musicsystem_type) { if (musicsystem) { I_ShutdownMusic(); S_StopMusic(); } I_InitMusic(newtype); } musicsystem->startSong(data, length, loop); // Hack for problems with Windows Vista/7 & SDL_Mixer // See comment for I_ResetMidiVolume(). I_ResetMidiVolume(); I_SetMusicVolume(snd_musicvolume); }
/* * @brief Shuts down music playback. */ void S_ShutdownMusic(void) { S_StopMusic(); }
void DoMain (HINSTANCE hInstance) { LONG WinWidth, WinHeight; int height, width, x, y; RECT cRect; TIMECAPS tc; DEVMODE displaysettings; try { #ifdef _MSC_VER _set_new_handler (NewFailure); #endif Args = new FArgs(__argc, __argv); // Load Win32 modules Kernel32Module.Load({"kernel32.dll"}); Shell32Module.Load({"shell32.dll"}); User32Module.Load({"user32.dll"}); // Under XP, get our session ID so we can know when the user changes/locks sessions. // Since we need to remain binary compatible with older versions of Windows, we // need to extract the ProcessIdToSessionId function from kernel32.dll manually. HMODULE kernel = GetModuleHandle ("kernel32.dll"); if (Args->CheckParm("-stdout")) { // As a GUI application, we don't normally get a console when we start. // If we were run from the shell and are on XP+, we can attach to its // console. Otherwise, we can create a new one. If we already have a // stdout handle, then we have been redirected and should just use that // handle instead of creating a console window. StdOut = GetStdHandle(STD_OUTPUT_HANDLE); if (StdOut != NULL) { // It seems that running from a shell always creates a std output // for us, even if it doesn't go anywhere. (Running from Explorer // does not.) If we can get file information for this handle, it's // a file or pipe, so use it. Otherwise, pretend it wasn't there // and find a console to use instead. BY_HANDLE_FILE_INFORMATION info; if (!GetFileInformationByHandle(StdOut, &info)) { StdOut = NULL; } } if (StdOut == NULL) { // AttachConsole was introduced with Windows XP. (OTOH, since we // have to share the console with the shell, I'm not sure if it's // a good idea to actually attach to it.) typedef BOOL (WINAPI *ac)(DWORD); ac attach_console = kernel != NULL ? (ac)GetProcAddress(kernel, "AttachConsole") : NULL; if (attach_console != NULL && attach_console(ATTACH_PARENT_PROCESS)) { StdOut = GetStdHandle(STD_OUTPUT_HANDLE); DWORD foo; WriteFile(StdOut, "\n", 1, &foo, NULL); AttachedStdOut = true; } if (StdOut == NULL && AllocConsole()) { StdOut = GetStdHandle(STD_OUTPUT_HANDLE); } FancyStdOut = true; } } // Set the timer to be as accurate as possible if (timeGetDevCaps (&tc, sizeof(tc)) != TIMERR_NOERROR) TimerPeriod = 1; // Assume minimum resolution of 1 ms else TimerPeriod = tc.wPeriodMin; timeBeginPeriod (TimerPeriod); /* killough 1/98: This fixes some problems with exit handling during abnormal situations. The old code called I_Quit() to end program, while now I_Quit() is installed as an exit handler and exit() is called to exit, either normally or abnormally. */ atexit (call_terms); atterm (I_Quit); // Figure out what directory the program resides in. char *program; #ifdef _MSC_VER if (_get_pgmptr(&program) != 0) { I_FatalError("Could not determine program location."); } #else char progbuff[1024]; GetModuleFileName(0, progbuff, sizeof(progbuff)); progbuff[1023] = '\0'; program = progbuff; #endif progdir = program; program = progdir.LockBuffer(); *(strrchr(program, '\\') + 1) = '\0'; FixPathSeperator(program); progdir.Truncate((long)strlen(program)); progdir.UnlockBuffer(); HDC screenDC = GetDC(0); int dpi = GetDeviceCaps(screenDC, LOGPIXELSX); ReleaseDC(0, screenDC); width = (512 * dpi + 96 / 2) / 96; height = (384 * dpi + 96 / 2) / 96; // Many Windows structures that specify their size do so with the first // element. DEVMODE is not one of those structures. memset (&displaysettings, 0, sizeof(displaysettings)); displaysettings.dmSize = sizeof(displaysettings); EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &displaysettings); x = (displaysettings.dmPelsWidth - width) / 2; y = (displaysettings.dmPelsHeight - height) / 2; if (Args->CheckParm ("-0")) { x = y = 0; } WNDCLASS WndClass; WndClass.style = 0; WndClass.lpfnWndProc = LConProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = hInstance; WndClass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ICON1)); WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); WndClass.hbrBackground = NULL; WndClass.lpszMenuName = NULL; WndClass.lpszClassName = (LPCTSTR)WinClassName; /* register this new class with Windows */ if (!RegisterClass((LPWNDCLASS)&WndClass)) I_FatalError ("Could not register window class"); /* create window */ char caption[100]; mysnprintf(caption, countof(caption), "" GAMESIG " %s " X64 " (%s)", GetVersionString(), GetGitTime()); Window = CreateWindowEx( WS_EX_APPWINDOW, (LPCTSTR)WinClassName, (LPCTSTR)caption, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, x, y, width, height, (HWND) NULL, (HMENU) NULL, hInstance, NULL); if (!Window) I_FatalError ("Could not open window"); if (kernel != NULL) { typedef BOOL (WINAPI *pts)(DWORD, DWORD *); pts pidsid = (pts)GetProcAddress (kernel, "ProcessIdToSessionId"); if (pidsid != 0) { if (!pidsid (GetCurrentProcessId(), &SessionID)) { SessionID = 0; } hwtsapi32 = LoadLibraryA ("wtsapi32.dll"); if (hwtsapi32 != 0) { FARPROC reg = GetProcAddress (hwtsapi32, "WTSRegisterSessionNotification"); if (reg == 0 || !((BOOL(WINAPI *)(HWND, DWORD))reg) (Window, NOTIFY_FOR_THIS_SESSION)) { FreeLibrary (hwtsapi32); hwtsapi32 = 0; } else { atterm (UnWTS); } } } } GetClientRect (Window, &cRect); WinWidth = cRect.right; WinHeight = cRect.bottom; CoInitialize (NULL); atterm (UnCOM); C_InitConsole (((WinWidth / 8) + 2) * 8, (WinHeight / 12) * 8, false); I_DetectOS (); D_DoomMain (); } catch (class CNoRunExit &) { I_ShutdownGraphics(); if (!batchrun) { if (FancyStdOut && !AttachedStdOut) { // Outputting to a new console window: Wait for a keypress before quitting. DWORD bytes; HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE); ShowWindow(Window, SW_HIDE); WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL); FlushConsoleInputBuffer(stdinput); SetConsoleMode(stdinput, 0); ReadConsole(stdinput, &bytes, 1, &bytes, NULL); } else if (StdOut == NULL) { ShowErrorPane(NULL); } } exit(0); } catch (class CDoomError &error) { I_ShutdownGraphics (); RestoreConView (); S_StopMusic(true); I_FlushBufferedConsoleStuff(); if (error.GetMessage ()) { if (!batchrun) { ShowErrorPane(error.GetMessage()); } else { Printf("%s\n", error.GetMessage()); } } exit (-1); } }
void F_Stop(void) { S_StopMusic(); //gameaction = ga_nothing; WIPE_FadeScreen(6); }
void P_Stop(void) { int i = 0; int action = gameaction; // // [d64] stop plasma buzz // S_StopSound(NULL, sfx_electric); for(i = 0; i < MAXPLAYERS; i++) { // take away cards and stuff if(playeringame[i]) { G_PlayerFinishLevel(i); } } // [kex] reset damage indicators if(p_damageindicator.value) { ST_ClearDamageMarkers(); } // free level tags Z_FreeTags(PU_LEVEL, PU_PURGELEVEL-1); if(automapactive) { AM_Stop(); } // music continues on exit if defined if(!P_GetMapInfo(gamemap)->contmusexit) { S_StopMusic(); } // end iwad demo playback here if(demoplayback && iwadDemo) { demoplayback = false; iwadDemo = false; } // do wipe/melt effect if(gameaction != ga_loadgame) { if(r_wipe.value) { if(gameaction != ga_warpquick) { WIPE_MeltScreen(); } else { S_StopMusic(); WIPE_FadeScreen(8); } } else { if(gameaction == ga_warpquick) { S_StopMusic(); } } } S_ResetSound(); // action is warpquick only because the user // cancelled demo playback... // boot the user back to the title screen if(gameaction == ga_warpquick && demoplayback) { gameaction = ga_title; demoplayback = false; } else { gameaction = action; } }