fix: PCM copy, device name encoding, double shutdown
- playRawPcm: ma_audio_buffer_init_copy instead of ma_audio_buffer_ref (copies PCM) - enumerateDevices: fromLocal8Bit instead of fromUtf8 for device names - AudioRecorder: m_deviceStarted flag prevents double ma_device_uninit - stopMicTest: delete instead of deleteLater to avoid deferred double shutdown
This commit is contained in:
1 parent
a4ae1c6b41
commit
ca9d1384f2
4 files changed
+24
-16
No files matched your search
@@ -56,11 +56,13 @@ bool AudioRecorder::init() {
|
||||
}
|
||||
|
||||
void AudioRecorder::shutdown() {
|
||||
if (!m_initialized) return;
|
||||
if (m_recording) stopRecording();
|
||||
if (m_device) {
|
||||
delete m_device;
|
||||
m_device = nullptr;
|
||||
if (m_deviceStarted) {
|
||||
m_deviceStarted = false;
|
||||
if (m_device) { ma_device_stop(m_device); ma_device_uninit(m_device); }
|
||||
}
|
||||
if (m_device) { delete m_device; m_device = nullptr; }
|
||||
m_initialized = false;
|
||||
qDebug("AudioRecorder: shutdown");
|
||||
}
|
||||
@@ -113,6 +115,7 @@ void AudioRecorder::startRecording() {
|
||||
}
|
||||
|
||||
m_recording = true;
|
||||
m_deviceStarted = true;
|
||||
m_durationTimer.start();
|
||||
qDebug("AudioRecorder: recording started");
|
||||
emit recordingStarted();
|
||||
@@ -122,8 +125,11 @@ void AudioRecorder::stopRecording() {
|
||||
if (!m_recording) return;
|
||||
|
||||
m_durationTimer.stop();
|
||||
ma_device_stop(m_device);
|
||||
ma_device_uninit(m_device);
|
||||
if (m_deviceStarted) {
|
||||
ma_device_stop(m_device);
|
||||
ma_device_uninit(m_device);
|
||||
m_deviceStarted = false;
|
||||
}
|
||||
|
||||
m_recording = false;
|
||||
int duration = m_elapsedMs;
|
||||
|
||||
Reference in new issue
Block a user