Ticket #8718: indent-fixed-playspeed.patch
File indent-fixed-playspeed.patch, 15.0 KB (added by , 14 years ago) |
---|
-
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 815 815 QString PlayerContext::GetPlayMessage(void) const 816 816 { 817 817 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 821 836 if (0) 822 837 { 823 838 QMutexLocker locker(&deletePlayerLock); … … QString PlayerContext::GetPlayMessage(void) const 825 840 if (is_progressive(scan) || is_interlaced(scan)) 826 841 mesg += " (" + toString(scan, true) + ")"; 827 842 } 828 843 829 844 return mesg; 830 845 } 831 846 -
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, 4484 4484 else if (tokens.size() == 3 && tokens[1] == "SPEED") 4485 4485 { 4486 4486 if (tokens[2] == "0x") 4487 4487 { 4488 4488 NormalSpeed(ctx); 4489 4489 StopFFRew(ctx); 4490 4490 4491 4491 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 } 4600 4596 } 4601 4597 else if (tokens.size() == 2 && tokens[1] == "STOP") 4602 4598 { … … void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 4612 4608 { 4613 4609 if (ctx->buffer && ctx->buffer->InDVDMenuOrStillFrame()) 4614 4610 return; 4615 4611 4616 4612 ctx->LockDeletePlayer(__FILE__, __LINE__); 4617 4613 long long fplay = 0; 4618 4614 if (ctx->player && (tokens[2] == "BEGINNING" || tokens[2] == "POSITION")) … … void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 4633 4629 { 4634 4630 long long rel_frame = tokens[3].toInt(); 4635 4631 rel_frame -= (long long) (fplay * (1.0 / ctx->last_framerate)), 4636 4632 DoSeek(ctx, rel_frame, tr("Jump To")); 4637 4633 } 4638 4634 } 4639 4635 else if (tokens.size() >= 3 && tokens[1] == "VOLUME") … … void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 4642 4638 if (tokens[2].contains(re)) 4643 4639 { 4644 4640 QStringList matches = re.capturedTexts(); 4645 4641 4646 4642 VERBOSE(VB_IMPORTANT, QString("Set Volume to %1%").arg(matches[1])); 4647 4643 4648 4644 bool ok = false; 4649 4645 4650 4646 int vol = matches[1].toInt(&ok); 4651 4647 4652 4648 if (!ok) 4653 4649 return; 4654 4650 4655 4651 if ( 0 <= vol && vol <= 100) 4656 4652 { 4657 4653 ctx->LockDeletePlayer(__FILE__, __LINE__); … … void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 4660 4656 ctx->UnlockDeletePlayer(__FILE__, __LINE__); 4661 4657 return; 4662 4658 } 4663 4659 4664 4660 vol -= ctx->player->GetVolume(); 4665 4661 vol = ctx->player->AdjustVolume(vol); 4666 4662 ctx->UnlockDeletePlayer(__FILE__, __LINE__); 4667 4663 4668 4664 if (!browsemode && !editmode) 4669 4665 { 4670 4666 UpdateOSDStatus(ctx, tr("Adjust Volume"), tr("Volume"), … … void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 4681 4677 if (tokens[2] == "POSITION") 4682 4678 { 4683 4679 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 } 4703 4702 4704 4703 osdInfo info; 4705 4704 ctx->CalcPlayerSliderPosition(info, true); … … void TV::ProcessNetworkControlCommand(PlayerContext *ctx, 4728 4727 infoStr = "Recorded"; 4729 4728 else 4730 4729 infoStr = "Video"; 4731 4730 4732 4731 if (ctx->playingInfo) 4733 4732 respDate = ctx->playingInfo->GetRecordingStartTime(); 4734 4733 } 4735 4734 4736 4735 if ((infoStr == "Recorded") || (infoStr == "LiveTV")) 4737 4736 { 4738 4737 infoStr += QString(" %1 %2 %3 %4 %5 %6 %7") … … void TV::SetFFRew(PlayerContext *ctx, int index) 5917 5916 { 5918 5917 mesg = tr("Forward %1X").arg(ff_rew_speeds[ctx->ff_rew_index]); 5919 5918 speed = ff_rew_speeds[ctx->ff_rew_index]; 5919 ctx->ff_rew_speed = speed; 5920 5920 } 5921 5921 else 5922 5922 { 5923 5923 mesg = tr("Rewind %1X").arg(ff_rew_speeds[ctx->ff_rew_index]); 5924 5924 speed = -ff_rew_speeds[ctx->ff_rew_index]; 5925 ctx->ff_rew_speed = speed; 5925 5926 } 5926 5927 5927 5928 ctx->LockDeletePlayer(__FILE__, __LINE__); … … void TV::ToggleTimeStretch(PlayerContext *ctx) 7977 7978 7978 7979 void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit) 7979 7980 { 7980 const float kTimeStretchMin = 0. 5;7981 const float kTimeStretchMax = 2.0;7981 const float kTimeStretchMin = 0.0625; 7982 const float kTimeStretchMax = 16.0; 7982 7983 float new_ts_normal = ctx->ts_normal + 0.05*dir; 7983 7984 stretchAdjustment = allowEdit; 7984 7985 7985 7986 if (new_ts_normal > kTimeStretchMax && 7986 7987 ctx->ts_normal < kTimeStretchMax) 7987 7988 { … … void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit) 7992 7993 { 7993 7994 new_ts_normal = kTimeStretchMin; 7994 7995 } 7995 7996 7996 7997 if (new_ts_normal > kTimeStretchMax || 7997 7998 new_ts_normal < kTimeStretchMin) 7998 7999 { 7999 8000 return; 8000 8001 } 8001 8002 8002 8003 ctx->ts_normal = new_ts_normal; 8003 8004 8004 8005 if (!ctx->paused) 8005 8006 { 8006 8007 ctx->LockDeletePlayer(__FILE__, __LINE__); … … void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit) 8012 8013 if (!browsemode) 8013 8014 { 8014 8015 if (!allowEdit) 8015 { 8016 { 8016 8017 UpdateOSDSeekMessage(ctx, ctx->GetPlayMessage(), kOSDTimeout_Med); 8017 8018 } 8018 8019 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) 714 714 QString token2 = nc->getArg(2).toLower(); 715 715 if ((token2.contains(QRegExp("^\\-*\\d+x$"))) || 716 716 (token2.contains(QRegExp("^\\-*\\d+\\/\\d+x$"))) || 717 (token2.contains(QRegExp("^\\ d*\\.\\d+x$"))))717 (token2.contains(QRegExp("^\\-*\\d*\\.\\d+x$")))) 718 718 message = QString("NETWORK_CONTROL SPEED %1").arg(token2); 719 719 else if (is_abbrev("normal", token2)) 720 720 message = QString("NETWORK_CONTROL SPEED 1x"); … … QString NetworkControl::processHelp(NetworkCommand *nc) 1024 1024 "play speed pause - Pause playback\r\n" 1025 1025 "play speed normal - Playback at normal speed\r\n" 1026 1026 "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" 1029 1028 "play speed 1/8x - Playback at 1/8x speed\r\n" 1030 1029 "play speed 1/4x - Playback at 1/4x speed\r\n" 1030 "play speed 1/3x - Playback at 1/3x speed\r\n" 1031 1031 "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"1036 1032 "play stop - Stop playback\r\n"; 1037 1033 } 1038 1034 else if (is_abbrev("query", command))