Formatting
This commit is contained in:
@@ -44,7 +44,7 @@ QList<DeviceFinder::Device> AlsaPCMDeviceFinder::ListDevices() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (void **n = hints ; *n ; ++n) {
|
||||
for (void **n = hints; *n; ++n) {
|
||||
char *io = snd_device_name_get_hint(*n, "IOID");
|
||||
char *name = snd_device_name_get_hint(*n, "NAME");
|
||||
char *desc = snd_device_name_get_hint(*n, "DESC");
|
||||
@@ -52,7 +52,7 @@ QList<DeviceFinder::Device> AlsaPCMDeviceFinder::ListDevices() {
|
||||
|
||||
char *desc_last = desc;
|
||||
QString description;
|
||||
for (char *desc_i = desc ; desc_i && *desc_i != '\0' ; ++desc_i) {
|
||||
for (char *desc_i = desc; desc_i && *desc_i != '\0'; ++desc_i) {
|
||||
if (*desc_i == '\n') {
|
||||
*desc_i = '\0';
|
||||
if (!description.isEmpty()) description.append(' ');
|
||||
|
||||
@@ -175,8 +175,9 @@ void Engine::Base::ReloadSettings() {
|
||||
|
||||
void Engine::Base::EmitAboutToEnd() {
|
||||
|
||||
if (about_to_end_emitted_)
|
||||
if (about_to_end_emitted_) {
|
||||
return;
|
||||
}
|
||||
|
||||
about_to_end_emitted_ = true;
|
||||
emit TrackAboutToEnd();
|
||||
|
||||
@@ -122,10 +122,12 @@ GstEngine::~GstEngine() {
|
||||
|
||||
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_);
|
||||
if (discovery_finished_cb_id_ != -1)
|
||||
}
|
||||
if (discovery_finished_cb_id_ != -1) {
|
||||
g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_finished_cb_id_);
|
||||
}
|
||||
|
||||
gst_discoverer_stop(discoverer_);
|
||||
g_object_unref(discoverer_);
|
||||
@@ -210,8 +212,9 @@ bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::T
|
||||
SetEqualizerParameters(equalizer_preamp_, equalizer_gains_);
|
||||
|
||||
// Maybe fade in this track
|
||||
if (crossfade)
|
||||
if (crossfade) {
|
||||
current_pipeline_->StartFader(fadeout_duration_nanosec_, QTimeLine::Forward);
|
||||
}
|
||||
|
||||
// Setting up stream discoverer
|
||||
if (!discoverer_) {
|
||||
@@ -640,6 +643,7 @@ void GstEngine::SeekNow() {
|
||||
if (!current_pipeline_->Seek(seek_pos_)) {
|
||||
qLog(Warning) << "Seek failed";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GstEngine::PlayDone(const GstStateChangeReturn ret, const quint64 offset_nanosec, const int pipeline_id) {
|
||||
|
||||
@@ -130,17 +130,21 @@ GstEnginePipeline::~GstEnginePipeline() {
|
||||
|
||||
if (pipeline_) {
|
||||
|
||||
if (pad_added_cb_id_ != -1)
|
||||
if (pad_added_cb_id_ != -1) {
|
||||
g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_);
|
||||
}
|
||||
|
||||
if (notify_source_cb_id_ != -1)
|
||||
if (notify_source_cb_id_ != -1) {
|
||||
g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_);
|
||||
}
|
||||
|
||||
if (about_to_finish_cb_id_ != -1)
|
||||
if (about_to_finish_cb_id_ != -1) {
|
||||
g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_);
|
||||
}
|
||||
|
||||
if (bus_cb_id_ != -1)
|
||||
if (bus_cb_id_ != -1) {
|
||||
g_source_remove(bus_cb_id_);
|
||||
}
|
||||
|
||||
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_));
|
||||
if (bus) {
|
||||
@@ -170,9 +174,11 @@ void GstEnginePipeline::set_volume_enabled(const bool enabled) {
|
||||
}
|
||||
|
||||
void GstEnginePipeline::set_stereo_balancer_enabled(const bool enabled) {
|
||||
|
||||
stereo_balancer_enabled_ = enabled;
|
||||
if (!enabled) stereo_balance_ = 0.0F;
|
||||
if (pipeline_) UpdateStereoBalance();
|
||||
|
||||
}
|
||||
|
||||
void GstEnginePipeline::set_equalizer_enabled(const bool enabled) {
|
||||
@@ -647,7 +653,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
|
||||
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
|
||||
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size));
|
||||
memset(d, 0, 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));
|
||||
}
|
||||
gst_buffer_unmap(buf, &map_info);
|
||||
@@ -668,7 +674,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
|
||||
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
|
||||
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size));
|
||||
memset(d, 0, buf16_size);
|
||||
for (int i = 0 ; i < (samples * channels) ; ++i) {
|
||||
for (int i = 0; i < (samples * channels); ++i) {
|
||||
float sample_float = (s[i] * float(32768.0));
|
||||
d[i] = static_cast<int16_t>(sample_float);
|
||||
}
|
||||
@@ -690,7 +696,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
|
||||
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
|
||||
int16_t *s16 = static_cast<int16_t*>(g_malloc(buf16_size));
|
||||
memset(s16, 0, 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));
|
||||
s24 += 3;
|
||||
if (s24 >= s24e) break;
|
||||
@@ -1071,8 +1077,9 @@ void GstEnginePipeline::BufferingMessageReceived(GstMessage *msg) {
|
||||
|
||||
qint64 GstEnginePipeline::position() const {
|
||||
|
||||
if (pipeline_is_initialized_)
|
||||
if (pipeline_is_initialized_) {
|
||||
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &last_known_position_ns_);
|
||||
}
|
||||
|
||||
return last_known_position_ns_;
|
||||
|
||||
@@ -1090,8 +1097,9 @@ qint64 GstEnginePipeline::length() const {
|
||||
GstState GstEnginePipeline::state() const {
|
||||
|
||||
GstState s = GST_STATE_NULL, sp = GST_STATE_NULL;
|
||||
if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE)
|
||||
if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE) {
|
||||
return GST_STATE_NULL;
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
@@ -1179,10 +1187,12 @@ void GstEnginePipeline::UpdateEqualizer() {
|
||||
// Update band gains
|
||||
for (int i = 0; i < kEqBandCount; ++i) {
|
||||
float gain = eq_enabled_ ? eq_band_gains_[i] : float(0.0);
|
||||
if (gain < 0)
|
||||
if (gain < 0) {
|
||||
gain *= 0.24;
|
||||
else
|
||||
}
|
||||
else {
|
||||
gain *= 0.12;
|
||||
}
|
||||
|
||||
const int index_in_eq = i + 1;
|
||||
// Offset because of the first dummy band we created.
|
||||
|
||||
@@ -53,7 +53,7 @@ QList<DeviceFinder::Device> MMDeviceFinder::ListDevices() {
|
||||
UINT count;
|
||||
hr = collection->GetCount(&count);
|
||||
if (hr == S_OK) {
|
||||
for (ULONG i = 0 ; i < count ; i++) {
|
||||
for (ULONG i = 0; i < count; i++) {
|
||||
IMMDevice *endpoint = nullptr;
|
||||
hr = collection->Item(i, &endpoint);
|
||||
if (hr == S_OK) {
|
||||
|
||||
@@ -189,19 +189,24 @@ void VLCEngine::Seek(const quint64 offset_nanosec) {
|
||||
}
|
||||
|
||||
void VLCEngine::SetVolumeSW(const uint percent) {
|
||||
|
||||
if (!Initialized()) return;
|
||||
if (!volume_control_ && percent != 100) return;
|
||||
libvlc_audio_set_volume(player_, percent);
|
||||
|
||||
}
|
||||
|
||||
qint64 VLCEngine::position_nanosec() const {
|
||||
|
||||
if (state_ == Engine::Empty) return 0;
|
||||
const qint64 result = (position() * kNsecPerMsec);
|
||||
return qint64(qMax(0LL, result));
|
||||
|
||||
|
||||
}
|
||||
|
||||
qint64 VLCEngine::length_nanosec() const {
|
||||
|
||||
if (state_ == Engine::Empty) return 0;
|
||||
const qint64 result = (end_nanosec_ - beginning_nanosec_);
|
||||
if (result > 0) {
|
||||
@@ -211,6 +216,7 @@ qint64 VLCEngine::length_nanosec() const {
|
||||
// Get the length from the pipeline if we don't know.
|
||||
return (length() * kNsecPerMsec);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
|
||||
@@ -330,7 +336,7 @@ EngineBase::PluginDetailsList VLCEngine::GetPluginList() const {
|
||||
ret << details;
|
||||
}
|
||||
|
||||
for (libvlc_audio_output_t *audio_output = audio_output_list ; audio_output ; audio_output = audio_output->p_next) {
|
||||
for (libvlc_audio_output_t *audio_output = audio_output_list; audio_output; audio_output = audio_output->p_next) {
|
||||
PluginDetails details;
|
||||
details.name = QString::fromUtf8(audio_output->psz_name);
|
||||
details.description = QString::fromUtf8(audio_output->psz_description);
|
||||
@@ -349,7 +355,7 @@ void VLCEngine::GetDevicesList(const QString &output) const {
|
||||
Q_UNUSED(output);
|
||||
|
||||
libvlc_audio_output_device_t *audio_output_device_list = libvlc_audio_output_device_list_get(instance_, output_.toUtf8().constData());
|
||||
for (libvlc_audio_output_device_t *audio_device = audio_output_device_list ; audio_device ; audio_device = audio_device->p_next) {
|
||||
for (libvlc_audio_output_device_t *audio_device = audio_output_device_list; audio_device; audio_device = audio_device->p_next) {
|
||||
qLog(Debug) << audio_device->psz_device << audio_device->psz_description;
|
||||
}
|
||||
libvlc_audio_output_device_list_release(audio_output_device_list);
|
||||
|
||||
Reference in New Issue
Block a user