现在RtAudio使用默认输出设备, 并新增打印当前所有设备函数

This commit is contained in:
Nanako 2024-03-22 15:59:17 +08:00
parent f3e3c4f660
commit 4746178a62
2 changed files with 13 additions and 0 deletions

@ -20,6 +20,10 @@ void audio_device_manager::init(singleton_initliazer& initliazer) {
singleton_t<audio_device_manager>::init(initliazer);
options_.flags = RTAUDIO_NONINTERLEAVED;
audio_ = new RtAudio();
log_all_devices();
output_params_.deviceId = audio_->getDefaultOutputDevice();
output_params_.nChannels = get_output_channel_count();
spdlog::info("using output device id: {}", output_params_.deviceId);
}
void audio_device_manager::release(singleton_release_guard& release_guard) {
@ -70,6 +74,14 @@ int audio_device_manager::stream_callback(float** output, float** input, unsigne
return 0;
}
void audio_device_manager::log_all_devices() {
const auto& device_count = audio_->getDeviceIds();
for (const auto& device_id: device_count) {
const auto& device_info = audio_->getDeviceInfo(device_id);
spdlog::info("find device id: {}, name: {}", device_id, device_info.name);
}
}
void audio_device_manager::start_render_thread() {
render_thread_ = std::thread(&audio_device_manager::render_thread, this);
render_thread_.detach();

@ -21,6 +21,7 @@ public:
CORE_API uint32_t get_output_channel_count() const;
int stream_callback(float** output, float** input, unsigned long frame_count, double stream_time, RtAudioStreamStatus status);
void log_all_devices();
protected:
#pragma region render_thread
void start_render_thread();