fix: use DEBUG_* macros instead of qDebug in AudioRecorder/AudioCompressor
This commit is contained in:
1 parent
f1b599f0c0
commit
5ec1cb78be
2 files changed
+23
-24
No files matched your search
@@ -3,11 +3,10 @@
|
||||
#include "miniaudio.h"
|
||||
#include "sound_manager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include "../../lib/debug_config.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
|
||||
static AudioRecorder* g_recorder = nullptr;
|
||||
|
||||
void audioCaptureCallback(ma_device* pDevice, void* pOutput, const void* pInput, unsigned int frameCount) {
|
||||
@@ -74,7 +73,7 @@ bool AudioRecorder::init() {
|
||||
m_device = new ma_device;
|
||||
std::memset(m_device, 0, sizeof(*m_device));
|
||||
m_initialized = true;
|
||||
qDebug("AudioRecorder: initialized (sampleRate=%d, channels=%d)", m_sampleRate, m_channels);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "initialized (sampleRate=%d, channels=%d)", m_sampleRate, m_channels);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,12 +86,12 @@ void AudioRecorder::shutdown() {
|
||||
}
|
||||
if (m_device) { delete m_device; m_device = nullptr; }
|
||||
m_initialized = false;
|
||||
qDebug("AudioRecorder: shutdown");
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "shutdown");
|
||||
}
|
||||
|
||||
void AudioRecorder::startRecording() {
|
||||
if (m_recording) return;
|
||||
if (!m_initialized) { qWarning("AudioRecorder: not initialized"); return; }
|
||||
if (!m_initialized) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "not initialized"); return; }
|
||||
|
||||
m_pcmBuffer.clear();
|
||||
m_waveformLevels.clear();
|
||||
@@ -102,7 +101,7 @@ void AudioRecorder::startRecording() {
|
||||
if (m_compressor) m_compressor->reset();
|
||||
|
||||
ma_context* ctx = SoundManager::instance()->context();
|
||||
if (!ctx) { qWarning("AudioRecorder: no audio context"); return; }
|
||||
if (!ctx) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "no audio context"); return; }
|
||||
|
||||
ma_device_config config = ma_device_config_init(ma_device_type_capture);
|
||||
config.capture.format = ma_format_s16;
|
||||
@@ -118,25 +117,25 @@ void AudioRecorder::startRecording() {
|
||||
ma_result r = ma_context_get_devices(ctx, nullptr, nullptr, &pCaptureDevices, &captureCount);
|
||||
if (r == MA_SUCCESS && (ma_uint32)m_captureDeviceIndex < captureCount) {
|
||||
config.capture.pDeviceID = &pCaptureDevices[m_captureDeviceIndex].id;
|
||||
qDebug("AudioRecorder: using capture device[%d]: %s", m_captureDeviceIndex,
|
||||
pCaptureDevices[m_captureDeviceIndex].name);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "using capture device[%d]: %s", m_captureDeviceIndex,
|
||||
pCaptureDevices[m_captureDeviceIndex].name);
|
||||
}
|
||||
}
|
||||
|
||||
ma_result r = ma_device_init(ctx, &config, m_device);
|
||||
if (r != MA_SUCCESS) {
|
||||
qWarning("AudioRecorder: device init failed (%d), trying default", r);
|
||||
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "device init failed (%d), trying default", r);
|
||||
config.capture.pDeviceID = nullptr;
|
||||
r = ma_device_init(ctx, &config, m_device);
|
||||
if (r != MA_SUCCESS) {
|
||||
qWarning("AudioRecorder: default device init also failed (%d)", r);
|
||||
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "default device init also failed (%d)", r);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
r = ma_device_start(m_device);
|
||||
if (r != MA_SUCCESS) {
|
||||
qWarning("AudioRecorder: device start failed (%d)", r);
|
||||
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "device start failed (%d)", r);
|
||||
ma_device_uninit(m_device);
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +143,7 @@ void AudioRecorder::startRecording() {
|
||||
m_recording = true;
|
||||
m_deviceStarted = true;
|
||||
m_durationTimer.start();
|
||||
qDebug("AudioRecorder: recording started");
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "recording started");
|
||||
emit recordingStarted();
|
||||
}
|
||||
|
||||
@@ -163,8 +162,8 @@ void AudioRecorder::stopRecording() {
|
||||
|
||||
int duration = m_elapsedMs;
|
||||
size_t bufSize = (m_compressor && m_compressorEnabled) ? m_compressor->outputBuffer().size() : m_pcmBuffer.size();
|
||||
qDebug("AudioRecorder: recording stopped, duration=%dms, pcmSamples=%zu, compressor=%d",
|
||||
duration, bufSize, m_compressorEnabled ? 1 : 0);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "recording stopped, duration=%dms, pcmSamples=%zu, compressor=%d",
|
||||
duration, bufSize, m_compressorEnabled ? 1 : 0);
|
||||
emit recordingStopped(duration);
|
||||
emit durationChanged(0);
|
||||
}
|
||||
@@ -187,5 +186,5 @@ const std::vector<int16_t>& AudioRecorder::buffer() const {
|
||||
void AudioRecorder::setCompressorEnabled(bool enabled) {
|
||||
m_compressorEnabled = enabled;
|
||||
if (m_compressor) m_compressor->setEnabled(enabled);
|
||||
qDebug("AudioRecorder: compressor %s", enabled ? "enabled" : "disabled");
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "compressor %s", enabled ? "enabled" : "disabled");
|
||||
}
|
||||
Reference in new issue
Block a user