repairs to AudioScriptingInterface playSound

This commit is contained in:
Stephen Birarda 2015-01-12 16:04:00 -08:00
parent 208af5cbca
commit 661221a189
5 changed files with 26 additions and 10 deletions

View file

@ -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();
}
}

View file

@ -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

View file

@ -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() {

View file

@ -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) :

View file

@ -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