|
|
|
|
@ -143,21 +143,22 @@ ma_context* SoundManager::context() {
|
|
|
|
|
void SoundManager::playRawPcm(const int16_t* pcm, int sampleCount, int sampleRate, int channels) { |
|
|
|
|
if (!m_engine || !m_initialized) return; |
|
|
|
|
|
|
|
|
|
ma_audio_buffer_ref* ref = new ma_audio_buffer_ref; |
|
|
|
|
ma_result r = ma_audio_buffer_ref_init(ma_format_s16, (ma_uint32)channels, |
|
|
|
|
pcm, (ma_uint64)sampleCount, ref); |
|
|
|
|
ma_audio_buffer_config bufCfg = ma_audio_buffer_config_init( |
|
|
|
|
ma_format_s16, (ma_uint32)channels, (ma_uint64)sampleCount, pcm, NULL); |
|
|
|
|
ma_audio_buffer* buf = new ma_audio_buffer; |
|
|
|
|
ma_result r = ma_audio_buffer_init_copy(&bufCfg, buf); |
|
|
|
|
if (r != MA_SUCCESS) { |
|
|
|
|
qWarning("SoundManager: audio_buffer_ref_init failed (%d)", r); |
|
|
|
|
delete ref; |
|
|
|
|
qWarning("SoundManager: audio_buffer_init_copy failed (%d)", r); |
|
|
|
|
delete buf; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ma_sound* sound = new ma_sound; |
|
|
|
|
r = ma_sound_init_from_data_source(m_engine, (ma_data_source*)ref, 0, nullptr, sound); |
|
|
|
|
r = ma_sound_init_from_data_source(m_engine, (ma_data_source*)buf, 0, nullptr, sound); |
|
|
|
|
if (r != MA_SUCCESS) { |
|
|
|
|
qWarning("SoundManager: PCM sound init failed (%d)", r); |
|
|
|
|
ma_audio_buffer_ref_uninit(ref); |
|
|
|
|
delete ref; |
|
|
|
|
ma_audio_buffer_uninit(buf); |
|
|
|
|
delete buf; |
|
|
|
|
delete sound; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -176,7 +177,7 @@ QVector<SoundManager::DeviceInfo> SoundManager::enumeratePlaybackDevices() {
|
|
|
|
|
ma_uint32 count = 0; |
|
|
|
|
if (ma_context_get_devices(ctx, &pDevices, &count, nullptr, nullptr) != MA_SUCCESS) return result; |
|
|
|
|
for (ma_uint32 i = 0; i < count; i++) |
|
|
|
|
result.append({QString::fromUtf8(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
result.append({QString::fromLocal8Bit(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -189,6 +190,6 @@ QVector<SoundManager::DeviceInfo> SoundManager::enumerateCaptureDevices() {
|
|
|
|
|
ma_uint32 count = 0; |
|
|
|
|
if (ma_context_get_devices(ctx, nullptr, nullptr, &pDevices, &count) != MA_SUCCESS) return result; |
|
|
|
|
for (ma_uint32 i = 0; i < count; i++) |
|
|
|
|
result.append({QString::fromUtf8(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
result.append({QString::fromLocal8Bit(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|