@@ -13,8 +13,8 @@ namespace audio_daemon {
1313
1414CapturePipeline::CapturePipeline (const DaemonConfig& config)
1515 : config_(config), downmix_mono_(config.audio.downmix_mono) {
16- gain_db_.store (config.audio .gain_db , std::memory_order_relaxed);
17- gain_linear_.store (std::pow (10.0 , config.audio .gain_db / 20.0 ),
16+ gain_db_.store (static_cast < float >( config.audio .gain_db ) , std::memory_order_relaxed);
17+ gain_linear_.store (static_cast < float >( std::pow (10.0 , config.audio .gain_db / 20.0 ) ),
1818 std::memory_order_relaxed);
1919 if (config.audio .gain_db != 0.0 ) {
2020 LOG_INFO (" Mic boost: " , config.audio .gain_db , " dB (linear " ,
@@ -148,8 +148,8 @@ bool CapturePipeline::set_parameter(const std::string& key,
148148 const std::string& value) {
149149 if (key == " gain_db" || key == " gain" ) {
150150 double db = std::stod (value);
151- gain_db_.store (db , std::memory_order_relaxed);
152- gain_linear_.store (std::pow (10.0 , db / 20.0 ),
151+ gain_db_.store (static_cast < float >(db) , std::memory_order_relaxed);
152+ gain_linear_.store (static_cast < float >( std::pow (10.0 , db / 20.0 ) ),
153153 std::memory_order_relaxed);
154154 LOG_INFO (" Mic boost set to " , db, " dB" );
155155 return true ;
@@ -189,9 +189,9 @@ void CapturePipeline::on_audio_chunk(const AudioChunkMeta& meta,
189189 size_t data_size = cur_samples * bytes_per_sample;
190190
191191 // Apply mic boost if gain != 0 dB
192- double gain = gain_linear_.load (std::memory_order_relaxed);
192+ float gain = gain_linear_.load (std::memory_order_relaxed);
193193 const uint8_t * out_data = cur_data;
194- if (gain != 1.0 ) {
194+ if (gain != 1 .0f ) {
195195 if (gain_buffer_.size () < data_size) {
196196 gain_buffer_.resize (data_size);
197197 }
@@ -337,14 +337,14 @@ void CapturePipeline::on_audio_chunk(const AudioChunkMeta& meta,
337337 }
338338 }
339339 peak_level_.store (static_cast <int16_t >(std::min (peak, (int32_t )32767 )), std::memory_order_relaxed);
340- rms_level_.store (std::sqrt (sum_sq / static_cast <double >(cur_samples)),
340+ rms_level_.store (static_cast < float >( std::sqrt (sum_sq / static_cast <double >(cur_samples) )),
341341 std::memory_order_relaxed);
342342 total_frames_.fetch_add (frame_count, std::memory_order_relaxed);
343343}
344344
345345void CapturePipeline::apply_gain (const uint8_t * src, uint8_t * dst,
346346 size_t sample_count, uint16_t bits_per_sample,
347- double gain) const {
347+ float gain) const {
348348 switch (bits_per_sample) {
349349 case 16 : {
350350 const int16_t * sp = reinterpret_cast <const int16_t *>(src);
@@ -580,11 +580,11 @@ std::string CapturePipeline::get_status_json() const {
580580std::string CapturePipeline::get_levels_json () const {
581581 std::ostringstream oss;
582582 int16_t peak = peak_level_.load (std::memory_order_relaxed);
583- double rms = rms_level_.load (std::memory_order_relaxed);
583+ float rms = rms_level_.load (std::memory_order_relaxed);
584584 double peak_db = (peak > 0 )
585585 ? 20.0 * std::log10 (static_cast <double >(peak) / 32768.0 ) : -96.0 ;
586586 double rms_db = (rms > 0 )
587- ? 20.0 * std::log10 (rms / 32768.0 ) : -96.0 ;
587+ ? 20.0 * std::log10 (static_cast < double >( rms) / 32768.0 ) : -96.0 ;
588588 oss << R"( {"peak":)" << peak
589589 << R"( ,"peak_db":)" << peak_db
590590 << R"( ,"rms":)" << rms
0 commit comments