mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 21:32:31 +02:00
repairs to AudioScriptingInterface playSound
This commit is contained in:
parent
208af5cbca
commit
661221a189
5 changed files with 26 additions and 10 deletions
|
@ -138,8 +138,10 @@ function drawLobby() {
|
|||
// add an attachment on this avatar so other people see them in the lobby
|
||||
MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15);
|
||||
|
||||
// start the drone sound
|
||||
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||
if (droneSound.downloaded) {
|
||||
// start the drone sound
|
||||
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||
}
|
||||
|
||||
// start one of our muzak sounds
|
||||
playRandomMuzak();
|
||||
|
@ -353,7 +355,7 @@ function update(deltaTime) {
|
|||
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
||||
|
||||
// if the reticle is up then we may need to play the next muzak
|
||||
if (!Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
if (currentMuzakInjector && !Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
playNextMuzak();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -880,7 +880,7 @@ bool Audio::outputLocalInjector(bool isStereo, qreal volume, AudioInjector* inje
|
|||
localFormat.setChannelCount(isStereo ? 2 : 1);
|
||||
|
||||
QAudioOutput* localOutput = new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName),
|
||||
localFormat, this);
|
||||
localFormat);
|
||||
localOutput->setVolume(volume);
|
||||
|
||||
// move the localOutput to the same thread as the local injector buffer
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
void registerAudioMetaTypes(QScriptEngine* engine) {
|
||||
qScriptRegisterMetaType(engine, injectorOptionsToScriptValue, injectorOptionsFromScriptValue);
|
||||
qScriptRegisterMetaType(engine, soundToScriptValue, soundFromScriptValue);
|
||||
qScriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue);
|
||||
qScriptRegisterMetaType(engine, soundPointerToScriptValue, soundPointerFromScriptValue);
|
||||
}
|
||||
|
||||
AudioScriptingInterface& AudioScriptingInterface::getInstance() {
|
||||
|
|
|
@ -29,13 +29,22 @@
|
|||
#include "AudioEditBuffer.h"
|
||||
#include "Sound.h"
|
||||
|
||||
QScriptValue soundToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in) {
|
||||
static int soundMetaTypeId = qRegisterMetaType<Sound*>();
|
||||
|
||||
QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in) {
|
||||
return engine->newQObject(in.data());
|
||||
}
|
||||
|
||||
void soundFromScriptValue(const QScriptValue &object, SharedSoundPointer &out) {
|
||||
void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out) {
|
||||
out = SharedSoundPointer(qobject_cast<Sound*>(object.toQObject()));
|
||||
qDebug() << "Sound from script value" << out.data();
|
||||
}
|
||||
|
||||
QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in) {
|
||||
return engine->newQObject(in);
|
||||
}
|
||||
|
||||
void soundPointerFromScriptValue(const QScriptValue &object, Sound* &out) {
|
||||
out = qobject_cast<Sound*>(object.toQObject());
|
||||
}
|
||||
|
||||
Sound::Sound(const QUrl& url, bool isStereo) :
|
||||
|
|
|
@ -45,8 +45,12 @@ private:
|
|||
typedef QSharedPointer<Sound> SharedSoundPointer;
|
||||
|
||||
Q_DECLARE_METATYPE(SharedSoundPointer)
|
||||
QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in);
|
||||
void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out);
|
||||
|
||||
Q_DECLARE_METATYPE(Sound*)
|
||||
QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in);
|
||||
void soundPointerFromScriptValue(const QScriptValue& object, Sound* &out);
|
||||
|
||||
QScriptValue soundToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in);
|
||||
void soundFromScriptValue(const QScriptValue& object, SharedSoundPointer& out);
|
||||
|
||||
#endif // hifi_Sound_h
|
||||
|
|
Loading…
Reference in a new issue