~ubuntu-branches/ubuntu/maverick/mythtv/maverick

« back to all changes in this revision

Viewing changes to programs/mythfrontend/playbackboxhelper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello, Dave Walker, Mario Limonciello
  • Date: 2010-02-27 14:33:45 UTC
  • mfrom: (1.1.48 upstream)
  • Revision ID: james.westby@ubuntu.com-20100227143345-qye52374g4b4caf9
Tags: 0.23.0~trunk23623-0ubuntu1
[ Dave Walker ]
* debian/control:  Added quilt as a build-depends, primarily
  for karmic builds.

[ Mario Limonciello ]
* New checkout (r23623).
  - Fixes audio issues w/ ac3 audio.
* debian/patches/36_setgroups_too:
  - Set the right args for setgroups. (LP: #524822)
* debian/rules:
  - Explicitly set all shell scripts executable.  Fixes problems on < lucid
    builds.
* debian/control:
  - Correct the replaces statements. (LP: #527288)

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
        else if (me->Message() == "GET_PREVIEW")
125
125
        {
126
126
            ProgramInfo evinfo;
127
 
            if (evinfo.FromStringList(me->ExtraDataList(), 0))
 
127
            if (evinfo.FromStringList(me->ExtraDataList(), 0) &&
 
128
                evinfo.IsFileReadable())
128
129
            {
 
130
                // Note: IsFileReadable() implicitly calls GetPlaybackURL()
 
131
                // when necessary, so we might as well update the pathname
 
132
                // in the PBB cache to avoid calling this again...
 
133
                QStringList list;
 
134
                list.push_back(evinfo.MakeUniqueKey());
 
135
                list.push_back(evinfo.pathname);            
 
136
                MythEvent *e0 = new MythEvent("SET_PLAYBACK_URL", list);
 
137
                QCoreApplication::postEvent(m_pbh.m_listener, e0);
 
138
 
129
139
                QString fn = m_pbh.GeneratePreviewImage(evinfo);
130
140
                if (!fn.isEmpty())
131
141
                {
177
187
 
178
188
            QStringList list;
179
189
            list.push_back(evinfo.MakeUniqueKey());
 
190
            list.push_back(evinfo.pathname);            
 
191
            MythEvent *e0 = new MythEvent("SET_PLAYBACK_URL", list);
 
192
            QCoreApplication::postEvent(m_pbh.m_listener, e0);
 
193
 
 
194
            list.clear();
 
195
            list.push_back(evinfo.MakeUniqueKey());
180
196
            list.push_back(QString::number((int)cat));
181
197
            list.push_back(QString::number((int)availableStatus));
182
198
            list.push_back(QString::number(evinfo.filesize));
342
358
    if (pginfo.availableStatus == asPendingDelete)
343
359
        return QString();
344
360
 
345
 
    QString filename = pginfo.GetPlaybackURL() + ".png";
 
361
    QString filename = pginfo.pathname + ".png";
346
362
 
347
363
    // If someone is asking for this preview it must be on screen
348
364
    // and hence higher priority than anything else we may have
429
445
        uint attempts = IncPreviewGeneratorAttempts(filename);
430
446
        if (attempts < PreviewGenState::maxAttempts)
431
447
        {
 
448
            VERBOSE(VB_PLAYBACK, LOC +
 
449
                    QString("Requesting preview for '%1'")
 
450
                    .arg(filename));
432
451
            PreviewGenerator::Mode mode =
433
452
                (PreviewGenerator::Mode) m_previewGeneratorMode;
434
 
            SetPreviewGenerator(filename, new PreviewGenerator(&pginfo, mode));
 
453
            PreviewGenerator *pg = new PreviewGenerator(&pginfo, mode);
 
454
            while (!SetPreviewGenerator(filename, pg)) usleep(50000);
 
455
            VERBOSE(VB_PLAYBACK, LOC +
 
456
                    QString("Requested preview for '%1'")
 
457
                    .arg(filename));
435
458
        }
436
459
        else if (attempts == PreviewGenState::maxAttempts)
437
460
        {
441
464
                    .arg(filename).arg(PreviewGenState::maxAttempts));
442
465
        }
443
466
    }
 
467
    else if (bookmark_updated || !preview_exists)
 
468
    {
 
469
        VERBOSE(VB_PLAYBACK, LOC +
 
470
                "Not requesting preview as it "
 
471
                "is already being generated");
 
472
    }
444
473
 
445
474
    UpdatePreviewGeneratorThreads();
446
475
 
492
521
bool PlaybackBoxHelper::SetPreviewGenerator(const QString &xfn, PreviewGenerator *g)
493
522
{
494
523
    QString fn = xfn.mid(max(xfn.lastIndexOf('/') + 1,0));
495
 
    QMutexLocker locker(&m_previewGeneratorLock);
 
524
 
 
525
    if (!m_previewGeneratorLock.tryLock())
 
526
        return false;
496
527
 
497
528
    if (!g)
498
529
    {
499
530
        m_previewGeneratorRunning = max(0, (int)m_previewGeneratorRunning - 1);
500
531
        PreviewMap::iterator it = m_previewGenerator.find(fn);
501
532
        if (it == m_previewGenerator.end())
 
533
        {
 
534
            m_previewGeneratorLock.unlock();
502
535
            return false;
 
536
        }
503
537
 
504
538
        (*it).gen        = NULL;
505
539
        (*it).genStarted = false;
509
543
        (*it).blockRetryUntil =
510
544
            QDateTime::currentDateTime().addSecs((*it).lastBlockTime);
511
545
 
 
546
        m_previewGeneratorLock.unlock();
512
547
        return true;
513
548
    }
514
549
 
519
554
 
520
555
    m_previewGeneratorLock.unlock();
521
556
    IncPreviewGeneratorPriority(xfn);
522
 
    m_previewGeneratorLock.lock();
523
557
 
524
558
    return true;
525
559
}
573
607
 
574
608
void PlaybackBoxHelper::previewThreadDone(const QString &fn, bool &success)
575
609
{
 
610
    VERBOSE(VB_PLAYBACK, LOC + QString("Preview for '%1' done").arg(fn));
576
611
    success = SetPreviewGenerator(fn, NULL);
577
612
    UpdatePreviewGeneratorThreads();
578
613
}
590
625
    QString xfn = pginfo->pathname + ".png";
591
626
    QString fn = xfn.mid(max(xfn.lastIndexOf('/') + 1,0));
592
627
 
 
628
    VERBOSE(VB_PLAYBACK, LOC + QString("Preview for '%1' ready")
 
629
            .arg(pginfo->pathname));
 
630
 
593
631
    m_previewGeneratorLock.lock();
594
632
    PreviewMap::iterator it = m_previewGenerator.find(fn);
595
633
    if (it != m_previewGenerator.end())
602
640
 
603
641
    if (pginfo)
604
642
    {
605
 
        QStringList extra;
606
 
        pginfo->ToStringList(extra);
607
 
        MythEvent *e = new MythEvent("GET_PREVIEW", extra);
608
 
        QCoreApplication::postEvent(m_eventHandler, e);        
 
643
        QStringList list;
 
644
        list.push_back(pginfo->MakeUniqueKey());
 
645
        list.push_back(xfn);
 
646
        MythEvent *e = new MythEvent("PREVIEW_READY", list);
 
647
        QCoreApplication::postEvent(m_listener, e);        
609
648
    }
610
649
}