VirtualBox

Changeset 50314 in vbox


Ignore:
Timestamp:
Feb 3, 2014 7:29:26 PM (11 years ago)
Author:
vboxsync
Message:

crOpenGL/VideoRec: do hardweight screen capthure only when recorder is ready

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/VBoxCrOpenGLSvc.h

    r50313 r50314  
    386386                uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
    387387
     388typedef DECLCALLBACKPTR(bool, PFNCRSCREENSHOTBEGIN)(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
     389typedef DECLCALLBACKPTR(void, PFNCRSCREENSHOTEND)(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
     390
    388391#define CRSCREEN_ALL (0xffffffff)
    389392
     
    393396    uint32_t u32Screen;
    394397    void *pvContext;
    395     PFNCRSCREENSHOTREPORT pfnScreenshot;
     398    PFNCRSCREENSHOTBEGIN pfnScreenshotBegin;
     399    PFNCRSCREENSHOTREPORT pfnScreenshotPerform;
     400    PFNCRSCREENSHOTEND pfnScreenshotEnd;
    396401} CRVBOXHGCMTAKESCREENSHOT;
    397402
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r50313 r50314  
    933933}
    934934
     935static void crScreenshotHandle(CRVBOXHGCMTAKESCREENSHOT *pScreenshot, uint32_t idScreen, uint64_t u64Now)
     936{
     937    if (!pScreenshot->pfnScreenshotBegin || pScreenshot->pfnScreenshotBegin(pScreenshot->pvContext, idScreen, u64Now))
     938    {
     939        CR_SCREENSHOT Screenshot;
     940
     941        int rc = crServerVBoxScreenshotGet(idScreen, &Screenshot);
     942        if (RT_SUCCESS(rc))
     943        {
     944            pScreenshot->pfnScreenshotPerform(pScreenshot->pvContext, idScreen,
     945                    0, 0, 32,
     946                    Screenshot.Img.pitch, Screenshot.Img.width, Screenshot.Img.height,
     947                    (uint8_t*)Screenshot.Img.pvData, u64Now);
     948            crServerVBoxScreenshotRelease(&Screenshot);
     949        }
     950        else
     951        {
     952            Assert(rc == VERR_INVALID_STATE);
     953        }
     954
     955        if (pScreenshot->pfnScreenshotEnd)
     956            pScreenshot->pfnScreenshotEnd(pScreenshot->pvContext, idScreen, u64Now);
     957    }
     958}
     959
    935960/*
    936961 * We differentiate between a function handler for the guest and one for the host.
     
    12251250                for (uint32_t i = 0; i < g_u32ScreenCount; ++i)
    12261251                {
    1227                     CR_SCREENSHOT Screenshot;
    1228 
    1229                     int rc = crServerVBoxScreenshotGet(i, &Screenshot);
    1230                     if (RT_SUCCESS(rc))
    1231                     {
    1232                         pScreenshot->pfnScreenshot(pScreenshot->pvContext, i,
    1233                                 0, 0, 32,
    1234                                 Screenshot.Img.pitch, Screenshot.Img.width, Screenshot.Img.height,
    1235                                 (uint8_t*)Screenshot.Img.pvData, u64Now);
    1236                         crServerVBoxScreenshotRelease(&Screenshot);
    1237                     }
    1238                     else
    1239                     {
    1240                         Assert(rc == VERR_INVALID_STATE);
    1241                     }
     1252                    crScreenshotHandle(pScreenshot, i, u64Now);
    12421253                }
    12431254            }
    12441255            else if (pScreenshot->u32Screen < g_u32ScreenCount)
    12451256            {
    1246                 CR_SCREENSHOT Screenshot;
    1247 
    1248                 int rc = crServerVBoxScreenshotGet(pScreenshot->u32Screen, &Screenshot);
    1249                 if (RT_SUCCESS(rc))
    1250                 {
    1251                     pScreenshot->pfnScreenshot(pScreenshot->pvContext, pScreenshot->u32Screen,
    1252                             0, 0, 32,
    1253                             Screenshot.Img.pitch, Screenshot.Img.width, Screenshot.Img.height,
    1254                             (uint8_t*)Screenshot.Img.pvData, u64Now);
    1255                     crServerVBoxScreenshotRelease(&Screenshot);
    1256                 }
    1257                 else
    1258                 {
    1259                     Assert(rc == VERR_INVALID_STATE);
    1260                 }
     1257                crScreenshotHandle(pScreenshot, pScreenshot->u32Screen, u64Now);
    12611258            }
    12621259            else
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r50313 r50314  
    178178#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
    179179    void  handleCrAsyncCmdCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
    180     void  handleCrVRecScreenshot(uint32_t uScreen,
     180    void  handleCrVRecScreenshotPerform(uint32_t uScreen,
    181181                    uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
    182182                    uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
    183183                    uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
     184    bool handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t u64TimeStamp);
     185    void handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64TimeStamp);
    184186    void  handleVRecCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
    185187#endif
     
    283285
    284286#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
    285     static DECLCALLBACK(void) displayCrVRecScreenshot(void *pvCtx, uint32_t uScreen,
     287    static DECLCALLBACK(void) displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
    286288                    uint32_t x, uint32_t y, uint32_t uBitsPerPixel,
    287289                    uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
    288290                    uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
     291    static DECLCALLBACK(bool) displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
     292    static DECLCALLBACK(void) displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
     293
    289294    static DECLCALLBACK(void)  displayVRecCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
    290295    static DECLCALLBACK(void)  displayCrAsyncCmdCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r50313 r50314  
    155155    mCrOglScreenshotData.u32Screen = CRSCREEN_ALL;
    156156    mCrOglScreenshotData.pvContext = this;
    157     mCrOglScreenshotData.pfnScreenshot = displayCrVRecScreenshot;
     157    mCrOglScreenshotData.pfnScreenshotBegin = displayCrVRecScreenshotBegin;
     158    mCrOglScreenshotData.pfnScreenshotPerform = displayCrVRecScreenshotPerform;
     159    mCrOglScreenshotData.pfnScreenshotEnd = displayCrVRecScreenshotEnd;
    158160#endif
    159161
     
    42054207}
    42064208
    4207 
    4208 void  Display::handleCrVRecScreenshot(uint32_t uScreen,
     4209bool  Display::handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t u64TimeStamp)
     4210{
     4211    return VideoRecIsReady(mpVideoRecCtx, uScreen, u64TimeStamp);
     4212}
     4213
     4214void  Display::handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64TimeStamp)
     4215{
     4216}
     4217
     4218void  Display::handleCrVRecScreenshotPerform(uint32_t uScreen,
    42094219                uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
    42104220                uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
     
    42174227                              uGuestWidth, uGuestHeight,
    42184228                              pu8BufferAddress, u64TimeStamp);
    4219     Assert(rc == VINF_SUCCESS || rc == VERR_TRY_AGAIN || rc == VINF_TRY_AGAIN);
     4229    Assert(rc == VINF_SUCCESS/* || rc == VERR_TRY_AGAIN || rc == VINF_TRY_AGAIN*/);
    42204230}
    42214231
     
    42264236}
    42274237
    4228 DECLCALLBACK(void) Display::displayCrVRecScreenshot(void *pvCtx, uint32_t uScreen,
     4238DECLCALLBACK(void) Display::displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
    42294239                uint32_t x, uint32_t y, uint32_t uBitsPerPixel,
    42304240                uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
     
    42324242{
    42334243    Display *pDisplay = (Display *)pvCtx;
    4234     pDisplay->handleCrVRecScreenshot(uScreen,
     4244    pDisplay->handleCrVRecScreenshotPerform(uScreen,
    42354245            x, y, FramebufferPixelFormat_FOURCC_RGB, uBitsPerPixel,
    42364246            uBytesPerLine, uGuestWidth, uGuestHeight,
    42374247            pu8BufferAddress, u64TimeStamp);
     4248}
     4249
     4250DECLCALLBACK(bool) Display::displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp)
     4251{
     4252    Display *pDisplay = (Display *)pvCtx;
     4253    return pDisplay->handleCrVRecScreenshotBegin(uScreen, u64TimeStamp);
     4254}
     4255
     4256DECLCALLBACK(void) Display::displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp)
     4257{
     4258    Display *pDisplay = (Display *)pvCtx;
     4259    pDisplay->handleCrVRecScreenshotEnd(uScreen, u64TimeStamp);
    42384260}
    42394261
  • trunk/src/VBox/Main/src-client/VideoRec.cpp

    r50041 r50314  
    603603
    604604/**
     605 * VideoRec utility function to check if recording engine is ready to accept a new frame
     606 * for the given screen.
     607 *
     608 * @returns true if recording engine is ready
     609 * @param   pCtx   Pointer to video recording context.
     610 * @param   uScreen screen id.
     611 * @param   u64TimeStamp current time stamp
     612 */
     613bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t u64TimeStamp)
     614{
     615    uint32_t enmState = ASMAtomicReadU32(&g_enmState);
     616    if (enmState != VIDREC_IDLE)
     617        return false;
     618
     619    PVIDEORECSTREAM pStrm = &pCtx->Strm[uScreen];
     620    if (!pStrm->fEnabled)
     621        return false;
     622
     623    if (u64TimeStamp < pStrm->u64LastTimeStamp + pStrm->uDelay)
     624        return false;
     625
     626    if (ASMAtomicReadBool(&pStrm->fRgbFilled))
     627        return false;
     628
     629    return true;
     630}
     631
     632/**
    605633 * VideoRec utility function to encode the source image and write the encoded
    606634 * image to target file.
  • trunk/src/VBox/Main/src-client/VideoRec.h

    r50313 r50314  
    3434                          uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
    3535                          uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
     36bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t u64TimeStamp);
    3637
    3738#endif /* !____H_VIDEOREC */
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