expose audio mixer threads to gui

This commit is contained in:
Zach Pomerantz 2016-11-28 18:40:11 -05:00
parent 7a440def87
commit b4638105e3
3 changed files with 38 additions and 3 deletions

View file

@ -41,6 +41,7 @@ static const float DEFAULT_NOISE_MUTING_THRESHOLD = 0.003f;
static const QString AUDIO_MIXER_LOGGING_TARGET_NAME = "audio-mixer";
static const QString AUDIO_ENV_GROUP_KEY = "audio_env";
static const QString AUDIO_BUFFER_GROUP_KEY = "audio_buffer";
static const QString AUDIO_THREADING_GROUP_KEY = "audio_threading";
int AudioMixer::_numStaticJitterFrames{ -1 };
float AudioMixer::_noiseMutingThreshold{ DEFAULT_NOISE_MUTING_THRESHOLD };
@ -368,11 +369,11 @@ void AudioMixer::start() {
});
// mix across slave threads
slavePool.mix(nodes, frame);
_slavePool.mix(nodes, frame);
}
// gather stats
slavePool.each([&](AudioMixerSlave& slave) {
_slavePool.each([&](AudioMixerSlave& slave) {
_stats.accumulate(slave.stats);
slave.stats.reset();
});
@ -469,6 +470,17 @@ int AudioMixer::prepareFrame(const SharedNodePointer& node, unsigned int frame)
}
void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) {
if (settingsObject.contains(AUDIO_THREADING_GROUP_KEY)) {
QJsonObject audioThreadingGroupObject = settingsObject[AUDIO_THREADING_GROUP_KEY].toObject();
const QString AUTO_THREADS = "auto_threads";
bool autoThreads = audioThreadingGroupObject[AUTO_THREADS].toBool();
if (!autoThreads) {
const QString NUM_THREADS = "num_threads";
int numThreads = audioThreadingGroupObject[NUM_THREADS].toInt();
_slavePool.setNumThreads(numThreads);
}
}
if (settingsObject.contains(AUDIO_BUFFER_GROUP_KEY)) {
QJsonObject audioBufferGroupObject = settingsObject[AUDIO_BUFFER_GROUP_KEY].toObject();

View file

@ -88,7 +88,7 @@ private:
QString _codecPreferenceOrder;
AudioMixerSlavePool slavePool;
AudioMixerSlavePool _slavePool;
static int _numStaticJitterFrames; // -1 denotes dynamic jitter buffering
static float _noiseMutingThreshold;

View file

@ -978,6 +978,29 @@
}
]
},
{
"name": "audio_threading",
"label": "Audio Threading",
"assignment-types": [0],
"settings": [
{
"name": "auto_threads",
"label": "Automatically determine thread count",
"type": "checkbox",
"help": "Allow system to determine number of threads (recommended)",
"default": true,
"advanced": true
},
{
"name": "num_threads",
"label": "Number of Threads",
"help": "Threads to spin up for audio mixing (if not automatically set)",
"placeholder": "1",
"default": "1",
"advanced": true
}
]
},
{
"name": "audio_env",
"label": "Audio Environment",