Ticket #2426: embed_playback_part2.2.diff

File embed_playback_part2.2.diff, 17.0 KB (added by skamithi, 14 years ago)

remove pbinfolock around runplaybackbox call in tv_play.cpp .

  • libs/libmythtv/libmythtv.pro

     
    139139HEADERS += playgroup.h              progdetails.h
    140140HEADERS += channeleditor.h          channelsettings.h
    141141HEADERS += previewgenerator.h       dvbtransporteditor.h
     142HEADERS += playbackbox.h
    142143
    143144SOURCES += programinfo.cpp          proglist.cpp
    144145SOURCES += RingBuffer.cpp
     
    160161SOURCES += progdetails.cpp
    161162SOURCES += channeleditor.cpp        channelsettings.cpp
    162163SOURCES += previewgenerator.cpp     dvbtransporteditor.cpp
     164SOURCES += playbackbox.cpp
    163165
    164166# DiSEqC
    165167HEADERS += diseqc.h                 diseqcsettings.h
  • libs/libmythtv/tv_play.h

     
    6868enum scheduleEditTypes {
    6969    kScheduleProgramGuide = 0,
    7070    kScheduleProgramFinder,
    71     kScheduledRecording
     71    kScheduledRecording,
     72    kPlaybackBox,
    7273};
    7374
    7475class MPUBLIC TV : public QObject
     
    112113    // Recording commands
    113114    int  PlayFromRecorder(int recordernum);
    114115    int  Playback(ProgramInfo *rcinfo);
     116
     117    // Various commands
    115118    void setLastProgram(ProgramInfo *rcinfo);
    116119    ProgramInfo *getLastProgram(void) { return lastProgram; }
    117120    void setInPlayList(bool setting) { inPlaylist = setting; }
    118121    void setUnderNetworkControl(bool setting) { underNetworkControl = setting; }
     122    bool IsSameProgram(ProgramInfo *p);
    119123
    120     // Various commands
    121124    void ShowNoRecorderDialog(void);
    122125    void FinishRecording(void);
    123126    void AskAllowRecording(const QStringList&, int, bool);
     
    194197    static void *EPGMenuHandler(void *param);
    195198    static void *FinderMenuHandler(void *param);
    196199    static void *ScheduleMenuHandler(void *param);
     200    static void *RecordedShowMenuHandler(void *param);
    197201
    198202    void RunTV(void);
    199203    static void *EventThread(void *param);
     
    297301    void SetAutoCommercialSkip(enum commSkipMode skipMode = CommSkipOff);
    298302    void SetManualZoom(bool zoomON = false);
    299303
    300     void DoDisplayJumpMenu(void);
    301304    void SetJumpToProgram(QString progKey = "", int progIndex = 0);
    302305 
    303306    bool ClearOSD(void);
     
    325328    void ToggleActiveWindow(void);
    326329    void SwapPIP(void);
    327330    void SwapPIPSoon(void) { needToSwapPIP = true; }
    328     void DisplayJumpMenuSoon(void) { needToJumpMenu = true; }
    329331
    330332    void ToggleAutoExpire(void);
    331333
     
    426428
    427429    bool ignoreKeys;
    428430    bool needToSwapPIP;
    429     bool needToJumpMenu;
    430431    QMap<QString,ProgramList> progLists;
    431432
    432433    mutable QMutex chanEditMapLock; ///< Lock for chanEditMap and ddMap
  • libs/libmythtv/tv_play.cpp

     
    3939#include "DVDRingBuffer.h"
    4040#include "datadirect.h"
    4141#include "sourceutil.h"
     42#include "playbackbox.h"
    4243
    4344#ifndef HAVE_ROUND
    4445#define round(x) ((int) ((x) + 0.5))
     
    415416      queuedTranscode(false), getRecorderPlaybackInfo(false),
    416417      adjustingPicture(kAdjustingPicture_None),
    417418      adjustingPictureAttribute(kPictureAttribute_None),
    418       ignoreKeys(false), needToSwapPIP(false), needToJumpMenu(false),
     419      ignoreKeys(false), needToSwapPIP(false),
    419420      // Channel Editing
    420421      chanEditMapLock(true), ddMapSourceId(0), ddMapLoaderRunning(false),
    421422      // Sleep Timer
     
    19351936            SwapPIP();
    19361937            needToSwapPIP = false;
    19371938        }
    1938 
    1939         if (needToJumpMenu)
    1940         {
    1941             DoDisplayJumpMenu();
    1942             needToJumpMenu = false;
    1943         }
    19441939    }
    19451940 
    19461941    if (!IsErrored() && (GetState() != kState_None))
     
    26852680            jumpToProgram = true;
    26862681        }
    26872682        else if (action == "JUMPREC")
    2688             DisplayJumpMenuSoon();
     2683            EditSchedule(kPlaybackBox);
    26892684        else if (action == "SIGNALMON")
    26902685        {
    26912686            if ((GetState() == kState_WatchingLiveTV) && activerecorder)
     
    49384933    pbinfoLock.unlock();
    49394934
    49404935    bool changeChannel = false;
     4936    ProgramInfo *nextProgram = NULL;
    49414937
    49424938    if (StateIsLiveTV(GetState()))
    49434939    {
     
    49674963                    RunProgramFind(true, false);
    49684964                    break;
    49694965            case kScheduledRecording:
     4966            {
    49704967                    pbinfoLock.lock();
    49714968                    ScheduledRecording record;
    49724969                    record.loadByProgram(playbackinfo);
    49734970                    record.exec();
    49744971                    pbinfoLock.unlock();
    49754972                    break;
     4973            }
     4974            case kPlaybackBox:
     4975            {
     4976                    nextProgram = PlaybackBox::RunPlaybackBox(this, true);
     4977                    if (nextProgram)
     4978                    {
     4979                        setLastProgram(nextProgram);
     4980                        jumpToProgram = true;
     4981                        exitPlayer = true;
     4982                        delete nextProgram;
     4983                    }
     4984                    break;
     4985            }
    49764986        }
    49774987
    49784988        if (!stayPaused)
     
    50185028    return NULL;
    50195029}
    50205030
     5031void *TV::RecordedShowMenuHandler(void *param)
     5032{
     5033    TV *obj = (TV *)param;
     5034    obj->doEditSchedule(kPlaybackBox);
     5035
     5036    return NULL;
     5037}
     5038
    50215039void TV::EditSchedule(int editType)
    50225040{
    50235041    if (menurunning == true)
     
    50405058        case kScheduledRecording:
    50415059                pthread_create(&tid, &attr, TV::ScheduleMenuHandler, this);
    50425060                break;
     5061        case kPlaybackBox:
     5062                pthread_create(&tid, &attr, TV::RecordedShowMenuHandler, this);
    50435063    }
    50445064}
    50455065
     
    63356355            jumpToProgram = true;
    63366356        }
    63376357        else if (action == "JUMPREC")
    6338             DisplayJumpMenuSoon();
     6358            EditSchedule(kPlaybackBox);
    63396359        else if (action.left(8) == "JUMPPROG")
    63406360        {
    63416361            SetJumpToProgram(action.section(" ",1,-2),
     
    63666386    }
    63676387}
    63686388
    6369 void TV::DoDisplayJumpMenu(void)
    6370 {
    6371     if (treeMenu)
    6372         delete treeMenu;
    6373 
    6374     treeMenu = new OSDGenericTree(NULL, "treeMenu");
    6375     OSDGenericTree *item, *subitem;
    6376 
    6377     // Build jumpMenu of recorded program titles
    6378     ProgramInfo *p;
    6379     progLists.clear();
    6380     vector<ProgramInfo *> *infoList;
    6381     infoList = RemoteGetRecordedList(false);
    6382 
    6383     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
    6384 
    6385     if (infoList)
    6386     {
    6387         pbinfoLock.lock();
    6388         vector<ProgramInfo *>::iterator i = infoList->begin();
    6389         for ( ; i != infoList->end(); i++)
    6390         {
    6391             p = *i;
    6392             //if (p->recgroup != "LiveTV" || LiveTVInAllPrograms)
    6393             if (p->recgroup == playbackinfo->recgroup)
    6394                 progLists[p->title].prepend(p);
    6395         }
    6396         pbinfoLock.unlock();
    6397 
    6398         QMap<QString,ProgramList>::Iterator Iprog;
    6399         for (Iprog = progLists.begin(); Iprog != progLists.end(); Iprog++)
    6400         {
    6401             ProgramList plist = Iprog.data();
    6402             int progIndex = plist.count();
    6403             if (progIndex == 1)
    6404             {
    6405                 item = new OSDGenericTree(treeMenu, tr(Iprog.key()),
    6406                     QString("JUMPPROG %1 0").arg(Iprog.key()));
    6407             }
    6408             else
    6409             {
    6410                 item = new OSDGenericTree(treeMenu, tr(Iprog.key()));
    6411                 for (int i = 0; i < progIndex; i++)
    6412                 {
    6413                     p = plist.at(i);
    6414                     if (p->subtitle != "")
    6415                         subitem = new OSDGenericTree(item, tr(p->subtitle),
    6416                             QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i));
    6417                     else
    6418                         subitem = new OSDGenericTree(item, tr(p->title),
    6419                             QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i));
    6420                 }
    6421             }
    6422         }
    6423     }
    6424 
    6425     if (GetOSD())
    6426     {
    6427         ClearOSD();
    6428 
    6429         OSDListTreeType *tree = GetOSD()->ShowTreeMenu("menu", treeMenu);
    6430         if (tree)
    6431         {
    6432             connect(tree, SIGNAL(itemSelected(OSDListTreeType *,OSDGenericTree *)),
    6433                     this, SLOT(TreeMenuSelected(OSDListTreeType *, OSDGenericTree *)));
    6434 
    6435             connect(tree, SIGNAL(itemEntered(OSDListTreeType *, OSDGenericTree *)),
    6436                     this, SLOT(TreeMenuEntered(OSDListTreeType *, OSDGenericTree *)));
    6437         }
    6438     }
    6439 }
    6440 
    64416389void TV::ShowOSDTreeMenu(void)
    64426390{
    64436391    BuildOSDTreeMenu();
     
    74017349        lastProgram = NULL;
    74027350}
    74037351
     7352bool TV::IsSameProgram(ProgramInfo *rcinfo)
     7353{
     7354    if (rcinfo && playbackinfo)
     7355        return playbackinfo->IsSameProgram(*rcinfo);
     7356
     7357    return false;
     7358}
     7359
    74047360/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • programs/mythfrontend/playbackbox.cpp

     
    1616#include <qfileinfo.h>
    1717#include <qsqldatabase.h>
    1818#include <qmap.h>
     19#include <qwaitcondition.h>
    1920
    2021#include <cmath>
    2122#include <unistd.h>
     
    5051
    5152#define USE_PREV_GEN_THREAD
    5253
     54QWaitCondition pbbIsVisibleCond;
     55
    5356static int comp_programid(ProgramInfo *a, ProgramInfo *b)
    5457{
    5558    if (a->programid == b->programid)
     
    185188        return (a->startts.date() > b->startts.date() ? 1 : -1);
    186189}
    187190
     191
     192ProgramInfo * PlaybackBox::RunPlaybackBox(TV *player, bool thread)
     193{
     194    ProgramInfo *nextProgram = NULL;
     195    if (thread)
     196        qApp->lock();
     197
     198    PlaybackBox *pbb = new PlaybackBox(PlaybackBox::Play,
     199            gContext->GetMainWindow(), "tvplayselect", player);
     200    pbb->Show();
     201
     202    if (thread)
     203    {
     204        qApp->unlock();
     205        pbbIsVisibleCond.wait();
     206    }
     207    else
     208        pbb->exec();
     209
     210    if (pbb->getSelected())
     211        nextProgram = new ProgramInfo(*pbb->getSelected());
     212   
     213    delete pbb;
     214   
     215    return nextProgram;
     216}
     217
    188218PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent,
    189                          const char *name)
     219                         const char *name, TV *player)
    190220    : MythDialog(parent, name),
    191221      // Settings
    192222      type(ltype),
     
    248278      previewPixmapEnabled(false),      previewPixmap(NULL),
    249279      previewSuspend(false),            previewChanid(""),
    250280      // Network Control Variables
    251       underNetworkControl(false)
     281      underNetworkControl(false),
     282      m_player(NULL)
    252283{
    253284    formatShortDate    = gContext->GetSetting("ShortDateFormat", "M/d");
    254285    formatLongDate     = gContext->GetSetting("DateFormat", "ddd MMMM d");
     
    263294    groupnameAsAllProg = gContext->GetNumSetting("DispRecGroupAsAllProg", 0);
    264295    arrowAccel         = gContext->GetNumSetting("UseArrowAccels", 1);
    265296    inTitle            = gContext->GetNumSetting("PlaybackBoxStartInTitle", 0);
    266     previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview");
     297    if (!player)
     298        previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview");
    267299    previewPixmapEnabled=gContext->GetNumSetting("GeneratePreviewPixmaps");
    268300    previewFromBookmark= gContext->GetNumSetting("PreviewFromBookmark");
    269301    drawTransPixmap    = gContext->LoadScalePixmap("trans-backup.png");
     
    283315    titleList << "";
    284316    playList.clear();
    285317
     318    if (player)
     319        m_player = player;
     320
    286321    // recording group stuff
    287322    recGroupType.clear();
    288323    recGroupType[recGroup] = (displayCat) ? "category" : "recgroup";
     
    369404    gContext->removeListener(this);
    370405    gContext->removeCurrentLocation();
    371406
    372     killPlayerSafe();
     407    if (!m_player)
     408        killPlayerSafe();
    373409
    374410    if (previewVideoRefreshTimer)
    375411    {
     
    566602
    567603void PlaybackBox::exitWin()
    568604{
    569     killPlayerSafe();
     605    if (m_player)
     606    {
     607        if (curitem)
     608            delete curitem;
     609        curitem = NULL;
     610        pbbIsVisibleCond.wakeAll();
     611    }
     612    else
     613        killPlayerSafe();
     614
    570615    accept();
    571616}
    572617
     
    12471292                if (playList.grep(tempInfo->MakeUniqueKey()).count())
    12481293                    ltype->EnableForcedFont(cnt, "tagged");
    12491294
    1250                 if (tempInfo->availableStatus != asAvailable)
     1295                if (tempInfo->availableStatus != asAvailable ||
     1296                        (m_player && m_player->IsSameProgram(tempInfo)))
    12511297                    ltype->EnableForcedFont(cnt, "inactive");
    12521298            }
    12531299        }
     
    20792125    if (!curitem)
    20802126        return;
    20812127
     2128    if (m_player && m_player->IsSameProgram(curitem))
     2129        exitWin();
     2130
    20822131    if (curitem && curitem->availableStatus != asAvailable)
    20832132        showAvailablePopup(curitem);
    20842133    else
    20852134        play(curitem);
     2135
     2136    if (m_player)
     2137    {
     2138        pbbIsVisibleCond.wakeAll();
     2139        accept();
     2140    }
    20862141}
    20872142
    20882143void PlaybackBox::stopSelected()
     
    22112266        popup->addButton(tr("Playlist options"), this,
    22122267                         SLOT(showPlaylistPopup()));
    22132268    }
    2214     else
     2269    else if (!m_player)
    22152270    {
    22162271        if (inTitle)
    22172272        {
     
    22542309    if (!rec)
    22552310        return false;
    22562311
     2312    if (m_player)
     2313        return true;
     2314           
    22572315    if (fileExists(rec) == false)
    22582316    {
    22592317        QString msg =
     
    29122970
    29132971    initPopup(popup, program, "", "");
    29142972
    2915     QButton *playButton;
     2973    QButton *playButton = new QButton();
    29162974
    2917     if (curitem->programflags & FL_BOOKMARK)
    2918         playButton = popup->addButton(tr("Play from..."), this,
    2919                                       SLOT(showPlayFromPopup()));
    2920     else
    2921         playButton = popup->addButton(tr("Play"), this, SLOT(doPlay()));
     2975    if (!(m_player && m_player->IsSameProgram(curitem)))
     2976    {
     2977        if (curitem->programflags & FL_BOOKMARK)
     2978            popup->addButton(tr("Play from..."), this,
     2979                                        SLOT(showPlayFromPopup()));
     2980        else
     2981            popup->addButton(tr("Play"), this, SLOT(doPlay()));
     2982    }
    29222983
    2923     if (playList.grep(curitem->MakeUniqueKey()).count())
    2924         popup->addButton(tr("Remove from Playlist"), this,
    2925                          SLOT(togglePlayListItem()));
    2926     else
    2927         popup->addButton(tr("Add to Playlist"), this,
    2928                          SLOT(togglePlayListItem()));
     2984    if (!m_player)
     2985    {
     2986        if (playList.grep(curitem->MakeUniqueKey()).count())
     2987            popup->addButton(tr("Remove from Playlist"), this,
     2988                            SLOT(togglePlayListItem()));
     2989        else
     2990            popup->addButton(tr("Add to Playlist"), this,
     2991                            SLOT(togglePlayListItem()));
     2992    }
    29292993
    29302994    if (program->recstatus == rsRecording)
    29312995        popup->addButton(tr("Stop Recording"), this, SLOT(askStop()));
     
    29413005    popup->addButton(tr("Recording Options"), this, SLOT(showRecordingPopup()));
    29423006    popup->addButton(tr("Job Options"), this, SLOT(showJobPopup()));
    29433007
    2944     popup->addButton(tr("Delete"), this, SLOT(askDelete()));
     3008    if (!(m_player && m_player->IsSameProgram(curitem)))
     3009        popup->addButton(tr("Delete"), this, SLOT(askDelete()));
    29453010
    29463011    popup->ShowPopup(this, SLOT(doCancel()));
    29473012
  • programs/mythfrontend/mythfrontend.pro

     
    2323QMAKE_CLEAN += $(TARGET)
    2424
    2525# Input
    26 HEADERS += manualbox.h playbackbox.h viewscheduled.h globalsettings.h
     26HEADERS += manualbox.h viewscheduled.h globalsettings.h
    2727HEADERS += manualschedule.h programrecpriority.h channelrecpriority.h
    2828HEADERS += statusbox.h networkcontrol.h
    2929
    30 SOURCES += main.cpp manualbox.cpp playbackbox.cpp viewscheduled.cpp
     30SOURCES += main.cpp manualbox.cpp viewscheduled.cpp
    3131SOURCES += globalsettings.cpp manualschedule.cpp programrecpriority.cpp
    3232SOURCES += channelrecpriority.cpp statusbox.cpp networkcontrol.cpp
    3333
  • programs/mythfrontend/playbackbox.h

     
    1313#include "xmlparse.h"
    1414#include "programinfo.h"
    1515#include "jobqueue.h"
     16#include "tv_play.h"
    1617
    1718#include <qvaluelist.h>
    1819#include <pthread.h>
     
    9899    } killStateType;
    99100     
    100101
    101     PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0);
     102    PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0, TV *player = NULL);
    102103   ~PlaybackBox(void);
    103104   
    104105    void customEvent(QCustomEvent *e);
    105  
     106    static ProgramInfo *RunPlaybackBox(TV *player, bool thread = false);
     107   
     108   
    106109  protected slots:
    107110    void timeout(void);
    108111
     
    246249    void stop(ProgramInfo *);
    247250    void remove(ProgramInfo *);
    248251    void showActions(ProgramInfo *);
     252    ProgramInfo *getSelected(void){ return curitem; }
     253       
    249254
    250255    void togglePlayListItem(ProgramInfo *pginfo);
    251256    void randomizePlayList(void);
     
    451456    mutable QMutex      ncLock;
    452457    QValueList<QString> networkControlCommands;
    453458    bool                underNetworkControl;
     459   
     460    TV                  *m_player;
    454461};
    455462
    456463#endif