Fix dangle build issues, do some tweaks to investigate performance

This commit is contained in:
jacqueline
2023-08-07 09:47:44 +10:00
parent 60f7677132
commit 4118d880c3
6 changed files with 7 additions and 12 deletions
+1 -1
View File
@@ -7,6 +7,6 @@ idf_component_register(
"stream_message.cpp" "i2s_audio_output.cpp" "stream_buffer.cpp" "track_queue.cpp"
"stream_event.cpp" "stream_info.cpp" "audio_fsm.cpp" "sink_mixer.cpp" "resample.cpp"
INCLUDE_DIRS "include"
REQUIRES "codecs" "drivers" "cbor" "result" "tasks" "span" "memory" "tinyfsm" "database" "system_fsm" "playlist" "libsamplerate")
REQUIRES "codecs" "drivers" "cbor" "result" "tasks" "span" "memory" "tinyfsm" "database" "system_fsm" "playlist")
target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS})
+1 -1
View File
@@ -127,7 +127,7 @@ auto I2SAudioOutput::PrepareFormat(const StreamInfo::Pcm& orig)
return StreamInfo::Pcm{
.channels = std::min<uint8_t>(orig.channels, 2),
.bits_per_sample = 16,
.sample_rate = 48000,
.sample_rate = 44100,
};
}
-1
View File
@@ -12,7 +12,6 @@
#include "resample.hpp"
#include "sample.hpp"
#include "samplerate.h"
#include "audio_decoder.hpp"
#include "audio_sink.hpp"
+2 -1
View File
@@ -231,7 +231,8 @@ auto Resampler::Process(cpp::span<const sample::Sample> input,
cpp::span<sample::Sample> output,
bool end_of_data) -> std::pair<size_t, size_t> {
size_t samples_used = 0;
std::vector<size_t> samples_produced = {num_channels_, 0};
std::vector<size_t> samples_produced = {};
samples_produced.resize(num_channels_, 0);
size_t total_samples_produced = 0;
size_t slop = (factor_ >> kPhaseBits) + 1;
+3 -7
View File
@@ -15,7 +15,6 @@
#include "freertos/projdefs.h"
#include "resample.hpp"
#include "sample.hpp"
#include "samplerate.h"
#include "stream_info.hpp"
#include "tasks.hpp"
@@ -23,7 +22,7 @@
static constexpr char kTag[] = "mixer";
static constexpr std::size_t kSourceBufferLength = 2 * 1024;
static constexpr std::size_t kSampleBufferLength = 4 * 1024;
static constexpr std::size_t kSampleBufferLength = 2 * 1024;
namespace audio {
@@ -33,8 +32,8 @@ SinkMixer::SinkMixer(StreamBufferHandle_t dest)
resampler_(nullptr),
source_(xStreamBufferCreate(kSourceBufferLength, 1)),
sink_(dest) {
input_stream_.reset(new RawStream(kSampleBufferLength));
resampled_stream_.reset(new RawStream(kSampleBufferLength));
input_stream_.reset(new RawStream(kSampleBufferLength, MALLOC_CAP_SPIRAM));
resampled_stream_.reset(new RawStream(kSampleBufferLength, MALLOC_CAP_SPIRAM));
tasks::StartPersistent<tasks::Type::kMixer>([&]() { Main(); });
}
@@ -188,9 +187,6 @@ auto SinkMixer::Resample(InputStream& in, OutputStream& out) -> bool {
auto res = resampler_->Process(in.data_as<sample::Sample>(),
out.data_as<sample::Sample>(), false);
ESP_LOGI(kTag, "resampler sent %u samples, consumed %u, produced %u",
in.data().size(), res.first, res.second);
in.consume(res.first * sizeof(sample::Sample));
out.add(res.first * sizeof(sample::Sample));