Fix cast warnings with MSVC

This commit is contained in:
Jonas Kvinge
2025-03-25 00:37:07 +01:00
parent d5281abb22
commit 5e031be42c
59 changed files with 207 additions and 207 deletions

View File

@@ -100,7 +100,7 @@ void AnalyzerBase::transform(Scope &scope) {
fht_->logSpectrum(scope.data(), aux.data()); fht_->logSpectrum(scope.data(), aux.data());
fht_->scale(scope.data(), 1.0F / 20); fht_->scale(scope.data(), 1.0F / 20);
scope.resize(fht_->size() / 2); // second half of values are rubbish scope.resize(static_cast<size_t>(fht_->size() / 2)); // second half of values are rubbish
} }
@@ -112,7 +112,7 @@ void AnalyzerBase::paintEvent(QPaintEvent *e) {
switch (engine_->state()) { switch (engine_->state()) {
case EngineBase::State::Playing:{ case EngineBase::State::Playing:{
const EngineBase::Scope &thescope = engine_->scope(timeout_); 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 // convert to mono here - our built in analyzers need mono, but the engines provide interleaved pcm
for (uint x = 0; static_cast<int>(x) < fht_->size(); ++x) { for (uint x = 0; static_cast<int>(x) < fht_->size(); ++x) {
@@ -124,7 +124,7 @@ void AnalyzerBase::paintEvent(QPaintEvent *e) {
transform(lastscope_); transform(lastscope_);
analyze(p, lastscope_, new_frame_); analyze(p, lastscope_, new_frame_);
lastscope_.resize(fht_->size()); lastscope_.resize(static_cast<size_t>(fht_->size()));
break; break;
} }
@@ -153,7 +153,7 @@ int AnalyzerBase::resizeExponent(int exp) {
if (exp != fht_->sizeExp()) { if (exp != fht_->sizeExp()) {
delete fht_; delete fht_;
fht_ = new FHT(exp); fht_ = new FHT(static_cast<uint>(exp));
} }
return exp; return exp;

View File

@@ -85,7 +85,7 @@ void BlockAnalyzer::resizeEvent(QResizeEvent *e) {
// this is the y-offset for drawing from the top of the widget // this is the y-offset for drawing from the top of the widget
y_ = (height() - (rows_ * (kHeight + 1)) + 2) / 2; y_ = (height() - (rows_ * (kHeight + 1)) + 2) / 2;
scope_.resize(columns_); scope_.resize(static_cast<size_t>(columns_));
if (rows_ != oldRows) { if (rows_ != oldRows) {
barpixmap_ = QPixmap(kWidth, rows_ * (kHeight + 1)); 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 // Paint the background
canvas_painter.drawPixmap(0, 0, background_); canvas_painter.drawPixmap(0, 0, background_);
for (int x = 0, y = 0; x < static_cast<int>(scope_.size()); ++x) { for (qint64 x = 0, y = 0; x < static_cast<qint64>(scope_.size()); ++x) {
// determine y // determine y
for (y = 0; scope_[x] < yscale_.at(y); ++y); for (y = 0; scope_[static_cast<quint64>(x)] < yscale_.at(y); ++y);
// This is opposite to what you'd think, higher than y means the bar is lower than y (physically) // This is opposite to what you'd think, higher than y means the bar is lower than y (physically)
if (static_cast<double>(y) > store_.at(x)) { if (static_cast<double>(y) > store_.at(x)) {
@@ -175,13 +175,13 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) {
y = static_cast<int>(store_.value(x)); y = static_cast<int>(store_.value(x));
} }
else { else {
store_[x] = y; store_[x] = static_cast<double>(y);
} }
// If y is lower than fade_pos_, then the bar has exceeded the height of the fadeout // 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 the fadeout is quite faded now, then display the new one
if (y <= fade_pos_.at(x) /*|| fade_intensity_[x] < kFadeSize / 3*/) { if (y <= fade_pos_.at(x) /*|| fade_intensity_[x] < kFadeSize / 3*/) {
fade_pos_[x] = y; fade_pos_[x] = static_cast<int>(y);
fade_intensity_[x] = kFadeSize; fade_intensity_[x] = kFadeSize;
} }
@@ -189,13 +189,13 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) {
--fade_intensity_[x]; --fade_intensity_[x];
const int offset = fade_intensity_.value(x); const int offset = fade_intensity_.value(x);
const int y2 = y_ + (fade_pos_.value(x) * (kHeight + 1)); 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<int>(x) * (kWidth + 1), y2, fade_bars_[offset], 0, 0, kWidth, height() - y2);
} }
if (fade_intensity_.at(x) == 0) fade_pos_[x] = rows_; 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 // 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<int>(x) * (kWidth + 1), static_cast<int>(y) * (kHeight + 1) + y_, *bar(), 0, static_cast<int>(y) * (kHeight + 1), bar()->width(), bar()->height());
} }
for (int x = 0; x < store_.size(); ++x) { for (int x = 0; x < store_.size(); ++x) {

View File

@@ -76,7 +76,7 @@ void BoomAnalyzer::resizeEvent(QResizeEvent *e) {
const double h = 1.2 / HEIGHT; const double h = 1.2 / HEIGHT;
bands_ = qMin(static_cast<int>(static_cast<double>(width() + 1) / (kColumnWidth + 1)) + 1, kMaxBandCount); bands_ = qMin(static_cast<int>(static_cast<double>(width() + 1) / (kColumnWidth + 1)) + 1, kMaxBandCount);
scope_.resize(bands_); scope_.resize(static_cast<size_t>(bands_));
F_ = static_cast<double>(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/); F_ = static_cast<double>(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/);
@@ -112,17 +112,19 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame
return; return;
} }
const uint MAX_HEIGHT = height() - 1; const uint MAX_HEIGHT = static_cast<uint>(height() - 1);
QPainter canvas_painter(&canvas_); QPainter canvas_painter(&canvas_);
canvas_.fill(palette().color(QPalette::Window)); canvas_.fill(palette().color(QPalette::Window));
interpolate(scope, scope_); 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<size_t>(bands_); ++i, x += kColumnWidth + 1) {
double h = log10(scope_[i] * 256.0) * F_; double h = log10(scope_[i] * 256.0) * F_;
if (h > MAX_HEIGHT) h = MAX_HEIGHT; h = std::min(h, static_cast<double>(MAX_HEIGHT));
if (h > bar_height_[i]) { if (h > bar_height_[i]) {
bar_height_[i] = h; bar_height_[i] = h;
@@ -138,7 +140,7 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame
else { else {
if (bar_height_[i] > 0.0) { if (bar_height_[i] > 0.0) {
bar_height_[i] -= K_barHeight_; // 1.4 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: 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_height_[i] -= peak_speed_[i];
peak_speed_[i] *= F_peakSpeed_; // 1.12 peak_speed_[i] *= F_peakSpeed_; // 1.12
if (peak_height_[i] < bar_height_[i]) peak_height_[i] = bar_height_[i]; peak_height_[i] = std::max(bar_height_[i], bar_height_[i]);
if (peak_height_[i] < 0.0) peak_height_[i] = 0.0; peak_height_[i] = std::max(0.0, peak_height_[i]);
} }
} }

View File

@@ -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, // of band pass filters for this, so bands can leak into neighbouring bands,
// but for now it's a series of separate square filters. // but for now it's a series of separate square filters.
const int samples_per_band = scope_size / kRainbowBands; const int samples_per_band = scope_size / kRainbowBands;
int sample = 0; size_t sample = 0;
for (int band = 0; band < kRainbowBands; ++band) { for (int band = 0; band < kRainbowBands; ++band) {
float accumulator = 0.0; float accumulator = 0.0;
for (int i = 0; i < samples_per_band; ++i) { for (int i = 0; i < samples_per_band; ++i) {

View File

@@ -85,10 +85,10 @@ void SonogramAnalyzer::transform(Scope &scope) {
fht_->power2(scope.data()); fht_->power2(scope.data());
fht_->scale(scope.data(), 1.0 / 256); fht_->scale(scope.data(), 1.0 / 256);
scope.resize(fht_->size() / 2); scope.resize(static_cast<size_t>(fht_->size() / 2));
} }
void SonogramAnalyzer::demo(QPainter &p) { void SonogramAnalyzer::demo(QPainter &p) {
analyze(p, Scope(fht_->size(), 0), new_frame_); analyze(p, Scope(static_cast<size_t>(fht_->size()), 0), new_frame_);
} }

View File

@@ -43,7 +43,7 @@ void TurbineAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_fr
return; return;
} }
const uint hd2 = height() / 2; const uint hd2 = static_cast<uint>(height() / 2);
const uint kMaxHeight = hd2 - 1; const uint kMaxHeight = hd2 - 1;
QPainter canvas_painter(&canvas_); QPainter canvas_painter(&canvas_);
@@ -67,7 +67,7 @@ void TurbineAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_fr
else { else {
if (bar_height_[i] > 0.0) { if (bar_height_[i] > 0.0) {
bar_height_[i] -= K_barHeight_; // 1.4 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: peak_handling:

View File

@@ -54,13 +54,13 @@ void WaveRubberAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_fra
const float *amplitude_data = s.data(); const float *amplitude_data = s.data();
const int mid_y = height() / 4; const int mid_y = height() / 4;
const int num_samples = static_cast<int>(s.size()); const size_t num_samples = static_cast<size_t>(s.size());
const float x_scale = static_cast<float>(width()) / static_cast<float>(num_samples); const float x_scale = static_cast<float>(width()) / static_cast<float>(num_samples);
float prev_y = static_cast<float>(mid_y); float prev_y = static_cast<float>(mid_y);
// Draw the waveform // 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 // Normalize amplitude to 0-1 range
const float color_factor = amplitude_data[i] / 2.0F + 0.5F; 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) { void WaveRubberAnalyzer::demo(QPainter &p) {
analyze(p, Scope(fht_->size(), 0), new_frame_); analyze(p, Scope(static_cast<size_t>(fht_->size()), 0), new_frame_);
} }

View File

@@ -199,8 +199,8 @@ void CollectionLibrary::SyncPlaycountAndRatingToFiles() {
task_manager_->SetTaskBlocksCollectionScans(task_id); task_manager_->SetTaskBlocksCollectionScans(task_id);
const SongList songs = backend_->GetAllSongs(); const SongList songs = backend_->GetAllSongs();
const qint64 nb_songs = songs.size(); const quint64 nb_songs = static_cast<quint64>(songs.size());
int i = 0; quint64 i = 0;
for (const Song &song : songs) { for (const Song &song : songs) {
(void)tagreader_client_->SaveSongPlaycountBlocking(song.url().toLocalFile(), song.playcount()); (void)tagreader_client_->SaveSongPlaycountBlocking(song.url().toLocalFile(), song.playcount());
(void)tagreader_client_->SaveSongRatingBlocking(song.url().toLocalFile(), song.rating()); (void)tagreader_client_->SaveSongRatingBlocking(song.url().toLocalFile(), song.rating());

View File

@@ -155,7 +155,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
int total_artist_count() const { return total_artist_count_; } int total_artist_count() const { return total_artist_count_; }
int total_album_count() const { return total_album_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<quint64>(icon_disk_cache_->cacheSize()); }
const CollectionModel::Grouping GetGroupBy() const { return options_current_.group_by; } const CollectionModel::Grouping GetGroupBy() const { return options_current_.group_by; }
void SetGroupBy(const CollectionModel::Grouping g, const std::optional<bool> separate_albums_by_grouping = std::optional<bool>()); void SetGroupBy(const CollectionModel::Grouping g, const std::optional<bool> separate_albums_by_grouping = std::optional<bool>());

View File

@@ -858,7 +858,7 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file,
QHash<quint64, Song> sections_map; QHash<quint64, Song> sections_map;
for (const Song &song : old_cue_songs) { for (const Song &song : old_cue_songs) {
sections_map.insert(song.beginning_nanosec(), song); sections_map.insert(static_cast<quint64>(song.beginning_nanosec()), song);
} }
// Load new CUE songs // Load new CUE songs
@@ -879,8 +879,8 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file,
PerformEBUR128Analysis(new_cue_song); PerformEBUR128Analysis(new_cue_song);
new_cue_song.set_fingerprint(fingerprint); new_cue_song.set_fingerprint(fingerprint);
if (sections_map.contains(new_cue_song.beginning_nanosec())) { // Changed section if (sections_map.contains(static_cast<quint64>(new_cue_song.beginning_nanosec()))) { // Changed section
const Song matching_cue_song = sections_map[new_cue_song.beginning_nanosec()]; const Song matching_cue_song = sections_map[static_cast<quint64>(new_cue_song.beginning_nanosec())];
new_cue_song.set_id(matching_cue_song.id()); new_cue_song.set_id(matching_cue_song.id());
new_cue_song.set_art_automatic(art_automatic); new_cue_song.set_art_automatic(art_automatic);
new_cue_song.MergeUserSetData(matching_cue_song, true, true); 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(); const QDateTime cue_last_modified = fileinfo.lastModified();
return cue_last_modified.isValid() ? cue_last_modified.toSecsSinceEpoch() : 0; return cue_last_modified.isValid() ? static_cast<quint64>(cue_last_modified.toSecsSinceEpoch()) : 0;
} }

View File

@@ -598,7 +598,7 @@ void Database::BackupFile(const QString &filename) {
do { do {
ret = sqlite3_backup_step(backup, 16); ret = sqlite3_backup_step(backup, 16);
const int page_count = sqlite3_backup_pagecount(backup); 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<quint64>(page_count - sqlite3_backup_remaining(backup)), static_cast<quint64>(page_count));
} }
while (ret == SQLITE_OK); while (ret == SQLITE_OK);

View File

@@ -92,7 +92,7 @@ void DeleteFiles::ProcessSomeFiles() {
// None left? // None left?
if (progress_ >= songs_.count()) { if (progress_ >= songs_.count()) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count()); task_manager_->SetTaskProgress(task_id_, static_cast<quint64>(progress_), static_cast<quint64>(songs_.count()));
QString error_text; QString error_text;
storage_->FinishCopy(songs_with_errors_.isEmpty(), error_text); storage_->FinishCopy(songs_with_errors_.isEmpty(), error_text);
@@ -114,7 +114,7 @@ void DeleteFiles::ProcessSomeFiles() {
const qint64 n = qMin(static_cast<qint64>(songs_.count()), static_cast<qint64>(progress_ + kBatchSize)); const qint64 n = qMin(static_cast<qint64>(songs_.count()), static_cast<qint64>(progress_ + kBatchSize));
for (; progress_ < n; ++progress_) { for (; progress_ < n; ++progress_) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count()); task_manager_->SetTaskProgress(task_id_, static_cast<quint64>(progress_), static_cast<quint64>(songs_.count()));
const Song song = songs_.value(progress_); const Song song = songs_.value(progress_);

View File

@@ -52,7 +52,7 @@ LocalRedirectServer::~LocalRedirectServer() {
bool LocalRedirectServer::Listen() { bool LocalRedirectServer::Listen() {
if (!listen(QHostAddress::LocalHost, port_)) { if (!listen(QHostAddress::LocalHost, static_cast<quint64>(port_))) {
success_ = false; success_ = false;
error_ = errorString(); error_ = errorString();
return false; return false;

View File

@@ -2566,10 +2566,10 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
} }
if (options.seek_to() != -1) { if (options.seek_to() != -1) {
app_->player()->SeekTo(options.seek_to()); app_->player()->SeekTo(static_cast<quint64>(options.seek_to()));
} }
else if (options.seek_by() != 0) { else if (options.seek_by() != 0) {
app_->player()->SeekTo(app_->player()->engine()->position_nanosec() / kNsecPerSec + options.seek_by()); app_->player()->SeekTo(static_cast<quint64>(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); if (options.play_track_at() != -1) app_->player()->PlayAt(options.play_track_at(), false, 0, EngineBase::TrackChangeType::Manual, Playlist::AutoScroll::Maybe, true);

View File

@@ -88,6 +88,4 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c
} }
} }
return 0;
} }

View File

@@ -86,7 +86,7 @@ void NetworkProxyFactory::ReloadSettings() {
mode_ = static_cast<Mode>(s.value("mode", static_cast<int>(Mode::System)).toInt()); mode_ = static_cast<Mode>(s.value("mode", static_cast<int>(Mode::System)).toInt());
type_ = QNetworkProxy::ProxyType(s.value("type", QNetworkProxy::HttpProxy).toInt()); type_ = QNetworkProxy::ProxyType(s.value("type", QNetworkProxy::HttpProxy).toInt());
hostname_ = s.value("hostname").toString(); 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(); use_authentication_ = s.value("use_authentication", false).toBool();
username_ = s.value("username").toString(); username_ = s.value("username").toString();
password_ = s.value("password").toString(); password_ = s.value("password").toString();

View File

@@ -57,7 +57,7 @@ class NetworkProxyFactory : public QNetworkProxyFactory {
Mode mode_; Mode mode_;
QNetworkProxy::ProxyType type_; QNetworkProxy::ProxyType type_;
QString hostname_; QString hostname_;
int port_; quint64 port_;
bool use_authentication_; bool use_authentication_;
QString username_; QString username_;
QString password_; QString password_;

View File

@@ -182,7 +182,7 @@ void OAuthenticator::LoadSession() {
expires_in_ = s.value(kExpiresIn, 0LL).toLongLong(); expires_in_ = s.value(kExpiresIn, 0LL).toLongLong();
login_time_ = s.value(kLoginTime, 0LL).toLongLong(); login_time_ = s.value(kLoginTime, 0LL).toLongLong();
country_code_ = s.value(kCountryCode).toString(); country_code_ = s.value(kCountryCode).toString();
user_id_ = s.value(kUserId).toInt(); user_id_ = s.value(kUserId).toULongLong();
s.endGroup(); s.endGroup();
StartRefreshLoginTimer(); StartRefreshLoginTimer();
@@ -557,7 +557,7 @@ void OAuthenticator::AccessTokenRequestFinished(QNetworkReply *reply) {
const QJsonObject object_user = json_object["user"_L1].toObject(); const QJsonObject object_user = json_object["user"_L1].toObject();
if (object_user.contains("countryCode"_L1) && object_user.contains("userId"_L1)) { if (object_user.contains("countryCode"_L1) && object_user.contains("userId"_L1)) {
country_code_ = object_user["countryCode"_L1].toString(); country_code_ = object_user["countryCode"_L1].toString();
user_id_ = object_user["userId"_L1].toInt(); user_id_ = static_cast<quint64>(object_user["userId"_L1].toInt());
} }
} }

View File

@@ -173,7 +173,7 @@ void Player::LoadVolume() {
Settings s; Settings s;
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
const uint volume = s.value(kVolume, 100).toInt(); const uint volume = s.value(kVolume, 100).toUInt();
s.endGroup(); s.endGroup();
SetVolume(volume); SetVolume(volume);
@@ -240,7 +240,7 @@ void Player::ResumePlayback() {
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
const EngineBase::State playback_state = static_cast<EngineBase::State>(s.value(kPlaybackState, static_cast<int>(EngineBase::State::Empty)).toInt()); const EngineBase::State playback_state = static_cast<EngineBase::State>(s.value(kPlaybackState, static_cast<int>(EngineBase::State::Empty)).toInt());
const int playback_playlist = s.value(kPlaybackPlaylist, -1).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(); s.endGroup();
if (playback_playlist == playlist_manager_->current()->id()) { if (playback_playlist == playlist_manager_->current()->id()) {
@@ -372,7 +372,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
if (is_current) { if (is_current) {
qLog(Debug) << "Playing song" << current_item->Metadata().title() << result.stream_url_ << "position" << play_offset_nanosec_; 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<quint64>(song.beginning_nanosec()), song.end_nanosec(), play_offset_nanosec_, song.ebur128_integrated_loudness_lufs());
current_item_ = current_item; current_item_ = current_item;
play_offset_nanosec_ = 0; play_offset_nanosec_ = 0;
} }
@@ -528,7 +528,7 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll
} }
else { else {
pause_time_ = QDateTime::currentDateTime(); pause_time_ = QDateTime::currentDateTime();
play_offset_nanosec_ = engine_->position_nanosec(); play_offset_nanosec_ = static_cast<quint64>(engine_->position_nanosec());
engine_->Pause(); engine_->Pause();
} }
break; break;
@@ -556,10 +556,10 @@ void Player::UnPause() {
if (current_item_ && pause_time_.isValid()) { if (current_item_ && pause_time_.isValid()) {
const Song &song = current_item_->Metadata(); const Song &song = current_item_->Metadata();
if (url_handlers_->CanHandle(song.url()) && song.stream_url_can_expire()) { 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. if (time >= 30) { // Stream URL might be expired.
qLog(Debug) << "Re-requesting stream URL for" << song.url(); qLog(Debug) << "Re-requesting stream URL for" << song.url();
play_offset_nanosec_ = engine_->position_nanosec(); play_offset_nanosec_ = static_cast<quint64>(engine_->position_nanosec());
UrlHandler *url_handler = url_handlers_->GetUrlHandler(song.url()); UrlHandler *url_handler = url_handlers_->GetUrlHandler(song.url());
HandleLoadResult(url_handler->StartLoading(song.url())); HandleLoadResult(url_handler->StartLoading(song.url()));
return; return;
@@ -654,7 +654,7 @@ void Player::EngineStateChanged(const EngineBase::State state) {
switch (state) { switch (state) {
case EngineBase::State::Paused: case EngineBase::State::Paused:
pause_time_ = QDateTime::currentDateTime(); pause_time_ = QDateTime::currentDateTime();
play_offset_nanosec_ = engine_->position_nanosec(); play_offset_nanosec_ = static_cast<quint64>(engine_->position_nanosec());
Q_EMIT Paused(); Q_EMIT Paused();
break; break;
case EngineBase::State::Playing: case EngineBase::State::Playing:
@@ -774,7 +774,7 @@ void Player::PlayAt(const int index, const bool pause, const quint64 offset_nano
} }
else { else {
qLog(Debug) << "Playing song" << current_item_->Metadata().title() << url << "position" << offset_nanosec; 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<quint64>(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) { 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 // 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<quint64>(metadata.beginning_nanosec()), metadata.end_nanosec());
} }
@@ -796,7 +796,7 @@ void Player::SeekTo(const quint64 seconds) {
} }
const qint64 nanosec = qBound(0LL, static_cast<qint64>(seconds) * kNsecPerSec, length_nanosec); const qint64 nanosec = qBound(0LL, static_cast<qint64>(seconds) * kNsecPerSec, length_nanosec);
engine_->Seek(nanosec); engine_->Seek(static_cast<quint64>(nanosec));
qLog(Debug) << "Track seeked to" << nanosec << "ns - updating scrobble point"; qLog(Debug) << "Track seeked to" << nanosec << "ns - updating scrobble point";
playlist_manager_->active()->UpdateScrobblePoint(nanosec); playlist_manager_->active()->UpdateScrobblePoint(nanosec);
@@ -810,11 +810,11 @@ void Player::SeekTo(const quint64 seconds) {
} }
void Player::SeekForward() { void Player::SeekForward() {
SeekTo(engine()->position_nanosec() / kNsecPerSec + seek_step_sec_); SeekTo(static_cast<quint64>(engine()->position_nanosec() / kNsecPerSec + seek_step_sec_));
} }
void Player::SeekBackward() { void Player::SeekBackward() {
SeekTo(engine()->position_nanosec() / kNsecPerSec - seek_step_sec_); SeekTo(static_cast<quint64>(engine()->position_nanosec() / kNsecPerSec - seek_step_sec_));
} }
void Player::EngineMetadataReceived(const EngineMetadata &engine_metadata) { void Player::EngineMetadataReceived(const EngineMetadata &engine_metadata) {

View File

@@ -140,12 +140,12 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
for (int i = 0; i < actions_.count(); ++i) { for (int i = 0; i < actions_.count(); ++i) {
const QAction *action = actions_[i]; const QAction *action = actions_[i];
THUMBBUTTON *button = &buttons[i]; THUMBBUTTON *button = &buttons[i];
button->iId = i; button->iId = static_cast<UINT>(i);
SetupButton(action, button); SetupButton(action, button);
} }
qLog(Debug) << "Adding" << actions_.count() << "buttons"; qLog(Debug) << "Adding" << actions_.count() << "buttons";
HRESULT hr = taskbar_list_->ThumbBarAddButtons(reinterpret_cast<HWND>(widget_->winId()), actions_.count(), buttons); HRESULT hr = taskbar_list_->ThumbBarAddButtons(reinterpret_cast<HWND>(widget_->winId()), static_cast<UINT>(actions_.count()), buttons);
if (hr != S_OK) { if (hr != S_OK) {
qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD(hr); qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD(hr);
} }
@@ -185,11 +185,11 @@ void Windows7ThumbBar::ActionChanged() {
QAction *action = actions_[i]; QAction *action = actions_[i];
THUMBBUTTON *button = &buttons[i]; THUMBBUTTON *button = &buttons[i];
button->iId = i; button->iId = static_cast<UINT>(i);
SetupButton(action, button); SetupButton(action, button);
} }
HRESULT hr = taskbar_list_->ThumbBarUpdateButtons(reinterpret_cast<HWND>(widget_->winId()), actions_.count(), buttons); HRESULT hr = taskbar_list_->ThumbBarUpdateButtons(reinterpret_cast<HWND>(widget_->winId()), static_cast<UINT>(actions_.count()), buttons);
if (hr != S_OK) { if (hr != S_OK) {
qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD(hr); qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD(hr);
} }

View File

@@ -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); Error(QStringLiteral("Invalid Json reply, results value object is missing ID, title or resource_url."), object_result);
continue; continue;
} }
const quint64 release_id = object_result["id"_L1].toInt(); const quint64 release_id = static_cast<quint64>(object_result["id"_L1].toInt());
const QUrl resource_url(object_result["resource_url"_L1].toString()); const QUrl resource_url(object_result["resource_url"_L1].toString());
QString title = object_result["title"_L1].toString(); QString title = object_result["title"_L1].toString();

View File

@@ -54,7 +54,7 @@ class DiscogsCoverProvider : public JsonCoverProvider {
}; };
struct DiscogsCoverReleaseContext { 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; int search_id;
quint64 id; quint64 id;
QUrl url; QUrl url;

View File

@@ -99,7 +99,7 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() {
dev.id_ = q.value(0).toInt(); dev.id_ = q.value(0).toInt();
dev.unique_id_ = q.value(1).toString(); dev.unique_id_ = q.value(1).toString();
dev.friendly_name_ = q.value(2).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(); dev.icon_name_ = q.value(4).toString();
int schema_version = q.value(5).toInt(); int schema_version = q.value(5).toInt();
dev.transcode_mode_ = static_cast<MusicStorage::TranscodeMode>(q.value(6).toInt()); dev.transcode_mode_ = static_cast<MusicStorage::TranscodeMode>(q.value(6).toInt());

View File

@@ -184,11 +184,11 @@ void DeviceProperties::UpdateHardwareInfo() {
} }
// Size // 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); QVariant free_var = index_.data(DeviceManager::Role_FreeSpace);
if (free_var.isValid()) { 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_total_bytes(total);
ui_->free_space_bar->set_free_bytes(free); ui_->free_space_bar->set_free_bytes(free);

View File

@@ -137,8 +137,8 @@ EditTagDialog::EditTagDialog(const SharedPtr<NetworkAccessManager> network,
image_no_cover_thumbnail_(ImageUtils::GenerateNoCoverImage(QSize(128, 128), devicePixelRatioF())), image_no_cover_thumbnail_(ImageUtils::GenerateNoCoverImage(QSize(128, 128), devicePixelRatioF())),
loading_(false), loading_(false),
ignore_edits_(false), ignore_edits_(false),
summary_cover_art_id_(-1), summary_cover_art_id_(0),
tags_cover_art_id_(-1), tags_cover_art_id_(0),
cover_art_is_set_(false), cover_art_is_set_(false),
save_tag_pending_(0), save_tag_pending_(0),
lyrics_id_(-1) { lyrics_id_(-1) {
@@ -719,7 +719,7 @@ void EditTagDialog::SelectionChanged() {
const bool enable_change_art = first_song.is_local_collection_song(); const bool enable_change_art = first_song.is_local_collection_song();
ui_->tags_art_button->setEnabled(enable_change_art); ui_->tags_art_button->setEnabled(enable_change_art);
if ((art_different && first_cover_action != UpdateCoverAction::New) || action_different) { 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->clear();
ui_->tags_art->setText(QLatin1String(kArtDifferentHintText)); ui_->tags_art->setText(QLatin1String(kArtDifferentHintText));
album_cover_choice_controller_->show_cover_action()->setEnabled(false); 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)); 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<uint>::max()) { // -1 if (time == std::numeric_limits<qint64>::max()) { // -1
label->setText(QObject::tr("Unknown")); label->setText(QObject::tr("Unknown"));
} }
else { else {
@@ -819,7 +819,7 @@ void EditTagDialog::UpdateSummaryTab(const Song &song) {
ui_->filesize->setText(tr("Unknown")); ui_->filesize->setText(tr("Unknown"));
} }
else { else {
ui_->filesize->setText(Utilities::PrettySize(song.filesize())); ui_->filesize->setText(Utilities::PrettySize(static_cast<quint64>(song.filesize())));
} }
ui_->filetype->setText(song.TextForFiletype()); 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); summary += GetArtSummary(data_[idx.row()].current_, result.type);
ui_->summary->setText(summary); ui_->summary->setText(summary);
} }
summary_cover_art_id_ = -1; summary_cover_art_id_ = 0;
} }
else if (id == tags_cover_art_id_) { else if (id == tags_cover_art_id_) {
if (result.success && !result.image_scaled.isNull() && result.type != AlbumCoverLoaderResult::Type::Unset) { 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); ui_->tags_summary->setText(summary);
enable_change_art = first_song.is_local_collection_song() && !first_song.effective_albumartist().isEmpty() && !first_song.album().isEmpty(); 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_->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_->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); album_cover_choice_controller_->delete_cover_action()->setEnabled(enable_change_art && result.success && result.type != AlbumCoverLoaderResult::Type::Unset);

View File

@@ -187,7 +187,7 @@ class EditTagDialog : public QDialog {
void SaveData(); void SaveData();
static void SetText(QLabel *label, const int value, const QString &suffix, const QString &def = QString()); 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: private:
static const char kTagsDifferentHintText[]; static const char kTagsDifferentHintText[];

View File

@@ -8,6 +8,9 @@
#include <wrl.h> #include <wrl.h>
#include <windows.foundation.h> #include <windows.foundation.h>
#pragma warning(push)
#pragma warning(disable : 4100)
// eg. TOperation = IAsyncOperationWithProgress<UINT32, UINT32> // eg. TOperation = IAsyncOperationWithProgress<UINT32, UINT32>
// eg. THandler = IAsyncOperationWithProgressCompletedHandler<UINT, UINT> // eg. THandler = IAsyncOperationWithProgressCompletedHandler<UINT, UINT>
template<typename TOperation, typename THandler> template<typename TOperation, typename THandler>
@@ -83,3 +86,5 @@ template<typename TResult, typename TProgress>
HRESULT SyncWait(_In_ ABI::Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress> *pOperation, _In_ DWORD dwMilliseconds = INFINITE) { HRESULT SyncWait(_In_ ABI::Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress> *pOperation, _In_ DWORD dwMilliseconds = INFINITE) {
return SyncWait<ABI::Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress>, ABI::Windows::Foundation::IAsyncOperationWithProgressCompletedHandler<TResult, TProgress>>(pOperation, dwMilliseconds); return SyncWait<ABI::Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress>, ABI::Windows::Foundation::IAsyncOperationWithProgressCompletedHandler<TResult, TProgress>>(pOperation, dwMilliseconds);
} }
#pragma warning(pop)

View File

@@ -257,17 +257,17 @@ bool operator!=(const FrameFormat &lhs, const FrameFormat &rhs) {
EBUR128State::EBUR128State(const FrameFormat &_dsc) : dsc(_dsc) { 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<uint>(dsc.channels), static_cast<ulong>(dsc.samplerate), EBUR128_MODE_I | EBUR128_MODE_LRA));
Q_ASSERT(st); Q_ASSERT(st);
std::vector<GstAudioChannelPosition> positions(dsc.channels, GST_AUDIO_CHANNEL_POSITION_INVALID); std::vector<GstAudioChannelPosition> positions(static_cast<uint>(dsc.channels), GST_AUDIO_CHANNEL_POSITION_INVALID);
gboolean success = gst_audio_channel_positions_from_mask(dsc.channels, dsc.channel_mask, positions.data()); gboolean success = gst_audio_channel_positions_from_mask(dsc.channels, dsc.channel_mask, positions.data());
Q_ASSERT(success); Q_ASSERT(success);
// Propagate our knowledge of audio channel mapping to libebur128, doing so // Propagate our knowledge of audio channel mapping to libebur128, doing so
// is important because loudness measurement is channel-position dependent. // is important because loudness measurement is channel-position dependent.
for (int channel_number = 0; channel_number != dsc.channels; ++channel_number) { 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<uint>(channel_number), gst_channel_to_ebur_channel(positions[static_cast<uint>(channel_number)]));
} }
} }
@@ -371,7 +371,7 @@ GstFlowReturn EBUR128AnalysisImpl::NewBufferCallback(GstAppSink *app_sink, gpoin
if (buffer) { if (buffer) {
GstMapInfo map; GstMapInfo map;
if (gst_buffer_map(buffer, &map, GST_MAP_READ)) { if (gst_buffer_map(buffer, &map, GST_MAP_READ)) {
me->state->AddFrames(reinterpret_cast<const char*>(map.data), static_cast<qint64>(map.size)); me->state->AddFrames(reinterpret_cast<const char*>(map.data), static_cast<size_t>(map.size));
gst_buffer_unmap(buffer, &map); gst_buffer_unmap(buffer, &map);
} }
} }

View File

@@ -163,7 +163,7 @@ void EngineBase::ReloadSettings() {
channels_enabled_ = s.value(BackendSettings::kChannelsEnabled, false).toBool(); channels_enabled_ = s.value(BackendSettings::kChannelsEnabled, false).toBool();
channels_ = s.value(BackendSettings::kChannels, 0).toInt(); 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_low_watermark_ = s.value(BackendSettings::kBufferLowWatermark, BackendSettings::kDefaultBufferLowWatermark).toDouble();
buffer_high_watermark_ = s.value(BackendSettings::kBufferHighWatermark, BackendSettings::kDefaultBufferHighWatermark).toDouble(); buffer_high_watermark_ = s.value(BackendSettings::kBufferHighWatermark, BackendSettings::kDefaultBufferHighWatermark).toDouble();

View File

@@ -137,10 +137,10 @@ GstEngine::~GstEngine() {
if (discoverer_) { if (discoverer_) {
if (discovery_discovered_cb_id_ != -1) { 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<gulong>(discovery_discovered_cb_id_));
} }
if (discovery_finished_cb_id_ != -1) { 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<gulong>(discovery_finished_cb_id_));
} }
gst_discoverer_stop(discoverer_); gst_discoverer_stop(discoverer_);
@@ -244,8 +244,8 @@ bool GstEngine::Load(const QUrl &media_url, const QUrl &stream_url, const Engine
if (!discoverer_) { if (!discoverer_) {
discoverer_ = gst_discoverer_new(kDiscoveryTimeoutS * GST_SECOND, nullptr); discoverer_ = gst_discoverer_new(kDiscoveryTimeoutS * GST_SECOND, nullptr);
if (discoverer_) { if (discoverer_) {
discovery_discovered_cb_id_ = CHECKED_GCONNECT(G_OBJECT(discoverer_), "discovered", &StreamDiscovered, this); discovery_discovered_cb_id_ = static_cast<int>(CHECKED_GCONNECT(G_OBJECT(discoverer_), "discovered", &StreamDiscovered, this));
discovery_finished_cb_id_ = CHECKED_GCONNECT(G_OBJECT(discoverer_), "finished", &StreamDiscoveryFinished, this); discovery_finished_cb_id_ = static_cast<int>(CHECKED_GCONNECT(G_OBJECT(discoverer_), "finished", &StreamDiscoveryFinished, this));
gst_discoverer_start(discoverer_); gst_discoverer_start(discoverer_);
} }
} }
@@ -315,7 +315,8 @@ void GstEngine::Stop(const bool stop_after) {
media_url_.clear(); media_url_.clear();
stream_url_.clear(); // To ensure we return Empty from state() 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. // 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_) { 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 = old_pipeline->stream_url();
stream_url.detach(); 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<qint64>(beginning_offset_nanosec_), end_offset_nanosec_, old_pipeline->ebur128_loudness_normalizing_gain_db());
FinishPipeline(old_pipeline); FinishPipeline(old_pipeline);
Play(pause, offset_nanosec); Play(pause, offset_nanosec);
return; return;
@@ -787,7 +788,7 @@ void GstEngine::BufferingStarted() {
} }
void GstEngine::BufferingProgress(const int percent) { void GstEngine::BufferingProgress(const int percent) {
task_manager_->SetTaskProgress(buffering_task_id_, percent, 100); task_manager_->SetTaskProgress(buffering_task_id_, static_cast<quint64>(percent), 100UL);
} }
void GstEngine::BufferingFinished() { void GstEngine::BufferingFinished() {

View File

@@ -163,15 +163,6 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
equalizer_(nullptr), equalizer_(nullptr),
equalizer_preamp_(nullptr), equalizer_preamp_(nullptr),
eventprobe_(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), logged_unsupported_analyzer_format_(false),
about_to_finish_(false), about_to_finish_(false),
finish_requested_(false), finish_requested_(false),
@@ -360,52 +351,52 @@ void GstEnginePipeline::Disconnect() {
fader_.reset(); fader_.reset();
} }
if (element_added_cb_id_ != -1) { if (element_added_cb_id_.has_value()) {
g_signal_handler_disconnect(G_OBJECT(audiobin_), element_added_cb_id_); g_signal_handler_disconnect(G_OBJECT(audiobin_), element_added_cb_id_.value());
element_added_cb_id_ = -1; element_added_cb_id_.reset();
} }
if (element_removed_cb_id_ != -1) { if (element_removed_cb_id_.has_value()) {
g_signal_handler_disconnect(G_OBJECT(audiobin_), element_removed_cb_id_); g_signal_handler_disconnect(G_OBJECT(audiobin_), element_removed_cb_id_.value());
element_removed_cb_id_ = -1; element_removed_cb_id_.reset();
} }
if (pad_added_cb_id_ != -1) { if (pad_added_cb_id_.has_value()) {
g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_); g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_.value());
pad_added_cb_id_ = -1; pad_added_cb_id_.reset();
} }
if (notify_source_cb_id_ != -1) { if (notify_source_cb_id_.has_value()) {
g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_); g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_.value());
notify_source_cb_id_ = -1; notify_source_cb_id_.reset();
} }
if (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_); g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_.value());
about_to_finish_cb_id_ = -1; about_to_finish_cb_id_.reset();
} }
if (notify_volume_cb_id_ != -1) { if (notify_volume_cb_id_.has_value()) {
g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_); g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_.value());
notify_volume_cb_id_ = -1; 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"); GstPad *pad = gst_element_get_static_pad(eventprobe_, "src");
if (pad) { 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); 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"); GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
if (pad) { 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); 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; int last_band_frequency = 0;
for (int i = 0; i < kEqBandCount; ++i) { for (int i = 0; i < kEqBandCount; ++i) {
const int index_in_eq = i + 1; 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<guint>(index_in_eq)));
if (band) { if (band) {
const float frequency = static_cast<float>(kEqBandFrequencies[i]); const float frequency = static_cast<float>(kEqBandFrequencies[i]);
const float bandwidth = frequency - static_cast<float>(last_band_frequency); const float bandwidth = frequency - static_cast<float>(last_band_frequency);
@@ -943,13 +934,13 @@ void GstEnginePipeline::SetupVolume(GstElement *element) {
if (volume_) { if (volume_) {
qLog(Debug) << "Disonnecting volume notify on" << volume_; qLog(Debug) << "Disonnecting volume notify on" << volume_;
g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_); g_signal_handler_disconnect(G_OBJECT(volume_), notify_volume_cb_id_.value());
notify_volume_cb_id_ = -1; notify_volume_cb_id_.reset();
volume_ = nullptr; volume_ = nullptr;
} }
qLog(Debug) << "Connecting volume notify on" << element; 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<glong>(CHECKED_GCONNECT(G_OBJECT(element), "notify::volume", &NotifyVolumeCallback, this));
volume_ = element; volume_ = element;
volume_set_ = false; volume_set_ = false;
@@ -1029,10 +1020,10 @@ void GstEnginePipeline::ElementRemovedCallback(GstBin *bin, GstBin *sub_bin, Gst
if (bin != GST_BIN(instance->audiobin_)) return; 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_; qLog(Debug) << "Disconnecting volume notify on" << instance->volume_;
g_signal_handler_disconnect(G_OBJECT(instance->volume_), instance->notify_volume_cb_id_); g_signal_handler_disconnect(G_OBJECT(instance->volume_), instance->notify_volume_cb_id_.value());
instance->notify_volume_cb_id_ = -1; instance->notify_volume_cb_id_.reset();
instance->volume_ = nullptr; instance->volume_ = nullptr;
instance->volume_set_ = false; instance->volume_set_ = false;
} }
@@ -1239,14 +1230,14 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
int32_t *s = reinterpret_cast<int32_t*>(map_info.data); int32_t *s = reinterpret_cast<int32_t*>(map_info.data);
int samples = static_cast<int>((map_info.size / sizeof(int32_t)) / channels); int samples = static_cast<int>((map_info.size / sizeof(int32_t)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels; int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size)); int16_t *d = static_cast<int16_t*>(g_malloc(static_cast<gsize>(buf16_size)));
memset(d, 0, buf16_size); memset(d, 0, static_cast<size_t>(buf16_size));
for (int i = 0; i < (samples * channels); ++i) { for (int i = 0; i < (samples * channels); ++i) {
d[i] = static_cast<int16_t>((s[i] >> 16)); d[i] = static_cast<int16_t>((s[i] >> 16));
} }
gst_buffer_unmap(buf, &map_info); gst_buffer_unmap(buf, &map_info);
buf16 = gst_buffer_new_wrapped(d, buf16_size); buf16 = gst_buffer_new_wrapped(d, static_cast<gsize>(buf16_size));
GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast<guint64>(samples * sizeof(int16_t) / channels), static_cast<guint64>(rate));
buf = buf16; buf = buf16;
instance->logged_unsupported_analyzer_format_ = false; instance->logged_unsupported_analyzer_format_ = false;
@@ -1260,15 +1251,15 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
float *s = reinterpret_cast<float*>(map_info.data); float *s = reinterpret_cast<float*>(map_info.data);
int samples = static_cast<int>((map_info.size / sizeof(float)) / channels); int samples = static_cast<int>((map_info.size / sizeof(float)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels; int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size)); int16_t *d = static_cast<int16_t*>(g_malloc(static_cast<gsize>(buf16_size)));
memset(d, 0, buf16_size); memset(d, 0, static_cast<size_t>(buf16_size));
for (int i = 0; i < (samples * channels); ++i) { for (int i = 0; i < (samples * channels); ++i) {
float sample_float = (s[i] * static_cast<float>(32768.0)); float sample_float = (s[i] * static_cast<float>(32768.0));
d[i] = static_cast<int16_t>(sample_float); d[i] = static_cast<int16_t>(sample_float);
} }
gst_buffer_unmap(buf, &map_info); gst_buffer_unmap(buf, &map_info);
buf16 = gst_buffer_new_wrapped(d, buf16_size); buf16 = gst_buffer_new_wrapped(d, static_cast<gsize>(buf16_size));
GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast<guint64>(samples * sizeof(int16_t) / channels), static_cast<guint64>(rate));
buf = buf16; buf = buf16;
instance->logged_unsupported_analyzer_format_ = false; instance->logged_unsupported_analyzer_format_ = false;
@@ -1282,16 +1273,16 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
int8_t *s24e = s24 + map_info.size; int8_t *s24e = s24 + map_info.size;
int samples = static_cast<int>((map_info.size / sizeof(int8_t)) / channels); int samples = static_cast<int>((map_info.size / sizeof(int8_t)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels; int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *s16 = static_cast<int16_t*>(g_malloc(buf16_size)); int16_t *s16 = static_cast<int16_t*>(g_malloc(static_cast<gsize>(buf16_size)));
memset(s16, 0, buf16_size); memset(s16, 0, static_cast<size_t>(buf16_size));
for (int i = 0; i < (samples * channels); ++i) { for (int i = 0; i < (samples * channels); ++i) {
s16[i] = *(reinterpret_cast<int16_t*>(s24 + 1)); s16[i] = *(reinterpret_cast<int16_t*>(s24 + 1));
s24 += 3; s24 += 3;
if (s24 >= s24e) break; if (s24 >= s24e) break;
} }
gst_buffer_unmap(buf, &map_info); gst_buffer_unmap(buf, &map_info);
buf16 = gst_buffer_new_wrapped(s16, buf16_size); buf16 = gst_buffer_new_wrapped(s16, static_cast<gsize>(buf16_size));
GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast<guint64>(samples * sizeof(int16_t) / channels), static_cast<guint64>(rate));
buf = buf16; buf = buf16;
instance->logged_unsupported_analyzer_format_ = false; instance->logged_unsupported_analyzer_format_ = false;
@@ -1306,8 +1297,8 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
int32_t *s32p = s32; int32_t *s32p = s32;
int samples = static_cast<int>((map_info.size / sizeof(int32_t)) / channels); int samples = static_cast<int>((map_info.size / sizeof(int32_t)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels; int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *s16 = static_cast<int16_t*>(g_malloc(buf16_size)); int16_t *s16 = static_cast<int16_t*>(g_malloc(static_cast<gsize>(buf16_size)));
memset(s16, 0, buf16_size); memset(s16, 0, static_cast<size_t>(buf16_size));
for (int i = 0; i < (samples * channels); ++i) { for (int i = 0; i < (samples * channels); ++i) {
int8_t *s24 = reinterpret_cast<int8_t*>(s32p); int8_t *s24 = reinterpret_cast<int8_t*>(s32p);
s16[i] = *(reinterpret_cast<int16_t*>(s24 + 1)); s16[i] = *(reinterpret_cast<int16_t*>(s24 + 1));
@@ -1315,8 +1306,8 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
if (s32p > s32e) break; if (s32p > s32e) break;
} }
gst_buffer_unmap(buf, &map_info); gst_buffer_unmap(buf, &map_info);
buf16 = gst_buffer_new_wrapped(s16, buf16_size); buf16 = gst_buffer_new_wrapped(s16, static_cast<gsize>(buf16_size));
GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) / channels, rate); GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(static_cast<guint64>(samples * sizeof(int16_t) / channels), static_cast<guint64>(rate));
buf = buf16; buf = buf16;
instance->logged_unsupported_analyzer_format_ = false; instance->logged_unsupported_analyzer_format_ = false;
@@ -2021,7 +2012,7 @@ void GstEnginePipeline::UpdateEqualizer() {
const int index_in_eq = i + 1; const int index_in_eq = i + 1;
// Offset because of the first dummy band we created. // 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<guint>(index_in_eq)));
g_object_set(G_OBJECT(band), "gain", gain, nullptr); g_object_set(G_OBJECT(band), "gain", gain, nullptr);
g_object_unref(G_OBJECT(band)); g_object_unref(G_OBJECT(band));
} }

View File

@@ -24,6 +24,8 @@
#include "config.h" #include "config.h"
#include <optional>
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
#include <glib/gtypes.h> #include <glib/gtypes.h>
@@ -357,15 +359,15 @@ class GstEnginePipeline : public QObject {
GstElement *equalizer_preamp_; GstElement *equalizer_preamp_;
GstElement *eventprobe_; GstElement *eventprobe_;
gulong upstream_events_probe_cb_id_; std::optional<gulong> upstream_events_probe_cb_id_;
gulong buffer_probe_cb_id_; std::optional<gulong> buffer_probe_cb_id_;
gulong pad_probe_cb_id_; std::optional<gulong> pad_probe_cb_id_;
glong element_added_cb_id_; std::optional<gulong> element_added_cb_id_;
glong element_removed_cb_id_; std::optional<gulong> element_removed_cb_id_;
glong pad_added_cb_id_; std::optional<gulong> pad_added_cb_id_;
glong notify_source_cb_id_; std::optional<gulong> notify_source_cb_id_;
glong about_to_finish_cb_id_; std::optional<gulong> about_to_finish_cb_id_;
glong notify_volume_cb_id_; std::optional<gulong> notify_volume_cb_id_;
bool logged_unsupported_analyzer_format_; bool logged_unsupported_analyzer_format_;
mutex_protected<bool> about_to_finish_; mutex_protected<bool> about_to_finish_;

View File

@@ -52,10 +52,17 @@ enum {
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wold-style-cast"
#endif #endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4514)
#endif
G_DEFINE_TYPE(GstStrawberryFastSpectrum, gst_strawberry_fastspectrum, GST_TYPE_AUDIO_FILTER) G_DEFINE_TYPE(GstStrawberryFastSpectrum, gst_strawberry_fastspectrum, GST_TYPE_AUDIO_FILTER)
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
static void gst_strawberry_fastspectrum_finalize(GObject *object); 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); 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<GstStrawberryFastSpectrum*>(transform); GstStrawberryFastSpectrum *fastspectrum = reinterpret_cast<GstStrawberryFastSpectrum*>(transform);
const guint rate = GST_AUDIO_FILTER_RATE(fastspectrum); const guint rate = static_cast<guint>(GST_AUDIO_FILTER_RATE(fastspectrum));
const guint bps = GST_AUDIO_FILTER_BPS(fastspectrum); const guint bps = static_cast<guint>(GST_AUDIO_FILTER_BPS(fastspectrum));
const guint64 bpf = GST_AUDIO_FILTER_BPF(fastspectrum); const guint64 bpf = static_cast<guint64>(GST_AUDIO_FILTER_BPF(fastspectrum));
const double max_value = static_cast<double>((1UL << ((bps << 3) - 1)) - 1); const double max_value = static_cast<double>((1UL << ((bps << 3) - 1)) - 1);
const guint bands = fastspectrum->bands; const guint bands = fastspectrum->bands;
const guint nfft = 2 * bands - 2; const guint nfft = 2 * bands - 2;

View File

@@ -42,7 +42,7 @@ int GlobalShortcut::nativeKeycode(const Qt::Key qt_keycode) {
int key_code = 0; int key_code = 0;
if (KeyMapperWin::keymapper_win_.contains(qt_keycode)) { if (KeyMapperWin::keymapper_win_.contains(qt_keycode)) {
key_code = KeyMapperWin::keymapper_win_.value(qt_keycode); key_code = static_cast<int>(KeyMapperWin::keymapper_win_.value(qt_keycode));
} }
return key_code; 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) { 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<UINT>(native_mods), static_cast<UINT>(native_key));
} }

View File

@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
// Seed the random number generators. // Seed the random number generators.
time_t t = time(nullptr); time_t t = time(nullptr);
srand(t); srand(static_cast<uint>(t));
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
Utilities::IncreaseFDLimit(); Utilities::IncreaseFDLimit();

View File

@@ -56,7 +56,7 @@ void MoodbarBuilder::Init(const int bands, const int rate_hz) {
barkband++; barkband++;
} }
barkband_table_.append(barkband); barkband_table_.append(static_cast<uint>(barkband));
} }
} }

View File

@@ -78,7 +78,7 @@ Organize::Organize(const SharedPtr<TaskManager> task_manager,
overwrite_(overwrite), overwrite_(overwrite),
albumcover_(albumcover), albumcover_(albumcover),
eject_after_(eject_after), eject_after_(eject_after),
task_count_(songs_info.count()), task_count_(static_cast<quint64>(songs_info.count())),
playlist_(playlist), playlist_(playlist),
tasks_complete_(0), tasks_complete_(0),
started_(false), started_(false),
@@ -355,7 +355,7 @@ void Organize::UpdateProgress() {
// Add the progress of the track that's currently copying // Add the progress of the track that's currently copying
progress += current_copy_progress_; progress += current_copy_progress_;
task_manager_->SetTaskProgress(task_id_, progress, total); task_manager_->SetTaskProgress(task_id_, static_cast<quint64>(progress), total);
} }

View File

@@ -499,8 +499,8 @@ void OrganizeDialog::UpdatePreviews() {
} }
// Update the free space bar // Update the free space bar
quint64 capacity = destination.data(MusicStorage::Role_Capacity).toLongLong(); quint64 capacity = destination.data(MusicStorage::Role_Capacity).toULongLong();
quint64 free = destination.data(MusicStorage::Role_FreeSpace).toLongLong(); quint64 free = destination.data(MusicStorage::Role_FreeSpace).toULongLong();
if (capacity > 0) { if (capacity > 0) {
ui_->free_space->show(); ui_->free_space->show();

View File

@@ -463,9 +463,9 @@ bool OSDBase::SupportsNativeNotifications() const {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
return SupportsTrayPopups(); return SupportsTrayPopups();
#endif #else
return false; return false;
#endif
} }

View File

@@ -233,8 +233,8 @@ void OSDPretty::Load() {
Settings s; Settings s;
s.beginGroup(OSDPrettySettings::kSettingsGroup); s.beginGroup(OSDPrettySettings::kSettingsGroup);
foreground_color_ = QColor(s.value(OSDPrettySettings::kForegroundColor, 0).toInt()); foreground_color_ = QColor(static_cast<QRgb>(s.value(OSDPrettySettings::kForegroundColor, 0).toInt()));
background_color_ = QColor(s.value(OSDPrettySettings::kBackgroundColor, OSDPrettySettings::kPresetBlue).toInt()); background_color_ = QColor(static_cast<QRgb>(s.value(OSDPrettySettings::kBackgroundColor, OSDPrettySettings::kPresetBlue).toInt()));
background_opacity_ = s.value(OSDPrettySettings::kBackgroundOpacity, 0.85).toFloat(); 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()); 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(); disable_duration_ = s.value(OSDPrettySettings::kDisableDuration, false).toBool();

View File

@@ -1439,8 +1439,6 @@ QString Playlist::abbreviated_column_name(const Column column) {
return column_name; return column_name;
} }
return ""_L1;
} }
void Playlist::sort(const int column_number, const Qt::SortOrder order) { void Playlist::sort(const int column_number, const Qt::SortOrder order) {

View File

@@ -177,12 +177,12 @@ void SongLoaderInserter::AsyncLoad() {
// First, quick load raw songs. // First, quick load raw songs.
int async_progress = 0; int async_progress = 0;
int async_load_id = task_manager_->StartTask(tr("Loading tracks")); 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<quint64>(async_progress), static_cast<quint64>(pending_.count()));
bool first_loaded = false; bool first_loaded = false;
for (int i = 0; i < pending_.count(); ++i) { for (int i = 0; i < pending_.count(); ++i) {
SongLoader *loader = pending_.value(i); SongLoader *loader = pending_.value(i);
const SongLoader::Result result = loader->LoadFilenamesBlocking(); const SongLoader::Result result = loader->LoadFilenamesBlocking();
task_manager_->SetTaskProgress(async_load_id, ++async_progress); task_manager_->SetTaskProgress(async_load_id, static_cast<quint64>(++async_progress));
if (result == SongLoader::Result::Error) { if (result == SongLoader::Result::Error) {
const QStringList errors = loader->errors(); const QStringList errors = loader->errors();
@@ -209,7 +209,7 @@ void SongLoaderInserter::AsyncLoad() {
// Songs are inserted in playlist, now load them completely. // Songs are inserted in playlist, now load them completely.
async_progress = 0; async_progress = 0;
async_load_id = task_manager_->StartTask(tr("Loading tracks info")); 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<quint64>(async_progress), static_cast<quint64>(songs_.count()));
SongList songs; SongList songs;
for (int i = 0; i < pending_.count(); ++i) { for (int i = 0; i < pending_.count(); ++i) {
SongLoader *loader = pending_.value(i); SongLoader *loader = pending_.value(i);
@@ -218,7 +218,7 @@ void SongLoaderInserter::AsyncLoad() {
loader->LoadMetadataBlocking(); loader->LoadMetadataBlocking();
} }
songs << loader->songs(); songs << loader->songs();
task_manager_->SetTaskProgress(async_load_id, songs.count()); task_manager_->SetTaskProgress(async_load_id, static_cast<quint64>(songs.count()));
} }
task_manager_->SetTaskFinished(async_load_id); task_manager_->SetTaskFinished(async_load_id);

View File

@@ -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) { for (int x = 0, y = 0; x < app_secret_binary.length(); ++x , ++y) {
if (y == appid.length()) y = 0; if (y == appid.length()) y = 0;
const uint rc = app_secret_binary[x] ^ appid[y]; const uint rc = static_cast<uint>(app_secret_binary[x] ^ appid[y]);
if (rc > 0xFFFF) { if (rc > 0xFFFF) {
return app_secret_base64; return app_secret_base64;
} }

View File

@@ -112,7 +112,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
reply_->deleteLater(); reply_->deleteLater();
} }
const quint64 timestamp = QDateTime::currentSecsSinceEpoch(); const quint64 timestamp = static_cast<quint64>(QDateTime::currentSecsSinceEpoch());
ParamList params_to_sign = ParamList() << Param(u"format_id"_s, QString::number(service_->format())) ParamList params_to_sign = ParamList() << Param(u"format_id"_s, QString::number(service_->format()))
<< Param(u"track_id"_s, QString::number(song_id_)); << Param(u"track_id"_s, QString::number(song_id_));

View File

@@ -241,8 +241,8 @@ void Queue::UpdateTotalLength() {
Q_ASSERT(playlist_->has_item_at(id)); Q_ASSERT(playlist_->has_item_at(id));
quint64 length = playlist_->item_at(id)->Metadata().length_nanosec(); const qint64 length = playlist_->item_at(id)->Metadata().length_nanosec();
if (length > 0) total += length; if (length > 0) total += static_cast<quint64>(length);
} }
total_length_ns_ = total; total_length_ns_ = total;

View File

@@ -306,7 +306,7 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
song_playing_ = song; song_playing_ = song;
scrobbled_ = false; scrobbled_ = false;
timestamp_ = QDateTime::currentSecsSinceEpoch(); timestamp_ = static_cast<quint64>(QDateTime::currentSecsSinceEpoch());
if (!song.is_metadata_good() || !authenticated() || settings_->offline()) return; if (!song.is_metadata_good() || !authenticated() || settings_->offline()) return;

View File

@@ -389,7 +389,7 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
CheckScrobblePrevSong(); CheckScrobblePrevSong();
song_playing_ = song; song_playing_ = song;
timestamp_ = QDateTime::currentSecsSinceEpoch(); timestamp_ = static_cast<quint64>(QDateTime::currentSecsSinceEpoch());
scrobbled_ = false; scrobbled_ = false;
if (!authenticated() || !song.is_metadata_good() || settings_->offline()) return; if (!authenticated() || !song.is_metadata_good() || settings_->offline()) return;

View File

@@ -296,8 +296,6 @@ QString SmartPlaylistSearchTerm::OperatorText(const Type type, const Operator op
return QString(); return QString();
} }
return QString();
} }
QString SmartPlaylistSearchTerm::FieldColumnName(const Field field) { QString SmartPlaylistSearchTerm::FieldColumnName(const Field field) {

View File

@@ -285,8 +285,6 @@ QVariant SmartPlaylistsModel::data(const QModelIndex &idx, const int role) const
return QVariant(); return QVariant();
} }
return QVariant();
} }
QStringList SmartPlaylistsModel::mimeTypes() const { QStringList SmartPlaylistsModel::mimeTypes() const {

View File

@@ -198,7 +198,7 @@ void SpotifyService::ReloadSettings() {
enabled_ = s.value(SpotifySettings::kEnabled, false).toBool(); 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(); artistssearchlimit_ = s.value(SpotifySettings::kArtistsSearchLimit, 4).toInt();
albumssearchlimit_ = s.value(SpotifySettings::kAlbumsSearchLimit, 10).toInt(); albumssearchlimit_ = s.value(SpotifySettings::kAlbumsSearchLimit, 10).toInt();
songssearchlimit_ = s.value(SpotifySettings::kSongsSearchLimit, 10).toInt(); songssearchlimit_ = s.value(SpotifySettings::kSongsSearchLimit, 10).toInt();

View File

@@ -136,7 +136,7 @@ void StreamTagReader::seek(const TagLibOffsetType offset, const TagLib::IOStream
switch (position) { switch (position) {
case TagLib::IOStream::Beginning: case TagLib::IOStream::Beginning:
cursor_ = offset; cursor_ = static_cast<TagLibLengthType>(offset);
break; break;
case TagLib::IOStream::Current: case TagLib::IOStream::Current:

View File

@@ -108,7 +108,7 @@ TagReaderResult GME::SPC::Read(const QFileInfo &fileinfo, Song *song) {
if (length_in_sec <= 0 || length_in_sec >= 0x1FFF) { if (length_in_sec <= 0 || length_in_sec >= 0x1FFF) {
// This means that parsing the length as a string failed, so get value LE. // 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<quint64>(length_bytes[0] | (length_bytes[1] << 8) | (length_bytes[2] << 16));
} }
if (length_in_sec < 0x1FFF) { 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); quint64 fade_length_in_ms = ConvertSPCStringToNum(fade_bytes);
if (fade_length_in_ms > 0x7FFF) { 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<quint64>(fade_bytes[0] | (fade_bytes[1] << 8) | (fade_bytes[2] << 16) | (fade_bytes[3] << 24));
} }
Q_UNUSED(fade_length_in_ms) Q_UNUSED(fade_length_in_ms)
} }
@@ -188,7 +188,7 @@ quint64 GME::SPC::ConvertSPCStringToNum(const QByteArray &arr) {
quint64 result = 0; quint64 result = 0;
for (auto it = arr.begin(); it != arr.end(); it++) { for (auto it = arr.begin(); it != arr.end(); it++) {
unsigned int num = *it - '0'; const uint num = static_cast<uint>(*it - '0');
if (num > 9) break; if (num > 9) break;
result = (result * 10) + num; // Shift Left and add. 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; return TagReaderResult::ErrorCode::FileParseError;
} }
quint64 pt = GME::UnpackBytes32(gd3_head.constData(), gd3_head.size()); quint64 pt = GME::UnpackBytes32(gd3_head.constData(), static_cast<size_t>(gd3_head.size()));
file.seek(SAMPLE_COUNT); file.seek(SAMPLE_COUNT);
QByteArray sample_count_bytes = file.read(4); 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); file.seek(file.pos() + 4);
QByteArray gd3_length_bytes = file.read(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<size_t>(gd3_length_bytes.size()));
QByteArray gd3Data = file.read(gd3_length); QByteArray gd3Data = file.read(gd3_length);
QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly); 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 (sample_count_bytes.size() != 4) return false;
if (loop_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<size_t>(sample_count_bytes.size()));
if (sample_count == 0) return false; 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<size_t>(loop_count_bytes.size()));
if (loop_sample_count == 0) { if (loop_sample_count == 0) {
out_length = sample_count * 1000 / SAMPLE_TIMEBASE; out_length = sample_count * 1000 / SAMPLE_TIMEBASE;

View File

@@ -625,7 +625,7 @@ void TagReaderTagLib::ParseID3v2Tags(TagLib::ID3v2::Tag *tag, QString *disc, QSt
if (frame_field_list.size() > 1) { if (frame_field_list.size() > 1) {
const int playcount = TagLibStringToQString(frame_field_list[1]).toInt(); const int playcount = TagLibStringToQString(frame_field_list[1]).toInt();
if (song->playcount() <= 0 && playcount > 0) { if (song->playcount() <= 0 && playcount > 0) {
song->set_playcount(playcount); song->set_playcount(static_cast<uint>(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()->setAlbum(song.album().isEmpty() ? TagLib::String() : QStringToTagLibString(song.album()));
fileref->tag()->setGenre(song.genre().isEmpty() ? TagLib::String() : QStringToTagLibString(song.genre())); fileref->tag()->setGenre(song.genre().isEmpty() ? TagLib::String() : QStringToTagLibString(song.genre()));
fileref->tag()->setComment(song.comment().isEmpty() ? TagLib::String() : QStringToTagLibString(song.comment())); fileref->tag()->setComment(song.comment().isEmpty() ? TagLib::String() : QStringToTagLibString(song.comment()));
fileref->tag()->setYear(song.year() <= 0 ? 0 : song.year()); fileref->tag()->setYear(song.year() <= 0 ? 0 : static_cast<uint>(song.year()));
fileref->tag()->setTrack(song.track() <= 0 ? 0 : song.track()); fileref->tag()->setTrack(song.track() <= 0 ? 0 : static_cast<uint>(song.track()));
} }
bool is_flac = false; 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(); TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture();
picture->setType(TagLib::FLAC::Picture::FrontCover); picture->setType(TagLib::FLAC::Picture::FrontCover);
picture->setMimeType(QStringToTagLibString(mimetype)); picture->setMimeType(QStringToTagLibString(mimetype));
picture->setData(TagLib::ByteVector(data.constData(), data.size())); picture->setData(TagLib::ByteVector(data.constData(), static_cast<uint>(data.size())));
flac_file->addPicture(picture); flac_file->addPicture(picture);
} }
@@ -1537,7 +1537,7 @@ void TagReaderTagLib::SetEmbeddedCover(TagLib::Ogg::XiphComment *vorbis_comment,
TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture(); TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture();
picture->setType(TagLib::FLAC::Picture::FrontCover); picture->setType(TagLib::FLAC::Picture::FrontCover);
picture->setMimeType(QStringToTagLibString(mimetype)); picture->setMimeType(QStringToTagLibString(mimetype));
picture->setData(TagLib::ByteVector(data.constData(), data.size())); picture->setData(TagLib::ByteVector(data.constData(), static_cast<uint>(data.size())));
vorbis_comment->addPicture(picture); 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 = new TagLib::ID3v2::AttachedPictureFrame(kID3v2_CoverArt);
frontcover->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover); frontcover->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
frontcover->setMimeType(QStringToTagLibString(mimetype)); frontcover->setMimeType(QStringToTagLibString(mimetype));
frontcover->setPicture(TagLib::ByteVector(data.constData(), data.size())); frontcover->setPicture(TagLib::ByteVector(data.constData(), static_cast<uint>(data.size())));
tag->addFrame(frontcover); tag->addFrame(frontcover);
} }
@@ -1583,7 +1583,7 @@ void TagReaderTagLib::SetEmbeddedCover(TagLib::MP4::File *aac_file, TagLib::MP4:
else { else {
return; 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<uint>(data.size()))));
tag->setItem(kMP4_CoverArt, covers); tag->setItem(kMP4_CoverArt, covers);
} }

View File

@@ -224,7 +224,7 @@ void TidalService::ReloadSettings() {
enabled_ = s.value(TidalSettings::kEnabled, false).toBool(); enabled_ = s.value(TidalSettings::kEnabled, false).toBool();
client_id_ = s.value(TidalSettings::kClientId).toString(); client_id_ = s.value(TidalSettings::kClientId).toString();
quality_ = s.value(TidalSettings::kQuality, u"LOSSLESS"_s).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(); artistssearchlimit_ = s.value(TidalSettings::kArtistsSearchLimit, 4).toInt();
albumssearchlimit_ = s.value(TidalSettings::kAlbumsSearchLimit, 10).toInt(); albumssearchlimit_ = s.value(TidalSettings::kAlbumsSearchLimit, 10).toInt();
songssearchlimit_ = s.value(TidalSettings::kSongsSearchLimit, 10).toInt(); songssearchlimit_ = s.value(TidalSettings::kSongsSearchLimit, 10).toInt();

View File

@@ -604,7 +604,7 @@ void Transcoder::SetElementProperties(const QString &name, GObject *object) {
break; break;
} }
case G_TYPE_UINT:{ case G_TYPE_UINT:{
const guint g_value = static_cast<gint>(value.toUInt()); const guint g_value = static_cast<guint>(value.toUInt());
qLog(Debug) << "Setting" << property->name << "(uint)" << "to" << g_value; qLog(Debug) << "Setting" << property->name << "(uint)" << "to" << g_value;
g_object_set(object, property->name, g_value, nullptr); g_object_set(object, property->name, g_value, nullptr);
break; break;

View File

@@ -59,7 +59,7 @@ bool Copy(QIODevice *source, QIODevice *destination) {
if (!destination->open(QIODevice::WriteOnly)) return false; if (!destination->open(QIODevice::WriteOnly)) return false;
const qint64 bytes = source->size(); const qint64 bytes = source->size();
unique_ptr<char[]> data(new char[bytes]); unique_ptr<char[]> data(new char[static_cast<size_t>(bytes)]);
qint64 pos = 0; qint64 pos = 0;
qint64 bytes_read = 0; qint64 bytes_read = 0;

View File

@@ -23,7 +23,7 @@
#include "scopedwchararray.h" #include "scopedwchararray.h"
ScopedWCharArray::ScopedWCharArray(const QString &str) ScopedWCharArray::ScopedWCharArray(const QString &str)
: chars_(str.length()), data_(new wchar_t[chars_ + 1]) { : chars_(str.length()), data_(new wchar_t[static_cast<size_t>(chars_ + 1)]) {
str.toWCharArray(data_.get()); str.toWCharArray(data_.get());
data_[chars_] = '\0'; data_[static_cast<size_t>(chars_)] = '\0';
} }

View File

@@ -36,7 +36,7 @@ class ScopedWCharArray {
explicit operator wchar_t *() const { return get(); } explicit operator wchar_t *() const { return get(); }
qint64 characters() const { return chars_; } qint64 characters() const { return chars_; }
qint64 bytes() const { return (chars_ + 1) * sizeof(wchar_t); } qint64 bytes() const { return (chars_ + 1) * static_cast<qint64>(sizeof(wchar_t)); }
private: private:
Q_DISABLE_COPY(ScopedWCharArray) Q_DISABLE_COPY(ScopedWCharArray)

View File

@@ -80,7 +80,7 @@ uint SqlHelper::ValueToUInt(const T &q, const int n) {
Q_ASSERT(n < q.count()); 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();
} }