Browse Source

update

master
zhaohe 2 years ago
parent
commit
a2ab53b854
  1. 6
      src/iflytop/components/audio/audio_recoder.cpp
  2. 9
      src/iflytop/components/audio/audio_recoder.hpp

6
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;

9
src/iflytop/components/audio/audio_recoder.hpp

@ -15,9 +15,8 @@
#include <string>
#include <vector>
#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<AudioRecoder> {
unique_ptr<Thread> 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<void(shared_ptr<AudioClip> audioclip)> onRecordData;
private:

Loading…
Cancel
Save