diff --git a/src/analyzers/analyzerbase.cpp b/src/analyzers/analyzerbase.cpp index e2f25877e..00c2e57ee 100755 --- a/src/analyzers/analyzerbase.cpp +++ b/src/analyzers/analyzerbase.cpp @@ -52,7 +52,7 @@ Analyzer::Base::Base(QWidget* parent, uint scopeSize) m_fht(new FHT(scopeSize)), m_engine(nullptr), m_lastScope(512), - current_chunk(0), + current_chunk_(0), new_frame_(false), is_playing_(false) {} diff --git a/src/analyzers/analyzerbase.h b/src/analyzers/analyzerbase.h index 85a4c7a9f..1bc3bd90b 100755 --- a/src/analyzers/analyzerbase.h +++ b/src/analyzers/analyzerbase.h @@ -73,7 +73,7 @@ class Base : public QWidget { FHT* m_fht; EngineBase* m_engine; Scope m_lastScope; - int current_chunk; + int current_chunk_; bool new_frame_; bool is_playing_; diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 3fd173306..337df9899 100755 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -45,6 +45,7 @@ #include "gstenginepipeline.h" #include "core/logging.h" #include "core/taskmanager.h" +#include "core/timeconstants.h" #include "core/utilities.h" #ifdef HAVE_MOODBAR @@ -98,8 +99,8 @@ GstEngine::GstEngine(TaskManager* task_manager) next_element_id_(0), is_fading_out_to_pause_(false), has_faded_out_(false), - scope_chunk(0), - have_new_buffer(false) { + scope_chunk_(0), + have_new_buffer_(false) { seek_timer_->setSingleShot(true); seek_timer_->setInterval(kSeekDelayNanosec / kNsecPerMsec); connect(seek_timer_, SIGNAL(timeout()), SLOT(SeekNow())); @@ -240,37 +241,37 @@ void GstEngine::AddBufferToScope(GstBuffer* buf, int pipeline_id) { } latest_buffer_ = buf; - have_new_buffer = true; + have_new_buffer_ = true; } const Engine::Scope& GstEngine::scope(int chunk_length) { // the new buffer could have a different size - if (have_new_buffer) { + if (have_new_buffer_) { if (latest_buffer_ != nullptr) { - scope_chunks = ceil(((double)GST_BUFFER_DURATION(latest_buffer_) / - (double)(chunk_length * 1000000))); - } - - // if the buffer is shorter than the chunk length - if (scope_chunks <= 0) { - scope_chunks = 1; + scope_chunks_ = ceil(((double)GST_BUFFER_DURATION(latest_buffer_) / + (double)(chunk_length * 1000000))); } - scope_chunk = 0; - have_new_buffer = false; + // if the buffer is shorter than the chunk length + if (scope_chunks_ <= 0) { + scope_chunks_ = 1; + } + + scope_chunk_ = 0; + have_new_buffer_ = false; } UpdateScope(chunk_length); return scope_; } -void GstEngine::UpdateScope(int chunk_length_) { +void GstEngine::UpdateScope(int chunk_length) { typedef Engine::Scope::value_type sample_type; // determine where to split the buffer - int chunk_density = GST_BUFFER_SIZE(latest_buffer_) / - (GST_BUFFER_DURATION(latest_buffer_) / 1000000); - int chunk_size = chunk_length_ * chunk_density; + int chunk_density = GST_BUFFER_SIZE(latest_buffer_) / + (GST_BUFFER_DURATION(latest_buffer_) / kNsecPerMsec); + int chunk_size = chunk_length * chunk_density; // determine the number of channels GstStructure* structure = @@ -282,31 +283,31 @@ void GstEngine::UpdateScope(int chunk_length_) { if (channels > 2) return; // in case a buffer doesn't arrive in time - if (scope_chunk >= scope_chunks) { - scope_chunk = 0; + if (scope_chunk_ >= scope_chunks_) { + scope_chunk_ = 0; return; } // set the starting point in the buffer to take data from const sample_type* source = reinterpret_cast(GST_BUFFER_DATA(latest_buffer_)); - source += (chunk_size / sizeof(sample_type)) * scope_chunk; + source += (chunk_size / sizeof(sample_type)) * scope_chunk_; sample_type* dest = scope_.data(); - int bytes; + int bytes = 0; // make sure we don't go beyond the end of the buffer - if (scope_chunk == scope_chunks - 1) { - bytes = qMin( - static_cast(GST_BUFFER_SIZE(latest_buffer_) - (chunk_size * scope_chunk)), - scope_.size() * sizeof(sample_type)); + if (scope_chunk_ == scope_chunks_ - 1) { + bytes = + qMin(static_cast( + GST_BUFFER_SIZE(latest_buffer_) - (chunk_size * scope_chunk_)), + scope_.size() * sizeof(sample_type)); } else { - bytes = qMin( - static_cast(chunk_size), - scope_.size() * sizeof(sample_type)); + bytes = qMin(static_cast(chunk_size), + scope_.size() * sizeof(sample_type)); } - scope_chunk++; + scope_chunk_++; memcpy(dest, source, bytes); } diff --git a/src/engines/gstengine.h b/src/engines/gstengine.h index f50b51a05..ad1819691 100755 --- a/src/engines/gstengine.h +++ b/src/engines/gstengine.h @@ -224,9 +224,9 @@ class GstEngine : public Engine::Base, public BufferConsumer { bool is_fading_out_to_pause_; bool has_faded_out_; - int scope_chunk; - bool have_new_buffer; - int scope_chunks; + int scope_chunk_; + bool have_new_buffer_; + int scope_chunks_; QList device_finders_; };