Ticket #5956: 5956-v1.patch

File 5956-v1.patch, 4.7 KB (added by danielk, 11 years ago)

Possible fix

  • libs/libmythtv/videoout_xv.cpp

     
    8686
    8787#define NUM_VDPAU_BUFFERS 17
    8888
    89 static QStringList allowed_video_renderers(MythCodecID codec_id,
    90                                            Display *XJ_disp);
     89static QStringList allowed_video_renderers(
     90    MythCodecID codec_id, Display *display, Screen *screen, Window curwin);
    9191
    9292static void SetFromEnv(bool &useXvVLD, bool &useXvIDCT, bool &useXvMC,
    9393                       bool &useXV, bool &useShm, bool &useOpenGL,
    9494                       bool &useVDPAU);
    95 static void SetFromHW(Display *d, bool &useXvMC, bool &useXV,
     95static void SetFromHW(Display *d, Screen *screen, Window curwin,
     96                      bool &useXvMC, bool &useXV,
    9697                      bool &useShm, bool &useXvMCOpenGL,
    9798                      bool &useOpenGL, bool &useVDPAU,
    9899                      MythCodecID myth_codec_id);
     
    15561557    if ((dec == "libmpeg2") || (dec == "ffmpeg"))
    15571558        return (MythCodecID)(kCodec_MPEG1 + (stream_type-1));
    15581559
    1559     Display *disp = MythXOpenDisplay();
    1560 
    15611560    // Disable features based on environment and DB values.
    15621561    bool use_xvmc_vld = false, use_xvmc_idct = false, use_xvmc = false;
    15631562    bool use_xv = true, use_shm = true, use_opengl = true;
     
    15751574
    15761575    // Disable features based on hardware capabilities.
    15771576    bool use_xvmc_opengl = use_xvmc;
    1578     SetFromHW(disp, use_xvmc, use_xv, use_shm,
     1577    Display *disp = MythXOpenDisplay();
     1578    X11L;
     1579    Screen *screen = DefaultScreenOfDisplay(disp);
     1580    Window  root   = DefaultRootWindow(disp);
     1581    X11U;
     1582    SetFromHW(disp, screen, root, use_xvmc, use_xv, use_shm,
    15791583              use_xvmc_opengl, use_opengl, use_vdpau,
    1580              (MythCodecID)(kCodec_MPEG1_VDPAU + (stream_type-1)));
     1584              (MythCodecID)(kCodec_MPEG1_VDPAU + (stream_type-1)));
    15811585
    15821586    MythCodecID ret = (MythCodecID)(kCodec_MPEG1 + (stream_type-1));
    15831587#ifdef USING_XVMC
     
    16031607    bool ok = true;
    16041608    if (test_surface && ret > kCodec_NORMAL_END)
    16051609    {
    1606         Window root;
    16071610        XvMCSurfaceInfo info;
    16081611
    16091612        ok = false;
    1610         X11S(root = DefaultRootWindow(disp));
    16111613        int port = GrabSuitableXvPort(disp, root, ret, width, height,
    16121614                                      xvmc_chroma, &info);
    16131615        if (port >= 0)
     
    17991801{
    18001802    // Figure out what video renderer to use
    18011803    db_vdisp_profile->SetInput(windows[0].GetVideoDim());
    1802     QStringList renderers = allowed_video_renderers(myth_codec_id, XJ_disp);
     1804    QStringList renderers = allowed_video_renderers(
     1805        myth_codec_id, XJ_disp, XJ_screen, XJ_curwin);
    18031806    QString     renderer  = QString::null;
    18041807
    18051808    QString tmp = db_vdisp_profile->GetVideoRenderer();
     
    49534956    if (!disp)
    49544957        return list;
    49554958
    4956     list = allowed_video_renderers(myth_codec_id, disp);
     4959    X11L;
     4960    Screen *screen = DefaultScreenOfDisplay(disp);
     4961    Window  window = DefaultRootWindow(disp);
     4962    X11U;
    49574963
     4964    list = allowed_video_renderers(myth_codec_id, disp, screen, window);
     4965
    49584966    XCloseDisplay(disp);
    49594967
    49604968    return list;
     
    49824990}
    49834991
    49844992static void SetFromHW(Display *d,
    4985                       bool &useXvMC, bool &useXVideo,
    4986                       bool &useShm,  bool &useXvMCOpenGL,
    4987                       bool &useOpenGL, bool &useVDPAU,
     4993                      Screen  *screen,    Window  curwin,
     4994                      bool    &useXvMC,   bool   &useXVideo,
     4995                      bool    &useShm,    bool   &useXvMCOpenGL,
     4996                      bool    &useOpenGL, bool   &useVDPAU,
    49884997                      MythCodecID vdpau_codec_id)
    49894998{
    49904999    (void) vdpau_codec_id;
     
    50565065        useVDPAU = false;
    50575066#ifdef USING_VDPAU
    50585067        useVDPAU = VDPAUContext::CheckCodecSupported(vdpau_codec_id);
     5068        if (useVDPAU)
     5069        {
     5070            VDPAUContext *c = new VDPAUContext();
     5071            useVDPAU = c->Init(d, screen, curwin, QSize(1920,1200), false);
     5072            c->Deinit();
     5073            delete c;
     5074        }
    50595075#endif // USING_VDPAU
    50605076    }
    50615077}
    50625078
    5063 static QStringList allowed_video_renderers(MythCodecID myth_codec_id,
    5064                                            Display *XJ_disp)
     5079static QStringList allowed_video_renderers(
     5080    MythCodecID myth_codec_id, Display *display, Screen *screen, Window curwin)
    50655081{
    50665082    bool vld, idct, mc, xv, shm, xvmc_opengl, opengl, vdpau;
    50675083
     
    50715087    xvmc_opengl = vld || idct || mc;
    50725088
    50735089    SetFromEnv(vld, idct, mc, xv, shm, opengl, vdpau);
    5074     SetFromHW(XJ_disp, mc, xv, shm, xvmc_opengl,
     5090    SetFromHW(display, screen, curwin, mc, xv, shm, xvmc_opengl,
    50755091              opengl, vdpau, myth_codec_id);
    50765092    idct &= mc;
    50775093