Fix narrowing conversions

This commit is contained in:
Jonas Kvinge
2021-10-30 02:21:29 +02:00
parent a704412dee
commit 79ac53b2d9
111 changed files with 376 additions and 373 deletions

View File

@@ -149,7 +149,7 @@ QString Chromaprinter::CreateFingerprint() {
gst_message_unref(msg);
}
const int decode_time = time.restart();
const qint64 decode_time = time.restart();
buffer_.close();
@@ -177,7 +177,7 @@ QString Chromaprinter::CreateFingerprint() {
}
chromaprint_free(chromaprint);
const int codegen_time = time.elapsed();
const qint64 codegen_time = time.elapsed();
qLog(Debug) << "Decode time:" << decode_time << "Codegen time:" << codegen_time;
@@ -216,7 +216,7 @@ GstFlowReturn Chromaprinter::NewBufferCallback(GstAppSink *app_sink, gpointer se
if (buffer) {
GstMapInfo map;
if (gst_buffer_map(buffer, &map, GST_MAP_READ)) {
me->buffer_.write(reinterpret_cast<const char*>(map.data), map.size);
me->buffer_.write(reinterpret_cast<const char*>(map.data), static_cast<qint64>(map.size));
gst_buffer_unmap(buffer, &map);
}
}

View File

@@ -237,7 +237,7 @@ struct SimpleMetaBundle {
Song::FileType filetype;
int samplerate;
int bitdepth;
qint64 bitrate;
int bitrate;
QString lyrics;
};

View File

@@ -352,7 +352,7 @@ qint64 GstEngine::position_nanosec() const {
if (!current_pipeline_) return 0;
const qint64 result = current_pipeline_->position() - beginning_nanosec_;
const qint64 result = current_pipeline_->position() - static_cast<qint64>(beginning_nanosec_);
return qint64(qMax(0LL, result));
}
@@ -361,7 +361,7 @@ qint64 GstEngine::length_nanosec() const {
if (!current_pipeline_) return 0;
const qint64 result = end_nanosec_ - beginning_nanosec_;
const qint64 result = end_nanosec_ - static_cast<qint64>(beginning_nanosec_);
if (result > 0) {
return result;
@@ -512,7 +512,7 @@ void GstEngine::timerEvent(QTimerEvent *e) {
const qint64 remaining = current_length - current_position;
const qint64 fudge = kTimerIntervalNanosec + 100 * kNsecPerMsec; // Mmm fudge
const qint64 gap = buffer_duration_nanosec_ + (autocrossfade_enabled_ ? fadeout_duration_nanosec_ : kPreloadGapNanosec);
const qint64 gap = static_cast<qint64>(buffer_duration_nanosec_) + (autocrossfade_enabled_ ? fadeout_duration_nanosec_ : kPreloadGapNanosec);
// only if we know the length of the current stream...
if (current_length > 0) {
@@ -618,7 +618,7 @@ void GstEngine::SeekNow() {
if (!current_pipeline_) return;
if (!current_pipeline_->Seek(seek_pos_)) {
if (!current_pipeline_->Seek(static_cast<qint64>(seek_pos_))) {
qLog(Warning) << "Seek failed";
}
@@ -924,9 +924,9 @@ void GstEngine::StreamDiscovered(GstDiscoverer*, GstDiscovererInfo *info, GError
bundle.url = instance->current_pipeline_->next_original_url();
}
bundle.stream_url = QUrl(discovered_url);
bundle.samplerate = gst_discoverer_audio_info_get_sample_rate(GST_DISCOVERER_AUDIO_INFO(stream_info));
bundle.bitdepth = gst_discoverer_audio_info_get_depth(GST_DISCOVERER_AUDIO_INFO(stream_info));
bundle.bitrate = gst_discoverer_audio_info_get_bitrate(GST_DISCOVERER_AUDIO_INFO(stream_info)) / 1000;
bundle.samplerate = static_cast<int>(gst_discoverer_audio_info_get_sample_rate(GST_DISCOVERER_AUDIO_INFO(stream_info)));
bundle.bitdepth = static_cast<int>(gst_discoverer_audio_info_get_depth(GST_DISCOVERER_AUDIO_INFO(stream_info)));
bundle.bitrate = static_cast<int>(gst_discoverer_audio_info_get_bitrate(GST_DISCOVERER_AUDIO_INFO(stream_info)) / 1000);
GstCaps *caps = gst_discoverer_stream_info_get_caps(stream_info);

View File

@@ -185,7 +185,7 @@ void GstEnginePipeline::set_replaygain(const bool enabled, const int mode, const
}
void GstEnginePipeline::set_buffer_duration_nanosec(const qint64 buffer_duration_nanosec) {
void GstEnginePipeline::set_buffer_duration_nanosec(const quint64 buffer_duration_nanosec) {
buffer_duration_nanosec_ = buffer_duration_nanosec;
}
@@ -209,14 +209,14 @@ void GstEnginePipeline::set_channels(const bool enabled, const int channels) {
channels_ = channels;
}
GstElement *GstEnginePipeline::CreateElement(const QString &factory_name, const QString &name, GstElement *bin, QString &error) {
GstElement *GstEnginePipeline::CreateElement(const QString &factory_name, const QString &name, GstElement *bin, QString &error) const {
QString unique_name = QString("pipeline") + "-" + QString::number(id_) + "-" + (name.isEmpty() ? factory_name : name);
GstElement *element = gst_element_factory_make(factory_name.toUtf8().constData(), unique_name.toUtf8().constData());
if (!element) {
qLog(Error) << "GStreamer could not create the element" << factory_name << "with name" << unique_name;
error = QString("GStreamer could not create the element %1 with name %2.").arg(factory_name).arg(unique_name);
error = QString("GStreamer could not create the element %1 with name %2.").arg(factory_name, unique_name);
}
if (bin && element) gst_bin_add(GST_BIN(bin), element);
@@ -586,7 +586,7 @@ GstPadProbeReturn GstEnginePipeline::EventHandoffCallback(GstPad*, GstPadProbeIn
// The segment start time is used to calculate the proper offset of data buffers from the start of the stream
const GstSegment *segment = nullptr;
gst_event_parse_segment(e, &segment);
instance->segment_start_ = segment->start;
instance->segment_start_ = static_cast<qint64>(segment->start);
instance->segment_start_received_ = true;
}
break;
@@ -663,7 +663,7 @@ void GstEnginePipeline::NewPadCallback(GstElement*, GstPad *pad, gpointer self)
// Offset the timestamps on all the buffers coming out of the playbin so they line up exactly with the end of the last buffer from the old playbin.
// "Running time" is the time since the last flushing seek.
GstClockTime running_time = gst_segment_to_running_time(&instance->last_playbin_segment_, GST_FORMAT_TIME, instance->last_playbin_segment_.position);
gst_pad_set_offset(pad, running_time);
gst_pad_set_offset(pad, static_cast<gint64>(running_time));
// Add a probe to the pad so we can update last_playbin_segment_.
gst_pad_add_probe(pad, static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH), PlaybinProbe, instance, nullptr);
@@ -720,7 +720,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
GstEnginePipeline *instance = reinterpret_cast<GstEnginePipeline*>(self);
QString format;
int channels = 0;
int channels = 1;
int rate = 0;
GstCaps *caps = gst_pad_get_current_caps(pad);
@@ -739,7 +739,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
quint64 start_time = GST_BUFFER_TIMESTAMP(buf) - instance->segment_start_;
quint64 duration = GST_BUFFER_DURATION(buf);
qint64 end_time = start_time + duration;
qint64 end_time = static_cast<qint64>(start_time + duration);
if (format.startsWith("S16LE")) {
instance->logged_unsupported_analyzer_format_ = false;
@@ -1079,7 +1079,7 @@ void GstEnginePipeline::TagMessageReceived(GstMessage *msg) {
bundle.artist = ParseStrTag(taglist, GST_TAG_ARTIST);
bundle.comment = ParseStrTag(taglist, GST_TAG_COMMENT);
bundle.album = ParseStrTag(taglist, GST_TAG_ALBUM);
bundle.bitrate = ParseUIntTag(taglist, GST_TAG_BITRATE) / 1000;
bundle.bitrate = static_cast<int>(ParseUIntTag(taglist, GST_TAG_BITRATE) / 1000);
bundle.lyrics = ParseStrTag(taglist, GST_TAG_LYRICS);
if (!bundle.title.isEmpty() && bundle.artist.isEmpty() && bundle.album.isEmpty()) {
@@ -1259,7 +1259,7 @@ bool GstEnginePipeline::Seek(const qint64 nanosec) {
}
void GstEnginePipeline::SetVolume(const int percent) {
void GstEnginePipeline::SetVolume(const uint percent) {
if (!volume_) return;
volume_percent_ = percent;
@@ -1312,7 +1312,7 @@ void GstEnginePipeline::UpdateEqualizer() {
// Update band gains
for (int i = 0; i < kEqBandCount; ++i) {
float gain = eq_enabled_ ? eq_band_gains_[i] : static_cast<float>(0.0);
float gain = eq_enabled_ ? static_cast<float>(eq_band_gains_[i]) : static_cast<float>(0.0);
if (gain < 0) {
gain *= 0.24;
}
@@ -1357,7 +1357,7 @@ void GstEnginePipeline::StartFader(const qint64 duration_nanosec, const QTimeLin
QObject::connect(fader_.get(), &QTimeLine::finished, this, &GstEnginePipeline::FaderTimelineFinished);
fader_->setDirection(direction);
fader_->setEasingCurve(shape);
fader_->setCurrentTime(start_time);
fader_->setCurrentTime(static_cast<int>(start_time));
fader_->resume();
fader_fudge_timer_.stop();

View File

@@ -68,7 +68,7 @@ class GstEnginePipeline : public QObject {
void set_stereo_balancer_enabled(const bool enabled);
void set_equalizer_enabled(const bool enabled);
void set_replaygain(const bool enabled, const int mode, const double preamp, const double fallbackgain, const bool compression);
void set_buffer_duration_nanosec(const qint64 duration_nanosec);
void set_buffer_duration_nanosec(const quint64 duration_nanosec);
void set_buffer_low_watermark(const double value);
void set_buffer_high_watermark(const double value);
void set_proxy_settings(const QString &address, const bool authentication, const QString &user, const QString &pass);
@@ -85,7 +85,7 @@ class GstEnginePipeline : public QObject {
// Control the music playback
QFuture<GstStateChangeReturn> SetState(const GstState state);
Q_INVOKABLE bool Seek(const qint64 nanosec);
void SetVolume(const int percent);
void SetVolume(const uint percent);
void SetStereoBalance(const float value);
void SetEqualizerParams(const int preamp, const QList<int> &band_gains);
@@ -138,7 +138,7 @@ class GstEnginePipeline : public QObject {
void timerEvent(QTimerEvent*) override;
private:
GstElement *CreateElement(const QString &factory_name, const QString &name, GstElement *bin, QString &error);
GstElement *CreateElement(const QString &factory_name, const QString &name, GstElement *bin, QString &error) const;
bool InitAudioBin(QString &error);
// Static callbacks. The GstEnginePipeline instance is passed in the last argument.
@@ -266,7 +266,7 @@ class GstEnginePipeline : public QObject {
// Complete the transition to the next song when it starts playing
bool next_uri_set_;
int volume_percent_;
uint volume_percent_;
qreal volume_modifier_;
std::unique_ptr<QTimeLine> fader_;

View File

@@ -182,7 +182,7 @@ void VLCEngine::Seek(const quint64 offset_nanosec) {
uint len = length();
if (len == 0) return;
float pos = static_cast<float>(offset) / len;
float pos = static_cast<float>(offset) / static_cast<float>(len);
libvlc_media_player_set_position(player_, pos);
@@ -192,7 +192,7 @@ void VLCEngine::SetVolumeSW(const uint percent) {
if (!Initialized()) return;
if (!volume_control_ && percent != 100) return;
libvlc_audio_set_volume(player_, percent);
libvlc_audio_set_volume(player_, static_cast<int>(percent));
}
@@ -208,7 +208,7 @@ qint64 VLCEngine::position_nanosec() const {
qint64 VLCEngine::length_nanosec() const {
if (state_ == Engine::Empty) return 0;
const qint64 result = (end_nanosec_ - beginning_nanosec_);
const qint64 result = (end_nanosec_ - static_cast<qint64>(beginning_nanosec_));
if (result > 0) {
return result;
}
@@ -261,7 +261,7 @@ uint VLCEngine::position() const {
if (!Initialized() || !libvlc_media_player_is_playing(player_)) return 0;
float pos = libvlc_media_player_get_position(player_);
return (pos * length());
return (static_cast<uint>(pos) * length());
}