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