From 8171828c2a6237f84e218ce0490baca721ef4073 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 1 Mar 2019 18:41:10 +0400 Subject: [PATCH] Fix build on GCC. --- Telegram/SourceFiles/data/data_document.cpp | 2 -- Telegram/SourceFiles/mainwidget.cpp | 4 ++-- .../SourceFiles/media/clip/media_clip_ffmpeg.cpp | 2 +- .../SourceFiles/media/clip/media_clip_reader.cpp | 4 ++-- .../media/player/media_player_widget.cpp | 10 ++++++++-- .../media/streaming/media_streaming_player.cpp | 6 +++--- .../streaming/media_streaming_video_track.cpp | 8 +++++--- .../media/view/media_view_overlay_widget.cpp | 2 +- .../media/view/media_view_playback_controls.cpp | 16 +++++++++++----- .../mtproto/special_config_request.cpp | 6 +++--- .../ui/effects/send_action_animations.cpp | 2 +- .../SourceFiles/window/notifications_manager.cpp | 2 +- 12 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 40c1df5ffa..3f36c3964c 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -309,7 +309,6 @@ void DocumentOpenClickHandler::Open( return; } if (!location.isEmpty() || (!data->data().isEmpty() && (playVoice || playAnimation))) { - using State = Media::Player::State; if (playVoice) { Media::Player::instance()->playPause({ data, msgId }); } else if (data->size < App::kImageSizeLimit) { @@ -723,7 +722,6 @@ void DocumentData::performActionOnLoad() { return; } } - using State = Media::Player::State; if (playVoice || playMusic) { DocumentOpenClickHandler::Open({}, this, item, ActionOnLoadNone); } else if (playAnimation) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index f18451cad4..e0924effc1 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -3248,7 +3248,7 @@ bool MainWidget::failDifference(const RPCError &error) { } void MainWidget::getDifferenceByPts() { - auto now = crl::now(), wait = 0LL; + auto now = crl::now(), wait = crl::time(0); if (_getDifferenceTimeByPts) { if (_getDifferenceTimeByPts > now) { wait = _getDifferenceTimeByPts - now; @@ -3273,7 +3273,7 @@ void MainWidget::getDifferenceByPts() { } void MainWidget::getDifferenceAfterFail() { - auto now = crl::now(), wait = 0LL; + auto now = crl::now(), wait = crl::time(0); if (_getDifferenceTimeAfterFail) { if (_getDifferenceTimeAfterFail > now) { wait = _getDifferenceTimeAfterFail - now; diff --git a/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp b/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp index 3961828b9e..0cc1e7a070 100644 --- a/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp +++ b/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp @@ -206,7 +206,7 @@ crl::time FFMpegReaderImplementation::frameRealTime() const { } crl::time FFMpegReaderImplementation::framePresentationTime() const { - return qMax(_frameTime + _frameTimeCorrection, 0LL); + return qMax(_frameTime + _frameTimeCorrection, crl::time(0)); } crl::time FFMpegReaderImplementation::durationMs() const { diff --git a/Telegram/SourceFiles/media/clip/media_clip_reader.cpp b/Telegram/SourceFiles/media/clip/media_clip_reader.cpp index 5c77758342..1468ea7d65 100644 --- a/Telegram/SourceFiles/media/clip/media_clip_reader.cpp +++ b/Telegram/SourceFiles/media/clip/media_clip_reader.cpp @@ -765,7 +765,7 @@ void Manager::process() { _processingInThread = thread(); bool checkAllReaders = false; - auto ms = crl::now(), minms = ms + 86400 * 1000LL; + auto ms = crl::now(), minms = ms + 86400 * crl::time(1000); { QMutexLocker lock(&_readerPointersMutex); for (auto it = _readerPointers.begin(), e = _readerPointers.end(); it != e; ++it) { @@ -867,7 +867,7 @@ FileMediaInformation::Video PrepareForSending(const QString &fname, const QByteA auto localLocation = FileLocation(fname); auto localData = QByteArray(data); - auto seekPositionMs = 0LL; + auto seekPositionMs = crl::time(0); auto reader = std::make_unique(&localLocation, &localData, AudioMsgId()); if (reader->start(internal::ReaderImplementation::Mode::Inspecting, seekPositionMs)) { auto durationMs = reader->durationMs(); diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index 4d368867b5..45ae234e63 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -233,7 +233,10 @@ Widget::~Widget() = default; void Widget::handleSeekProgress(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + const auto positionMs = snap( + static_cast(progress * _lastDurationMs), + crl::time(0), + _lastDurationMs); if (_seekPositionMs != positionMs) { _seekPositionMs = positionMs; updateTimeLabel(); @@ -245,7 +248,10 @@ void Widget::handleSeekProgress(float64 progress) { void Widget::handleSeekFinished(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + const auto positionMs = snap( + static_cast(progress * _lastDurationMs), + crl::time(0), + _lastDurationMs); _seekPositionMs = -1; instance()->finishSeeking(_type, progress); diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_player.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_player.cpp index 3218dd0397..4137ae880b 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_player.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_player.cpp @@ -34,7 +34,7 @@ constexpr auto kLoadFullIfStuckAfterPlayback = 3 * crl::time(1000); ? position : (position == kReceivedTillEnd) ? state.duration - : std::clamp(position, 0LL, state.duration - 1); + : std::clamp(position, crl::time(0), state.duration - 1); } [[nodiscard]] bool FullTrackReceived(const TrackState &state) { @@ -126,7 +126,7 @@ void Player::trackReceivedTill( if (position == kTimeUnknown) { return; } else if (state.duration != kTimeUnknown) { - position = std::clamp(position, 0LL, state.duration); + position = std::clamp(position, crl::time(0), state.duration); if (state.receivedTill < position) { state.receivedTill = position; trackSendReceivedTill(track, state); @@ -150,7 +150,7 @@ void Player::trackPlayedTill( const auto guard = base::make_weak(&_sessionGuard); trackReceivedTill(track, state, position); if (guard && position != kTimeUnknown) { - position = std::clamp(position, 0LL, state.duration); + position = std::clamp(position, crl::time(0), state.duration); state.position = position; _updates.fire({ PlaybackUpdate{ position } }); } diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp index 47cf624b8d..fe5f900104 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp @@ -109,15 +109,17 @@ VideoTrackObject::VideoTrackObject( rpl::producer VideoTrackObject::displayFrameAt() const { return interrupted() - ? rpl::complete() + ? (rpl::complete() | rpl::type_erased()) : (_nextFrameDisplayTime == kTimeUnknown) - ? _nextFrameTimeUpdates.events() + ? (_nextFrameTimeUpdates.events() | rpl::type_erased()) : _nextFrameTimeUpdates.events_starting_with_copy( _nextFrameDisplayTime); } rpl::producer<> VideoTrackObject::waitingForData() const { - return interrupted() ? rpl::never() : _waitingForData.events(); + return interrupted() + ? (rpl::never() | rpl::type_erased()) + : _waitingForData.events(); } void VideoTrackObject::process(Packet &&packet) { diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 961ec312ef..dd475f83ff 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2252,7 +2252,7 @@ void OverlayWidget::updatePlaybackState() { if (duration > 0) { state.length = std::max( duration * crl::time(1000), - state.position); + crl::time(state.position)); } } if (state.position != kTimeUnknown && state.length != kTimeUnknown) { diff --git a/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp b/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp index 525ad40fd1..be91e337c5 100644 --- a/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp +++ b/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp @@ -79,7 +79,10 @@ PlaybackControls::PlaybackControls(QWidget *parent, not_null delegat void PlaybackControls::handleSeekProgress(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + const auto positionMs = snap( + static_cast(progress * _lastDurationMs), + crl::time(0), + _lastDurationMs); if (_seekPositionMs != positionMs) { _seekPositionMs = positionMs; refreshTimeTexts(); @@ -92,7 +95,10 @@ void PlaybackControls::handleSeekProgress(float64 progress) { void PlaybackControls::handleSeekFinished(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + const auto positionMs = snap( + static_cast(progress * _lastDurationMs), + crl::time(0), + _lastDurationMs); _seekPositionMs = -1; _delegate->playbackControlsSeekFinished(positionMs); refreshTimeTexts(); @@ -172,7 +178,7 @@ void PlaybackControls::updateTimeTexts(const Player::TrackState &state) { auto playAlready = position / playFrequency; auto playLeft = (state.length / playFrequency) - playAlready; - _lastDurationMs = (state.length * 1000LL) / playFrequency; + _lastDurationMs = (state.length * crl::time(1000)) / playFrequency; _timeAlready = formatDurationText(playAlready); auto minus = QChar(8722); @@ -188,8 +194,8 @@ void PlaybackControls::refreshTimeTexts() { auto timeAlready = _timeAlready; auto timeLeft = _timeLeft; if (_seekPositionMs >= 0) { - auto playAlready = _seekPositionMs / 1000LL; - auto playLeft = (_lastDurationMs / 1000LL) - playAlready; + auto playAlready = _seekPositionMs / crl::time(1000); + auto playLeft = (_lastDurationMs / crl::time(1000)) - playAlready; timeAlready = formatDurationText(playAlready); auto minus = QChar(8722); diff --git a/Telegram/SourceFiles/mtproto/special_config_request.cpp b/Telegram/SourceFiles/mtproto/special_config_request.cpp index 4783f5bc62..d8093ec3b1 100644 --- a/Telegram/SourceFiles/mtproto/special_config_request.cpp +++ b/Telegram/SourceFiles/mtproto/special_config_request.cpp @@ -21,7 +21,7 @@ namespace { struct DnsEntry { QString data; - int64 TTL = 0; + crl::time TTL = 0; }; constexpr auto kSendNextTimeout = crl::time(1000); @@ -155,8 +155,8 @@ std::vector ParseDnsResponse( const auto ttlIt = object.find(qsl("TTL")); const auto ttl = (ttlIt != object.constEnd()) - ? int64(std::round((*ttlIt).toDouble())) - : int64(0); + ? crl::time(std::round((*ttlIt).toDouble())) + : crl::time(0); result.push_back({ (*dataIt).toString(), ttl }); } return result; diff --git a/Telegram/SourceFiles/ui/effects/send_action_animations.cpp b/Telegram/SourceFiles/ui/effects/send_action_animations.cpp index 9a0983871d..8842aa55c9 100644 --- a/Telegram/SourceFiles/ui/effects/send_action_animations.cpp +++ b/Telegram/SourceFiles/ui/effects/send_action_animations.cpp @@ -203,7 +203,7 @@ void SendActionAnimation::Impl::paint( x, y, outerWidth, - anim::Disabled() ? 0 : (qMax(ms - _started, 0LL) % _period)); + anim::Disabled() ? 0 : (qMax(ms - _started, crl::time(0)) % _period)); } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 529d070e6e..349f3b6b5a 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -235,7 +235,7 @@ void System::showNext() { return false; }; - auto ms = crl::now(), nextAlert = 0LL; + auto ms = crl::now(), nextAlert = crl::time(0); bool alert = false; int32 now = unixtime(); for (auto i = _whenAlerts.begin(); i != _whenAlerts.end();) {