~ubuntu-branches/ubuntu/lucid/mythtv/lucid

« back to all changes in this revision

Viewing changes to libs/libmythtv/vsync.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey), Jamie Bennett, Mario Limonciello, Dave Walker (Daviey)
  • Date: 2010-03-23 19:32:33 UTC
  • mfrom: (1.1.49 upstream)
  • Revision ID: james.westby@ubuntu.com-20100323193233-5sv9djoxtlmwt3ca
Tags: 0.23.0+fixes23789-0ubuntu1
[ Jamie Bennett ]
* Fix FTBFS on armel (LP: #537714)

[ Mario Limonciello ]
* mythtv-{common,backend}.{config,templates,postinst}: (LP: #483748)
  - Simplify debconf questions by avoiding showing the generated pw
  - Don't warn about mythtv group.
  - Don't notify about running mythtv-setup.  This is optional (but
    of course encouraged!)
* Set version to include a "+" delimitter.
* Restore libfaad-dev dependency. (LP: #546552)

[ Dave Walker (Daviey) ]
* New snapshot (r23789), based from 0.23-fixes.
* debian/control:
  - mythtv-frontend set to Conflict with mythflix, as it's dropped
    upstream. (LP: #544521)
  - Remove unnecessary and potentially problematic use of Pre-Depends.
  - Set the debug package to Priority extra.
  - Change *-perl Section's from libs to perl
  - add ${shlibs:Depends} for mythtv-common Depends field
  - Minor spelling fix.
  - Fixes the long description for one of the packages, ensuring the
    description doesn't exceed 80 characters.
  - Vcs-* set to -fixes, rather than -trunk.
* debian/rules:
  - Use debconf-updatepo to update translations when required
  - Ensure license files are not included in the binary packages, except 
    for debian/copyright.
  - Fixes the permissions of certain files in the packaging.
* debian/copyright:
  - updated to reflect that mythtv is GPL-2 only.
  - inserted better licence statement and Copyright reference.
* debian/mythtv-*.templates
  - Simplified strings; removed verbosity and improved readability.
* Prevent the maintainer scripts from failing in case any questions 
  can't be displayed.
* Added holding debian/mythtv-frontend.config, mainly to appease lintian.
* debian/mythtv-frontend.menu: Changed section to Applications/Graphics.
* debian/mythtv-backend.postinst: Load debconf libraries.
* debian/source.lintian-overrides: Removes the unecessary override of the 
  binNMU warnings.
* Fix perl binding installation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                          refresh_interval, halve_frame_interval); \
66
66
        if (trial->TryInit()) \
67
67
        { \
68
 
            m_forceskip = skip; \
69
 
            tryingVideoSync = false; \
70
 
            return trial; \
 
68
            m_forceskip = skip; \
 
69
            tryingVideoSync = false; \
 
70
            return trial; \
71
71
        } \
72
72
        delete trial; \
73
73
    } } while (false)
90
90
    if (m_forceskip)
91
91
    {
92
92
        VERBOSE(VB_PLAYBACK, QString("A previous trial crashed,"
93
 
                " skipping %1").arg(m_forceskip));
94
 
    
95
 
        skip = m_forceskip;
96
 
        m_forceskip = 0;
 
93
                " skipping %1").arg(m_forceskip));
 
94
 
 
95
        skip = m_forceskip;
 
96
        m_forceskip = 0;
97
97
    }
98
98
 
99
99
#ifdef USING_VDPAU
100
100
//    TESTVIDEOSYNC(VDPAUVideoSync);
101
 
#endif    
 
101
#endif
102
102
#ifndef _WIN32
103
103
    TESTVIDEOSYNC(DRMVideoSync);
104
104
    if (tryOpenGL)
171
171
 
172
172
/** \fn VideoSync::UpdateNexttrigger()
173
173
 *  \brief Internal method to tells video synchronization method to use
174
 
 *         the next frame (or field, if interlaced) for CalcDelay() 
 
174
 *         the next frame (or field, if interlaced) for CalcDelay()
175
175
 *         and WaitForFrame().
176
176
 */
177
177
void VideoSync::UpdateNexttrigger()
189
189
 *
190
190
 *   Regardless of the timing method, if delay is greater than four full
191
191
 *   frames (could be greater than 20 or greater than 200), we don't want
192
 
 *   to freeze while waiting for a huge delay. Instead, contine playing 
 
192
 *   to freeze while waiting for a huge delay. Instead, contine playing
193
193
 *   video at half speed and continue to read new audio and video frames
194
194
 *   from the file until the sync is 'in the ballpark'.
195
195
 *   Also prevent the nexttrigger from falling too far in the past in case
199
199
{
200
200
    struct timeval now;
201
201
    gettimeofday(&now, NULL);
202
 
    //cout << "CalcDelay: next: " << timeval_str(m_nexttrigger) << " now " 
 
202
    //cout << "CalcDelay: next: " << timeval_str(m_nexttrigger) << " now "
203
203
    // << timeval_str(now) << endl;
204
 
        
 
204
 
205
205
    int ret_val = (m_nexttrigger.tv_sec - now.tv_sec) * 1000000 +
206
206
                  (m_nexttrigger.tv_usec - now.tv_usec);
207
207
 
314
314
                " %1, %2").arg(sm_dri_dev).arg(strerror(errno)));
315
315
        return false; // couldn't open device
316
316
    }
317
 
    
 
317
 
318
318
    blank.request.type = DRM_VBLANK_RELATIVE;
319
319
    blank.request.sequence = 1;
320
320
    if (drmWaitVBlank(m_dri_fd, &blank))
334
334
    blank.request.type = DRM_VBLANK_RELATIVE;
335
335
    blank.request.sequence = 1;
336
336
    drmWaitVBlank(m_dri_fd, &blank);
337
 
    VideoSync::Start(); 
 
337
    VideoSync::Start();
338
338
}
339
339
 
340
340
void DRMVideoSync::WaitForFrame(int sync_delay)
341
341
{
342
342
    // Offset for externally-provided A/V sync delay
343
343
    OffsetTimeval(m_nexttrigger, sync_delay);
344
 
    
 
344
 
345
345
    m_delay = CalcDelay();
346
346
    //cerr << "WaitForFrame at : " << m_delay;
347
347
 
348
348
    // Always sync to the next retrace execpt when we are very late.
349
 
    if (m_delay > -(m_refresh_interval/2)) 
 
349
    if (m_delay > -(m_refresh_interval/2))
350
350
    {
351
351
        drm_wait_vblank_t blank;
352
352
        blank.request.type = DRM_VBLANK_RELATIVE;
492
492
        err = gMythGLXWaitVideoSyncSGI(2, (count+1)%2 ,&count);
493
493
        checkGLSyncError("OpenGLVideoSync::Start(): A/V Sync", err);
494
494
    }
495
 
    // Initialize next trigger 
 
495
    // Initialize next trigger
496
496
    VideoSync::Start();
497
497
#endif /* USING_OPENGL_VSYNC */
498
498
}
517
517
    if (!m_context)
518
518
        return;
519
519
    unsigned int frameNum = 0;
520
 
    
 
520
 
521
521
    OpenGLContextLocker ctx_lock(m_context);
522
522
    err = gMythGLXGetVideoSyncSGI(&frameNum);
523
523
    checkGLSyncError("Frame Number Query", err);
524
524
 
525
525
    // Always sync to the next retrace execpt when we are very late.
526
 
    if ((m_delay = CalcDelay()) > -(m_refresh_interval/2)) 
 
526
    if ((m_delay = CalcDelay()) > -(m_refresh_interval/2))
527
527
    {
528
528
        err = gMythGLXWaitVideoSyncSGI(2, (frameNum+1)%2 ,&frameNum);
529
529
        checkGLSyncError(msg1, err);
538
538
        checkGLSyncError(msg2, err);
539
539
        m_delay = CalcDelay();
540
540
    }
541
 
    
 
541
 
542
542
#endif /* USING_OPENGL_VSYNC */
543
543
}
544
544
 
590
590
                "timer interrupts, %1.").arg(strerror(errno)));
591
591
        return false;
592
592
    }
593
 
    
 
593
 
594
594
    return true;
595
595
}
596
596
 
658
658
#endif
659
659
 
660
660
BusyWaitVideoSync::BusyWaitVideoSync(VideoOutput *vo,
661
 
                                     int fr, int ri, bool intl) : 
662
 
    VideoSync(vo, fr, ri, intl) 
 
661
                                     int fr, int ri, bool intl) :
 
662
    VideoSync(vo, fr, ri, intl)
663
663
{
664
664
    m_cheat = 5000;
665
665
    m_fudge = 0;
689
689
        // the CPU early for about half the frames.
690
690
        if (m_delay > (m_cheat - m_fudge))
691
691
            usleep(m_delay - (m_cheat - m_fudge));
692
 
        
 
692
 
693
693
        // If late, draw the frame ASAP.  If early, hold the CPU until
694
694
        // half as late as the previous frame (fudge).
695
695
        m_delay = CalcDelay();
711
711
}
712
712
 
713
713
USleepVideoSync::USleepVideoSync(VideoOutput *vo,
714
 
                                 int fr, int ri, bool intl) : 
 
714
                                 int fr, int ri, bool intl) :
715
715
    VideoSync(vo, fr, ri, intl)
716
716
{
717
717
}
729
729
{
730
730
    // Offset for externally-provided A/V sync delay
731
731
    OffsetTimeval(m_nexttrigger, sync_delay);
732
 
    
 
732
 
733
733
    m_delay = CalcDelay();
734
734
    if (m_delay > 0)
735
735
        usleep(m_delay);