mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 19:57:11 +02:00
provide old ASI APIs in AudioInjector
This commit is contained in:
parent
7b485829c4
commit
0498c5c708
2 changed files with 35 additions and 40 deletions
|
@ -34,35 +34,20 @@ void injectorFromScriptValue(const QScriptValue& object, AudioInjector*& out) {
|
|||
}
|
||||
|
||||
AudioInjector::AudioInjector(QObject* parent) :
|
||||
QObject(parent),
|
||||
_options(),
|
||||
_shouldStop(false),
|
||||
_loudness(0.0f),
|
||||
_isFinished(false),
|
||||
_currentSendPosition(0),
|
||||
_localBuffer(NULL)
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AudioInjector::AudioInjector(Sound* sound, const AudioInjectorOptions& injectorOptions) :
|
||||
_audioData(sound->getByteArray()),
|
||||
_options(injectorOptions),
|
||||
_shouldStop(false),
|
||||
_loudness(0.0f),
|
||||
_isFinished(false),
|
||||
_currentSendPosition(0),
|
||||
_localBuffer(NULL)
|
||||
_options(injectorOptions)
|
||||
{
|
||||
}
|
||||
|
||||
AudioInjector::AudioInjector(const QByteArray& audioData, const AudioInjectorOptions& injectorOptions) :
|
||||
_audioData(audioData),
|
||||
_options(injectorOptions),
|
||||
_shouldStop(false),
|
||||
_loudness(0.0f),
|
||||
_isFinished(false),
|
||||
_currentSendPosition(0),
|
||||
_localBuffer(NULL)
|
||||
_options(injectorOptions)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -83,6 +68,7 @@ float AudioInjector::getLoudness() {
|
|||
|
||||
void AudioInjector::injectAudio() {
|
||||
|
||||
if (!_isStarted) {
|
||||
// check if we need to offset the sound by some number of seconds
|
||||
if (_options.secondOffset > 0.0f) {
|
||||
|
||||
|
@ -98,6 +84,9 @@ void AudioInjector::injectAudio() {
|
|||
} else {
|
||||
injectToMixer();
|
||||
}
|
||||
} else {
|
||||
qDebug() << "AudioInjector::injectAudio called but already started.";
|
||||
}
|
||||
}
|
||||
|
||||
void AudioInjector::injectLocally() {
|
||||
|
|
|
@ -43,25 +43,31 @@ public:
|
|||
public slots:
|
||||
void injectAudio();
|
||||
void stop();
|
||||
void stopAndDeleteLater();
|
||||
void setOptions(AudioInjectorOptions& options);
|
||||
void setCurrentSendPosition(int currentSendPosition) { _currentSendPosition = currentSendPosition; }
|
||||
float getLoudness();
|
||||
float getLoudness() const;
|
||||
bool isPlaying() const { return !_isFinished; }
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
|
||||
private slots:
|
||||
void stopAndDeleteLater();
|
||||
private:
|
||||
void injectToMixer();
|
||||
void injectLocally();
|
||||
|
||||
QByteArray _audioData;
|
||||
AudioInjectorOptions _options;
|
||||
bool _shouldStop;
|
||||
float _loudness;
|
||||
bool _isFinished;
|
||||
int _currentSendPosition;
|
||||
AbstractAudioInterface* _localAudioInterface;
|
||||
AudioInjectorLocalBuffer* _localBuffer;
|
||||
bool _shouldStop = false;
|
||||
float _loudness = 0.0f;
|
||||
bool _isStarted = false;
|
||||
bool _isFinished = false;
|
||||
int _currentSendPosition = 0;
|
||||
AbstractAudioInterface* _localAudioInterface = NULL;
|
||||
AudioInjectorLocalBuffer* _localBuffer = NULL;
|
||||
|
||||
friend QScriptValue injectorToScriptValue(QScriptEngine* engine, AudioInjector* const& in);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AudioInjector*)
|
||||
|
|
Loading…
Reference in a new issue