From a2ab53b854cdca82ea5bdded0e2c43ef4cba4804 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 10 Sep 2023 23:53:17 +0800 Subject: [PATCH] update --- src/iflytop/components/audio/audio_recoder.cpp | 6 ++++++ src/iflytop/components/audio/audio_recoder.hpp | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/iflytop/components/audio/audio_recoder.cpp b/src/iflytop/components/audio/audio_recoder.cpp index f51e5fe..d553496 100644 --- a/src/iflytop/components/audio/audio_recoder.cpp +++ b/src/iflytop/components/audio/audio_recoder.cpp @@ -118,6 +118,7 @@ bool AudioRecoder::initialize(const char *pcmName, unsigned int channels, unsign // snd_pcm_hw_params_free(params); // snd_pcm_sw_params_free(swparams); + initedsuc = true; return true; err: @@ -144,6 +145,11 @@ void AudioRecoder::onAudio(uint8_t *voice, int size) { } void AudioRecoder::startRecord() { + if(!initedsuc){ + logger->error("AudioRecoder::startRecord failed, not initedsuc"); + return; + } + m_recordThread.reset(new Thread("AudioRecoder", [this]() { ThisThread thisThread; int err = 0; diff --git a/src/iflytop/components/audio/audio_recoder.hpp b/src/iflytop/components/audio/audio_recoder.hpp index 09dac6b..16e1fd6 100644 --- a/src/iflytop/components/audio/audio_recoder.hpp +++ b/src/iflytop/components/audio/audio_recoder.hpp @@ -15,9 +15,8 @@ #include #include -#include "iflytop/core/core.hpp" #include "audio_clip.hpp" - +#include "iflytop/core/core.hpp" /** * @brief @@ -57,10 +56,12 @@ class AudioRecoder : public enable_shared_from_this { unique_ptr m_recordThread; + bool initedsuc = false; + public: - bool initialize(const char *pcmName, unsigned int channels, unsigned int sample_rate, snd_pcm_format_t format, - int rec_period_time_ms); + bool initialize(const char *pcmName, unsigned int channels, unsigned int sample_rate, snd_pcm_format_t format, int rec_period_time_ms); void startRecord(); + nod::signal audioclip)> onRecordData; private: