mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Changed voice playback speed setting to storage value of speed.
This commit is contained in:
parent
eadd7704ef
commit
b635a9d4a5
5 changed files with 35 additions and 26 deletions
|
@ -140,7 +140,7 @@ QByteArray Settings::serialize() const {
|
|||
<< qint32(_askDownloadPath ? 1 : 0)
|
||||
<< _downloadPath.current()
|
||||
<< _downloadPathBookmark
|
||||
<< qint32(_voiceMsgPlaybackDoubled ? 1 : 0)
|
||||
<< qint32(0) // Old double voice playback speed.
|
||||
<< qint32(_soundNotify ? 1 : 0)
|
||||
<< qint32(_desktopNotify ? 1 : 0)
|
||||
<< qint32(_flashBounceNotify ? 1 : 0)
|
||||
|
@ -219,7 +219,8 @@ QByteArray Settings::serialize() const {
|
|||
<< qint32(_hiddenGroupCallTooltips.value())
|
||||
<< qint32(_disableOpenGL ? 1 : 0)
|
||||
<< _photoEditorBrush
|
||||
<< qint32(_groupCallNoiseSuppression ? 1 : 0);
|
||||
<< qint32(_groupCallNoiseSuppression ? 1 : 0)
|
||||
<< qint32(_voicePlaybackSpeed * 100);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -240,7 +241,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
qint32 askDownloadPath = _askDownloadPath ? 1 : 0;
|
||||
QString downloadPath = _downloadPath.current();
|
||||
QByteArray downloadPathBookmark = _downloadPathBookmark;
|
||||
qint32 voiceMsgPlaybackDoubled = _voiceMsgPlaybackDoubled ? 1 : 0;
|
||||
qint32 oldVoiceMsgPlaybackDoubled = 0;
|
||||
qint32 soundNotify = _soundNotify ? 1 : 0;
|
||||
qint32 desktopNotify = _desktopNotify ? 1 : 0;
|
||||
qint32 flashBounceNotify = _flashBounceNotify ? 1 : 0;
|
||||
|
@ -271,6 +272,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
qint32 suggestStickersByEmoji = _suggestStickersByEmoji ? 1 : 0;
|
||||
qint32 spellcheckerEnabled = _spellcheckerEnabled.current() ? 1 : 0;
|
||||
qint32 videoPlaybackSpeed = Core::Settings::SerializePlaybackSpeed(_videoPlaybackSpeed.current());
|
||||
qint32 voicePlaybackSpeed = _voicePlaybackSpeed * 100;
|
||||
QByteArray videoPipGeometry = _videoPipGeometry;
|
||||
qint32 dictionariesEnabledCount = 0;
|
||||
std::vector<int> dictionariesEnabled;
|
||||
|
@ -312,7 +314,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
>> askDownloadPath
|
||||
>> downloadPath
|
||||
>> downloadPathBookmark
|
||||
>> voiceMsgPlaybackDoubled
|
||||
>> oldVoiceMsgPlaybackDoubled
|
||||
>> soundNotify
|
||||
>> desktopNotify
|
||||
>> flashBounceNotify
|
||||
|
@ -455,6 +457,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
if (!stream.atEnd()) {
|
||||
stream >> groupCallNoiseSuppression;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> voicePlaybackSpeed;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||
|
@ -471,7 +476,6 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_askDownloadPath = (askDownloadPath == 1);
|
||||
_downloadPath = downloadPath;
|
||||
_downloadPathBookmark = downloadPathBookmark;
|
||||
_voiceMsgPlaybackDoubled = (voiceMsgPlaybackDoubled == 1);
|
||||
_soundNotify = (soundNotify == 1);
|
||||
_desktopNotify = (desktopNotify == 1);
|
||||
_flashBounceNotify = (flashBounceNotify == 1);
|
||||
|
@ -525,6 +529,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_suggestStickersByEmoji = (suggestStickersByEmoji == 1);
|
||||
_spellcheckerEnabled = (spellcheckerEnabled == 1);
|
||||
_videoPlaybackSpeed = DeserializePlaybackSpeed(videoPlaybackSpeed);
|
||||
_voicePlaybackSpeed = oldVoiceMsgPlaybackDoubled
|
||||
? 2.0
|
||||
: voicePlaybackSpeed / 100.;
|
||||
_videoPipGeometry = (videoPipGeometry);
|
||||
_dictionariesEnabled = std::move(dictionariesEnabled);
|
||||
_autoDownloadDictionaries = (autoDownloadDictionaries == 1);
|
||||
|
@ -782,7 +789,6 @@ void Settings::resetOnLastLogout() {
|
|||
_downloadPath = QString();
|
||||
_downloadPathBookmark = QByteArray();
|
||||
|
||||
_voiceMsgPlaybackDoubled = false;
|
||||
_soundNotify = true;
|
||||
_desktopNotify = true;
|
||||
_flashBounceNotify = true;
|
||||
|
@ -826,6 +832,7 @@ void Settings::resetOnLastLogout() {
|
|||
_suggestStickersByEmoji = true;
|
||||
_spellcheckerEnabled = true;
|
||||
_videoPlaybackSpeed = 1.;
|
||||
_voicePlaybackSpeed = 1.;
|
||||
//_videoPipGeometry = QByteArray();
|
||||
_dictionariesEnabled = std::vector<int>();
|
||||
_autoDownloadDictionaries = true;
|
||||
|
|
|
@ -146,12 +146,6 @@ public:
|
|||
void setDownloadPathBookmark(const QByteArray &value) {
|
||||
_downloadPathBookmark = value;
|
||||
}
|
||||
[[nodiscard]] bool voiceMsgPlaybackDoubled() const {
|
||||
return _voiceMsgPlaybackDoubled;
|
||||
}
|
||||
void setVoiceMsgPlaybackDoubled(bool value) {
|
||||
_voiceMsgPlaybackDoubled = value;
|
||||
}
|
||||
[[nodiscard]] bool soundNotify() const {
|
||||
return _soundNotify;
|
||||
}
|
||||
|
@ -427,6 +421,12 @@ public:
|
|||
void setVideoPlaybackSpeed(float64 speed) {
|
||||
_videoPlaybackSpeed = speed;
|
||||
}
|
||||
[[nodiscard]] float64 voicePlaybackSpeed() const {
|
||||
return _voicePlaybackSpeed;
|
||||
}
|
||||
void setVoicePlaybackSpeed(float64 speed) {
|
||||
_voicePlaybackSpeed = speed;
|
||||
}
|
||||
[[nodiscard]] QByteArray videoPipGeometry() const {
|
||||
return _videoPipGeometry;
|
||||
}
|
||||
|
@ -633,7 +633,6 @@ private:
|
|||
bool _askDownloadPath = false;
|
||||
rpl::variable<QString> _downloadPath;
|
||||
QByteArray _downloadPathBookmark;
|
||||
bool _voiceMsgPlaybackDoubled = false;
|
||||
bool _soundNotify = true;
|
||||
bool _desktopNotify = true;
|
||||
bool _flashBounceNotify = true;
|
||||
|
@ -670,6 +669,7 @@ private:
|
|||
bool _suggestStickersByEmoji = true;
|
||||
rpl::variable<bool> _spellcheckerEnabled = true;
|
||||
rpl::variable<float64> _videoPlaybackSpeed = 1.;
|
||||
float64 _voicePlaybackSpeed = 1.;
|
||||
QByteArray _videoPipGeometry;
|
||||
rpl::variable<std::vector<int>> _dictionariesEnabled;
|
||||
rpl::variable<bool> _autoDownloadDictionaries = true;
|
||||
|
|
|
@ -36,8 +36,6 @@ namespace {
|
|||
|
||||
Instance *SingleInstance = nullptr;
|
||||
|
||||
constexpr auto kVoicePlaybackSpeedMultiplier = 1.7;
|
||||
|
||||
// Preload X message ids before and after current.
|
||||
constexpr auto kIdsLimit = 32;
|
||||
|
||||
|
@ -46,6 +44,10 @@ constexpr auto kIdsPreloadAfter = 28;
|
|||
|
||||
constexpr auto kMinLengthForSavePosition = 20 * TimeId(60); // 20 minutes.
|
||||
|
||||
auto VoicePlaybackSpeed() {
|
||||
return std::clamp(Core::App().settings().voicePlaybackSpeed(), 0.6, 1.7);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
struct Instance::Streamed {
|
||||
|
@ -518,9 +520,8 @@ Streaming::PlaybackOptions Instance::streamingOptions(
|
|||
? Streaming::Mode::Both
|
||||
: Streaming::Mode::Audio;
|
||||
result.speed = (document
|
||||
&& (document->isVoiceMessage() || document->isVideoMessage())
|
||||
&& Core::App().settings().voiceMsgPlaybackDoubled())
|
||||
? kVoicePlaybackSpeedMultiplier
|
||||
&& (document->isVoiceMessage() || document->isVideoMessage()))
|
||||
? VoicePlaybackSpeed()
|
||||
: 1.;
|
||||
result.audioId = audioId;
|
||||
if (position >= 0) {
|
||||
|
@ -678,9 +679,7 @@ void Instance::cancelSeeking(AudioMsgId::Type type) {
|
|||
void Instance::updateVoicePlaybackSpeed() {
|
||||
if (const auto data = getData(AudioMsgId::Type::Voice)) {
|
||||
if (const auto streamed = data->streamed.get()) {
|
||||
streamed->instance.setSpeed(Core::App().settings().voiceMsgPlaybackDoubled()
|
||||
? kVoicePlaybackSpeedMultiplier
|
||||
: 1.);
|
||||
streamed->instance.setSpeed(VoicePlaybackSpeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,8 +148,9 @@ Widget::Widget(QWidget *parent, not_null<Main::Session*> session)
|
|||
|
||||
updatePlaybackSpeedIcon();
|
||||
_playbackSpeed->setClickedCallback([=] {
|
||||
const auto doubled = !Core::App().settings().voiceMsgPlaybackDoubled();
|
||||
Core::App().settings().setVoiceMsgPlaybackDoubled(doubled);
|
||||
const auto doubled = (Core::App().settings().voicePlaybackSpeed()
|
||||
== 2.);
|
||||
Core::App().settings().setVoicePlaybackSpeed(doubled ? 1. : 2.);
|
||||
instance()->updateVoicePlaybackSpeed();
|
||||
updatePlaybackSpeedIcon();
|
||||
Core::App().saveSettingsDelayed();
|
||||
|
@ -396,8 +397,8 @@ void Widget::updateRepeatTrackIcon() {
|
|||
}
|
||||
|
||||
void Widget::updatePlaybackSpeedIcon() {
|
||||
const auto doubled = Core::App().settings().voiceMsgPlaybackDoubled();
|
||||
const auto isDefaultSpeed = !doubled;
|
||||
const auto speed = Core::App().settings().voicePlaybackSpeed();
|
||||
const auto isDefaultSpeed = (speed == 1.);
|
||||
_playbackSpeed->setIconOverride(
|
||||
isDefaultSpeed ? &st::mediaPlayerSpeedDisabledIcon : nullptr,
|
||||
isDefaultSpeed ? &st::mediaPlayerSpeedDisabledIconOver : nullptr);
|
||||
|
|
|
@ -1112,7 +1112,9 @@ bool ReadSetting(
|
|||
stream >> v;
|
||||
if (!CheckStreamStatus(stream)) return false;
|
||||
|
||||
Core::App().settings().setVoiceMsgPlaybackDoubled(v == 2);
|
||||
if (v == 2) {
|
||||
Core::App().settings().setVoicePlaybackSpeed(2.);
|
||||
}
|
||||
context.legacyRead = true;
|
||||
} break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue