4490 | | DoTogglePause(ctx, true); |
4491 | | } |
4492 | | else if (tokens[2].contains(QRegExp("^\\-*\\d+x$"))) |
4493 | | { |
4494 | | QString speed = tokens[2].left(tokens[2].length()-1); |
4495 | | bool ok = false; |
4496 | | int tmpSpeed = speed.toInt(&ok); |
4497 | | int searchSpeed = abs(tmpSpeed); |
4498 | | unsigned int index; |
4499 | | |
4500 | | if (ctx->paused) |
4501 | | DoTogglePause(ctx, true); |
4502 | | |
4503 | | if (tmpSpeed == 1) |
4504 | | { |
4505 | | StopFFRew(ctx); |
4506 | | ctx->ts_normal = 1.0f; |
4507 | | ChangeTimeStretch(ctx, 0, false); |
4508 | | |
4509 | | ReturnPlayerLock(ctx); |
4510 | | return; |
4511 | | } |
4512 | | |
4513 | | NormalSpeed(ctx); |
4514 | | |
4515 | | for (index = 0; index < ff_rew_speeds.size(); index++) |
4516 | | if (ff_rew_speeds[index] == searchSpeed) |
4517 | | break; |
4518 | | |
4519 | | if ((index < ff_rew_speeds.size()) && |
4520 | | (ff_rew_speeds[index] == searchSpeed)) |
4521 | | { |
4522 | | if (tmpSpeed < 0) |
4523 | | ctx->ff_rew_state = -1; |
4524 | | else if (tmpSpeed > 1) |
4525 | | ctx->ff_rew_state = 1; |
4526 | | else |
4527 | | StopFFRew(ctx); |
4528 | | |
4529 | | if (ctx->ff_rew_state) |
4530 | | SetFFRew(ctx, index); |
4531 | | } |
4532 | | else |
4533 | | { |
4534 | | VERBOSE(VB_IMPORTANT, QString("Couldn't find %1 speed in " |
4535 | | "FFRewSpeed settings array, changing to default speed " |
4536 | | "of 1x").arg(searchSpeed)); |
4537 | | |
4538 | | ctx->ff_rew_state = 0; |
4539 | | SetFFRew(ctx, kInitFFRWSpeed); |
4540 | | } |
4541 | | } |
4542 | | else if (tokens[2].contains(QRegExp("^\\d*\\.\\d+x$"))) |
4543 | | { |
4544 | | QString tmpSpeed = tokens[2].left(tokens[2].length() - 1); |
4545 | | |
4546 | | if (ctx->paused) |
4547 | | DoTogglePause(ctx, true); |
4548 | | |
4549 | | StopFFRew(ctx); |
4550 | | |
4551 | | bool floatRead; |
4552 | | float stretch = tmpSpeed.toFloat(&floatRead); |
4553 | | if (floatRead && |
4554 | | stretch <= 2.0 && |
4555 | | stretch >= 0.48) |
4556 | | { |
4557 | | ctx->ts_normal = stretch; // alter speed before display |
4558 | | ChangeTimeStretch(ctx, 0, false); |
4559 | | } |
4560 | | } |
4561 | | else if (tokens[2].contains(QRegExp("^\\d+\\/\\d+x$"))) |
4562 | | { |
4563 | | if (ctx->buffer && ctx->buffer->InDVDMenuOrStillFrame()) |
4564 | | { |
4565 | | ReturnPlayerLock(ctx); |
4566 | | return; |
4567 | | } |
4568 | | |
4569 | | if (ctx->paused) |
4570 | | DoTogglePause(ctx, true); |
4571 | | |
4572 | | if (tokens[2] == "16x") |
4573 | | ChangeSpeed(ctx, 5 - ctx->ff_rew_speed); |
4574 | | else if (tokens[2] == "8x") |
4575 | | ChangeSpeed(ctx, 4 - ctx->ff_rew_speed); |
4576 | | else if (tokens[2] == "4x") |
4577 | | ChangeSpeed(ctx, 3 - ctx->ff_rew_speed); |
4578 | | else if (tokens[2] == "3x") |
4579 | | ChangeSpeed(ctx, 2 - ctx->ff_rew_speed); |
4580 | | else if (tokens[2] == "2x") |
4581 | | ChangeSpeed(ctx, 1 - ctx->ff_rew_speed); |
4582 | | else if (tokens[2] == "1x") |
4583 | | ChangeSpeed(ctx, 0 - ctx->ff_rew_speed); |
4584 | | else if (tokens[2] == "1/2x") |
4585 | | ChangeSpeed(ctx, -1 - ctx->ff_rew_speed); |
4586 | | else if (tokens[2] == "1/3x") |
4587 | | ChangeSpeed(ctx, -2 - ctx->ff_rew_speed); |
4588 | | else if (tokens[2] == "1/4x") |
4589 | | ChangeSpeed(ctx, -3 - ctx->ff_rew_speed); |
4590 | | else if (tokens[2] == "1/8x") |
4591 | | ChangeSpeed(ctx, -4 - ctx->ff_rew_speed); |
4592 | | else if (tokens[2] == "1/16x") |
4593 | | ChangeSpeed(ctx, -5 - ctx->ff_rew_speed); |
4594 | | } |
4595 | | else |
| 4490 | DoTogglePause(ctx, true); |
| 4491 | } |
| 4492 | else |
| 4493 | { |
| 4494 | float tmpSpeed; |
| 4495 | bool ok = false; |
| 4496 | |
| 4497 | if (tokens[2].contains(QRegExp("^\\-*\\d+x$"))) |
| 4498 | { |
| 4499 | QString speed = tokens[2].left(tokens[2].length()-1); |
| 4500 | tmpSpeed = speed.toFloat(&ok); |
| 4501 | } |
| 4502 | else if (tokens[2].contains(QRegExp("^\\-*\\d*\\.\\d+x$"))) |
| 4503 | { |
| 4504 | QString speed = tokens[2].left(tokens[2].length() - 1); |
| 4505 | tmpSpeed = speed.toFloat(&ok); |
| 4506 | } |
| 4507 | else { |
| 4508 | QRegExp re = QRegExp("^(\\-*\\d+)\\/(\\d+)x$"); |
| 4509 | if (tokens[2].contains(re)) |
| 4510 | { |
| 4511 | QStringList matches = re.capturedTexts(); |
| 4512 | |
| 4513 | int numerator, denominator; |
| 4514 | numerator = matches[1].toInt(&ok); |
| 4515 | denominator = matches[2].toInt(&ok); |
| 4516 | |
| 4517 | if (ok && denominator != 0) { |
| 4518 | tmpSpeed = static_cast<float>(numerator)/static_cast<float>(denominator); |
| 4519 | } else |
| 4520 | ok = false; |
| 4521 | } |
| 4522 | } |
| 4523 | |
| 4524 | if (ok) |
| 4525 | { |
| 4526 | |
| 4527 | float searchSpeed = fabs(tmpSpeed); |
| 4528 | unsigned int index; |
| 4529 | |
| 4530 | if (ctx->paused) |
| 4531 | DoTogglePause(ctx, true); |
| 4532 | |
| 4533 | if (tmpSpeed == 1.0f) |
| 4534 | { |
| 4535 | StopFFRew(ctx); |
| 4536 | ctx->ts_normal = 1.0f; |
| 4537 | ChangeTimeStretch(ctx, 0, false); |
| 4538 | |
| 4539 | ReturnPlayerLock(ctx); |
| 4540 | return; |
| 4541 | } |
| 4542 | |
| 4543 | NormalSpeed(ctx); |
| 4544 | |
| 4545 | for (index = 0; index < ff_rew_speeds.size(); index++) |
| 4546 | if (float(ff_rew_speeds[index]) == searchSpeed) |
| 4547 | break; |
| 4548 | |
| 4549 | if ((index < ff_rew_speeds.size()) && |
| 4550 | (float(ff_rew_speeds[index]) == searchSpeed)) |
| 4551 | { |
| 4552 | if (tmpSpeed < 0) |
| 4553 | ctx->ff_rew_state = -1; |
| 4554 | else if (tmpSpeed > 1) |
| 4555 | ctx->ff_rew_state = 1; |
| 4556 | else |
| 4557 | StopFFRew(ctx); |
| 4558 | |
| 4559 | if (ctx->ff_rew_state) |
| 4560 | SetFFRew(ctx, index); |
| 4561 | } |
| 4562 | else if (0.0625 <= tmpSpeed && tmpSpeed <= 2.0) { |
| 4563 | StopFFRew(ctx); |
| 4564 | |
| 4565 | ctx->ts_normal = tmpSpeed; // alter speed before display |
| 4566 | ChangeTimeStretch(ctx, 0, false); |
| 4567 | } |
| 4568 | else |
| 4569 | { |
| 4570 | VERBOSE(VB_IMPORTANT, QString("Couldn't find %1 speed" |
| 4571 | "Setting Speed to" |
| 4572 | "1x").arg(searchSpeed)); |
| 4573 | |
| 4574 | ctx->ff_rew_state = 0; |
| 4575 | SetFFRew(ctx, kInitFFRWSpeed); |
| 4576 | } |
| 4577 | } |
| 4578 | else |