Ticket #8718: indent-fixed-playspeed.patch

File indent-fixed-playspeed.patch, 15.0 KB (added by james.barrett@…, 14 years ago)

Fix for playspeed control and redout formatted correctly (hopefully)

  • mythtv/libs/libmythtv/playercontext.cpp

    diff --git a/mythtv/libs/libmythtv/playercontext.cpp b/mythtv/libs/libmythtv/playercontext.cpp
    index e177851..2929908 100644
    a b QString PlayerContext::GetFilters(const QString &baseFilters) const 
    815815QString PlayerContext::GetPlayMessage(void) const
    816816{
    817817    QString mesg = QObject::tr("Play");
    818     if (ts_normal != 1.0)
    819         mesg += QString(" %1X").arg(ts_normal);
    820 
     818    if (ts_normal != 1.0)
     819    {
     820        if (ts_normal == 0.5)
     821            mesg += QString(" 1/2x");
     822        else if (0.32 < ts_normal && ts_normal < 0.34)
     823        {
     824            mesg += QString(" 1/3x");
     825        }
     826        else if (ts_normal == 0.25)
     827            mesg += QString(" 1/4x");
     828        else if (ts_normal == 0.125)
     829            mesg += QString(" 1/8x");
     830        else if (ts_normal == 0.0625)
     831            mesg += QString(" 1/16x");
     832        else
     833            mesg += QString(" %1X").arg(ts_normal);
     834    }
     835   
    821836    if (0)
    822837    {
    823838        QMutexLocker locker(&deletePlayerLock);
    QString PlayerContext::GetPlayMessage(void) const 
    825840        if (is_progressive(scan) || is_interlaced(scan))
    826841            mesg += " (" + toString(scan, true) + ")";
    827842    }
    828 
     843   
    829844    return mesg;
    830845}
    831846
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index 0f05584..8c2d0f6 100644
    a b void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    44844484    else if (tokens.size() == 3 && tokens[1] == "SPEED")
    44854485    {
    44864486        if (tokens[2] == "0x")
    4487         {
     4487        {
    44884488            NormalSpeed(ctx);
    44894489            StopFFRew(ctx);
    4490 
     4490           
    44914491            if (!ctx->paused)
    4492                 DoTogglePause(ctx, true);
    4493         }
    4494         else if (tokens[2].contains(QRegExp("^\\-*\\d+x$")))
    4495         {
    4496             QString speed = tokens[2].left(tokens[2].length()-1);
    4497             bool ok = false;
    4498             int tmpSpeed = speed.toInt(&ok);
    4499             int searchSpeed = abs(tmpSpeed);
    4500             unsigned int index;
    4501 
    4502             if (ctx->paused)
    4503                 DoTogglePause(ctx, true);
    4504 
    4505             if (tmpSpeed == 1)
    4506             {
    4507                 StopFFRew(ctx);
    4508                 ctx->ts_normal = 1.0f;
    4509                 ChangeTimeStretch(ctx, 0, false);
    4510 
    4511                 ReturnPlayerLock(ctx);
    4512                 return;
    4513             }
    4514 
    4515             NormalSpeed(ctx);
    4516 
    4517             for (index = 0; index < ff_rew_speeds.size(); index++)
    4518                 if (ff_rew_speeds[index] == searchSpeed)
    4519                     break;
    4520 
    4521             if ((index < ff_rew_speeds.size()) &&
    4522                 (ff_rew_speeds[index] == searchSpeed))
    4523             {
    4524                 if (tmpSpeed < 0)
    4525                     ctx->ff_rew_state = -1;
    4526                 else if (tmpSpeed > 1)
    4527                     ctx->ff_rew_state = 1;
    4528                 else
    4529                     StopFFRew(ctx);
    4530 
    4531                 if (ctx->ff_rew_state)
    4532                     SetFFRew(ctx, index);
    4533             }
    4534             else
    4535             {
    4536                 VERBOSE(VB_IMPORTANT, QString("Couldn't find %1 speed in "
    4537                     "FFRewSpeed settings array, changing to default speed "
    4538                     "of 1x").arg(searchSpeed));
    4539 
    4540                 ctx->ff_rew_state = 0;
    4541                 SetFFRew(ctx, kInitFFRWSpeed);
    4542             }
    4543         }
    4544         else if (tokens[2].contains(QRegExp("^\\d*\\.\\d+x$")))
    4545         {
    4546             QString tmpSpeed = tokens[2].left(tokens[2].length() - 1);
    4547 
    4548             if (ctx->paused)
    4549                 DoTogglePause(ctx, true);
    4550 
    4551             StopFFRew(ctx);
    4552 
    4553             bool floatRead;
    4554             float stretch = tmpSpeed.toFloat(&floatRead);
    4555             if (floatRead &&
    4556                 stretch <= 2.0 &&
    4557                 stretch >= 0.48)
    4558             {
    4559                 ctx->ts_normal = stretch;   // alter speed before display
    4560                 ChangeTimeStretch(ctx, 0, false);
    4561             }
    4562         }
    4563         else if (tokens[2].contains(QRegExp("^\\d+\\/\\d+x$")))
    4564         {
    4565             if (ctx->buffer && ctx->buffer->InDVDMenuOrStillFrame())
    4566             {
    4567                 ReturnPlayerLock(ctx);
    4568                 return;
    4569             }
    4570 
    4571             if (ctx->paused)
    4572                 DoTogglePause(ctx, true);
    4573 
    4574             if (tokens[2] == "16x")
    4575                 ChangeSpeed(ctx, 5 - ctx->ff_rew_speed);
    4576             else if (tokens[2] == "8x")
    4577                 ChangeSpeed(ctx, 4 - ctx->ff_rew_speed);
    4578             else if (tokens[2] == "4x")
    4579                 ChangeSpeed(ctx, 3 - ctx->ff_rew_speed);
    4580             else if (tokens[2] == "3x")
    4581                 ChangeSpeed(ctx, 2 - ctx->ff_rew_speed);
    4582             else if (tokens[2] == "2x")
    4583                 ChangeSpeed(ctx, 1 - ctx->ff_rew_speed);
    4584             else if (tokens[2] == "1x")
    4585                 ChangeSpeed(ctx, 0 - ctx->ff_rew_speed);
    4586             else if (tokens[2] == "1/2x")
    4587                 ChangeSpeed(ctx, -1 - ctx->ff_rew_speed);
    4588             else if (tokens[2] == "1/3x")
    4589                 ChangeSpeed(ctx, -2 - ctx->ff_rew_speed);
    4590             else if (tokens[2] == "1/4x")
    4591                 ChangeSpeed(ctx, -3 - ctx->ff_rew_speed);
    4592             else if (tokens[2] == "1/8x")
    4593                 ChangeSpeed(ctx, -4 - ctx->ff_rew_speed);
    4594             else if (tokens[2] == "1/16x")
    4595                 ChangeSpeed(ctx, -5 - ctx->ff_rew_speed);
    4596         }
    4597         else
    4598             VERBOSE(VB_IMPORTANT,
    4599                 QString("Found an unknown speed of %1").arg(tokens[2]));
     4492                DoTogglePause(ctx, true);
     4493        }
     4494        else
     4495        {
     4496            float tmpSpeed;
     4497            bool ok = false;
     4498           
     4499            if (tokens[2].contains(QRegExp("^\\-*\\d+x$")))
     4500            {
     4501                QString speed = tokens[2].left(tokens[2].length()-1);
     4502                tmpSpeed = speed.toFloat(&ok);
     4503            }
     4504            else if (tokens[2].contains(QRegExp("^\\-*\\d*\\.\\d+x$")))
     4505            {
     4506                QString speed = tokens[2].left(tokens[2].length() - 1);
     4507                tmpSpeed = speed.toFloat(&ok);
     4508            }
     4509            else
     4510            {
     4511                QRegExp re = QRegExp("^(\\-*\\d+)\\/(\\d+)x$");
     4512                if (tokens[2].contains(re))
     4513                {
     4514                    QStringList matches = re.capturedTexts();
     4515                   
     4516                    int numerator, denominator;
     4517                    numerator = matches[1].toInt(&ok);
     4518                    denominator = matches[2].toInt(&ok);
     4519                   
     4520                    if (ok && denominator != 0)
     4521                    {
     4522                        tmpSpeed = static_cast<float>(numerator)/static_cast<float>(denominator);
     4523                    }
     4524                    else
     4525                        ok = false;
     4526                }
     4527            }
     4528           
     4529            if (ok)
     4530            {
     4531               
     4532                float searchSpeed = fabs(tmpSpeed);
     4533                unsigned int index;
     4534               
     4535                if (ctx->paused)
     4536                    DoTogglePause(ctx, true);
     4537               
     4538                if (tmpSpeed == 0.0f)
     4539                {
     4540                    NormalSpeed(ctx);
     4541                    StopFFRew(ctx);
     4542                   
     4543                    if (!ctx->paused)
     4544                        DoTogglePause(ctx, true);
     4545                }
     4546                else if (tmpSpeed == 1.0f)
     4547                {
     4548                    StopFFRew(ctx);
     4549                    ctx->ts_normal = 1.0f;
     4550                    ChangeTimeStretch(ctx, 0, false);
     4551                   
     4552                    ReturnPlayerLock(ctx);
     4553                    return;
     4554                }
     4555               
     4556                NormalSpeed(ctx);
     4557               
     4558                for (index = 0; index < ff_rew_speeds.size(); index++)
     4559                    if (float(ff_rew_speeds[index]) == searchSpeed)
     4560                        break;
     4561               
     4562                if ((index < ff_rew_speeds.size()) &&
     4563                    (float(ff_rew_speeds[index]) == searchSpeed))
     4564                {
     4565                    if (tmpSpeed < 0)
     4566                        ctx->ff_rew_state = -1;
     4567                    else if (tmpSpeed > 1)
     4568                        ctx->ff_rew_state = 1;
     4569                    else
     4570                        StopFFRew(ctx);
     4571                   
     4572                    if (ctx->ff_rew_state)
     4573                        SetFFRew(ctx, index);
     4574                }
     4575                else if (0.0625 <= tmpSpeed && tmpSpeed <= 2.0)
     4576                {
     4577                    StopFFRew(ctx);
     4578                   
     4579                    ctx->ts_normal = tmpSpeed;   // alter speed before display
     4580                    ChangeTimeStretch(ctx, 0, false);
     4581                }             
     4582                else
     4583                {
     4584                    VERBOSE(VB_IMPORTANT, QString("Couldn't find %1 speed"
     4585                                                  "Setting Speed to"
     4586                                                  "1x").arg(searchSpeed));
     4587                   
     4588                    ctx->ff_rew_state = 0;
     4589                    SetFFRew(ctx, kInitFFRWSpeed);
     4590                }
     4591            }
     4592            else
     4593                VERBOSE(VB_IMPORTANT,
     4594                        QString("Found an unknown speed of %1").arg(tokens[2]));
     4595        }
    46004596    }
    46014597    else if (tokens.size() == 2 && tokens[1] == "STOP")
    46024598    {
    void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    46124608    {
    46134609        if (ctx->buffer && ctx->buffer->InDVDMenuOrStillFrame())
    46144610            return;
    4615 
     4611       
    46164612        ctx->LockDeletePlayer(__FILE__, __LINE__);
    46174613        long long fplay = 0;
    46184614        if (ctx->player && (tokens[2] == "BEGINNING" || tokens[2] == "POSITION"))
    void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    46334629        {
    46344630            long long rel_frame = tokens[3].toInt();
    46354631            rel_frame -= (long long) (fplay * (1.0 / ctx->last_framerate)),
    4636             DoSeek(ctx, rel_frame, tr("Jump To"));
     4632                DoSeek(ctx, rel_frame, tr("Jump To"));
    46374633        }
    46384634    }
    46394635    else if (tokens.size() >= 3 && tokens[1] == "VOLUME")
    void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    46424638        if (tokens[2].contains(re))
    46434639        {
    46444640            QStringList matches = re.capturedTexts();
    4645 
     4641           
    46464642            VERBOSE(VB_IMPORTANT, QString("Set Volume to %1%").arg(matches[1]));
    4647 
     4643           
    46484644            bool ok = false;
    4649 
     4645           
    46504646            int vol = matches[1].toInt(&ok);
    4651 
     4647           
    46524648            if (!ok)
    46534649                return;
    4654 
     4650           
    46554651            if ( 0 <= vol && vol <= 100)
    46564652            {
    46574653                ctx->LockDeletePlayer(__FILE__, __LINE__);
    void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    46604656                    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
    46614657                    return;
    46624658                }
    4663 
     4659               
    46644660                vol -= ctx->player->GetVolume();
    46654661                vol = ctx->player->AdjustVolume(vol);
    46664662                ctx->UnlockDeletePlayer(__FILE__, __LINE__);
    4667 
     4663               
    46684664                if (!browsemode && !editmode)
    46694665                {
    46704666                    UpdateOSDStatus(ctx, tr("Adjust Volume"), tr("Volume"),
    void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    46814677        if (tokens[2] == "POSITION")
    46824678        {
    46834679            QString speedStr;
    4684 
    4685             switch (ctx->ff_rew_speed)
    4686             {
    4687                 case  4: speedStr = "16x"; break;
    4688                 case  3: speedStr = "8x";  break;
    4689                 case  2: speedStr = "3x";  break;
    4690                 case  1: speedStr = "2x";  break;
    4691                 case  0: speedStr = "1x";  break;
    4692                 case -1: speedStr = "1/3x"; break;
    4693                 case -2: speedStr = "1/8x"; break;
    4694                 case -3: speedStr = "1/16x"; break;
    4695                 case -4: speedStr = "0x"; break;
    4696                 default: speedStr = "1x"; break;
    4697             }
    4698 
    4699             if (ctx->ff_rew_state == -1)
    4700                 speedStr = QString("-%1").arg(speedStr);
    4701             else if (ctx->ts_normal != 1.0)
    4702                 speedStr = QString("%1X").arg(ctx->ts_normal);
     4680           
     4681            if (ctx->paused)
     4682            {
     4683                speedStr = "pause";
     4684            }
     4685            else if (ctx->ff_rew_state)
     4686            {           
     4687                speedStr = QString("%1x").arg(ctx->ff_rew_speed);
     4688            }
     4689            else
     4690            {
     4691                QRegExp re = QRegExp("Play (.*)x");
     4692                if (QString(ctx->GetPlayMessage()).contains(re))
     4693                {
     4694                    QStringList matches = re.capturedTexts();
     4695                    speedStr = QString("%1x").arg(matches[1]);
     4696                }
     4697                else
     4698                {
     4699                    speedStr = "1x";
     4700                }
     4701            }
    47034702
    47044703            osdInfo info;
    47054704            ctx->CalcPlayerSliderPosition(info, true);
    void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 
    47284727                    infoStr = "Recorded";
    47294728                else
    47304729                    infoStr = "Video";
    4731 
     4730               
    47324731                if (ctx->playingInfo)
    47334732                    respDate = ctx->playingInfo->GetRecordingStartTime();
    47344733            }
    4735 
     4734           
    47364735            if ((infoStr == "Recorded") || (infoStr == "LiveTV"))
    47374736            {
    47384737                infoStr += QString(" %1 %2 %3 %4 %5 %6 %7")
    void TV::SetFFRew(PlayerContext *ctx, int index) 
    59175916    {
    59185917        mesg = tr("Forward %1X").arg(ff_rew_speeds[ctx->ff_rew_index]);
    59195918        speed = ff_rew_speeds[ctx->ff_rew_index];
     5919        ctx->ff_rew_speed = speed;
    59205920    }
    59215921    else
    59225922    {
    59235923        mesg = tr("Rewind %1X").arg(ff_rew_speeds[ctx->ff_rew_index]);
    59245924        speed = -ff_rew_speeds[ctx->ff_rew_index];
     5925        ctx->ff_rew_speed = speed;
    59255926    }
    59265927
    59275928    ctx->LockDeletePlayer(__FILE__, __LINE__);
    void TV::ToggleTimeStretch(PlayerContext *ctx) 
    79777978
    79787979void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit)
    79797980{
    7980     const float kTimeStretchMin = 0.5;
    7981     const float kTimeStretchMax = 2.0;
     7981    const float kTimeStretchMin = 0.0625;
     7982    const float kTimeStretchMax = 16.0;
    79827983    float new_ts_normal = ctx->ts_normal + 0.05*dir;
    79837984    stretchAdjustment = allowEdit;
    7984 
     7985   
    79857986    if (new_ts_normal > kTimeStretchMax &&
    79867987        ctx->ts_normal < kTimeStretchMax)
    79877988    {
    void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit) 
    79927993    {
    79937994        new_ts_normal = kTimeStretchMin;
    79947995    }
    7995 
     7996   
    79967997    if (new_ts_normal > kTimeStretchMax ||
    79977998        new_ts_normal < kTimeStretchMin)
    79987999    {
    79998000        return;
    80008001    }
    8001 
     8002   
    80028003    ctx->ts_normal = new_ts_normal;
    8003 
     8004   
    80048005    if (!ctx->paused)
    80058006    {
    80068007        ctx->LockDeletePlayer(__FILE__, __LINE__);
    void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit) 
    80128013    if (!browsemode)
    80138014    {
    80148015        if (!allowEdit)
    8015         {
     8016        {         
    80168017            UpdateOSDSeekMessage(ctx, ctx->GetPlayMessage(), kOSDTimeout_Med);
    80178018        }
    80188019        else
  • mythtv/programs/mythfrontend/networkcontrol.cpp

    diff --git a/mythtv/programs/mythfrontend/networkcontrol.cpp b/mythtv/programs/mythfrontend/networkcontrol.cpp
    index a84ac29..1f4b6ea 100644
    a b QString NetworkControl::processPlay(NetworkCommand *nc, int clientID) 
    714714        QString token2 = nc->getArg(2).toLower();
    715715        if ((token2.contains(QRegExp("^\\-*\\d+x$"))) ||
    716716            (token2.contains(QRegExp("^\\-*\\d+\\/\\d+x$"))) ||
    717             (token2.contains(QRegExp("^\\d*\\.\\d+x$"))))
     717            (token2.contains(QRegExp("^\\-*\\d*\\.\\d+x$"))))
    718718            message = QString("NETWORK_CONTROL SPEED %1").arg(token2);
    719719        else if (is_abbrev("normal", token2))
    720720            message = QString("NETWORK_CONTROL SPEED 1x");
    QString NetworkControl::processHelp(NetworkCommand *nc) 
    10241024            "play speed pause      - Pause playback\r\n"
    10251025            "play speed normal     - Playback at normal speed\r\n"
    10261026            "play speed 1x         - Playback at normal speed\r\n"
    1027             "play speed -1x        - Playback at normal speed in reverse\r\n"
    1028             "play speed 1/16x      - Playback at 1/16x speed\r\n"
     1027            "play speed SPEEDx     - Playback where SPEED must be a decimal\r\n"
    10291028            "play speed 1/8x       - Playback at 1/8x speed\r\n"
    10301029            "play speed 1/4x       - Playback at 1/4x speed\r\n"
     1030            "play speed 1/3x       - Playback at 1/3x speed\r\n"
    10311031            "play speed 1/2x       - Playback at 1/2x speed\r\n"
    1032             "play speed 2x         - Playback at 2x speed\r\n"
    1033             "play speed 4x         - Playback at 4x speed\r\n"
    1034             "play speed 8x         - Playback at 8x speed\r\n"
    1035             "play speed 16x        - Playback at 16x speed\r\n"
    10361032            "play stop             - Stop playback\r\n";
    10371033    }
    10381034    else if (is_abbrev("query", command))