Ticket #4115: 4115-v2.patch

File 4115-v2.patch, 7.3 KB (added by danielk, 16 years ago)

Updated patch for trunk

  • libs/libmythtv/tv_play.h

     
    9696
    9797    // User input processing commands
    9898    void ProcessKeypress(QKeyEvent *e);
    99     void processNetworkControlCommand(QString command);
     99    void ProcessNetworkControlCommand(const QString &command);
    100100    void customEvent(QCustomEvent *e);
    101101    bool HandleTrackAction(const QString &action);
    102102
  • libs/libmythtv/tv_play.cpp

     
    5555const int TV::kInputModeTimeout=5000;
    5656
    5757#define DEBUG_CHANNEL_PREFIX 0 /**< set to 1 to channel prefixing */
    58 #define DEBUG_ACTIONS 0 /**< set to 1 to debug actions */
     58#define DEBUG_ACTIONS 1 /**< set to 1 to debug actions */
    5959#define LOC QString("TV: ")
     60#define LOC_WARN QString("TV Warning: ")
    6061#define LOC_ERR QString("TV Error: ")
    6162
    6263/*
     
    16781679void TV::RunTV(void)
    16791680{
    16801681    paused = false;
    1681     QKeyEvent *keypressed;
    1682     QString netCmd;
    16831682
    16841683    doing_ff_rew = 0;
    16851684    ff_rew_index = kInitFFRWSpeed;
     
    17681767            getRecorderPlaybackInfo = false;
    17691768        }
    17701769
    1771         if (nvp && (keyList.count() > 0))
    1772         {
     1770        bool had_key = false;
     1771        if (nvp)
     1772        {
     1773            QKeyEvent *keypressed = NULL;
     1774
    17731775            keyListLock.lock();
    1774             keypressed = keyList.first();
    1775             keyList.removeFirst();
     1776            if (keyList.count() > 0)
     1777            {
     1778                keypressed = keyList.first();
     1779                keyList.removeFirst();
     1780            }
    17761781            keyListLock.unlock();
    17771782
    1778             ProcessKeypress(keypressed);
    1779             delete keypressed;
     1783            if (keypressed)
     1784            {
     1785                had_key = true;
     1786                ProcessKeypress(keypressed);
     1787                delete keypressed;
     1788            }
    17801789        }
    17811790
    1782         netCmd = "";
    1783         ncLock.lock();
    1784         if (networkControlCommands.size())
     1791        if (nvp && !had_key && !ignoreKeys)
    17851792        {
    1786             netCmd = networkControlCommands.front();
    1787             networkControlCommands.pop_front();
     1793            QString netCmd = QString::null;
     1794            ncLock.lock();
     1795            if (networkControlCommands.size())
     1796            {
     1797                netCmd = networkControlCommands.front();
     1798                networkControlCommands.pop_front();
     1799            }
     1800            ncLock.unlock();
     1801
     1802            if (!netCmd.isEmpty())
     1803                ProcessNetworkControlCommand(netCmd);
    17881804        }
    1789         ncLock.unlock();
    17901805
    1791         if (netCmd != "")
    1792             processNetworkControlCommand(netCmd);
    1793 
    17941806        if ((recorder && recorder->GetErrorStatus()) ||
    17951807            (nvp && nvp->IsErrored()) || IsErrored())
    17961808        {
     
    31203132    }
    31213133}
    31223134
    3123 void TV::processNetworkControlCommand(QString command)
     3135void TV::ProcessNetworkControlCommand(const QString &command)
    31243136{
     3137#ifdef DEBUG_ACTIONS
     3138    VERBOSE(VB_IMPORTANT, LOC + "ProcessNetworkControlCommand(" +
     3139            QString("%1)").arg(command));
     3140#endif
     3141
    31253142    QStringList tokens = QStringList::split(" ", command);
     3143    if (tokens.size() < 2)
     3144    {
     3145        VERBOSE(VB_IMPORTANT, LOC_ERR + "Not enough tokens"
     3146                "in network control command" + "\n\t\t\t" +
     3147                QString("'%1'").arg(command));
     3148        return;
     3149    }
    31263150
     3151    if (!dialogname.isEmpty())
     3152    {
     3153        VERBOSE(VB_IMPORTANT, LOC_WARN + "Ignoring network "
     3154                "control command\n\t\t\t" +
     3155                QString("because dialog '%1'").arg(dialogname) +
     3156                "is waiting for a response");
     3157        return;
     3158    }
     3159
    31273160    if (tokens[1] != "QUERY")
    31283161        ClearOSD();
    31293162
    31303163    if (tokens.size() == 3 && tokens[1] == "CHANID")
    31313164    {
    3132         ChangeChannel(tokens[2].toUInt(), "");
     3165        queuedChanID = tokens[2].toUInt();
     3166        queuedChanNum = QString::null;
     3167        CommitQueuedInput();
    31333168    }
    31343169    else if (tokens.size() == 3 && tokens[1] == "CHANNEL")
    31353170    {
    3136         if (tokens[2] == "UP")
    3137             ChangeChannel(CHANNEL_DIRECTION_UP);
    3138         else if (tokens[2] == "DOWN")
    3139             ChangeChannel(CHANNEL_DIRECTION_DOWN);
    3140         else if (tokens[2].contains(QRegExp("^[-\\.\\d_#]+$")))
    3141             ChangeChannel(0, tokens[2]);
     3171        uint aindx = (activenvp == nvp) ? 0 : 1;
     3172        if (StateIsLiveTV(GetState()) && !pseudoLiveTVState[aindx])
     3173        {
     3174            if (tokens[2] == "UP")
     3175                ChangeChannel(CHANNEL_DIRECTION_UP);
     3176            else if (tokens[2] == "DOWN")
     3177                ChangeChannel(CHANNEL_DIRECTION_DOWN);
     3178            else if (tokens[2].contains(QRegExp("^[-\\.\\d_#]+$")))
     3179                ChangeChannel(0, tokens[2]);
     3180        }
    31423181    }
    31433182    else if (tokens.size() == 3 && tokens[1] == "SPEED")
    31443183    {
     
    32203259        }
    32213260        else if (tokens[2].contains(QRegExp("^\\d+\\/\\d+x$")))
    32223261        {
     3262            if (activerbuffer->InDVDMenuOrStillFrame())
     3263                return;
     3264
    32233265            if (paused)
    32243266                DoPause();
    32253267
     
    32613303    }
    32623304    else if (tokens.size() >= 3 && tokens[1] == "SEEK" && activenvp)
    32633305    {
     3306        if (activerbuffer->InDVDMenuOrStillFrame())
     3307            return;
     3308
    32643309        if (tokens[2] == "BEGINNING")
    32653310            DoSeek(-activenvp->GetFramesPlayed(), tr("Jump to Beginning"));
    32663311        else if (tokens[2] == "FORWARD")
     
    57195764            if ((tokens[1] != "ANSWER") && (tokens[1] != "RESPONSE"))
    57205765            {
    57215766                ncLock.lock();
    5722                 networkControlCommands.push_back(message);
     5767                networkControlCommands.push_back(QDeepCopy<QString>(message));
    57235768                ncLock.unlock();
    57245769            }
    57255770        }
  • programs/mythfrontend/networkcontrol.cpp

     
    261261    if (result != "")
    262262    {
    263263        nrLock.lock();
    264         networkControlReplies.push_back(result);
     264        networkControlReplies.push_back(QDeepCopy<QString>(result));
    265265        nrLock.unlock();
    266266
    267267        notifyDataAvailable();
     
    296296    client = s;
    297297    cs = os;
    298298
     299    ncLock.lock();
    299300    networkControlCommands.clear();
     301    ncLock.unlock();
     302
     303    nrLock.lock();
    300304    networkControlReplies.clear();
     305    nrLock.unlock();
    301306
    302307    welcomeStr = "MythFrontend Network Control\r\n";
    303308    if (closedOldConn)
     
    332337        lineIn.replace(QRegExp("[\r\n]"), "");
    333338        lineIn.replace(QRegExp("^\\s"), "");
    334339
     340        if (lineIn.isEmpty())
     341            continue;
     342
    335343        tokens = QStringList::split(" ", lineIn);
    336344
    337345        ncLock.lock();
    338         networkControlCommands.push_back(lineIn);
     346        networkControlCommands.push_back(QDeepCopy<QString>(lineIn));
    339347        ncCond.wakeOne();
    340348        ncLock.unlock();
    341349    }
     
    831839            for (unsigned int i = 3; i < tokens.size(); i++)
    832840                response += QString(" ") + tokens[i];
    833841            nrLock.lock();
    834             networkControlReplies.push_back(response);
     842            networkControlReplies.push_back(QDeepCopy<QString>(response));
    835843            nrLock.unlock();
    836844
    837845            notifyDataAvailable();