VirtualBox

Changeset 104799 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
May 28, 2024 11:03:27 AM (8 months ago)
Author:
vboxsync
Message:

Recording/Main: Added (release) statistics (via STAM) for getting some numbers out of the current code. Simplified code path for starting/stopping recording within the Display implementation. Left a @todo in Display::attachFramebuffer(). bugref:10650

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r98103 r104799  
    190190
    191191#ifdef VBOX_WITH_RECORDING
    192     int  i_recordingInvalidate(void);
     192    int  i_recordingStart(void);
     193    int  i_recordingStop(void);
     194    int  i_recordingInvalidate(bool fForce = false);
    193195    void i_recordingScreenChanged(unsigned uScreenId);
    194196#endif
     
    420422#endif
    421423
     424#ifdef VBOX_WITH_STATISTICS
     425    struct
     426    {
     427        /** Profiling Display::i_displayRefreshCallback(). */
     428        STAMPROFILE profileDisplayRefreshCallback;
     429        /** Statistics for monitor N. */
     430        struct
     431        {
     432            /** Statistics for recording of monitor N. */
     433            struct
     434            {
     435                /** Profiling recording code of monitor N. */
     436                STAMPROFILE profileRecording;
     437            } Recording;
     438        } Monitor[SchemaDefs::MaxGuestMonitors];
     439        /** Statistics for audio/video recording. */
     440        struct
     441        {
     442            /** Profiling recording code of all active monitors. */
     443            STAMPROFILE profileRecording;
     444        } Recording;
     445    } Stats;
     446#endif
     447
    422448public:
    423449
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r104713 r104799  
    61376137                            && mRecording.mCtx.IsReady()) /* Any video recording (audio and/or video) feature enabled? */
    61386138                        {
    6139                             vrc = pDisplay->i_recordingInvalidate();
    6140                             if (RT_SUCCESS(vrc))
    6141                             {
    6142                                 vrc = i_recordingStart(pAutoLock);
    6143                                 if (RT_FAILURE(vrc))
    6144                                     setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Recording start failed (%Rrc) -- please consult log file for details"), vrc);
    6145                             }
     6139                            vrc = i_recordingStart(pAutoLock);
     6140                            if (RT_FAILURE(vrc))
     6141                                setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Recording start failed (%Rrc) -- please consult log file for details"), vrc);
    61466142                        }
    61476143                    }
     
    76437639    int vrc = mRecording.mCtx.Start();
    76447640    if (RT_SUCCESS(vrc))
    7645     {
    7646         for (unsigned uScreen = 0; uScreen < mRecording.mCtx.GetStreamCount(); uScreen++)
    7647             mDisplay->i_recordingScreenChanged(uScreen);
    7648     }
     7641        vrc = mDisplay->i_recordingStart();
    76497642
    76507643    LogFlowFuncLeaveRC(vrc);
     
    76677660    int vrc = mRecording.mCtx.Stop();
    76687661    if (RT_SUCCESS(vrc))
    7669     {
    7670         const size_t cStreams = mRecording.mCtx.GetStreamCount();
    7671         for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
    7672             mDisplay->i_recordingScreenChanged(uScreen);
    7673     }
     7662        vrc = mDisplay->i_recordingStop();
    76747663
    76757664    LogFlowFuncLeaveRC(vrc);
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r99912 r104799  
    15951595
    15961596    Console::SafeVMPtrQuiet ptrVM(mParent);
    1597     if (ptrVM.isOk())
     1597    if (ptrVM.isOk()) /** @todo r=andy This apparently *never* is true at this point? */
    15981598        ptrVM.vtable()->pfnVMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
    15991599                                              3, this, aScreenId, false);
     
    20962096#ifdef VBOX_WITH_RECORDING
    20972097/**
     2098 * Starts video (+ audio) recording.
     2099 *
     2100 * @returns VBox status code.
     2101 */
     2102int Display::i_recordingStart(void)
     2103{
     2104#ifdef VBOX_WITH_STATISTICS
     2105    Console::SafeVMPtrQuiet ptrVM(mParent);
     2106    if (ptrVM.isOk())
     2107    {
     2108        ptrVM.vtable()->pfnSTAMR3RegisterFU(ptrVM.rawUVM(), &Stats.profileDisplayRefreshCallback,
     2109                                                STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     2110                                                "Profiling display refresh.", "/Main/Display/ProfRefresh");
     2111        ptrVM.vtable()->pfnSTAMR3RegisterFU(ptrVM.rawUVM(), &Stats.Recording.profileRecording,
     2112                                            STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     2113                                            "Profiling recording time for all monitors.", "/Main/Display/ProfRecording");
     2114
     2115        for (unsigned i = 0; i < mcMonitors; i++)
     2116            ptrVM.vtable()->pfnSTAMR3RegisterFU(ptrVM.rawUVM(), &Stats.Monitor[i].Recording.profileRecording,
     2117                                                STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     2118                                                "Profiling recording time for this monitor.", "/Main/Display/Monitor%RU32/ProfRecording", i);
     2119    }
     2120#endif
     2121
     2122    return i_recordingInvalidate(true /* fForce */);
     2123}
     2124
     2125/**
     2126 * Stops video (+ audio) recording.
     2127 *
     2128 * @returns VBox status code.
     2129 */
     2130int Display::i_recordingStop(void)
     2131{
     2132#ifdef VBOX_WITH_STATISTICS
     2133    Console::SafeVMPtrQuiet ptrVM(mParent);
     2134    if (ptrVM.isOk())
     2135    {
     2136        ptrVM.vtable()->pfnSTAMR3DeregisterF(ptrVM.rawUVM(), "/Main/Display/ProfRefresh");
     2137        ptrVM.vtable()->pfnSTAMR3DeregisterF(ptrVM.rawUVM(), "/Main/Display/ProfRecording");
     2138
     2139        for (unsigned i = 0; i < mcMonitors; i++)
     2140            ptrVM.vtable()->pfnSTAMR3DeregisterF(ptrVM.rawUVM(), "/Main/Display/Monitor%RU32/ProfRecording", i);
     2141    }
     2142#endif
     2143
     2144    return i_recordingInvalidate(true /* fForce */);
     2145}
     2146
     2147/**
    20982148 * Invalidates the recording configuration.
    20992149 *
    2100  * @returns IPRT status code.
     2150 * @returns VBox status code.
     2151 * @param   fForce              Whether to force invalidation or not. Default is @c false.
    21012152 */
    2102 int Display::i_recordingInvalidate(void)
     2153int Display::i_recordingInvalidate(bool fForce /* = false */)
    21032154{
    21042155    RecordingContext *pCtx = mParent->i_recordingGetContext();
    2105     if (!pCtx || !pCtx->IsStarted())
     2156    if (!pCtx)
    21062157        return VINF_SUCCESS;
    21072158
     
    21112162    for (unsigned uScreen = 0; uScreen < mcMonitors; uScreen++)
    21122163    {
    2113         RecordingStream *pRecordingStream = pCtx->GetStream(uScreen);
    2114 
    2115         const bool fStreamEnabled = pRecordingStream->IsReady();
    2116               bool fChanged       = maRecordingEnabled[uScreen] != fStreamEnabled;
     2164        const RecordingStream *pRecordingStream = pCtx->GetStream(uScreen);
     2165
     2166        bool const fStreamEnabled = pRecordingStream->IsReady();
     2167        bool const fChanged       = (maRecordingEnabled[uScreen] != fStreamEnabled) || fForce;
    21172168
    21182169        maRecordingEnabled[uScreen] = fStreamEnabled;
     
    21252176}
    21262177
     2178/**
     2179 * Called when the recording state of a screen got changed.
     2180 *
     2181 * @param   uScreenId           ID of screen for which the recording state got changed.
     2182 */
    21272183void Display::i_recordingScreenChanged(unsigned uScreenId)
    21282184{
     
    29422998    PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
    29432999
    2944 #ifdef DEBUG_sunlover_2
    2945     LogFlowFunc(("pDrv->pDisplay->mfVideoAccelEnabled = %d\n",
    2946                  pDrv->pDisplay->mfVideoAccelEnabled));
    2947 #endif /* DEBUG_sunlover_2 */
     3000    STAM_PROFILE_START(&pDisplay->Stats.profileDisplayRefreshCallback, a);
    29483001
    29493002    Display *pDisplay = pDrv->pDisplay;
     
    29903043            }
    29913044
     3045            STAM_REL_PROFILE_START(&pDisplay->Stats.Recording.profileRecording, b);
     3046
    29923047            uint64_t tsNowMs = RTTimeProgramMilliTS();
    29933048            for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
     
    29983053                if (!pCtx->NeedsUpdate(uScreenId, tsNowMs))
    29993054                    continue;
     3055
     3056                STAM_REL_PROFILE_START(&pDisplay->Stats.Monitor[uScreenId].Recording.profileRecording, c);
    30003057
    30013058                DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
     
    30393096                        break;
    30403097                }
     3098
     3099                STAM_REL_PROFILE_STOP(&pDisplay->Stats.Monitor[uScreenId].Recording.profileRecording, c);
    30413100            }
     3101
     3102            STAM_REL_PROFILE_STOP(&pDisplay->Stats.Recording.profileRecording, b);
     3103
    30423104        } while (0);
    30433105    }
    30443106#endif /* VBOX_WITH_RECORDING */
    30453107
    3046 #ifdef DEBUG_sunlover_2
    3047     LogFlowFunc(("leave\n"));
    3048 #endif /* DEBUG_sunlover_2 */
     3108    STAM_PROFILE_STOP(&pDisplay->Stats.profileDisplayRefreshCallback, a);
    30493109}
    30503110
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette