|
|
|
|
@ -141,7 +141,11 @@ ma_context* SoundManager::context() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SoundManager::playRawPcm(const int16_t* pcm, int sampleCount, int sampleRate, int channels) { |
|
|
|
|
if (!m_engine || !m_initialized) return; |
|
|
|
|
if (!m_engine || !m_initialized) { |
|
|
|
|
qWarning("SoundManager::playRawPcm: not initialized (engine=%p init=%d)", (void*)m_engine, m_initialized); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
qDebug("SoundManager::playRawPcm: %d samples %dHz %dch vol=%.2f", sampleCount, sampleRate, channels, m_volume); |
|
|
|
|
|
|
|
|
|
ma_audio_buffer_config bufCfg = ma_audio_buffer_config_init( |
|
|
|
|
ma_format_s16, (ma_uint32)channels, (ma_uint64)sampleCount, pcm, NULL); |
|
|
|
|
@ -165,7 +169,14 @@ void SoundManager::playRawPcm(const int16_t* pcm, int sampleCount, int sampleRat
|
|
|
|
|
|
|
|
|
|
ma_sound_set_volume(sound, m_volume); |
|
|
|
|
ma_sound_start(sound); |
|
|
|
|
qDebug("SoundManager: playing PCM (%d samples, %dHz, %dch)", sampleCount, sampleRate, channels); |
|
|
|
|
qDebug("SoundManager::playRawPcm: started"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static QString decodeDeviceName(const char* name) { |
|
|
|
|
QString s = QString::fromUtf8(name); |
|
|
|
|
if (s.contains(QChar(0xFFFD))) |
|
|
|
|
s = QString::fromLocal8Bit(name); |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QVector<SoundManager::DeviceInfo> SoundManager::enumeratePlaybackDevices() { |
|
|
|
|
@ -177,7 +188,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::fromLocal8Bit(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
result.append({decodeDeviceName(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -190,6 +201,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::fromLocal8Bit(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
result.append({decodeDeviceName(pDevices[i].name), pDevices[i].isDefault != MA_FALSE}); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|