__LIKELY_IF(!(sound_ok)) {
sound_drv->start();
__UNLIKELY_IF(p_config != nullptr) {
- sound_drv->set_volume((int)(p_config->general_sound_level));
+ do_update_master_volume((int)(p_config->general_sound_level));
}
}
sound_ok = true;
nullptr,
0));
init_sound_device_list();
- emit sig_update_sound_output_list();
if(p_config != nullptr) {
- m_sound_driver->set_volume((int)(p_config->general_sound_level));
+ do_update_master_volume((int)(p_config->general_sound_level));
}
}
std::shared_ptr<SOUND_MODULE::OUTPUT::M_BASE>sound_drv = m_sound_driver;
set_osd(parent);
m_fileio.reset();
- if(m_channels.load() < 1) m_channels = 1;
+ if(m_channels.load() <= 1) m_channels = 2;
recalc_samples(m_rate.load(), m_latency_ms.load(), true, false);
bool _reinit = (deviceIO == nullptr) ? true : false;
if(latency_ms < 1) latency_ms = 1;
int64_t _samples =
((int64_t)rate * latency_ms) / 1000;
- size_t _chunk_bytes = (size_t)(_samples * m_wordsize.load());
+ size_t _chunk_bytes = (size_t)(_samples * m_wordsize.load() * m_channels.load());
int64_t _buffer_bytes = _chunk_bytes * 2;
bool _need_restart = false;
int64_t _result = -1;
qint64 _size = m_chunk_bytes.load();
if(samples > 0) {
- _size = (qint64)(samples * m_channels) * (qint64)m_wordsize;
+ _size = (qint64)samples * (qint64)(m_channels.load() * m_wordsize.load());
} else if(samples == 0) {
return _result;
}
_result = (int64_t)q->write((const char *)datasrc, _size);
}
if(_result > 0) {
- _result = _result / (qint64)(m_channels * m_wordsize);
+ _result = _result / (qint64)(m_channels.load() * m_wordsize.load());
}
return _result;
int _channels = m_channels.load();
int _rate = m_rate.load();
set_audio_format(tmp_output_device, tmp_output_format, _channels, _rate);
- if((_channels > 0) && (_rate > 0)) {
- m_channels = _channels;
- m_rate = _rate;
- } else {
+ if((_channels <= 0) || (_rate <= 0)) {
tmp_output_format = tmp_output_device.preferredFormat();
_channels = tmp_output_format.channelCount();
_rate = tmp_output_format.sampleRate();
m_config_ok = true;
}
m_samples = ((qint64)m_latency_ms.load() * (qint64)(m_rate.load())) / 1000;
- if(m_samples.load() <= 0) {
- m_samples = 4800;
+ if(m_samples.load() <= 100) {
+ m_samples = 100;
}
+ m_chunk_bytes = m_samples.load() * m_wordsize.load() * m_channels.load();
+ m_buffer_bytes = m_chunk_bytes.load() * 2;
update_driver_fileio();
__debug_log_func(_T("status=%s"), (m_config_ok) ? _T("OK") : _T("NG"));
memset(_ccp->sound_device_name, 0x00, sizeof(_ccp->sound_device_name));
my_tcscpy_s(_ccp->sound_device_name, (sizeof(_ccp->sound_device_name) / sizeof(_TCHAR)) - 1, _tmpname.toUtf8().constData());
}
-
+ m_channels = channels;
recalc_samples(rate, latency_ms, true, true);
std::lock_guard<std::recursive_timed_mutex> locker(m_locker);
int64_t _samples =
((int64_t)rate * latency_ms) / 1000;
- if(_samples < 100) _samples = 100;
+ if(_samples <= 100) _samples = 100;
if(m_fileio.get() != nullptr) {
std::lock_guard<std::recursive_timed_mutex> locker(m_locker);
if(m_fileio->isOpen()) {
m_latency_ms = latency_ms;
m_rate = rate;
m_channels = channels;
+ m_chunk_bytes = m_samples.load() * m_wordsize.load() * m_channels.load();
+ m_buffer_bytes = m_chunk_bytes.load() * 2;
}
}
__debug_log_func(_T("Result: rate=%d channels=%d latency=%dmSec reinit=%d"), m_rate.load(), m_channels.load(), m_latency_ms.load(), force_reinit);
channels = 2;
m_config_ok = false;
}
+ m_channels = channels;
if(recalc_samples(rate, latency_ms, true, false)) {
m_prev_started = m_mute = false;
}