Ticket #4115: 4115-fixes-v1.patch

File 4115-fixes-v1.patch, 6.9 KB (added by danielk, 16 years ago)

Backports network control changes to 0.20-fixes

  • libs/libmythtv/tv_play.cpp

     
    5353const int TV::kInputModeTimeout=5000;
    5454
    5555#define DEBUG_CHANNEL_PREFIX 0 /**< set to 1 to channel prefixing */
    56 #define DEBUG_ACTIONS 0 /**< set to 1 to debug actions */
     56#define DEBUG_ACTIONS 1 /**< set to 1 to debug actions */
    5757#define LOC QString("TV: ")
     58#define LOC_WARN QString("TV Warning: ")
    5859#define LOC_ERR QString("TV Error: ")
    5960
    6061void TV::InitKeys(void)
     
    14801481void TV::RunTV(void)
    14811482{
    14821483    paused = false;
    1483     QKeyEvent *keypressed;
    1484     QString netCmd;
    14851484
    14861485    doing_ff_rew = 0;
    14871486    ff_rew_index = kInitFFRWSpeed;
     
    15701569            getRecorderPlaybackInfo = false;
    15711570        }
    15721571
    1573         if (nvp && (keyList.count() > 0))
    1574         {
     1572        bool had_key = false;
     1573        if (nvp)
     1574        {
     1575            QKeyEvent *keypressed = NULL;
     1576
    15751577            keyListLock.lock();
    1576             keypressed = keyList.first();
    1577             keyList.removeFirst();
     1578            if (keyList.count() > 0)
     1579            {
     1580                keypressed = keyList.first();
     1581                keyList.removeFirst();
     1582            }
    15781583            keyListLock.unlock();
    15791584
    1580             ProcessKeypress(keypressed);
    1581             delete keypressed;
     1585            if (keypressed)
     1586            {
     1587                had_key = true;
     1588                ProcessKeypress(keypressed);
     1589                delete keypressed;
     1590            }
    15821591        }
    15831592
    1584         netCmd = "";
    1585         ncLock.lock();
    1586         if (networkControlCommands.size())
     1593        if (nvp && !had_key && !ignoreKeys)
    15871594        {
    1588             netCmd = networkControlCommands.front();
    1589             networkControlCommands.pop_front();
     1595            QString netCmd = QString::null;
     1596            ncLock.lock();
     1597            if (networkControlCommands.size())
     1598            {
     1599                netCmd = networkControlCommands.front();
     1600                networkControlCommands.pop_front();
     1601            }
     1602            ncLock.unlock();
     1603
     1604            if (!netCmd.isEmpty())
     1605                processNetworkControlCommand(netCmd);
    15901606        }
    1591         ncLock.unlock();
    15921607
    1593         if (netCmd != "")
    1594             processNetworkControlCommand(netCmd);
    1595 
    15961608        if ((recorder && recorder->GetErrorStatus()) ||
    15971609            (nvp && nvp->IsErrored()) || IsErrored())
    15981610        {
     
    27672779
    27682780void TV::processNetworkControlCommand(QString command)
    27692781{
     2782#ifdef DEBUG_ACTIONS
     2783    VERBOSE(VB_IMPORTANT, LOC + "ProcessNetworkControlCommand(" +
     2784            QString("%1)").arg(command));
     2785#endif
     2786
    27702787    QStringList tokens = QStringList::split(" ", command);
     2788    if (tokens.size() < 2)
     2789    {
     2790        VERBOSE(VB_IMPORTANT, LOC_ERR + "Not enough tokens"
     2791                "in network control command" + "\n\t\t\t" +
     2792                QString("'%1'").arg(command));
     2793        return;
     2794    }
    27712795
     2796    if (!dialogname.isEmpty())
     2797    {
     2798        VERBOSE(VB_IMPORTANT, LOC_WARN + "Ignoring network "
     2799                "control command\n\t\t\t" +
     2800                QString("because dialog '%1'").arg(dialogname) +
     2801                "is waiting for a response");
     2802        return;
     2803    }
     2804
    27722805    if (tokens[1] != "QUERY")
    27732806        ClearOSD();
    27742807
    27752808    if (tokens.size() == 3 && tokens[1] == "CHANID")
    27762809    {
    2777         ChangeChannel(tokens[2].toUInt(), "");
     2810        queuedChanID = tokens[2].toUInt();
     2811        queuedChanNum = QString::null;
     2812        CommitQueuedInput();
    27782813    }
    27792814    else if (tokens.size() == 3 && tokens[1] == "CHANNEL")
    27802815    {
    2781         if (tokens[2] == "UP")
    2782             ChangeChannel(CHANNEL_DIRECTION_UP);
    2783         else if (tokens[2] == "DOWN")
    2784             ChangeChannel(CHANNEL_DIRECTION_DOWN);
    2785         else if (tokens[2].contains(QRegExp("^[-\\.\\d_#]+$")))
    2786             ChangeChannel(0, tokens[2]);
     2816        uint aindx = (activenvp == nvp) ? 0 : 1;
     2817        if (StateIsLiveTV(GetState()) && !pseudoLiveTVState[aindx])
     2818        {
     2819            if (tokens[2] == "UP")
     2820                ChangeChannel(CHANNEL_DIRECTION_UP);
     2821            else if (tokens[2] == "DOWN")
     2822                ChangeChannel(CHANNEL_DIRECTION_DOWN);
     2823            else if (tokens[2].contains(QRegExp("^[-\\.\\d_#]+$")))
     2824                ChangeChannel(0, tokens[2]);
     2825        }
    27872826    }
    27882827    else if (tokens.size() == 3 && tokens[1] == "SPEED")
    27892828    {
     
    28652904        }
    28662905        else if (tokens[2].contains(QRegExp("^\\d+\\/\\d+x$")))
    28672906        {
     2907            if (activerbuffer->InDVDMenuOrStillFrame())
     2908                return;
     2909
    28682910            if (paused)
    28692911                DoPause();
    28702912
     
    29042946    }
    29052947    else if (tokens.size() >= 3 && tokens[1] == "SEEK" && activenvp)
    29062948    {
     2949        if (activerbuffer->InDVDMenuOrStillFrame())
     2950            return;
     2951
    29072952        if (tokens[2] == "BEGINNING")
    29082953            DoSeek(-activenvp->GetFramesPlayed(), tr("Jump to Beginning"));
    29092954        else if (tokens[2] == "FORWARD")
     
    51985243            if ((tokens[1] != "ANSWER") && (tokens[1] != "RESPONSE"))
    51995244            {
    52005245                ncLock.lock();
    5201                 networkControlCommands.push_back(message);
     5246                networkControlCommands.push_back(QDeepCopy<QString>(message));
    52025247                ncLock.unlock();
    52035248            }
    52045249        }
  • programs/mythfrontend/networkcontrol.cpp

     
    192192    if (result != "")
    193193    {
    194194        nrLock.lock();
    195         networkControlReplies.push_back(result);
     195        networkControlReplies.push_back(QDeepCopy<QString>(result));
    196196        nrLock.unlock();
    197197
    198198        notifyDataAvailable();
     
    227227    client = s;
    228228    cs = os;
    229229
     230    ncLock.lock();
    230231    networkControlCommands.clear();
     232    ncLock.unlock();
     233
     234    nrLock.lock();
    231235    networkControlReplies.clear();
     236    nrLock.unlock();
    232237
    233238    welcomeStr = "MythFrontend Network Control\r\n";
    234239    if (closedOldConn)
     
    263268        lineIn.replace(QRegExp("[\r\n]"), "");
    264269        lineIn.replace(QRegExp("^\\s"), "");
    265270
     271        if (lineIn.isEmpty())
     272            continue;
     273
    266274        tokens = QStringList::split(" ", lineIn);
    267         if (tokens[0].lower() != "key")
     275        if (tokens.size() && (tokens[0].lower() != "key"))
    268276            lineIn = lineIn.lower();
    269277
    270278        ncLock.lock();
    271         networkControlCommands.push_back(lineIn);
     279        networkControlCommands.push_back(QDeepCopy<QString>(lineIn));
    272280        ncLock.unlock();
    273281    }
    274282}
     
    723731            for (unsigned int i = 3; i < tokens.size(); i++)
    724732                response += QString(" ") + tokens[i];
    725733            nrLock.lock();
    726             networkControlReplies.push_back(response);
     734            networkControlReplies.push_back(QDeepCopy<QString>(response));
    727735            nrLock.unlock();
    728736
    729737            notifyDataAvailable();