| 2647 | extern bool CheckOpenALDeviceAndRecoverIfNeeded(); |
| 2648 | extern int g_screenshotFormat; |
| 2649 | void idSessionLocal::Frame() { |
| 2650 | D3P_ScopedCPUSample(Session_Frame); |
| 2651 | |
| 2652 | if ( com_asyncSound.GetInteger() == 0 ) { |
| 2653 | soundSystem->AsyncUpdateWrite( Sys_Milliseconds() ); |
| 2654 | } |
| 2655 | |
| 2656 | // DG: periodically check if sound device is still there and try to reset it if not |
| 2657 | // (calling this from idSoundSystem::AsyncUpdate(), which runs in a separate thread |
| 2658 | // by default, causes a deadlock when calling idCommon->Warning()) |
| 2659 | CheckOpenALDeviceAndRecoverIfNeeded(); |
| 2660 | |
| 2661 | // Editors that completely take over the game |
| 2662 | if ( com_editorActive && ( com_editors & ( EDITOR_RADIANT | EDITOR_GUI ) ) ) { |
| 2663 | return; |
| 2664 | } |
| 2665 | |
| 2666 | #if 0 // handled via Sys_GenerateEvents() -> handleMouseGrab() |
| 2667 | // if the console is down, we don't need to hold |
| 2668 | // the mouse cursor |
| 2669 | if ( console->Active() || com_editorActive ) { |
| 2670 | Sys_GrabMouseCursor( false ); |
| 2671 | } else { |
| 2672 | Sys_GrabMouseCursor( true ); |
| 2673 | } |
| 2674 | #endif |
| 2675 | |
| 2676 | // save the screenshot and audio from the last draw if needed |
| 2677 | if ( aviCaptureMode ) { |
| 2678 | idStr name; |
| 2679 | |
| 2680 | name = va("demos/%s/%s_%05i.tga", aviDemoShortName.c_str(), aviDemoShortName.c_str(), aviTicStart ); |
| 2681 | |
| 2682 | float ratio = 30.0f / ( 1000.0f / USERCMD_MSEC / com_aviDemoTics.GetInteger() ); |
| 2683 | aviDemoFrameCount += ratio; |
| 2684 | if ( aviTicStart + 1 != ( int )aviDemoFrameCount ) { |
| 2685 | // skipped frames so write them out |
| 2686 | int c = aviDemoFrameCount - aviTicStart; |
| 2687 | while ( c-- ) { |
| 2688 | g_screenshotFormat = 0; |
| 2689 | renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL ); |
| 2690 | name = va("demos/%s/%s_%05i.tga", aviDemoShortName.c_str(), aviDemoShortName.c_str(), ++aviTicStart ); |
| 2691 | } |
| 2692 | } |
| 2693 | aviTicStart = aviDemoFrameCount; |
| 2694 | |
| 2695 | // remove any printed lines at the top before taking the screenshot |
| 2696 | console->ClearNotifyLines(); |
| 2697 | |
| 2698 | // this will call Draw, possibly multiple times if com_aviDemoSamples is > 1 |
| 2699 | g_screenshotFormat = 0; |
| 2700 | renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL ); |
| 2701 | } |
| 2702 | |
| 2703 | // at startup, we may be backwards |
| 2704 | if ( latchedTicNumber > com_ticNumber ) { |
| 2705 | latchedTicNumber = com_ticNumber; |
| 2706 | } |
no test coverage detected