From 5e031be42cf0e1cfef2d476090cf7d794484d251 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 25 Mar 2025 00:37:07 +0100 Subject: [PATCH] Fix cast warnings with MSVC --- src/analyzer/analyzerbase.cpp | 8 +- src/analyzer/blockanalyzer.cpp | 14 +-- src/analyzer/boomanalyzer.cpp | 16 +-- src/analyzer/rainbowanalyzer.cpp | 2 +- src/analyzer/sonogramanalyzer.cpp | 4 +- src/analyzer/turbineanalyzer.cpp | 4 +- src/analyzer/waverubberanalyzer.cpp | 6 +- src/collection/collectionlibrary.cpp | 4 +- src/collection/collectionmodel.h | 2 +- src/collection/collectionwatcher.cpp | 8 +- src/core/database.cpp | 2 +- src/core/deletefiles.cpp | 4 +- src/core/localredirectserver.cpp | 2 +- src/core/mainwindow.cpp | 4 +- src/core/multisortfilterproxy.cpp | 2 - src/core/networkproxyfactory.cpp | 2 +- src/core/networkproxyfactory.h | 2 +- src/core/oauthenticator.cpp | 4 +- src/core/player.cpp | 24 ++-- src/core/windows7thumbbar.cpp | 8 +- src/covermanager/discogscoverprovider.cpp | 2 +- src/covermanager/discogscoverprovider.h | 2 +- src/device/devicedatabasebackend.cpp | 2 +- src/device/deviceproperties.cpp | 4 +- src/dialogs/edittagdialog.cpp | 16 +-- src/dialogs/edittagdialog.h | 2 +- src/engine/AsyncOperations.h | 5 + src/engine/ebur128analysis.cpp | 8 +- src/engine/enginebase.cpp | 2 +- src/engine/gstengine.cpp | 15 +-- src/engine/gstenginepipeline.cpp | 105 ++++++++---------- src/engine/gstenginepipeline.h | 20 ++-- src/engine/gstfastspectrum.cpp | 13 ++- src/globalshortcuts/globalshortcut-win.cpp | 4 +- src/main.cpp | 2 +- src/moodbar/moodbarbuilder.cpp | 2 +- src/organize/organize.cpp | 4 +- src/organize/organizedialog.cpp | 4 +- src/osd/osdbase.cpp | 4 +- src/osd/osdpretty.cpp | 4 +- src/playlist/playlist.cpp | 2 - src/playlist/songloaderinserter.cpp | 8 +- src/qobuz/qobuzservice.cpp | 2 +- src/qobuz/qobuzstreamurlrequest.cpp | 2 +- src/queue/queue.cpp | 4 +- src/scrobbler/listenbrainzscrobbler.cpp | 2 +- src/scrobbler/scrobblingapi20.cpp | 2 +- .../smartplaylistsearchterm.cpp | 2 - src/smartplaylists/smartplaylistsmodel.cpp | 2 - src/spotify/spotifyservice.cpp | 2 +- src/tagreader/streamtagreader.cpp | 2 +- src/tagreader/tagreadergme.cpp | 14 +-- src/tagreader/tagreadertaglib.cpp | 14 +-- src/tidal/tidalservice.cpp | 2 +- src/transcoder/transcoder.cpp | 2 +- src/utilities/fileutils.cpp | 2 +- src/utilities/scopedwchararray.cpp | 4 +- src/utilities/scopedwchararray.h | 2 +- src/utilities/sqlhelper.h | 2 +- 59 files changed, 207 insertions(+), 207 deletions(-) diff --git a/src/analyzer/analyzerbase.cpp b/src/analyzer/analyzerbase.cpp index 700bffd15..91596563a 100644 --- a/src/analyzer/analyzerbase.cpp +++ b/src/analyzer/analyzerbase.cpp @@ -100,7 +100,7 @@ void AnalyzerBase::transform(Scope &scope) { fht_->logSpectrum(scope.data(), aux.data()); fht_->scale(scope.data(), 1.0F / 20); - scope.resize(fht_->size() / 2); // second half of values are rubbish + scope.resize(static_cast(fht_->size() / 2)); // second half of values are rubbish } @@ -112,7 +112,7 @@ void AnalyzerBase::paintEvent(QPaintEvent *e) { switch (engine_->state()) { case EngineBase::State::Playing:{ const EngineBase::Scope &thescope = engine_->scope(timeout_); - int i = 0; + size_t i = 0; // convert to mono here - our built in analyzers need mono, but the engines provide interleaved pcm for (uint x = 0; static_cast(x) < fht_->size(); ++x) { @@ -124,7 +124,7 @@ void AnalyzerBase::paintEvent(QPaintEvent *e) { transform(lastscope_); analyze(p, lastscope_, new_frame_); - lastscope_.resize(fht_->size()); + lastscope_.resize(static_cast(fht_->size())); break; } @@ -153,7 +153,7 @@ int AnalyzerBase::resizeExponent(int exp) { if (exp != fht_->sizeExp()) { delete fht_; - fht_ = new FHT(exp); + fht_ = new FHT(static_cast(exp)); } return exp; diff --git a/src/analyzer/blockanalyzer.cpp b/src/analyzer/blockanalyzer.cpp index b86b125ab..5d61f88ec 100644 --- a/src/analyzer/blockanalyzer.cpp +++ b/src/analyzer/blockanalyzer.cpp @@ -85,7 +85,7 @@ void BlockAnalyzer::resizeEvent(QResizeEvent *e) { // this is the y-offset for drawing from the top of the widget y_ = (height() - (rows_ * (kHeight + 1)) + 2) / 2; - scope_.resize(columns_); + scope_.resize(static_cast(columns_)); if (rows_ != oldRows) { barpixmap_ = QPixmap(kWidth, rows_ * (kHeight + 1)); @@ -165,9 +165,9 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) { // Paint the background canvas_painter.drawPixmap(0, 0, background_); - for (int x = 0, y = 0; x < static_cast(scope_.size()); ++x) { + for (qint64 x = 0, y = 0; x < static_cast(scope_.size()); ++x) { // determine y - for (y = 0; scope_[x] < yscale_.at(y); ++y); + for (y = 0; scope_[static_cast(x)] < yscale_.at(y); ++y); // This is opposite to what you'd think, higher than y means the bar is lower than y (physically) if (static_cast(y) > store_.at(x)) { @@ -175,13 +175,13 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) { y = static_cast(store_.value(x)); } else { - store_[x] = y; + store_[x] = static_cast(y); } // If y is lower than fade_pos_, then the bar has exceeded the height of the fadeout // if the fadeout is quite faded now, then display the new one if (y <= fade_pos_.at(x) /*|| fade_intensity_[x] < kFadeSize / 3*/) { - fade_pos_[x] = y; + fade_pos_[x] = static_cast(y); fade_intensity_[x] = kFadeSize; } @@ -189,13 +189,13 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) { --fade_intensity_[x]; const int offset = fade_intensity_.value(x); const int y2 = y_ + (fade_pos_.value(x) * (kHeight + 1)); - canvas_painter.drawPixmap(x * (kWidth + 1), y2, fade_bars_[offset], 0, 0, kWidth, height() - y2); + canvas_painter.drawPixmap(static_cast(x) * (kWidth + 1), y2, fade_bars_[offset], 0, 0, kWidth, height() - y2); } if (fade_intensity_.at(x) == 0) fade_pos_[x] = rows_; // REMEMBER: y is a number from 0 to rows_, 0 means all blocks are glowing, rows_ means none are - canvas_painter.drawPixmap(x * (kWidth + 1), y * (kHeight + 1) + y_, *bar(), 0, y * (kHeight + 1), bar()->width(), bar()->height()); + canvas_painter.drawPixmap(static_cast(x) * (kWidth + 1), static_cast(y) * (kHeight + 1) + y_, *bar(), 0, static_cast(y) * (kHeight + 1), bar()->width(), bar()->height()); } for (int x = 0; x < store_.size(); ++x) { diff --git a/src/analyzer/boomanalyzer.cpp b/src/analyzer/boomanalyzer.cpp index ad61a66a0..91cfc5b28 100644 --- a/src/analyzer/boomanalyzer.cpp +++ b/src/analyzer/boomanalyzer.cpp @@ -76,7 +76,7 @@ void BoomAnalyzer::resizeEvent(QResizeEvent *e) { const double h = 1.2 / HEIGHT; bands_ = qMin(static_cast(static_cast(width() + 1) / (kColumnWidth + 1)) + 1, kMaxBandCount); - scope_.resize(bands_); + scope_.resize(static_cast(bands_)); F_ = static_cast(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/); @@ -112,17 +112,19 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame return; } - const uint MAX_HEIGHT = height() - 1; + const uint MAX_HEIGHT = static_cast(height() - 1); QPainter canvas_painter(&canvas_); canvas_.fill(palette().color(QPalette::Window)); interpolate(scope, scope_); - for (int i = 0, x = 0, y = 0; i < bands_; ++i, x += kColumnWidth + 1) { + int x = 0; + int y = 0; + for (size_t i = 0; i < static_cast(bands_); ++i, x += kColumnWidth + 1) { double h = log10(scope_[i] * 256.0) * F_; - if (h > MAX_HEIGHT) h = MAX_HEIGHT; + h = std::min(h, static_cast(MAX_HEIGHT)); if (h > bar_height_[i]) { bar_height_[i] = h; @@ -138,7 +140,7 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame else { if (bar_height_[i] > 0.0) { bar_height_[i] -= K_barHeight_; // 1.4 - if (bar_height_[i] < 0.0) bar_height_[i] = 0.0; + bar_height_[i] = std::max(0.0, bar_height_[i]); } peak_handling: @@ -147,8 +149,8 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame peak_height_[i] -= peak_speed_[i]; peak_speed_[i] *= F_peakSpeed_; // 1.12 - if (peak_height_[i] < bar_height_[i]) peak_height_[i] = bar_height_[i]; - if (peak_height_[i] < 0.0) peak_height_[i] = 0.0; + peak_height_[i] = std::max(bar_height_[i], bar_height_[i]); + peak_height_[i] = std::max(0.0, peak_height_[i]); } } diff --git a/src/analyzer/rainbowanalyzer.cpp b/src/analyzer/rainbowanalyzer.cpp index 2408f9de0..00bb6bd06 100644 --- a/src/analyzer/rainbowanalyzer.cpp +++ b/src/analyzer/rainbowanalyzer.cpp @@ -129,7 +129,7 @@ void RainbowAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) // of band pass filters for this, so bands can leak into neighbouring bands, // but for now it's a series of separate square filters. const int samples_per_band = scope_size / kRainbowBands; - int sample = 0; + size_t sample = 0; for (int band = 0; band < kRainbowBands; ++band) { float accumulator = 0.0; for (int i = 0; i < samples_per_band; ++i) { diff --git a/src/analyzer/sonogramanalyzer.cpp b/src/analyzer/sonogramanalyzer.cpp index bfa05aff4..23384f3c0 100644 --- a/src/analyzer/sonogramanalyzer.cpp +++ b/src/analyzer/sonogramanalyzer.cpp @@ -85,10 +85,10 @@ void SonogramAnalyzer::transform(Scope &scope) { fht_->power2(scope.data()); fht_->scale(scope.data(), 1.0 / 256); - scope.resize(fht_->size() / 2); + scope.resize(static_cast(fht_->size() / 2)); } void SonogramAnalyzer::demo(QPainter &p) { - analyze(p, Scope(fht_->size(), 0), new_frame_); + analyze(p, Scope(static_cast(fht_->size()), 0), new_frame_); } diff --git a/src/analyzer/turbineanalyzer.cpp b/src/analyzer/turbineanalyzer.cpp index 61bb089c9..97cece0ba 100644 --- a/src/analyzer/turbineanalyzer.cpp +++ b/src/analyzer/turbineanalyzer.cpp @@ -43,7 +43,7 @@ void TurbineAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_fr return; } - const uint hd2 = height() / 2; + const uint hd2 = static_cast(height() / 2); const uint kMaxHeight = hd2 - 1; QPainter canvas_painter(&canvas_); @@ -67,7 +67,7 @@ void TurbineAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_fr else { if (bar_height_[i] > 0.0) { bar_height_[i] -= K_barHeight_; // 1.4 - if (bar_height_[i] < 0.0) bar_height_[i] = 0.0; + bar_height_[i] = std::max(0.0, bar_height_[i]); } peak_handling: diff --git a/src/analyzer/waverubberanalyzer.cpp b/src/analyzer/waverubberanalyzer.cpp index dd2ecf07a..4a8d8a2f6 100644 --- a/src/analyzer/waverubberanalyzer.cpp +++ b/src/analyzer/waverubberanalyzer.cpp @@ -54,13 +54,13 @@ void WaveRubberAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_fra const float *amplitude_data = s.data(); const int mid_y = height() / 4; - const int num_samples = static_cast(s.size()); + const size_t num_samples = static_cast(s.size()); const float x_scale = static_cast(width()) / static_cast(num_samples); float prev_y = static_cast(mid_y); // Draw the waveform - for (int i = 0; i < num_samples; ++i) { + for (size_t i = 0; i < num_samples; ++i) { // Normalize amplitude to 0-1 range const float color_factor = amplitude_data[i] / 2.0F + 0.5F; @@ -88,5 +88,5 @@ void WaveRubberAnalyzer::transform(Scope &scope) { } void WaveRubberAnalyzer::demo(QPainter &p) { - analyze(p, Scope(fht_->size(), 0), new_frame_); + analyze(p, Scope(static_cast(fht_->size()), 0), new_frame_); } diff --git a/src/collection/collectionlibrary.cpp b/src/collection/collectionlibrary.cpp index 095d8bdf5..918279a8d 100644 --- a/src/collection/collectionlibrary.cpp +++ b/src/collection/collectionlibrary.cpp @@ -199,8 +199,8 @@ void CollectionLibrary::SyncPlaycountAndRatingToFiles() { task_manager_->SetTaskBlocksCollectionScans(task_id); const SongList songs = backend_->GetAllSongs(); - const qint64 nb_songs = songs.size(); - int i = 0; + const quint64 nb_songs = static_cast(songs.size()); + quint64 i = 0; for (const Song &song : songs) { (void)tagreader_client_->SaveSongPlaycountBlocking(song.url().toLocalFile(), song.playcount()); (void)tagreader_client_->SaveSongRatingBlocking(song.url().toLocalFile(), song.rating()); diff --git a/src/collection/collectionmodel.h b/src/collection/collectionmodel.h index 502400e05..ed65663b3 100644 --- a/src/collection/collectionmodel.h +++ b/src/collection/collectionmodel.h @@ -155,7 +155,7 @@ class CollectionModel : public SimpleTreeModel { int total_artist_count() const { return total_artist_count_; } int total_album_count() const { return total_album_count_; } - quint64 icon_disk_cache_size() { return icon_disk_cache_->cacheSize(); } + quint64 icon_disk_cache_size() { return static_cast(icon_disk_cache_->cacheSize()); } const CollectionModel::Grouping GetGroupBy() const { return options_current_.group_by; } void SetGroupBy(const CollectionModel::Grouping g, const std::optional separate_albums_by_grouping = std::optional()); diff --git a/src/collection/collectionwatcher.cpp b/src/collection/collectionwatcher.cpp index f55d48bb2..3475852f3 100644 --- a/src/collection/collectionwatcher.cpp +++ b/src/collection/collectionwatcher.cpp @@ -858,7 +858,7 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file, QHash sections_map; for (const Song &song : old_cue_songs) { - sections_map.insert(song.beginning_nanosec(), song); + sections_map.insert(static_cast(song.beginning_nanosec()), song); } // Load new CUE songs @@ -879,8 +879,8 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file, PerformEBUR128Analysis(new_cue_song); new_cue_song.set_fingerprint(fingerprint); - if (sections_map.contains(new_cue_song.beginning_nanosec())) { // Changed section - const Song matching_cue_song = sections_map[new_cue_song.beginning_nanosec()]; + if (sections_map.contains(static_cast(new_cue_song.beginning_nanosec()))) { // Changed section + const Song matching_cue_song = sections_map[static_cast(new_cue_song.beginning_nanosec())]; new_cue_song.set_id(matching_cue_song.id()); new_cue_song.set_art_automatic(art_automatic); new_cue_song.MergeUserSetData(matching_cue_song, true, true); @@ -1082,7 +1082,7 @@ quint64 CollectionWatcher::GetMtimeForCue(const QString &cue_path) { const QDateTime cue_last_modified = fileinfo.lastModified(); - return cue_last_modified.isValid() ? cue_last_modified.toSecsSinceEpoch() : 0; + return cue_last_modified.isValid() ? static_cast(cue_last_modified.toSecsSinceEpoch()) : 0; } diff --git a/src/core/database.cpp b/src/core/database.cpp index 75a206483..89629afe5 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -598,7 +598,7 @@ void Database::BackupFile(const QString &filename) { do { ret = sqlite3_backup_step(backup, 16); const int page_count = sqlite3_backup_pagecount(backup); - task_manager_->SetTaskProgress(task_id, page_count - sqlite3_backup_remaining(backup), page_count); + task_manager_->SetTaskProgress(task_id, static_cast(page_count - sqlite3_backup_remaining(backup)), static_cast(page_count)); } while (ret == SQLITE_OK); diff --git a/src/core/deletefiles.cpp b/src/core/deletefiles.cpp index 83afb74a4..0497cfc7f 100644 --- a/src/core/deletefiles.cpp +++ b/src/core/deletefiles.cpp @@ -92,7 +92,7 @@ void DeleteFiles::ProcessSomeFiles() { // None left? if (progress_ >= songs_.count()) { - task_manager_->SetTaskProgress(task_id_, progress_, songs_.count()); + task_manager_->SetTaskProgress(task_id_, static_cast(progress_), static_cast(songs_.count())); QString error_text; storage_->FinishCopy(songs_with_errors_.isEmpty(), error_text); @@ -114,7 +114,7 @@ void DeleteFiles::ProcessSomeFiles() { const qint64 n = qMin(static_cast(songs_.count()), static_cast(progress_ + kBatchSize)); for (; progress_ < n; ++progress_) { - task_manager_->SetTaskProgress(task_id_, progress_, songs_.count()); + task_manager_->SetTaskProgress(task_id_, static_cast(progress_), static_cast(songs_.count())); const Song song = songs_.value(progress_); diff --git a/src/core/localredirectserver.cpp b/src/core/localredirectserver.cpp index 333c977b2..47aa1154e 100644 --- a/src/core/localredirectserver.cpp +++ b/src/core/localredirectserver.cpp @@ -52,7 +52,7 @@ LocalRedirectServer::~LocalRedirectServer() { bool LocalRedirectServer::Listen() { - if (!listen(QHostAddress::LocalHost, port_)) { + if (!listen(QHostAddress::LocalHost, static_cast(port_))) { success_ = false; error_ = errorString(); return false; diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 17ab7afc3..d3faba61f 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -2566,10 +2566,10 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) { } if (options.seek_to() != -1) { - app_->player()->SeekTo(options.seek_to()); + app_->player()->SeekTo(static_cast(options.seek_to())); } else if (options.seek_by() != 0) { - app_->player()->SeekTo(app_->player()->engine()->position_nanosec() / kNsecPerSec + options.seek_by()); + app_->player()->SeekTo(static_cast(app_->player()->engine()->position_nanosec() / kNsecPerSec + options.seek_by())); } if (options.play_track_at() != -1) app_->player()->PlayAt(options.play_track_at(), false, 0, EngineBase::TrackChangeType::Manual, Playlist::AutoScroll::Maybe, true); diff --git a/src/core/multisortfilterproxy.cpp b/src/core/multisortfilterproxy.cpp index d7d8e4e64..445d627f5 100644 --- a/src/core/multisortfilterproxy.cpp +++ b/src/core/multisortfilterproxy.cpp @@ -88,6 +88,4 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c } } - return 0; - } diff --git a/src/core/networkproxyfactory.cpp b/src/core/networkproxyfactory.cpp index 13a39cb03..a3102dfe3 100644 --- a/src/core/networkproxyfactory.cpp +++ b/src/core/networkproxyfactory.cpp @@ -86,7 +86,7 @@ void NetworkProxyFactory::ReloadSettings() { mode_ = static_cast(s.value("mode", static_cast(Mode::System)).toInt()); type_ = QNetworkProxy::ProxyType(s.value("type", QNetworkProxy::HttpProxy).toInt()); hostname_ = s.value("hostname").toString(); - port_ = s.value("port", 8080).toInt(); + port_ = s.value("port", 8080).toULongLong(); use_authentication_ = s.value("use_authentication", false).toBool(); username_ = s.value("username").toString(); password_ = s.value("password").toString(); diff --git a/src/core/networkproxyfactory.h b/src/core/networkproxyfactory.h index a8888f874..4e8ae234d 100644 --- a/src/core/networkproxyfactory.h +++ b/src/core/networkproxyfactory.h @@ -57,7 +57,7 @@ class NetworkProxyFactory : public QNetworkProxyFactory { Mode mode_; QNetworkProxy::ProxyType type_; QString hostname_; - int port_; + quint64 port_; bool use_authentication_; QString username_; QString password_; diff --git a/src/core/oauthenticator.cpp b/src/core/oauthenticator.cpp index 0724590e8..26aa0d2d1 100644 --- a/src/core/oauthenticator.cpp +++ b/src/core/oauthenticator.cpp @@ -182,7 +182,7 @@ void OAuthenticator::LoadSession() { expires_in_ = s.value(kExpiresIn, 0LL).toLongLong(); login_time_ = s.value(kLoginTime, 0LL).toLongLong(); country_code_ = s.value(kCountryCode).toString(); - user_id_ = s.value(kUserId).toInt(); + user_id_ = s.value(kUserId).toULongLong(); s.endGroup(); StartRefreshLoginTimer(); @@ -557,7 +557,7 @@ void OAuthenticator::AccessTokenRequestFinished(QNetworkReply *reply) { const QJsonObject object_user = json_object["user"_L1].toObject(); if (object_user.contains("countryCode"_L1) && object_user.contains("userId"_L1)) { country_code_ = object_user["countryCode"_L1].toString(); - user_id_ = object_user["userId"_L1].toInt(); + user_id_ = static_cast(object_user["userId"_L1].toInt()); } } diff --git a/src/core/player.cpp b/src/core/player.cpp index d01721e5c..5dcf8a5b7 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -173,7 +173,7 @@ void Player::LoadVolume() { Settings s; s.beginGroup(kSettingsGroup); - const uint volume = s.value(kVolume, 100).toInt(); + const uint volume = s.value(kVolume, 100).toUInt(); s.endGroup(); SetVolume(volume); @@ -240,7 +240,7 @@ void Player::ResumePlayback() { s.beginGroup(kSettingsGroup); const EngineBase::State playback_state = static_cast(s.value(kPlaybackState, static_cast(EngineBase::State::Empty)).toInt()); const int playback_playlist = s.value(kPlaybackPlaylist, -1).toInt(); - const int playback_position = s.value(kPlaybackPosition, 0).toInt(); + const quint64 playback_position = s.value(kPlaybackPosition, 0).toULongLong(); s.endGroup(); if (playback_playlist == playlist_manager_->current()->id()) { @@ -372,7 +372,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) { if (is_current) { qLog(Debug) << "Playing song" << current_item->Metadata().title() << result.stream_url_ << "position" << play_offset_nanosec_; - engine_->Play(result.media_url_, result.stream_url_, pause_, stream_change_type_, song.has_cue(), song.beginning_nanosec(), song.end_nanosec(), play_offset_nanosec_, song.ebur128_integrated_loudness_lufs()); + engine_->Play(result.media_url_, result.stream_url_, pause_, stream_change_type_, song.has_cue(), static_cast(song.beginning_nanosec()), song.end_nanosec(), play_offset_nanosec_, song.ebur128_integrated_loudness_lufs()); current_item_ = current_item; play_offset_nanosec_ = 0; } @@ -528,7 +528,7 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll } else { pause_time_ = QDateTime::currentDateTime(); - play_offset_nanosec_ = engine_->position_nanosec(); + play_offset_nanosec_ = static_cast(engine_->position_nanosec()); engine_->Pause(); } break; @@ -556,10 +556,10 @@ void Player::UnPause() { if (current_item_ && pause_time_.isValid()) { const Song &song = current_item_->Metadata(); if (url_handlers_->CanHandle(song.url()) && song.stream_url_can_expire()) { - const quint64 time = QDateTime::currentSecsSinceEpoch() - pause_time_.toSecsSinceEpoch(); + const qint64 time = QDateTime::currentSecsSinceEpoch() - pause_time_.toSecsSinceEpoch(); if (time >= 30) { // Stream URL might be expired. qLog(Debug) << "Re-requesting stream URL for" << song.url(); - play_offset_nanosec_ = engine_->position_nanosec(); + play_offset_nanosec_ = static_cast(engine_->position_nanosec()); UrlHandler *url_handler = url_handlers_->GetUrlHandler(song.url()); HandleLoadResult(url_handler->StartLoading(song.url())); return; @@ -654,7 +654,7 @@ void Player::EngineStateChanged(const EngineBase::State state) { switch (state) { case EngineBase::State::Paused: pause_time_ = QDateTime::currentDateTime(); - play_offset_nanosec_ = engine_->position_nanosec(); + play_offset_nanosec_ = static_cast(engine_->position_nanosec()); Q_EMIT Paused(); break; case EngineBase::State::Playing: @@ -774,7 +774,7 @@ void Player::PlayAt(const int index, const bool pause, const quint64 offset_nano } else { qLog(Debug) << "Playing song" << current_item_->Metadata().title() << url << "position" << offset_nanosec; - engine_->Play(current_item_->Url(), url, pause, change, current_item_->Metadata().has_cue(), current_item_->effective_beginning_nanosec(), current_item_->effective_end_nanosec(), offset_nanosec, current_item_->effective_ebur128_integrated_loudness_lufs()); + engine_->Play(current_item_->Url(), url, pause, change, current_item_->Metadata().has_cue(), static_cast(current_item_->effective_beginning_nanosec()), current_item_->effective_end_nanosec(), offset_nanosec, current_item_->effective_ebur128_integrated_loudness_lufs()); } } @@ -782,7 +782,7 @@ void Player::PlayAt(const int index, const bool pause, const quint64 offset_nano void Player::CurrentMetadataChanged(const Song &metadata) { // Those things might have changed (especially when a previously invalid song was reloaded) so we push the latest version into Engine - engine_->RefreshMarkers(metadata.beginning_nanosec(), metadata.end_nanosec()); + engine_->RefreshMarkers(static_cast(metadata.beginning_nanosec()), metadata.end_nanosec()); } @@ -796,7 +796,7 @@ void Player::SeekTo(const quint64 seconds) { } const qint64 nanosec = qBound(0LL, static_cast(seconds) * kNsecPerSec, length_nanosec); - engine_->Seek(nanosec); + engine_->Seek(static_cast(nanosec)); qLog(Debug) << "Track seeked to" << nanosec << "ns - updating scrobble point"; playlist_manager_->active()->UpdateScrobblePoint(nanosec); @@ -810,11 +810,11 @@ void Player::SeekTo(const quint64 seconds) { } void Player::SeekForward() { - SeekTo(engine()->position_nanosec() / kNsecPerSec + seek_step_sec_); + SeekTo(static_cast(engine()->position_nanosec() / kNsecPerSec + seek_step_sec_)); } void Player::SeekBackward() { - SeekTo(engine()->position_nanosec() / kNsecPerSec - seek_step_sec_); + SeekTo(static_cast(engine()->position_nanosec() / kNsecPerSec - seek_step_sec_)); } void Player::EngineMetadataReceived(const EngineMetadata &engine_metadata) { diff --git a/src/core/windows7thumbbar.cpp b/src/core/windows7thumbbar.cpp index d55a73f8c..6e5c7a0da 100644 --- a/src/core/windows7thumbbar.cpp +++ b/src/core/windows7thumbbar.cpp @@ -140,12 +140,12 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) { for (int i = 0; i < actions_.count(); ++i) { const QAction *action = actions_[i]; THUMBBUTTON *button = &buttons[i]; - button->iId = i; + button->iId = static_cast(i); SetupButton(action, button); } qLog(Debug) << "Adding" << actions_.count() << "buttons"; - HRESULT hr = taskbar_list_->ThumbBarAddButtons(reinterpret_cast(widget_->winId()), actions_.count(), buttons); + HRESULT hr = taskbar_list_->ThumbBarAddButtons(reinterpret_cast(widget_->winId()), static_cast(actions_.count()), buttons); if (hr != S_OK) { qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD(hr); } @@ -185,11 +185,11 @@ void Windows7ThumbBar::ActionChanged() { QAction *action = actions_[i]; THUMBBUTTON *button = &buttons[i]; - button->iId = i; + button->iId = static_cast(i); SetupButton(action, button); } - HRESULT hr = taskbar_list_->ThumbBarUpdateButtons(reinterpret_cast(widget_->winId()), actions_.count(), buttons); + HRESULT hr = taskbar_list_->ThumbBarUpdateButtons(reinterpret_cast(widget_->winId()), static_cast(actions_.count()), buttons); if (hr != S_OK) { qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD(hr); } diff --git a/src/covermanager/discogscoverprovider.cpp b/src/covermanager/discogscoverprovider.cpp index 80377eef9..8813557d2 100644 --- a/src/covermanager/discogscoverprovider.cpp +++ b/src/covermanager/discogscoverprovider.cpp @@ -283,7 +283,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) Error(QStringLiteral("Invalid Json reply, results value object is missing ID, title or resource_url."), object_result); continue; } - const quint64 release_id = object_result["id"_L1].toInt(); + const quint64 release_id = static_cast(object_result["id"_L1].toInt()); const QUrl resource_url(object_result["resource_url"_L1].toString()); QString title = object_result["title"_L1].toString(); diff --git a/src/covermanager/discogscoverprovider.h b/src/covermanager/discogscoverprovider.h index f5624c3c6..1c61e1a00 100644 --- a/src/covermanager/discogscoverprovider.h +++ b/src/covermanager/discogscoverprovider.h @@ -54,7 +54,7 @@ class DiscogsCoverProvider : public JsonCoverProvider { }; struct DiscogsCoverReleaseContext { - explicit DiscogsCoverReleaseContext(const quint64 _search_id = 0, const quint64 _id = 0, const QUrl &_url = QUrl()) : search_id(_search_id), id(_id), url(_url) {} + explicit DiscogsCoverReleaseContext(const int _search_id = 0, const quint64 _id = 0, const QUrl &_url = QUrl()) : search_id(_search_id), id(_id), url(_url) {} int search_id; quint64 id; QUrl url; diff --git a/src/device/devicedatabasebackend.cpp b/src/device/devicedatabasebackend.cpp index 7f3cf646b..b29951be0 100644 --- a/src/device/devicedatabasebackend.cpp +++ b/src/device/devicedatabasebackend.cpp @@ -99,7 +99,7 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() { dev.id_ = q.value(0).toInt(); dev.unique_id_ = q.value(1).toString(); dev.friendly_name_ = q.value(2).toString(); - dev.size_ = q.value(3).toLongLong(); + dev.size_ = q.value(3).toULongLong(); dev.icon_name_ = q.value(4).toString(); int schema_version = q.value(5).toInt(); dev.transcode_mode_ = static_cast(q.value(6).toInt()); diff --git a/src/device/deviceproperties.cpp b/src/device/deviceproperties.cpp index f891b0d87..db666bcaa 100644 --- a/src/device/deviceproperties.cpp +++ b/src/device/deviceproperties.cpp @@ -184,11 +184,11 @@ void DeviceProperties::UpdateHardwareInfo() { } // Size - quint64 total = index_.data(DeviceManager::Role_Capacity).toLongLong(); + quint64 total = index_.data(DeviceManager::Role_Capacity).toULongLong(); QVariant free_var = index_.data(DeviceManager::Role_FreeSpace); if (free_var.isValid()) { - quint64 free = free_var.toLongLong(); + quint64 free = free_var.toULongLong(); ui_->free_space_bar->set_total_bytes(total); ui_->free_space_bar->set_free_bytes(free); diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index b8a2eca03..c0e0180c5 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -137,8 +137,8 @@ EditTagDialog::EditTagDialog(const SharedPtr network, image_no_cover_thumbnail_(ImageUtils::GenerateNoCoverImage(QSize(128, 128), devicePixelRatioF())), loading_(false), ignore_edits_(false), - summary_cover_art_id_(-1), - tags_cover_art_id_(-1), + summary_cover_art_id_(0), + tags_cover_art_id_(0), cover_art_is_set_(false), save_tag_pending_(0), lyrics_id_(-1) { @@ -719,7 +719,7 @@ void EditTagDialog::SelectionChanged() { const bool enable_change_art = first_song.is_local_collection_song(); ui_->tags_art_button->setEnabled(enable_change_art); if ((art_different && first_cover_action != UpdateCoverAction::New) || action_different) { - tags_cover_art_id_ = -1; // Cancels any pending art load. + tags_cover_art_id_ = 0; // Cancels any pending art load. ui_->tags_art->clear(); ui_->tags_art->setText(QLatin1String(kArtDifferentHintText)); album_cover_choice_controller_->show_cover_action()->setEnabled(false); @@ -784,9 +784,9 @@ void EditTagDialog::SetText(QLabel *label, const int value, const QString &suffi label->setText(value <= 0 ? def : (QString::number(value) + QLatin1Char(' ') + suffix)); } -void EditTagDialog::SetDate(QLabel *label, const uint time) { +void EditTagDialog::SetDate(QLabel *label, const qint64 time) { - if (time == std::numeric_limits::max()) { // -1 + if (time == std::numeric_limits::max()) { // -1 label->setText(QObject::tr("Unknown")); } else { @@ -819,7 +819,7 @@ void EditTagDialog::UpdateSummaryTab(const Song &song) { ui_->filesize->setText(tr("Unknown")); } else { - ui_->filesize->setText(Utilities::PrettySize(song.filesize())); + ui_->filesize->setText(Utilities::PrettySize(static_cast(song.filesize()))); } ui_->filetype->setText(song.TextForFiletype()); @@ -931,7 +931,7 @@ void EditTagDialog::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderRes summary += GetArtSummary(data_[idx.row()].current_, result.type); ui_->summary->setText(summary); } - summary_cover_art_id_ = -1; + summary_cover_art_id_ = 0; } else if (id == tags_cover_art_id_) { if (result.success && !result.image_scaled.isNull() && result.type != AlbumCoverLoaderResult::Type::Unset) { @@ -964,7 +964,7 @@ void EditTagDialog::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderRes ui_->tags_summary->setText(summary); enable_change_art = first_song.is_local_collection_song() && !first_song.effective_albumartist().isEmpty() && !first_song.album().isEmpty(); } - tags_cover_art_id_ = -1; + tags_cover_art_id_ = 0; album_cover_choice_controller_->show_cover_action()->setEnabled(result.success && result.type != AlbumCoverLoaderResult::Type::Unset); album_cover_choice_controller_->cover_to_file_action()->setEnabled(result.success && result.type != AlbumCoverLoaderResult::Type::Unset); album_cover_choice_controller_->delete_cover_action()->setEnabled(enable_change_art && result.success && result.type != AlbumCoverLoaderResult::Type::Unset); diff --git a/src/dialogs/edittagdialog.h b/src/dialogs/edittagdialog.h index c7e41a904..38e6832ed 100644 --- a/src/dialogs/edittagdialog.h +++ b/src/dialogs/edittagdialog.h @@ -187,7 +187,7 @@ class EditTagDialog : public QDialog { void SaveData(); static void SetText(QLabel *label, const int value, const QString &suffix, const QString &def = QString()); - static void SetDate(QLabel *label, const uint time); + static void SetDate(QLabel *label, const qint64 time); private: static const char kTagsDifferentHintText[]; diff --git a/src/engine/AsyncOperations.h b/src/engine/AsyncOperations.h index 68d4442e5..afba791f1 100644 --- a/src/engine/AsyncOperations.h +++ b/src/engine/AsyncOperations.h @@ -8,6 +8,9 @@ #include #include +#pragma warning(push) +#pragma warning(disable : 4100) + // eg. TOperation = IAsyncOperationWithProgress // eg. THandler = IAsyncOperationWithProgressCompletedHandler template @@ -83,3 +86,5 @@ template HRESULT SyncWait(_In_ ABI::Windows::Foundation::IAsyncOperationWithProgress *pOperation, _In_ DWORD dwMilliseconds = INFINITE) { return SyncWait, ABI::Windows::Foundation::IAsyncOperationWithProgressCompletedHandler>(pOperation, dwMilliseconds); } + +#pragma warning(pop) diff --git a/src/engine/ebur128analysis.cpp b/src/engine/ebur128analysis.cpp index 387502ad7..c0e330d47 100644 --- a/src/engine/ebur128analysis.cpp +++ b/src/engine/ebur128analysis.cpp @@ -257,17 +257,17 @@ bool operator!=(const FrameFormat &lhs, const FrameFormat &rhs) { EBUR128State::EBUR128State(const FrameFormat &_dsc) : dsc(_dsc) { - st.reset(ebur128_init(dsc.channels, dsc.samplerate, EBUR128_MODE_I | EBUR128_MODE_LRA)); + st.reset(ebur128_init(static_cast(dsc.channels), static_cast(dsc.samplerate), EBUR128_MODE_I | EBUR128_MODE_LRA)); Q_ASSERT(st); - std::vector positions(dsc.channels, GST_AUDIO_CHANNEL_POSITION_INVALID); + std::vector positions(static_cast(dsc.channels), GST_AUDIO_CHANNEL_POSITION_INVALID); gboolean success = gst_audio_channel_positions_from_mask(dsc.channels, dsc.channel_mask, positions.data()); Q_ASSERT(success); // Propagate our knowledge of audio channel mapping to libebur128, doing so // is important because loudness measurement is channel-position dependent. for (int channel_number = 0; channel_number != dsc.channels; ++channel_number) { - ebur128_set_channel(&*st, channel_number, gst_channel_to_ebur_channel(positions[channel_number])); + ebur128_set_channel(&*st, static_cast(channel_number), gst_channel_to_ebur_channel(positions[static_cast(channel_number)])); } } @@ -371,7 +371,7 @@ GstFlowReturn EBUR128AnalysisImpl::NewBufferCallback(GstAppSink *app_sink, gpoin if (buffer) { GstMapInfo map; if (gst_buffer_map(buffer, &map, GST_MAP_READ)) { - me->state->AddFrames(reinterpret_cast(map.data), static_cast(map.size)); + me->state->AddFrames(reinterpret_cast(map.data), static_cast(map.size)); gst_buffer_unmap(buffer, &map); } } diff --git a/src/engine/enginebase.cpp b/src/engine/enginebase.cpp index 3d6f2d0f3..e6cae0b90 100644 --- a/src/engine/enginebase.cpp +++ b/src/engine/enginebase.cpp @@ -163,7 +163,7 @@ void EngineBase::ReloadSettings() { channels_enabled_ = s.value(BackendSettings::kChannelsEnabled, false).toBool(); channels_ = s.value(BackendSettings::kChannels, 0).toInt(); - buffer_duration_nanosec_ = s.value(BackendSettings::kBufferDuration, BackendSettings::kDefaultBufferDuration).toLongLong() * kNsecPerMsec; + buffer_duration_nanosec_ = s.value(BackendSettings::kBufferDuration, BackendSettings::kDefaultBufferDuration).toULongLong() * kNsecPerMsec; buffer_low_watermark_ = s.value(BackendSettings::kBufferLowWatermark, BackendSettings::kDefaultBufferLowWatermark).toDouble(); buffer_high_watermark_ = s.value(BackendSettings::kBufferHighWatermark, BackendSettings::kDefaultBufferHighWatermark).toDouble(); diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index 8457f5846..5df4df704 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -137,10 +137,10 @@ GstEngine::~GstEngine() { if (discoverer_) { if (discovery_discovered_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_discovered_cb_id_); + g_signal_handler_disconnect(G_OBJECT(discoverer_), static_cast(discovery_discovered_cb_id_)); } if (discovery_finished_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_finished_cb_id_); + g_signal_handler_disconnect(G_OBJECT(discoverer_), static_cast(discovery_finished_cb_id_)); } gst_discoverer_stop(discoverer_); @@ -244,8 +244,8 @@ bool GstEngine::Load(const QUrl &media_url, const QUrl &stream_url, const Engine if (!discoverer_) { discoverer_ = gst_discoverer_new(kDiscoveryTimeoutS * GST_SECOND, nullptr); if (discoverer_) { - discovery_discovered_cb_id_ = CHECKED_GCONNECT(G_OBJECT(discoverer_), "discovered", &StreamDiscovered, this); - discovery_finished_cb_id_ = CHECKED_GCONNECT(G_OBJECT(discoverer_), "finished", &StreamDiscoveryFinished, this); + discovery_discovered_cb_id_ = static_cast(CHECKED_GCONNECT(G_OBJECT(discoverer_), "discovered", &StreamDiscovered, this)); + discovery_finished_cb_id_ = static_cast(CHECKED_GCONNECT(G_OBJECT(discoverer_), "finished", &StreamDiscoveryFinished, this)); gst_discoverer_start(discoverer_); } } @@ -315,7 +315,8 @@ void GstEngine::Stop(const bool stop_after) { media_url_.clear(); stream_url_.clear(); // To ensure we return Empty from state() - beginning_offset_nanosec_ = end_offset_nanosec_ = 0; + beginning_offset_nanosec_ = 0; + end_offset_nanosec_ = 0; // Check if we started a fade out. If it isn't finished yet and the user pressed stop, we cancel the fader and just stop the playback. if (fadeout_pause_pipeline_) { @@ -751,7 +752,7 @@ void GstEngine::PlayDone(const GstStateChangeReturn ret, const bool pause, const stream_url = old_pipeline->stream_url(); stream_url.detach(); } - current_pipeline_ = CreatePipeline(media_url, stream_url, redirect_url, beginning_offset_nanosec_, end_offset_nanosec_, old_pipeline->ebur128_loudness_normalizing_gain_db()); + current_pipeline_ = CreatePipeline(media_url, stream_url, redirect_url, static_cast(beginning_offset_nanosec_), end_offset_nanosec_, old_pipeline->ebur128_loudness_normalizing_gain_db()); FinishPipeline(old_pipeline); Play(pause, offset_nanosec); return; @@ -787,7 +788,7 @@ void GstEngine::BufferingStarted() { } void GstEngine::BufferingProgress(const int percent) { - task_manager_->SetTaskProgress(buffering_task_id_, percent, 100); + task_manager_->SetTaskProgress(buffering_task_id_, static_cast(percent), 100UL); } void GstEngine::BufferingFinished() { diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 73e012a1b..a88cbdf2a 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -163,15 +163,6 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent) equalizer_(nullptr), equalizer_preamp_(nullptr), eventprobe_(nullptr), - upstream_events_probe_cb_id_(0), - buffer_probe_cb_id_(0), - pad_probe_cb_id_(0), - element_added_cb_id_(-1), - element_removed_cb_id_(-1), - pad_added_cb_id_(-1), - notify_source_cb_id_(-1), - about_to_finish_cb_id_(-1), - notify_volume_cb_id_(-1), logged_unsupported_analyzer_format_(false), about_to_finish_(false), finish_requested_(false), @@ -360,52 +351,52 @@ void GstEnginePipeline::Disconnect() { fader_.reset(); } - if (element_added_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(audiobin_), element_added_cb_id_); - element_added_cb_id_ = -1; + if (element_added_cb_id_.has_value()) { + g_signal_handler_disconnect(G_OBJECT(audiobin_), element_added_cb_id_.value()); + element_added_cb_id_.reset(); } - if (element_removed_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(audiobin_), element_removed_cb_id_); - element_removed_cb_id_ = -1; + if (element_removed_cb_id_.has_value()) { + g_signal_handler_disconnect(G_OBJECT(audiobin_), element_removed_cb_id_.value()); + element_removed_cb_id_.reset(); } - if (pad_added_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_); - pad_added_cb_id_ = -1; + if (pad_added_cb_id_.has_value()) { + g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_.value()); + pad_added_cb_id_.reset(); } - if (notify_source_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_); - notify_source_cb_id_ = -1; + if (notify_source_cb_id_.has_value()) { + g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_.value()); + notify_source_cb_id_.reset(); } - if (about_to_finish_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_); - about_to_finish_cb_id_ = -1; + if (about_to_finish_cb_id_.has_value()) { + g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_.value()); + about_to_finish_cb_id_.reset(); } - if (notify_volume_cb_id_ != -1) { - g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_); - notify_volume_cb_id_ = -1; + if (notify_volume_cb_id_.has_value()) { + g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_.value()); + notify_volume_cb_id_.reset(); } - if (upstream_events_probe_cb_id_ != 0) { + if (upstream_events_probe_cb_id_.has_value()) { GstPad *pad = gst_element_get_static_pad(eventprobe_, "src"); if (pad) { - gst_pad_remove_probe(pad, upstream_events_probe_cb_id_); + gst_pad_remove_probe(pad, upstream_events_probe_cb_id_.value()); gst_object_unref(pad); } - upstream_events_probe_cb_id_ = 0; + upstream_events_probe_cb_id_.reset(); } - if (buffer_probe_cb_id_ != 0) { + if (buffer_probe_cb_id_.has_value()) { GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src"); if (pad) { - gst_pad_remove_probe(pad, buffer_probe_cb_id_); + gst_pad_remove_probe(pad, buffer_probe_cb_id_.value()); gst_object_unref(pad); } - buffer_probe_cb_id_ = 0; + buffer_probe_cb_id_.reset(); } { @@ -718,7 +709,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { int last_band_frequency = 0; for (int i = 0; i < kEqBandCount; ++i) { const int index_in_eq = i + 1; - GstObject *band = GST_OBJECT(gst_child_proxy_get_child_by_index(GST_CHILD_PROXY(equalizer_), index_in_eq)); + GstObject *band = GST_OBJECT(gst_child_proxy_get_child_by_index(GST_CHILD_PROXY(equalizer_), static_cast(index_in_eq))); if (band) { const float frequency = static_cast(kEqBandFrequencies[i]); const float bandwidth = frequency - static_cast(last_band_frequency); @@ -943,13 +934,13 @@ void GstEnginePipeline::SetupVolume(GstElement *element) { if (volume_) { qLog(Debug) << "Disonnecting volume notify on" << volume_; - g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_); - notify_volume_cb_id_ = -1; + g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_.value()); + notify_volume_cb_id_.reset(); volume_ = nullptr; } qLog(Debug) << "Connecting volume notify on" << element; - notify_volume_cb_id_ = CHECKED_GCONNECT(G_OBJECT(element), "notify::volume", &NotifyVolumeCallback, this); + notify_volume_cb_id_ = static_cast(CHECKED_GCONNECT(G_OBJECT(element), "notify::volume", &NotifyVolumeCallback, this)); volume_ = element; volume_set_ = false; @@ -1029,10 +1020,10 @@ void GstEnginePipeline::ElementRemovedCallback(GstBin *bin, GstBin *sub_bin, Gst if (bin != GST_BIN(instance->audiobin_)) return; - if (instance->notify_volume_cb_id_ != -1 && element == instance->volume_) { + if (instance->notify_volume_cb_id_.has_value() && element == instance->volume_) { qLog(Debug) << "Disconnecting volume notify on" << instance->volume_; - g_signal_handler_disconnect(G_OBJECT(instance->volume_), instance->notify_volume_cb_id_); - instance->notify_volume_cb_id_ = -1; + g_signal_handler_disconnect(G_OBJECT(instance->volume_), instance->notify_volume_cb_id_.value()); + instance->notify_volume_cb_id_.reset(); instance->volume_ = nullptr; instance->volume_set_ = false; } @@ -1239,14 +1230,14 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb int32_t *s = reinterpret_cast(map_info.data); int samples = static_cast((map_info.size / sizeof(int32_t)) / channels); int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; - int16_t *d = static_cast(g_malloc(buf16_size)); - memset(d, 0, buf16_size); + int16_t *d = static_cast(g_malloc(static_cast(buf16_size))); + memset(d, 0, static_cast(buf16_size)); for (int i = 0; i < (samples * channels); ++i) { d[i] = static_cast((s[i] >> 16)); } gst_buffer_unmap(buf, &map_info); - buf16 = gst_buffer_new_wrapped(d, buf16_size); - GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); + buf16 = gst_buffer_new_wrapped(d, static_cast(buf16_size)); + GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast(samples * sizeof(int16_t) / channels), static_cast(rate)); buf = buf16; instance->logged_unsupported_analyzer_format_ = false; @@ -1260,15 +1251,15 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb float *s = reinterpret_cast(map_info.data); int samples = static_cast((map_info.size / sizeof(float)) / channels); int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; - int16_t *d = static_cast(g_malloc(buf16_size)); - memset(d, 0, buf16_size); + int16_t *d = static_cast(g_malloc(static_cast(buf16_size))); + memset(d, 0, static_cast(buf16_size)); for (int i = 0; i < (samples * channels); ++i) { float sample_float = (s[i] * static_cast(32768.0)); d[i] = static_cast(sample_float); } gst_buffer_unmap(buf, &map_info); - buf16 = gst_buffer_new_wrapped(d, buf16_size); - GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); + buf16 = gst_buffer_new_wrapped(d, static_cast(buf16_size)); + GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast(samples * sizeof(int16_t) / channels), static_cast(rate)); buf = buf16; instance->logged_unsupported_analyzer_format_ = false; @@ -1282,16 +1273,16 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb int8_t *s24e = s24 + map_info.size; int samples = static_cast((map_info.size / sizeof(int8_t)) / channels); int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; - int16_t *s16 = static_cast(g_malloc(buf16_size)); - memset(s16, 0, buf16_size); + int16_t *s16 = static_cast(g_malloc(static_cast(buf16_size))); + memset(s16, 0, static_cast(buf16_size)); for (int i = 0; i < (samples * channels); ++i) { s16[i] = *(reinterpret_cast(s24 + 1)); s24 += 3; if (s24 >= s24e) break; } gst_buffer_unmap(buf, &map_info); - buf16 = gst_buffer_new_wrapped(s16, buf16_size); - GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); + buf16 = gst_buffer_new_wrapped(s16, static_cast(buf16_size)); + GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast(samples * sizeof(int16_t) / channels), static_cast(rate)); buf = buf16; instance->logged_unsupported_analyzer_format_ = false; @@ -1306,8 +1297,8 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb int32_t *s32p = s32; int samples = static_cast((map_info.size / sizeof(int32_t)) / channels); int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; - int16_t *s16 = static_cast(g_malloc(buf16_size)); - memset(s16, 0, buf16_size); + int16_t *s16 = static_cast(g_malloc(static_cast(buf16_size))); + memset(s16, 0, static_cast(buf16_size)); for (int i = 0; i < (samples * channels); ++i) { int8_t *s24 = reinterpret_cast(s32p); s16[i] = *(reinterpret_cast(s24 + 1)); @@ -1315,8 +1306,8 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb if (s32p > s32e) break; } gst_buffer_unmap(buf, &map_info); - buf16 = gst_buffer_new_wrapped(s16, buf16_size); - GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); + buf16 = gst_buffer_new_wrapped(s16, static_cast(buf16_size)); + GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast(samples * sizeof(int16_t) / channels), static_cast(rate)); buf = buf16; instance->logged_unsupported_analyzer_format_ = false; @@ -2021,7 +2012,7 @@ void GstEnginePipeline::UpdateEqualizer() { const int index_in_eq = i + 1; // Offset because of the first dummy band we created. - GstObject *band = GST_OBJECT(gst_child_proxy_get_child_by_index(GST_CHILD_PROXY(equalizer_), index_in_eq)); + GstObject *band = GST_OBJECT(gst_child_proxy_get_child_by_index(GST_CHILD_PROXY(equalizer_), static_cast(index_in_eq))); g_object_set(G_OBJECT(band), "gain", gain, nullptr); g_object_unref(G_OBJECT(band)); } diff --git a/src/engine/gstenginepipeline.h b/src/engine/gstenginepipeline.h index 97a6d40b8..4f99626e9 100644 --- a/src/engine/gstenginepipeline.h +++ b/src/engine/gstenginepipeline.h @@ -24,6 +24,8 @@ #include "config.h" +#include + #include #include #include @@ -357,15 +359,15 @@ class GstEnginePipeline : public QObject { GstElement *equalizer_preamp_; GstElement *eventprobe_; - gulong upstream_events_probe_cb_id_; - gulong buffer_probe_cb_id_; - gulong pad_probe_cb_id_; - glong element_added_cb_id_; - glong element_removed_cb_id_; - glong pad_added_cb_id_; - glong notify_source_cb_id_; - glong about_to_finish_cb_id_; - glong notify_volume_cb_id_; + std::optional upstream_events_probe_cb_id_; + std::optional buffer_probe_cb_id_; + std::optional pad_probe_cb_id_; + std::optional element_added_cb_id_; + std::optional element_removed_cb_id_; + std::optional pad_added_cb_id_; + std::optional notify_source_cb_id_; + std::optional about_to_finish_cb_id_; + std::optional notify_volume_cb_id_; bool logged_unsupported_analyzer_format_; mutex_protected about_to_finish_; diff --git a/src/engine/gstfastspectrum.cpp b/src/engine/gstfastspectrum.cpp index d17da71e4..5bd93fa29 100644 --- a/src/engine/gstfastspectrum.cpp +++ b/src/engine/gstfastspectrum.cpp @@ -52,10 +52,17 @@ enum { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wold-style-cast" #endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4514) +#endif G_DEFINE_TYPE(GstStrawberryFastSpectrum, gst_strawberry_fastspectrum, GST_TYPE_AUDIO_FILTER) #ifdef __GNUC__ #pragma GCC diagnostic pop #endif +#ifdef _MSC_VER +#pragma warning(pop) +#endif static void gst_strawberry_fastspectrum_finalize(GObject *object); static void gst_strawberry_fastspectrum_set_property(GObject *object, const guint prop_id, const GValue *value, GParamSpec *pspec); @@ -395,9 +402,9 @@ static GstFlowReturn gst_strawberry_fastspectrum_transform_ip(GstBaseTransform * GstStrawberryFastSpectrum *fastspectrum = reinterpret_cast(transform); - const guint rate = GST_AUDIO_FILTER_RATE(fastspectrum); - const guint bps = GST_AUDIO_FILTER_BPS(fastspectrum); - const guint64 bpf = GST_AUDIO_FILTER_BPF(fastspectrum); + const guint rate = static_cast(GST_AUDIO_FILTER_RATE(fastspectrum)); + const guint bps = static_cast(GST_AUDIO_FILTER_BPS(fastspectrum)); + const guint64 bpf = static_cast(GST_AUDIO_FILTER_BPF(fastspectrum)); const double max_value = static_cast((1UL << ((bps << 3) - 1)) - 1); const guint bands = fastspectrum->bands; const guint nfft = 2 * bands - 2; diff --git a/src/globalshortcuts/globalshortcut-win.cpp b/src/globalshortcuts/globalshortcut-win.cpp index eea4a2702..8f0bdf92a 100644 --- a/src/globalshortcuts/globalshortcut-win.cpp +++ b/src/globalshortcuts/globalshortcut-win.cpp @@ -42,7 +42,7 @@ int GlobalShortcut::nativeKeycode(const Qt::Key qt_keycode) { int key_code = 0; if (KeyMapperWin::keymapper_win_.contains(qt_keycode)) { - key_code = KeyMapperWin::keymapper_win_.value(qt_keycode); + key_code = static_cast(KeyMapperWin::keymapper_win_.value(qt_keycode)); } return key_code; @@ -81,7 +81,7 @@ int GlobalShortcut::nativeKeycode2(const Qt::Key qt_keycode) { bool GlobalShortcut::registerShortcut(const int native_key, const int native_mods) { - return RegisterHotKey(0, native_mods ^ native_key, native_mods, native_key); + return RegisterHotKey(0, native_mods ^ native_key, static_cast(native_mods), static_cast(native_key)); } diff --git a/src/main.cpp b/src/main.cpp index 451f626c4..a98998283 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) { // Seed the random number generators. time_t t = time(nullptr); - srand(t); + srand(static_cast(t)); #ifdef Q_OS_MACOS Utilities::IncreaseFDLimit(); diff --git a/src/moodbar/moodbarbuilder.cpp b/src/moodbar/moodbarbuilder.cpp index 9dc5e7c68..c1e3f55ba 100644 --- a/src/moodbar/moodbarbuilder.cpp +++ b/src/moodbar/moodbarbuilder.cpp @@ -56,7 +56,7 @@ void MoodbarBuilder::Init(const int bands, const int rate_hz) { barkband++; } - barkband_table_.append(barkband); + barkband_table_.append(static_cast(barkband)); } } diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index 62c570a4d..068e94fdf 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -78,7 +78,7 @@ Organize::Organize(const SharedPtr task_manager, overwrite_(overwrite), albumcover_(albumcover), eject_after_(eject_after), - task_count_(songs_info.count()), + task_count_(static_cast(songs_info.count())), playlist_(playlist), tasks_complete_(0), started_(false), @@ -355,7 +355,7 @@ void Organize::UpdateProgress() { // Add the progress of the track that's currently copying progress += current_copy_progress_; - task_manager_->SetTaskProgress(task_id_, progress, total); + task_manager_->SetTaskProgress(task_id_, static_cast(progress), total); } diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp index 0e49bb5a7..93e056f90 100644 --- a/src/organize/organizedialog.cpp +++ b/src/organize/organizedialog.cpp @@ -499,8 +499,8 @@ void OrganizeDialog::UpdatePreviews() { } // Update the free space bar - quint64 capacity = destination.data(MusicStorage::Role_Capacity).toLongLong(); - quint64 free = destination.data(MusicStorage::Role_FreeSpace).toLongLong(); + quint64 capacity = destination.data(MusicStorage::Role_Capacity).toULongLong(); + quint64 free = destination.data(MusicStorage::Role_FreeSpace).toULongLong(); if (capacity > 0) { ui_->free_space->show(); diff --git a/src/osd/osdbase.cpp b/src/osd/osdbase.cpp index 932381796..0cef742d5 100644 --- a/src/osd/osdbase.cpp +++ b/src/osd/osdbase.cpp @@ -463,9 +463,9 @@ bool OSDBase::SupportsNativeNotifications() const { #ifdef Q_OS_WIN32 return SupportsTrayPopups(); -#endif - +#else return false; +#endif } diff --git a/src/osd/osdpretty.cpp b/src/osd/osdpretty.cpp index 90c5ac828..1942f63a5 100644 --- a/src/osd/osdpretty.cpp +++ b/src/osd/osdpretty.cpp @@ -233,8 +233,8 @@ void OSDPretty::Load() { Settings s; s.beginGroup(OSDPrettySettings::kSettingsGroup); - foreground_color_ = QColor(s.value(OSDPrettySettings::kForegroundColor, 0).toInt()); - background_color_ = QColor(s.value(OSDPrettySettings::kBackgroundColor, OSDPrettySettings::kPresetBlue).toInt()); + foreground_color_ = QColor(static_cast(s.value(OSDPrettySettings::kForegroundColor, 0).toInt())); + background_color_ = QColor(static_cast(s.value(OSDPrettySettings::kBackgroundColor, OSDPrettySettings::kPresetBlue).toInt())); background_opacity_ = s.value(OSDPrettySettings::kBackgroundOpacity, 0.85).toFloat(); font_.fromString(s.value(OSDPrettySettings::kFont, u"Verdana,9,-1,5,50,0,0,0,0,0"_s).toString()); disable_duration_ = s.value(OSDPrettySettings::kDisableDuration, false).toBool(); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 4efa94869..cdaf8eccf 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -1439,8 +1439,6 @@ QString Playlist::abbreviated_column_name(const Column column) { return column_name; } - return ""_L1; - } void Playlist::sort(const int column_number, const Qt::SortOrder order) { diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index d3b163efd..a8826766a 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -177,12 +177,12 @@ void SongLoaderInserter::AsyncLoad() { // First, quick load raw songs. int async_progress = 0; int async_load_id = task_manager_->StartTask(tr("Loading tracks")); - task_manager_->SetTaskProgress(async_load_id, async_progress, pending_.count()); + task_manager_->SetTaskProgress(async_load_id, static_cast(async_progress), static_cast(pending_.count())); bool first_loaded = false; for (int i = 0; i < pending_.count(); ++i) { SongLoader *loader = pending_.value(i); const SongLoader::Result result = loader->LoadFilenamesBlocking(); - task_manager_->SetTaskProgress(async_load_id, ++async_progress); + task_manager_->SetTaskProgress(async_load_id, static_cast(++async_progress)); if (result == SongLoader::Result::Error) { const QStringList errors = loader->errors(); @@ -209,7 +209,7 @@ void SongLoaderInserter::AsyncLoad() { // Songs are inserted in playlist, now load them completely. async_progress = 0; async_load_id = task_manager_->StartTask(tr("Loading tracks info")); - task_manager_->SetTaskProgress(async_load_id, async_progress, songs_.count()); + task_manager_->SetTaskProgress(async_load_id, static_cast(async_progress), static_cast(songs_.count())); SongList songs; for (int i = 0; i < pending_.count(); ++i) { SongLoader *loader = pending_.value(i); @@ -218,7 +218,7 @@ void SongLoaderInserter::AsyncLoad() { loader->LoadMetadataBlocking(); } songs << loader->songs(); - task_manager_->SetTaskProgress(async_load_id, songs.count()); + task_manager_->SetTaskProgress(async_load_id, static_cast(songs.count())); } task_manager_->SetTaskFinished(async_load_id); diff --git a/src/qobuz/qobuzservice.cpp b/src/qobuz/qobuzservice.cpp index aa59f2d3c..40cdf9b8a 100644 --- a/src/qobuz/qobuzservice.cpp +++ b/src/qobuz/qobuzservice.cpp @@ -248,7 +248,7 @@ QString QobuzService::DecodeAppSecret(const QString &app_secret_base64) const { for (int x = 0, y = 0; x < app_secret_binary.length(); ++x , ++y) { if (y == appid.length()) y = 0; - const uint rc = app_secret_binary[x] ^ appid[y]; + const uint rc = static_cast(app_secret_binary[x] ^ appid[y]); if (rc > 0xFFFF) { return app_secret_base64; } diff --git a/src/qobuz/qobuzstreamurlrequest.cpp b/src/qobuz/qobuzstreamurlrequest.cpp index 3c444015e..d3fe7f74c 100644 --- a/src/qobuz/qobuzstreamurlrequest.cpp +++ b/src/qobuz/qobuzstreamurlrequest.cpp @@ -112,7 +112,7 @@ void QobuzStreamURLRequest::GetStreamURL() { reply_->deleteLater(); } - const quint64 timestamp = QDateTime::currentSecsSinceEpoch(); + const quint64 timestamp = static_cast(QDateTime::currentSecsSinceEpoch()); ParamList params_to_sign = ParamList() << Param(u"format_id"_s, QString::number(service_->format())) << Param(u"track_id"_s, QString::number(song_id_)); diff --git a/src/queue/queue.cpp b/src/queue/queue.cpp index 102b02ad1..4fc170a18 100644 --- a/src/queue/queue.cpp +++ b/src/queue/queue.cpp @@ -241,8 +241,8 @@ void Queue::UpdateTotalLength() { Q_ASSERT(playlist_->has_item_at(id)); - quint64 length = playlist_->item_at(id)->Metadata().length_nanosec(); - if (length > 0) total += length; + const qint64 length = playlist_->item_at(id)->Metadata().length_nanosec(); + if (length > 0) total += static_cast(length); } total_length_ns_ = total; diff --git a/src/scrobbler/listenbrainzscrobbler.cpp b/src/scrobbler/listenbrainzscrobbler.cpp index 4365f3505..bfaef5cc4 100644 --- a/src/scrobbler/listenbrainzscrobbler.cpp +++ b/src/scrobbler/listenbrainzscrobbler.cpp @@ -306,7 +306,7 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) { song_playing_ = song; scrobbled_ = false; - timestamp_ = QDateTime::currentSecsSinceEpoch(); + timestamp_ = static_cast(QDateTime::currentSecsSinceEpoch()); if (!song.is_metadata_good() || !authenticated() || settings_->offline()) return; diff --git a/src/scrobbler/scrobblingapi20.cpp b/src/scrobbler/scrobblingapi20.cpp index 34f069708..30cdf059a 100644 --- a/src/scrobbler/scrobblingapi20.cpp +++ b/src/scrobbler/scrobblingapi20.cpp @@ -389,7 +389,7 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) { CheckScrobblePrevSong(); song_playing_ = song; - timestamp_ = QDateTime::currentSecsSinceEpoch(); + timestamp_ = static_cast(QDateTime::currentSecsSinceEpoch()); scrobbled_ = false; if (!authenticated() || !song.is_metadata_good() || settings_->offline()) return; diff --git a/src/smartplaylists/smartplaylistsearchterm.cpp b/src/smartplaylists/smartplaylistsearchterm.cpp index 47273ffb3..99fe54552 100644 --- a/src/smartplaylists/smartplaylistsearchterm.cpp +++ b/src/smartplaylists/smartplaylistsearchterm.cpp @@ -296,8 +296,6 @@ QString SmartPlaylistSearchTerm::OperatorText(const Type type, const Operator op return QString(); } - return QString(); - } QString SmartPlaylistSearchTerm::FieldColumnName(const Field field) { diff --git a/src/smartplaylists/smartplaylistsmodel.cpp b/src/smartplaylists/smartplaylistsmodel.cpp index f91ac16af..0950f1d11 100644 --- a/src/smartplaylists/smartplaylistsmodel.cpp +++ b/src/smartplaylists/smartplaylistsmodel.cpp @@ -285,8 +285,6 @@ QVariant SmartPlaylistsModel::data(const QModelIndex &idx, const int role) const return QVariant(); } - return QVariant(); - } QStringList SmartPlaylistsModel::mimeTypes() const { diff --git a/src/spotify/spotifyservice.cpp b/src/spotify/spotifyservice.cpp index a0a2299d7..752e43d77 100644 --- a/src/spotify/spotifyservice.cpp +++ b/src/spotify/spotifyservice.cpp @@ -198,7 +198,7 @@ void SpotifyService::ReloadSettings() { enabled_ = s.value(SpotifySettings::kEnabled, false).toBool(); - quint64 search_delay = std::max(s.value(SpotifySettings::kSearchDelay, 1500).toInt(), 500); + quint64 search_delay = std::max(s.value(SpotifySettings::kSearchDelay, 1500).toULongLong(), 500ULL); artistssearchlimit_ = s.value(SpotifySettings::kArtistsSearchLimit, 4).toInt(); albumssearchlimit_ = s.value(SpotifySettings::kAlbumsSearchLimit, 10).toInt(); songssearchlimit_ = s.value(SpotifySettings::kSongsSearchLimit, 10).toInt(); diff --git a/src/tagreader/streamtagreader.cpp b/src/tagreader/streamtagreader.cpp index 0b596888a..d469b80b1 100644 --- a/src/tagreader/streamtagreader.cpp +++ b/src/tagreader/streamtagreader.cpp @@ -136,7 +136,7 @@ void StreamTagReader::seek(const TagLibOffsetType offset, const TagLib::IOStream switch (position) { case TagLib::IOStream::Beginning: - cursor_ = offset; + cursor_ = static_cast(offset); break; case TagLib::IOStream::Current: diff --git a/src/tagreader/tagreadergme.cpp b/src/tagreader/tagreadergme.cpp index 476d62601..1c887fb9c 100644 --- a/src/tagreader/tagreadergme.cpp +++ b/src/tagreader/tagreadergme.cpp @@ -108,7 +108,7 @@ TagReaderResult GME::SPC::Read(const QFileInfo &fileinfo, Song *song) { if (length_in_sec <= 0 || length_in_sec >= 0x1FFF) { // This means that parsing the length as a string failed, so get value LE. - length_in_sec = length_bytes[0] | (length_bytes[1] << 8) | (length_bytes[2] << 16); + length_in_sec = static_cast(length_bytes[0] | (length_bytes[1] << 8) | (length_bytes[2] << 16)); } if (length_in_sec < 0x1FFF) { @@ -122,7 +122,7 @@ TagReaderResult GME::SPC::Read(const QFileInfo &fileinfo, Song *song) { quint64 fade_length_in_ms = ConvertSPCStringToNum(fade_bytes); if (fade_length_in_ms > 0x7FFF) { - fade_length_in_ms = fade_bytes[0] | (fade_bytes[1] << 8) | (fade_bytes[2] << 16) | (fade_bytes[3] << 24); + fade_length_in_ms = static_cast(fade_bytes[0] | (fade_bytes[1] << 8) | (fade_bytes[2] << 16) | (fade_bytes[3] << 24)); } Q_UNUSED(fade_length_in_ms) } @@ -188,7 +188,7 @@ quint64 GME::SPC::ConvertSPCStringToNum(const QByteArray &arr) { quint64 result = 0; for (auto it = arr.begin(); it != arr.end(); it++) { - unsigned int num = *it - '0'; + const uint num = static_cast(*it - '0'); if (num > 9) break; result = (result * 10) + num; // Shift Left and add. } @@ -216,7 +216,7 @@ TagReaderResult GME::VGM::Read(const QFileInfo &fileinfo, Song *song) { return TagReaderResult::ErrorCode::FileParseError; } - quint64 pt = GME::UnpackBytes32(gd3_head.constData(), gd3_head.size()); + quint64 pt = GME::UnpackBytes32(gd3_head.constData(), static_cast(gd3_head.size())); file.seek(SAMPLE_COUNT); QByteArray sample_count_bytes = file.read(4); @@ -234,7 +234,7 @@ TagReaderResult GME::VGM::Read(const QFileInfo &fileinfo, Song *song) { file.seek(file.pos() + 4); QByteArray gd3_length_bytes = file.read(4); - quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes.constData(), gd3_length_bytes.size()); + quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes.constData(), static_cast(gd3_length_bytes.size())); QByteArray gd3Data = file.read(gd3_length); QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly); @@ -265,11 +265,11 @@ bool GME::VGM::GetPlaybackLength(const QByteArray &sample_count_bytes, const QBy if (sample_count_bytes.size() != 4) return false; if (loop_count_bytes.size() != 4) return false; - quint64 sample_count = GME::UnpackBytes32(sample_count_bytes.constData(), sample_count_bytes.size()); + quint64 sample_count = GME::UnpackBytes32(sample_count_bytes.constData(), static_cast(sample_count_bytes.size())); if (sample_count == 0) return false; - quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes.constData(), loop_count_bytes.size()); + quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes.constData(), static_cast(loop_count_bytes.size())); if (loop_sample_count == 0) { out_length = sample_count * 1000 / SAMPLE_TIMEBASE; diff --git a/src/tagreader/tagreadertaglib.cpp b/src/tagreader/tagreadertaglib.cpp index 07ad7ac9e..38044da03 100644 --- a/src/tagreader/tagreadertaglib.cpp +++ b/src/tagreader/tagreadertaglib.cpp @@ -625,7 +625,7 @@ void TagReaderTagLib::ParseID3v2Tags(TagLib::ID3v2::Tag *tag, QString *disc, QSt if (frame_field_list.size() > 1) { const int playcount = TagLibStringToQString(frame_field_list[1]).toInt(); if (song->playcount() <= 0 && playcount > 0) { - song->set_playcount(playcount); + song->set_playcount(static_cast(playcount)); } } } @@ -1041,8 +1041,8 @@ TagReaderResult TagReaderTagLib::WriteFile(const QString &filename, const Song & fileref->tag()->setAlbum(song.album().isEmpty() ? TagLib::String() : QStringToTagLibString(song.album())); fileref->tag()->setGenre(song.genre().isEmpty() ? TagLib::String() : QStringToTagLibString(song.genre())); fileref->tag()->setComment(song.comment().isEmpty() ? TagLib::String() : QStringToTagLibString(song.comment())); - fileref->tag()->setYear(song.year() <= 0 ? 0 : song.year()); - fileref->tag()->setTrack(song.track() <= 0 ? 0 : song.track()); + fileref->tag()->setYear(song.year() <= 0 ? 0 : static_cast(song.year())); + fileref->tag()->setTrack(song.track() <= 0 ? 0 : static_cast(song.track())); } bool is_flac = false; @@ -1523,7 +1523,7 @@ void TagReaderTagLib::SetEmbeddedCover(TagLib::FLAC::File *flac_file, TagLib::Og TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture(); picture->setType(TagLib::FLAC::Picture::FrontCover); picture->setMimeType(QStringToTagLibString(mimetype)); - picture->setData(TagLib::ByteVector(data.constData(), data.size())); + picture->setData(TagLib::ByteVector(data.constData(), static_cast(data.size()))); flac_file->addPicture(picture); } @@ -1537,7 +1537,7 @@ void TagReaderTagLib::SetEmbeddedCover(TagLib::Ogg::XiphComment *vorbis_comment, TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture(); picture->setType(TagLib::FLAC::Picture::FrontCover); picture->setMimeType(QStringToTagLibString(mimetype)); - picture->setData(TagLib::ByteVector(data.constData(), data.size())); + picture->setData(TagLib::ByteVector(data.constData(), static_cast(data.size()))); vorbis_comment->addPicture(picture); } @@ -1558,7 +1558,7 @@ void TagReaderTagLib::SetEmbeddedCover(TagLib::ID3v2::Tag *tag, const QByteArray frontcover = new TagLib::ID3v2::AttachedPictureFrame(kID3v2_CoverArt); frontcover->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover); frontcover->setMimeType(QStringToTagLibString(mimetype)); - frontcover->setPicture(TagLib::ByteVector(data.constData(), data.size())); + frontcover->setPicture(TagLib::ByteVector(data.constData(), static_cast(data.size()))); tag->addFrame(frontcover); } @@ -1583,7 +1583,7 @@ void TagReaderTagLib::SetEmbeddedCover(TagLib::MP4::File *aac_file, TagLib::MP4: else { return; } - covers.append(TagLib::MP4::CoverArt(cover_format, TagLib::ByteVector(data.constData(), data.size()))); + covers.append(TagLib::MP4::CoverArt(cover_format, TagLib::ByteVector(data.constData(), static_cast(data.size())))); tag->setItem(kMP4_CoverArt, covers); } diff --git a/src/tidal/tidalservice.cpp b/src/tidal/tidalservice.cpp index c416cb7d2..510844707 100644 --- a/src/tidal/tidalservice.cpp +++ b/src/tidal/tidalservice.cpp @@ -224,7 +224,7 @@ void TidalService::ReloadSettings() { enabled_ = s.value(TidalSettings::kEnabled, false).toBool(); client_id_ = s.value(TidalSettings::kClientId).toString(); quality_ = s.value(TidalSettings::kQuality, u"LOSSLESS"_s).toString(); - quint64 search_delay = s.value(TidalSettings::kSearchDelay, 1500).toInt(); + quint64 search_delay = s.value(TidalSettings::kSearchDelay, 1500).toULongLong(); artistssearchlimit_ = s.value(TidalSettings::kArtistsSearchLimit, 4).toInt(); albumssearchlimit_ = s.value(TidalSettings::kAlbumsSearchLimit, 10).toInt(); songssearchlimit_ = s.value(TidalSettings::kSongsSearchLimit, 10).toInt(); diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp index 537e755fd..f7bbd1406 100644 --- a/src/transcoder/transcoder.cpp +++ b/src/transcoder/transcoder.cpp @@ -604,7 +604,7 @@ void Transcoder::SetElementProperties(const QString &name, GObject *object) { break; } case G_TYPE_UINT:{ - const guint g_value = static_cast(value.toUInt()); + const guint g_value = static_cast(value.toUInt()); qLog(Debug) << "Setting" << property->name << "(uint)" << "to" << g_value; g_object_set(object, property->name, g_value, nullptr); break; diff --git a/src/utilities/fileutils.cpp b/src/utilities/fileutils.cpp index 3d3294c2b..facddfc82 100644 --- a/src/utilities/fileutils.cpp +++ b/src/utilities/fileutils.cpp @@ -59,7 +59,7 @@ bool Copy(QIODevice *source, QIODevice *destination) { if (!destination->open(QIODevice::WriteOnly)) return false; const qint64 bytes = source->size(); - unique_ptr data(new char[bytes]); + unique_ptr data(new char[static_cast(bytes)]); qint64 pos = 0; qint64 bytes_read = 0; diff --git a/src/utilities/scopedwchararray.cpp b/src/utilities/scopedwchararray.cpp index ceb1c3bef..7ec2d3052 100644 --- a/src/utilities/scopedwchararray.cpp +++ b/src/utilities/scopedwchararray.cpp @@ -23,7 +23,7 @@ #include "scopedwchararray.h" ScopedWCharArray::ScopedWCharArray(const QString &str) - : chars_(str.length()), data_(new wchar_t[chars_ + 1]) { + : chars_(str.length()), data_(new wchar_t[static_cast(chars_ + 1)]) { str.toWCharArray(data_.get()); - data_[chars_] = '\0'; + data_[static_cast(chars_)] = '\0'; } diff --git a/src/utilities/scopedwchararray.h b/src/utilities/scopedwchararray.h index 92d0e7063..2b7dfc710 100644 --- a/src/utilities/scopedwchararray.h +++ b/src/utilities/scopedwchararray.h @@ -36,7 +36,7 @@ class ScopedWCharArray { explicit operator wchar_t *() const { return get(); } qint64 characters() const { return chars_; } - qint64 bytes() const { return (chars_ + 1) * sizeof(wchar_t); } + qint64 bytes() const { return (chars_ + 1) * static_cast(sizeof(wchar_t)); } private: Q_DISABLE_COPY(ScopedWCharArray) diff --git a/src/utilities/sqlhelper.h b/src/utilities/sqlhelper.h index 14b273308..54aa4dc8a 100644 --- a/src/utilities/sqlhelper.h +++ b/src/utilities/sqlhelper.h @@ -80,7 +80,7 @@ uint SqlHelper::ValueToUInt(const T &q, const int n) { Q_ASSERT(n < q.count()); - return q.value(n).isNull() || q.value(n).toInt() < 0 ? 0 : q.value(n).toInt(); + return q.value(n).isNull() || q.value(n).toInt() < 0 ? 0 : q.value(n).toUInt(); }