Rename initialise to initialize
This commit is contained in:
@@ -35,8 +35,7 @@
|
||||
#include "alsadevicefinder.h"
|
||||
|
||||
AlsaDeviceFinder::AlsaDeviceFinder()
|
||||
: DeviceFinder("alsa", {"alsa","alsasink"}) {
|
||||
}
|
||||
: DeviceFinder("alsa", {"alsa","alsasink"}) {}
|
||||
|
||||
QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
||||
|
||||
@@ -45,7 +44,7 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
||||
snd_pcm_stream_name(SND_PCM_STREAM_PLAYBACK);
|
||||
|
||||
int card = -1;
|
||||
snd_ctl_card_info_t* cardinfo;
|
||||
snd_ctl_card_info_t *cardinfo = nullptr;
|
||||
snd_ctl_card_info_alloca(&cardinfo);
|
||||
while (true) {
|
||||
|
||||
@@ -59,7 +58,7 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
||||
char str[32];
|
||||
snprintf(str, sizeof(str) - 1, "hw:%d", card);
|
||||
|
||||
snd_ctl_t* handle;
|
||||
snd_ctl_t *handle = nullptr;
|
||||
result = snd_ctl_open(&handle, str, 0);
|
||||
if (result < 0) {
|
||||
qLog(Error) << "Unable to open soundcard" << card << ":" << snd_strerror(result);
|
||||
@@ -75,7 +74,7 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
||||
}
|
||||
|
||||
int dev = -1;
|
||||
snd_pcm_info_t* pcminfo;
|
||||
snd_pcm_info_t *pcminfo = nullptr;
|
||||
snd_pcm_info_alloca(&pcminfo);
|
||||
while (true) {
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class AlsaDeviceFinder : public DeviceFinder {
|
||||
public:
|
||||
explicit AlsaDeviceFinder();
|
||||
|
||||
bool Initialise() override { return true; }
|
||||
bool Initialize() override { return true; }
|
||||
QList<Device> ListDevices() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class DeviceFinder {
|
||||
void add_output(const QString output) { outputs_.append(output); }
|
||||
|
||||
// Does any necessary setup, returning false if this DeviceFinder cannot be used.
|
||||
virtual bool Initialise() = 0;
|
||||
virtual bool Initialize() = 0;
|
||||
|
||||
// Returns a list of available devices.
|
||||
virtual QList<Device> ListDevices() = 0;
|
||||
|
||||
@@ -70,8 +70,8 @@ void DeviceFinders::Init() {
|
||||
#endif
|
||||
|
||||
for (DeviceFinder *finder : device_finders) {
|
||||
if (!finder->Initialise()) {
|
||||
qLog(Warning) << "Failed to initialise DeviceFinder for" << finder->name();
|
||||
if (!finder->Initialize()) {
|
||||
qLog(Warning) << "Failed to initialize DeviceFinder for" << finder->name();
|
||||
delete finder;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class DirectSoundDeviceFinder : public DeviceFinder {
|
||||
public:
|
||||
explicit DirectSoundDeviceFinder();
|
||||
|
||||
virtual bool Initialise() { return true; }
|
||||
virtual bool Initialize() { return true; }
|
||||
virtual QList<Device> ListDevices();
|
||||
|
||||
private:
|
||||
|
||||
@@ -99,7 +99,7 @@ GstEngine::GstEngine(TaskManager *task_manager)
|
||||
|
||||
GstEngine::~GstEngine() {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
current_pipeline_.reset();
|
||||
|
||||
if (latest_buffer_) {
|
||||
@@ -136,7 +136,7 @@ Engine::State GstEngine::state() const {
|
||||
|
||||
void GstEngine::StartPreloading(const QUrl &stream_url, const QUrl &original_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
|
||||
QByteArray gst_url = FixupUrl(stream_url);
|
||||
|
||||
@@ -148,7 +148,7 @@ void GstEngine::StartPreloading(const QUrl &stream_url, const QUrl &original_url
|
||||
|
||||
bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
|
||||
Engine::Base::Load(stream_url, original_url, change, force_stop_at_end, beginning_nanosec, end_nanosec);
|
||||
|
||||
@@ -186,7 +186,7 @@ bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::T
|
||||
|
||||
bool GstEngine::Play(const quint64 offset_nanosec) {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
|
||||
if (!current_pipeline_ || current_pipeline_->is_buffering()) return false;
|
||||
|
||||
@@ -344,7 +344,7 @@ const Engine::Scope &GstEngine::scope(const int chunk_length) {
|
||||
|
||||
EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
||||
|
||||
const_cast<GstEngine*>(this)->EnsureInitialised();
|
||||
const_cast<GstEngine*>(this)->EnsureInitialized();
|
||||
|
||||
EngineBase::OutputDetailsList ret;
|
||||
|
||||
@@ -369,7 +369,7 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
||||
|
||||
bool GstEngine::ValidOutput(const QString &output) {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
|
||||
PluginDetailsList plugins = GetPluginList("Sink/Audio");
|
||||
for (const PluginDetails &plugin : plugins) {
|
||||
@@ -645,7 +645,7 @@ void GstEngine::BufferingFinished() {
|
||||
|
||||
GstEngine::PluginDetailsList GstEngine::GetPluginList(const QString &classname) const {
|
||||
|
||||
const_cast<GstEngine*>(this)->EnsureInitialised();
|
||||
const_cast<GstEngine*>(this)->EnsureInitialized();
|
||||
|
||||
PluginDetailsList ret;
|
||||
|
||||
@@ -672,7 +672,7 @@ GstEngine::PluginDetailsList GstEngine::GetPluginList(const QString &classname)
|
||||
|
||||
QByteArray GstEngine::FixupUrl(const QUrl &url) {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
|
||||
QByteArray uri;
|
||||
|
||||
@@ -749,7 +749,7 @@ void GstEngine::StopTimers() {
|
||||
|
||||
std::shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
|
||||
|
||||
EnsureInitialised();
|
||||
EnsureInitialized();
|
||||
|
||||
std::shared_ptr<GstEnginePipeline> ret(new GstEnginePipeline(this));
|
||||
ret->set_output_device(output_, device_);
|
||||
|
||||
@@ -85,7 +85,7 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
||||
bool ALSADeviceSupport(const QString &output) override;
|
||||
|
||||
void SetStartup(GstStartup *gst_startup) { gst_startup_ = gst_startup; }
|
||||
void EnsureInitialised() { gst_startup_->EnsureInitialised(); }
|
||||
void EnsureInitialized() { gst_startup_->EnsureInitialized(); }
|
||||
|
||||
GstElement *CreateElement(const QString &factoryName, GstElement *bin = nullptr, const bool showerror = true);
|
||||
void ConsumeBuffer(GstBuffer *buffer, const int pipeline_id, const QString &format) override;
|
||||
|
||||
@@ -92,7 +92,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine *engine)
|
||||
next_end_offset_nanosec_(-1),
|
||||
ignore_next_seek_(false),
|
||||
ignore_tags_(false),
|
||||
pipeline_is_initialised_(false),
|
||||
pipeline_is_initialized_(false),
|
||||
pipeline_is_connected_(false),
|
||||
pending_seek_nanosec_(-1),
|
||||
last_known_position_ns_(0),
|
||||
@@ -480,7 +480,7 @@ GstPadProbeReturn GstEnginePipeline::EventHandoffCallback(GstPad*, GstPadProbeIn
|
||||
|
||||
}
|
||||
|
||||
void GstEnginePipeline::SourceSetupCallback(GstPlayBin *bin, GParamSpec *, gpointer self) {
|
||||
void GstEnginePipeline::SourceSetupCallback(GstPlayBin *bin, GParamSpec*, gpointer self) {
|
||||
|
||||
GstEnginePipeline *instance = reinterpret_cast<GstEnginePipeline*>(self);
|
||||
|
||||
@@ -537,7 +537,7 @@ void GstEnginePipeline::NewPadCallback(GstElement*, GstPad *pad, gpointer self)
|
||||
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);
|
||||
|
||||
instance->pipeline_is_connected_ = true;
|
||||
if (instance->pending_seek_nanosec_ != -1 && instance->pipeline_is_initialised_) {
|
||||
if (instance->pending_seek_nanosec_ != -1 && instance->pipeline_is_initialized_) {
|
||||
QMetaObject::invokeMethod(instance, "Seek", Qt::QueuedConnection, Q_ARG(qint64, instance->pending_seek_nanosec_));
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ GstBusSyncReply GstEnginePipeline::BusCallbackSync(GstBus*, GstMessage *msg, gpo
|
||||
void GstEnginePipeline::StreamStatusMessageReceived(GstMessage *msg) {
|
||||
|
||||
GstStreamStatusType type;
|
||||
GstElement *owner;
|
||||
GstElement *owner = nullptr;
|
||||
gst_message_parse_stream_status(msg, &type, &owner);
|
||||
|
||||
if (type == GST_STREAM_STATUS_TYPE_CREATE) {
|
||||
@@ -835,9 +835,9 @@ void GstEnginePipeline::StreamStartMessageReceived() {
|
||||
|
||||
}
|
||||
|
||||
void GstEnginePipeline::TaskEnterCallback(GstTask *, GThread *, gpointer) {
|
||||
void GstEnginePipeline::TaskEnterCallback(GstTask*, GThread*, gpointer) {
|
||||
|
||||
// Bump the priority of the thread only on OS X
|
||||
// Bump the priority of the thread only on macOS
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
sched_param param;
|
||||
@@ -875,7 +875,7 @@ void GstEnginePipeline::ErrorMessageReceived(GstMessage *msg) {
|
||||
g_error_free(error);
|
||||
g_free(debugs);
|
||||
|
||||
if (state() == GST_STATE_PLAYING && pipeline_is_initialised_ && next_uri_set_ && (domain == GST_RESOURCE_ERROR || domain == GST_STREAM_ERROR)) {
|
||||
if (state() == GST_STATE_PLAYING && pipeline_is_initialized_ && next_uri_set_ && (domain == GST_RESOURCE_ERROR || domain == GST_STREAM_ERROR)) {
|
||||
// A track is still playing and the next uri is not playable. We ignore the error here so it can play until the end.
|
||||
// But there is no message send to the bus when the current track finishes, we have to add an EOS ourself.
|
||||
qLog(Info) << "Ignoring error when loading next track";
|
||||
@@ -990,15 +990,15 @@ void GstEnginePipeline::StateChangedMessageReceived(GstMessage *msg) {
|
||||
GstState old_state, new_state, pending;
|
||||
gst_message_parse_state_changed(msg, &old_state, &new_state, &pending);
|
||||
|
||||
if (!pipeline_is_initialised_ && (new_state == GST_STATE_PAUSED || new_state == GST_STATE_PLAYING)) {
|
||||
pipeline_is_initialised_ = true;
|
||||
if (!pipeline_is_initialized_ && (new_state == GST_STATE_PAUSED || new_state == GST_STATE_PLAYING)) {
|
||||
pipeline_is_initialized_ = true;
|
||||
if (pending_seek_nanosec_ != -1 && pipeline_is_connected_) {
|
||||
QMetaObject::invokeMethod(this, "Seek", Qt::QueuedConnection, Q_ARG(qint64, pending_seek_nanosec_));
|
||||
}
|
||||
}
|
||||
|
||||
if (pipeline_is_initialised_ && new_state != GST_STATE_PAUSED && new_state != GST_STATE_PLAYING) {
|
||||
pipeline_is_initialised_ = false;
|
||||
if (pipeline_is_initialized_ && new_state != GST_STATE_PAUSED && new_state != GST_STATE_PLAYING) {
|
||||
pipeline_is_initialized_ = false;
|
||||
|
||||
if (next_uri_set_ && new_state == GST_STATE_READY) {
|
||||
// Revert uri and go back to PLAY state again
|
||||
@@ -1050,7 +1050,7 @@ void GstEnginePipeline::BufferingMessageReceived(GstMessage *msg) {
|
||||
|
||||
qint64 GstEnginePipeline::position() const {
|
||||
|
||||
if (pipeline_is_initialised_)
|
||||
if (pipeline_is_initialized_)
|
||||
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &last_known_position_ns_);
|
||||
|
||||
return last_known_position_ns_;
|
||||
@@ -1087,7 +1087,7 @@ bool GstEnginePipeline::Seek(const qint64 nanosec) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pipeline_is_connected_ || !pipeline_is_initialised_) {
|
||||
if (!pipeline_is_connected_ || !pipeline_is_initialized_) {
|
||||
pending_seek_nanosec_ = nanosec;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ class GstEnginePipeline : public QObject {
|
||||
|
||||
// Seeking while the pipeline is in the READY state doesn't work, so we have to wait until it goes to PAUSED or PLAYING.
|
||||
// Also we have to wait for the playbin to be connected.
|
||||
bool pipeline_is_initialised_;
|
||||
bool pipeline_is_initialized_;
|
||||
bool pipeline_is_connected_;
|
||||
qint64 pending_seek_nanosec_;
|
||||
|
||||
|
||||
@@ -41,14 +41,12 @@
|
||||
#include "gststartup.h"
|
||||
|
||||
GstStartup::GstStartup(QObject *parent) : QObject(parent) {
|
||||
initialising_ = QtConcurrent::run([=]{ InitialiseGStreamer(); });
|
||||
initializing_ = QtConcurrent::run([=]{ InitializeGStreamer(); });
|
||||
}
|
||||
|
||||
GstStartup::~GstStartup() {
|
||||
//gst_deinit();
|
||||
}
|
||||
GstStartup::~GstStartup() {}
|
||||
|
||||
void GstStartup::InitialiseGStreamer() {
|
||||
void GstStartup::InitializeGStreamer() {
|
||||
|
||||
SetEnvironment();
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ class GstStartup : public QObject {
|
||||
explicit GstStartup(QObject *parent = nullptr);
|
||||
~GstStartup() override;
|
||||
|
||||
void EnsureInitialised() { initialising_.waitForFinished(); }
|
||||
void EnsureInitialized() { initializing_.waitForFinished(); }
|
||||
|
||||
private:
|
||||
void InitialiseGStreamer();
|
||||
void InitializeGStreamer();
|
||||
void SetEnvironment();
|
||||
QFuture<void> initialising_;
|
||||
QFuture<void> initializing_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class MacOsDeviceFinder : public DeviceFinder {
|
||||
public:
|
||||
explicit MacOsDeviceFinder();
|
||||
|
||||
virtual bool Initialise() { return true; }
|
||||
virtual bool Initialize() { return true; }
|
||||
virtual QList<Device> ListDevices();
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class MMDeviceFinder : public DeviceFinder {
|
||||
public:
|
||||
explicit MMDeviceFinder();
|
||||
|
||||
virtual bool Initialise() { return true; }
|
||||
virtual bool Initialize() { return true; }
|
||||
virtual QList<Device> ListDevices();
|
||||
};
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
PulseDeviceFinder::PulseDeviceFinder() : DeviceFinder("pulseaudio", {"pulseaudio", "pulse", "pulsesink"} ), mainloop_(nullptr), context_(nullptr) {
|
||||
}
|
||||
|
||||
bool PulseDeviceFinder::Initialise() {
|
||||
bool PulseDeviceFinder::Initialize() {
|
||||
|
||||
mainloop_ = pa_mainloop_new();
|
||||
if (!mainloop_) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class PulseDeviceFinder : public DeviceFinder {
|
||||
explicit PulseDeviceFinder();
|
||||
~PulseDeviceFinder() override;
|
||||
|
||||
bool Initialise() override;
|
||||
bool Initialize() override;
|
||||
QList<Device> ListDevices() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -108,7 +108,7 @@ bool VLCEngine::Load(const QUrl &stream_url, const QUrl &original_url, const Eng
|
||||
Q_UNUSED(beginning_nanosec);
|
||||
Q_UNUSED(end_nanosec);
|
||||
|
||||
if (!Initialised()) return false;
|
||||
if (!Initialized()) return false;
|
||||
|
||||
// Create the media object
|
||||
VlcScopedRef<libvlc_media_t> media(libvlc_media_new_location(instance_, stream_url.toEncoded().constData()));
|
||||
@@ -121,7 +121,7 @@ bool VLCEngine::Load(const QUrl &stream_url, const QUrl &original_url, const Eng
|
||||
|
||||
bool VLCEngine::Play(const quint64 offset_nanosec) {
|
||||
|
||||
if (!Initialised()) return false;
|
||||
if (!Initialized()) return false;
|
||||
|
||||
// Set audio output
|
||||
if (!output_.isEmpty() && output_ != "auto") {
|
||||
@@ -147,28 +147,28 @@ void VLCEngine::Stop(const bool stop_after) {
|
||||
|
||||
Q_UNUSED(stop_after);
|
||||
|
||||
if (!Initialised()) return;
|
||||
if (!Initialized()) return;
|
||||
libvlc_media_player_stop(player_);
|
||||
|
||||
}
|
||||
|
||||
void VLCEngine::Pause() {
|
||||
|
||||
if (!Initialised()) return;
|
||||
if (!Initialized()) return;
|
||||
libvlc_media_player_pause(player_);
|
||||
|
||||
}
|
||||
|
||||
void VLCEngine::Unpause() {
|
||||
|
||||
if (!Initialised()) return;
|
||||
if (!Initialized()) return;
|
||||
libvlc_media_player_play(player_);
|
||||
|
||||
}
|
||||
|
||||
void VLCEngine::Seek(const quint64 offset_nanosec) {
|
||||
|
||||
if (!Initialised()) return;
|
||||
if (!Initialized()) return;
|
||||
|
||||
int offset = (offset_nanosec / kNsecPerMsec);
|
||||
|
||||
@@ -182,7 +182,7 @@ void VLCEngine::Seek(const quint64 offset_nanosec) {
|
||||
}
|
||||
|
||||
void VLCEngine::SetVolumeSW(const uint percent) {
|
||||
if (!Initialised()) return;
|
||||
if (!Initialized()) return;
|
||||
if (!volume_control_ && percent != 100) return;
|
||||
libvlc_audio_set_volume(player_, percent);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ bool VLCEngine::ALSADeviceSupport(const QString &output) {
|
||||
|
||||
uint VLCEngine::position() const {
|
||||
|
||||
if (!Initialised()) return (0);
|
||||
if (!Initialized()) return (0);
|
||||
|
||||
bool is_playing = libvlc_media_player_is_playing(player_);
|
||||
if (!is_playing) return 0;
|
||||
@@ -260,7 +260,7 @@ uint VLCEngine::position() const {
|
||||
|
||||
uint VLCEngine::length() const {
|
||||
|
||||
if (!Initialised()) return(0);
|
||||
if (!Initialized()) return(0);
|
||||
|
||||
bool is_playing = libvlc_media_player_is_playing(player_);
|
||||
if (!is_playing) return 0;
|
||||
|
||||
@@ -72,7 +72,7 @@ class VLCEngine : public Engine::Base {
|
||||
libvlc_media_player_t *player_;
|
||||
Engine::State state_;
|
||||
|
||||
bool Initialised() const { return (instance_ && player_); }
|
||||
bool Initialized() const { return (instance_ && player_); }
|
||||
uint position() const;
|
||||
uint length() const;
|
||||
bool CanDecode(const QUrl &url);
|
||||
|
||||
Reference in New Issue
Block a user