mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
emit only when recording
This commit is contained in:
parent
d70a3685b8
commit
20d6615417
4 changed files with 21 additions and 10 deletions
|
@ -59,9 +59,7 @@ Audio::Audio() : _devices(_contextIsHMD) {
|
|||
}
|
||||
|
||||
void Audio::onOutputBufferReceived(const QByteArray outputBuffer) {
|
||||
if (_isRecording) {
|
||||
_audioFileWav.addRawAudioChunk((char*)outputBuffer.data(), outputBuffer.size());
|
||||
}
|
||||
_audioFileWav.addRawAudioChunk((char*)outputBuffer.data(), outputBuffer.size());
|
||||
}
|
||||
|
||||
bool Audio::startRecording(const QString& filepath) {
|
||||
|
@ -71,15 +69,21 @@ bool Audio::startRecording(const QString& filepath) {
|
|||
return false;
|
||||
}
|
||||
connect(client, &AudioClient::outputBufferReceived, this, &Audio::onOutputBufferReceived);
|
||||
_isRecording = true;
|
||||
client->setRecording(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Audio::getRecording() {
|
||||
auto client = DependencyManager::get<AudioClient>().data();
|
||||
return client->getRecording();
|
||||
}
|
||||
|
||||
void Audio::stopRecording() {
|
||||
auto client = DependencyManager::get<AudioClient>().data();
|
||||
disconnect(client, &AudioClient::outputBufferReceived, this, 0);
|
||||
if (_isRecording) {
|
||||
_isRecording = false;
|
||||
|
||||
if (client->getRecording()) {
|
||||
client->setRecording(false);
|
||||
_audioFileWav.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
Q_INVOKABLE bool startRecording(const QString& filename);
|
||||
Q_INVOKABLE void stopRecording();
|
||||
Q_INVOKABLE bool getRecording() { return _isRecording; };
|
||||
Q_INVOKABLE bool getRecording();
|
||||
|
||||
signals:
|
||||
void nop();
|
||||
|
@ -89,7 +89,6 @@ private:
|
|||
bool _isMuted { false };
|
||||
bool _enableNoiseReduction { true }; // Match default value of AudioClient::_isNoiseGateEnabled.
|
||||
bool _contextIsHMD { false };
|
||||
bool _isRecording { false };
|
||||
AudioDevices* getDevices() { return &_devices; }
|
||||
AudioDevices _devices;
|
||||
AudioFileWav _audioFileWav;
|
||||
|
|
|
@ -1909,8 +1909,11 @@ qint64 AudioClient::AudioOutputIODevice::readData(char * data, qint64 maxSize) {
|
|||
}
|
||||
|
||||
// send output buffer for recording
|
||||
QByteArray outputBuffer(reinterpret_cast<char*>(scratchBuffer), bytesWritten);
|
||||
emit _audio->outputBufferReceived(outputBuffer);
|
||||
if (_audio->_isRecording) {
|
||||
QByteArray outputBuffer(reinterpret_cast<char*>(scratchBuffer), bytesWritten);
|
||||
emit _audio->outputBufferReceived(outputBuffer);
|
||||
}
|
||||
|
||||
|
||||
int bytesAudioOutputUnplayed = _audio->_audioOutput->bufferSize() - _audio->_audioOutput->bytesFree();
|
||||
float msecsAudioOutputUnplayed = bytesAudioOutputUnplayed / (float)_audio->_outputFormat.bytesForDuration(USECS_PER_MSEC);
|
||||
|
|
|
@ -158,6 +158,9 @@ public:
|
|||
|
||||
bool getNamedAudioDeviceForModeExists(QAudio::Mode mode, const QString& deviceName);
|
||||
|
||||
void setRecording(bool isRecording) { _isRecording = isRecording; };
|
||||
bool getRecording() { return _isRecording; };
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static QString getWinDeviceName(wchar_t* guid);
|
||||
#endif
|
||||
|
@ -420,6 +423,8 @@ private:
|
|||
|
||||
QTimer* _checkDevicesTimer { nullptr };
|
||||
QTimer* _checkPeakValuesTimer { nullptr };
|
||||
|
||||
bool _isRecording { false };
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue