Clang-Tidy and Clazy fixes
This commit is contained in:
@@ -64,7 +64,7 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
||||
qLog(Error) << "Unable to open soundcard" << card << ":" << snd_strerror(result);
|
||||
continue;
|
||||
}
|
||||
BOOST_SCOPE_EXIT(&handle) { snd_ctl_close(handle); }
|
||||
BOOST_SCOPE_EXIT(&handle) { snd_ctl_close(handle); } // clazy:exclude=rule-of-three NOLINT(google-explicit-constructor)
|
||||
BOOST_SCOPE_EXIT_END
|
||||
|
||||
result = snd_ctl_card_info(handle, cardinfo);
|
||||
@@ -101,9 +101,9 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
||||
device.card = card;
|
||||
device.device = dev;
|
||||
|
||||
device.value = QString("hw:%1,%2").arg(card).arg(dev);
|
||||
device.value = QString("hw:%1,%2").arg(card).arg(dev); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
ret.append(device);
|
||||
device.value = QString("plughw:%1,%2").arg(card).arg(dev);
|
||||
device.value = QString("plughw:%1,%2").arg(card).arg(dev); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
ret.append(device);
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ class AlsaDeviceFinder : public DeviceFinder {
|
||||
|
||||
bool Initialize() override { return true; }
|
||||
QList<Device> ListDevices() override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(AlsaDeviceFinder)
|
||||
};
|
||||
|
||||
#endif // ALSADEVICEFINDER_H
|
||||
|
||||
@@ -68,10 +68,10 @@ QList<DeviceFinder::Device> AlsaPCMDeviceFinder::ListDevices() {
|
||||
}
|
||||
|
||||
Device device;
|
||||
device.value = name;
|
||||
device.value = name; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
device.description = description;
|
||||
device.iconname = GuessIconName(device.description);
|
||||
ret << device;
|
||||
ret << device; // clazy:exclude=reserve-candidates
|
||||
}
|
||||
if (io) free(io);
|
||||
if (name) free(name);
|
||||
|
||||
@@ -32,6 +32,9 @@ class AlsaPCMDeviceFinder : public DeviceFinder {
|
||||
|
||||
bool Initialize() override { return true; }
|
||||
QList<Device> ListDevices() override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(AlsaPCMDeviceFinder)
|
||||
};
|
||||
|
||||
#endif // ALSAPCMDEVICEFINDER_H
|
||||
|
||||
@@ -33,6 +33,7 @@ class DeviceFinder {
|
||||
|
||||
public:
|
||||
struct Device {
|
||||
Device() : card(0), device(0) {}
|
||||
QString description;
|
||||
QVariant value;
|
||||
QString iconname;
|
||||
@@ -44,7 +45,7 @@ class DeviceFinder {
|
||||
|
||||
QString name() const { return name_; }
|
||||
QStringList outputs() const { return outputs_; }
|
||||
void add_output(const QString output) { outputs_.append(output); }
|
||||
void add_output(const QString &output) { outputs_.append(output); }
|
||||
|
||||
// Does any necessary setup, returning false if this DeviceFinder cannot be used.
|
||||
virtual bool Initialize() = 0;
|
||||
@@ -61,6 +62,7 @@ class DeviceFinder {
|
||||
QString name_;
|
||||
QStringList outputs_;
|
||||
|
||||
Q_DISABLE_COPY(DeviceFinder)
|
||||
};
|
||||
|
||||
#endif // DEVICEFINDER_H
|
||||
|
||||
@@ -37,8 +37,11 @@
|
||||
#include "settings/backendsettingspage.h"
|
||||
#include "settings/networkproxysettingspage.h"
|
||||
|
||||
Engine::Base::Base()
|
||||
: volume_(100),
|
||||
Engine::Base::Base(const EngineType type, QObject *parent)
|
||||
: QObject(parent),
|
||||
type_(type),
|
||||
volume_control_(true),
|
||||
volume_(100),
|
||||
beginning_nanosec_(0),
|
||||
end_nanosec_(0),
|
||||
scope_(kScopeSize),
|
||||
|
||||
@@ -53,7 +53,7 @@ class Base : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
Base();
|
||||
Base(const EngineType type = EngineType::None, QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
~Base() override;
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
namespace Engine {
|
||||
|
||||
Engine::EngineType EngineTypeFromName(QString enginename) {
|
||||
Engine::EngineType EngineTypeFromName(const QString &enginename) {
|
||||
QString lower = enginename.toLower();
|
||||
if (lower == "gstreamer") return Engine::GStreamer;
|
||||
else if (lower == "vlc") return Engine::VLC;
|
||||
else return Engine::None;
|
||||
}
|
||||
|
||||
QString EngineName(Engine::EngineType enginetype) {
|
||||
QString EngineName(const Engine::EngineType enginetype) {
|
||||
switch (enginetype) {
|
||||
case Engine::GStreamer: return QString("gstreamer");
|
||||
case Engine::VLC: return QString("vlc");
|
||||
|
||||
@@ -34,9 +34,9 @@ enum EngineType {
|
||||
Xine
|
||||
};
|
||||
|
||||
Engine::EngineType EngineTypeFromName(QString enginename);
|
||||
QString EngineName(Engine::EngineType enginetype);
|
||||
QString EngineDescription(Engine::EngineType enginetype);
|
||||
Engine::EngineType EngineTypeFromName(const QString &enginename);
|
||||
QString EngineName(const Engine::EngineType enginetype);
|
||||
QString EngineDescription(const Engine::EngineType enginetype);
|
||||
|
||||
}
|
||||
Q_DECLARE_METATYPE(Engine::EngineType)
|
||||
|
||||
@@ -30,12 +30,16 @@
|
||||
class GstEnginePipeline;
|
||||
|
||||
class GstBufferConsumer {
|
||||
public:
|
||||
public:
|
||||
GstBufferConsumer() {}
|
||||
virtual ~GstBufferConsumer() {}
|
||||
|
||||
// This is called in some unspecified GStreamer thread.
|
||||
// Ownership of the buffer is transferred to the BufferConsumer and it should gst_buffer_unref it.
|
||||
virtual void ConsumeBuffer(GstBuffer *buffer, const int pipeline_id, const QString &format) = 0;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(GstBufferConsumer)
|
||||
};
|
||||
|
||||
#endif // GSTBUFFERCONSUMER_H
|
||||
|
||||
@@ -75,8 +75,9 @@ const char *GstEngine::kDirectSoundSink = "directsoundsink";
|
||||
const char *GstEngine::kOSXAudioSink = "osxaudiosink";
|
||||
const int GstEngine::kDiscoveryTimeoutS = 10;
|
||||
|
||||
GstEngine::GstEngine(TaskManager *task_manager)
|
||||
: task_manager_(task_manager),
|
||||
GstEngine::GstEngine(TaskManager *task_manager, QObject *parent)
|
||||
: Engine::Base(Engine::GStreamer, parent),
|
||||
task_manager_(task_manager),
|
||||
gst_startup_(nullptr),
|
||||
discoverer_(nullptr),
|
||||
buffering_task_id_(-1),
|
||||
@@ -96,7 +97,6 @@ GstEngine::GstEngine(TaskManager *task_manager)
|
||||
discovery_discovered_cb_id_(-1)
|
||||
{
|
||||
|
||||
type_ = Engine::GStreamer;
|
||||
seek_timer_->setSingleShot(true);
|
||||
seek_timer_->setInterval(kSeekDelayNanosec / kNsecPerMsec);
|
||||
QObject::connect(seek_timer_, &QTimer::timeout, this, &GstEngine::SeekNow);
|
||||
@@ -397,10 +397,9 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
||||
|
||||
const_cast<GstEngine*>(this)->EnsureInitialized();
|
||||
|
||||
EngineBase::OutputDetailsList ret;
|
||||
|
||||
PluginDetailsList plugins = GetPluginList("Sink/Audio");
|
||||
|
||||
EngineBase::OutputDetailsList ret;
|
||||
ret.reserve(plugins.count());
|
||||
for (const PluginDetails &plugin : plugins) {
|
||||
OutputDetails output;
|
||||
output.name = plugin.name;
|
||||
|
||||
@@ -58,7 +58,7 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GstEngine(TaskManager *task_manager);
|
||||
explicit GstEngine(TaskManager *task_manager, QObject *parent = nullptr);
|
||||
~GstEngine() override;
|
||||
|
||||
bool Init() override;
|
||||
|
||||
@@ -66,8 +66,8 @@ const int GstEnginePipeline::kEqBandFrequencies[] = { 60, 170, 310, 600, 1000, 3
|
||||
int GstEnginePipeline::sId = 1;
|
||||
GstElementDeleter *GstEnginePipeline::sElementDeleter = nullptr;
|
||||
|
||||
GstEnginePipeline::GstEnginePipeline(GstEngine *engine)
|
||||
: QObject(nullptr),
|
||||
GstEnginePipeline::GstEnginePipeline(GstEngine *engine, QObject *parent)
|
||||
: QObject(parent),
|
||||
engine_(engine),
|
||||
id_(sId++),
|
||||
valid_(false),
|
||||
@@ -121,6 +121,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine *engine)
|
||||
sElementDeleter = new GstElementDeleter(engine_);
|
||||
}
|
||||
|
||||
eq_band_gains_.reserve(kEqBandCount);
|
||||
for (int i = 0; i < kEqBandCount; ++i) eq_band_gains_ << 0;
|
||||
|
||||
}
|
||||
@@ -213,7 +214,7 @@ void GstEnginePipeline::set_channels(const bool enabled, const int channels) {
|
||||
channels_ = channels;
|
||||
}
|
||||
|
||||
bool GstEnginePipeline::InitFromUrl(const QByteArray &stream_url, const QUrl original_url, const qint64 end_nanosec) {
|
||||
bool GstEnginePipeline::InitFromUrl(const QByteArray &stream_url, const QUrl &original_url, const qint64 end_nanosec) {
|
||||
|
||||
stream_url_ = stream_url;
|
||||
original_url_ = original_url;
|
||||
|
||||
@@ -58,7 +58,7 @@ class GstEnginePipeline : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GstEnginePipeline(GstEngine *engine);
|
||||
explicit GstEnginePipeline(GstEngine *engine, QObject *parent = nullptr);
|
||||
~GstEnginePipeline() override;
|
||||
|
||||
// Globally unique across all pipelines.
|
||||
@@ -77,7 +77,7 @@ class GstEnginePipeline : public QObject {
|
||||
void set_channels(const bool enabled, const int channels);
|
||||
|
||||
// Creates the pipeline, returns false on error
|
||||
bool InitFromUrl(const QByteArray &stream_url, const QUrl original_url, const qint64 end_nanosec);
|
||||
bool InitFromUrl(const QByteArray &stream_url, const QUrl &original_url, const qint64 end_nanosec);
|
||||
|
||||
// GstBufferConsumers get fed audio data. Thread-safe.
|
||||
void AddBufferConsumer(GstBufferConsumer *consumer);
|
||||
@@ -97,7 +97,7 @@ class GstEnginePipeline : public QObject {
|
||||
void SetNextUrl(const QByteArray &stream_url, const QUrl &original_url, qint64 beginning_nanosec, qint64 end_nanosec);
|
||||
bool has_next_valid_url() const { return !next_stream_url_.isEmpty(); }
|
||||
|
||||
void SetSourceDevice(QString device) { source_device_ = device; }
|
||||
void SetSourceDevice(const QString &device) { source_device_ = device; }
|
||||
|
||||
// Get information about the music playback
|
||||
QByteArray stream_url() const { return stream_url_; }
|
||||
|
||||
@@ -125,7 +125,7 @@ void PulseDeviceFinder::GetSinkInfoCallback(pa_context *c, const pa_sink_info *i
|
||||
if (info) {
|
||||
Device dev;
|
||||
dev.description = QString::fromUtf8(info->description);
|
||||
dev.value = QString::fromUtf8(info->name);
|
||||
dev.value = QString::fromUtf8(info->name); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
dev.iconname = GuessIconName(dev.description);
|
||||
|
||||
state->devices.append(dev);
|
||||
|
||||
@@ -54,6 +54,7 @@ class PulseDeviceFinder : public DeviceFinder {
|
||||
pa_mainloop *mainloop_;
|
||||
pa_context *context_;
|
||||
|
||||
Q_DISABLE_COPY(PulseDeviceFinder)
|
||||
};
|
||||
|
||||
#endif // PULSEDEVICEFINDER_H
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
#include "vlcengine.h"
|
||||
#include "vlcscopedref.h"
|
||||
|
||||
VLCEngine::VLCEngine(TaskManager *task_manager)
|
||||
: instance_(nullptr),
|
||||
VLCEngine::VLCEngine(TaskManager *task_manager, QObject *parent)
|
||||
: Engine::Base(Engine::VLC, parent),
|
||||
instance_(nullptr),
|
||||
player_(nullptr),
|
||||
state_(Engine::Empty) {
|
||||
|
||||
Q_UNUSED(task_manager);
|
||||
|
||||
type_ = Engine::VLC;
|
||||
ReloadSettings();
|
||||
|
||||
}
|
||||
@@ -215,9 +215,9 @@ qint64 VLCEngine::length_nanosec() const {
|
||||
|
||||
EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
|
||||
|
||||
OutputDetailsList ret;
|
||||
|
||||
PluginDetailsList plugins = GetPluginList();
|
||||
OutputDetailsList ret;
|
||||
ret.reserve(plugins.count());
|
||||
for (const PluginDetails &plugin : plugins) {
|
||||
OutputDetails output;
|
||||
output.name = plugin.name;
|
||||
|
||||
@@ -42,7 +42,7 @@ class VLCEngine : public Engine::Base {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VLCEngine(TaskManager *task_manager);
|
||||
explicit VLCEngine(TaskManager *task_manager, QObject *parent = nullptr);
|
||||
~VLCEngine() override;
|
||||
|
||||
bool Init() override;
|
||||
|
||||
Reference in New Issue
Block a user