Merge branch 'master' of https://github.com/highfidelity/hifi into addCodecNameToStream

This commit is contained in:
Brad Hefta-Gaub 2016-07-18 22:43:16 -07:00
commit dbf60a594c
13 changed files with 102 additions and 93 deletions

View file

@ -1,19 +1,31 @@
include(ExternalProject)
include(SelectLibraryConfigurations)
set(EXTERNAL_NAME HiFiAudioCodec)
set(EXTERNAL_NAME hifiAudioCodec)
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
ExternalProject_Add(
${EXTERNAL_NAME}
URL https://s3.amazonaws.com/hifi-public/dependencies/codecSDK-1.zip
URL_MD5 23ec3fe51eaa155ea159a4971856fc13
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
)
if (WIN32 OR APPLE)
ExternalProject_Add(
${EXTERNAL_NAME}
URL http://s3.amazonaws.com/hifi-public/dependencies/codecSDK-1.zip
URL_MD5 23ec3fe51eaa155ea159a4971856fc13
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
)
elseif(NOT ANDROID)
ExternalProject_Add(
${EXTERNAL_NAME}
URL http://s3.amazonaws.com/hifi-public/dependencies/codecSDK-linux.zip
URL_MD5 7d37914a18aa4de971d2f45dd3043bde
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
)
endif()
# Hide this external target (for ide users)
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
@ -23,11 +35,9 @@ ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE TYPE INTERNAL)
if (WIN32)
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/Release/audio.lib CACHE TYPE INTERNAL)
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/Release/audio.lib CACHE TYPE INTERNAL)
elseif(APPLE)
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/Release/libaudio.a CACHE TYPE INTERNAL)
elseif(NOT ANDROID)
# FIXME need to account for different architectures
#set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/linux64/audio.so CACHE TYPE INTERNAL)
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/Release/libaudio.a CACHE TYPE INTERNAL)
endif()

View file

@ -43,4 +43,4 @@ macro(ADD_DEPENDENCY_EXTERNAL_PROJECTS)
endforeach()
endmacro()
endmacro()

View file

@ -37,7 +37,7 @@ macro(SETUP_HIFI_CLIENT_SERVER_PLUGIN)
${CLIENT_PLUGIN_FULL_PATH}
)
# copy the client plugin binaries
add_custom_command(TARGET ${DIR} POST_BUILD
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${TARGET_NAME}>"
${CLIENT_PLUGIN_FULL_PATH}
@ -50,7 +50,7 @@ macro(SETUP_HIFI_CLIENT_SERVER_PLUGIN)
${SERVER_PLUGIN_FULL_PATH}
)
# copy the server plugin binaries
add_custom_command(TARGET ${DIR} POST_BUILD
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${TARGET_NAME}>"
${SERVER_PLUGIN_FULL_PATH}

View file

@ -207,8 +207,10 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
}
withWriteLock([&]{
if (_previousSet) {
if (_previousSet &&
_positionalTarget != _previousPositionalTarget) { // don't average in a zero velocity if we get the same data
glm::vec3 oneFrameVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
if (_measuredLinearVelocitiesIndex >= AvatarActionHold::velocitySmoothFrames) {
_measuredLinearVelocitiesIndex = 0;
@ -228,9 +230,9 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
// 3 -- ignore i of 0 1 2
// 4 -- ignore i of 1 2 3
// 5 -- ignore i of 2 3 4
if ((i + 1) % 6 == _measuredLinearVelocitiesIndex ||
(i + 2) % 6 == _measuredLinearVelocitiesIndex ||
(i + 3) % 6 == _measuredLinearVelocitiesIndex) {
if ((i + 1) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex ||
(i + 2) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex ||
(i + 3) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex) {
continue;
}
measuredLinearVelocity += _measuredLinearVelocities[i];

View file

@ -165,14 +165,10 @@ void AudioInjector::restart() {
if (!_options.localOnly) {
if (!injectorManager->restartFinishedInjector(this)) {
// TODO: this logic seems to remove the pending delete,
// which makes me wonder about the deleteLater calls
_state = AudioInjectorState::Finished; // we're not playing, so reset the state used by isPlaying.
}
}
} else {
// TODO: this logic seems to remove the pending delete,
// which makes me wonder about the deleteLater calls
_state = AudioInjectorState::Finished; // we failed to play, so we are finished again
}
}

View file

@ -34,11 +34,11 @@ class AudioInjectorManager;
enum class AudioInjectorState : uint8_t {
NotFinished = 1,
Finished = 2,
PendingDelete = 4,
LocalInjectionFinished = 8,
NetworkInjectionFinished = 16
NotFinished = 0,
Finished = 1,
PendingDelete = 2,
LocalInjectionFinished = 4,
NetworkInjectionFinished = 8
};
AudioInjectorState operator& (AudioInjectorState lhs, AudioInjectorState rhs);
@ -50,12 +50,6 @@ class AudioInjector : public QObject {
Q_OBJECT
public:
static const uint8_t NotFinished = 1;
static const uint8_t Finished = 2;
static const uint8_t PendingDelete = 4;
static const uint8_t LocalInjectionFinished = 8;
static const uint8_t NetworkInjectionFinished = 16;
AudioInjector(QObject* parent);
AudioInjector(const Sound& sound, const AudioInjectorOptions& injectorOptions);
AudioInjector(const QByteArray& audioData, const AudioInjectorOptions& injectorOptions);
@ -90,7 +84,7 @@ public slots:
void setOptions(const AudioInjectorOptions& options);
float getLoudness() const { return _loudness; }
bool isPlaying() const { return stateHas(AudioInjectorState::NotFinished); }
bool isPlaying() const { return !stateHas(AudioInjectorState::Finished); }
void finish();
void finishLocalInjection();
void finishNetworkInjection();

View file

@ -36,7 +36,15 @@ OffscreenGLCanvas::~OffscreenGLCanvas() {
delete _logger;
_logger = nullptr;
}
_context->doneCurrent();
delete _context;
_context = nullptr;
_offscreenSurface->destroy();
delete _offscreenSurface;
_offscreenSurface = nullptr;
}
bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {

View file

@ -34,8 +34,8 @@ public:
protected:
std::once_flag _reportOnce;
QOpenGLContext* _context;
QOffscreenSurface* _offscreenSurface;
QOpenGLContext* _context{ nullptr };
QOffscreenSurface* _offscreenSurface{ nullptr };
QOpenGLDebugLogger* _logger{ nullptr };
};

View file

@ -28,16 +28,17 @@ QOpenGLContext* QOpenGLContextWrapper::currentContext() {
return QOpenGLContext::currentContext();
}
QOpenGLContextWrapper::QOpenGLContextWrapper() :
_context(new QOpenGLContext)
{
}
_ownContext(true), _context(new QOpenGLContext) { }
QOpenGLContextWrapper::QOpenGLContextWrapper(QOpenGLContext* context) :
_context(context)
{
_context(context) { }
QOpenGLContextWrapper::~QOpenGLContextWrapper() {
if (_ownContext) {
delete _context;
_context = nullptr;
}
}
void QOpenGLContextWrapper::setFormat(const QSurfaceFormat& format) {

View file

@ -23,6 +23,7 @@ class QOpenGLContextWrapper {
public:
QOpenGLContextWrapper();
QOpenGLContextWrapper(QOpenGLContext* context);
virtual ~QOpenGLContextWrapper();
void setFormat(const QSurfaceFormat& format);
bool create();
void swapBuffers(QSurface* surface);
@ -40,6 +41,7 @@ public:
private:
bool _ownContext { false };
QOpenGLContext* _context { nullptr };
};

View file

@ -187,7 +187,11 @@ GLTexture::~GLTexture() {
}
}
Backend::decrementTextureGPUCount();
if (_id) {
glDeleteTextures(1, &_id);
const_cast<GLuint&>(_id) = 0;
Backend::decrementTextureGPUCount();
}
Backend::updateTextureGPUMemoryUsage(_size, 0);
Backend::updateTextureGPUVirtualMemoryUsage(_virtualSize, 0);
}

View file

@ -6,15 +6,11 @@
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
#
if (WIN32 OR APPLE)
set(TARGET_NAME hifiCodec)
setup_hifi_client_server_plugin()
link_hifi_libraries(audio shared plugins)
add_dependency_external_projects(HiFiAudioCodec)
target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAUDIOCODEC_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${HIFIAUDIOCODEC_LIBRARIES})
install_beside_console()
endif()
set(TARGET_NAME hifiCodec)
setup_hifi_client_server_plugin()
link_hifi_libraries(audio shared plugins)
add_dependency_external_projects(hifiAudioCodec)
target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAUDIOCODEC_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${HIFIAUDIOCODEC_LIBRARIES})
install_beside_console()

View file

@ -202,8 +202,7 @@ CONTROLLER_STATE_MACHINE[STATE_NEAR_GRABBING] = {
CONTROLLER_STATE_MACHINE[STATE_HOLD] = {
name: "hold",
enterMethod: "nearGrabbingEnter",
updateMethod: "nearGrabbing",
exitMethod: "holdExit"
updateMethod: "nearGrabbing"
};
CONTROLLER_STATE_MACHINE[STATE_NEAR_TRIGGER] = {
name: "trigger",
@ -228,7 +227,7 @@ function colorPow(color, power) {
return {
red: Math.pow(color.red / 255.0, power) * 255,
green: Math.pow(color.green / 255.0, power) * 255,
blue: Math.pow(color.blue / 255.0, power) * 255,
blue: Math.pow(color.blue / 255.0, power) * 255
};
}
@ -271,14 +270,12 @@ function propsArePhysical(props) {
return isPhysical;
}
// currently disabled.
var USE_ATTACH_POINT_SETTINGS = false;
var USE_ATTACH_POINT_SETTINGS = true;
var ATTACH_POINT_SETTINGS = "io.highfidelity.attachPoints";
function getAttachPointSettings() {
try {
var str = Settings.getValue(ATTACH_POINT_SETTINGS);
print("getAttachPointSettings = " + str);
if (str === "false") {
return {};
} else {
@ -291,7 +288,6 @@ function getAttachPointSettings() {
}
function setAttachPointSettings(attachPointSettings) {
var str = JSON.stringify(attachPointSettings);
print("setAttachPointSettings = " + str);
Settings.setValue(ATTACH_POINT_SETTINGS, str);
}
function getAttachPointForHotspotFromSettings(hotspot, hand) {
@ -765,9 +761,8 @@ function MyController(hand) {
}
};
var SEARCH_SPHERE_ALPHA = 0.5;
this.searchSphereOn = function (location, size, color) {
var rotation = Quat.lookAt(location, Camera.getPosition(), Vec3.UP);
var brightColor = colorPow(color, 0.06);
if (this.searchSphere === null) {
@ -790,7 +785,7 @@ function MyController(hand) {
position: location,
rotation: rotation,
innerColor: brightColor,
outerColor: color,
outerColor: color,
innerAlpha: 1.0,
outerAlpha: 0.0,
outerRadius: size * 1.2,
@ -1961,12 +1956,12 @@ function MyController(hand) {
this.currentObjectRotation = grabbedProperties.rotation;
this.currentVelocity = ZERO_VEC;
this.currentAngularVelocity = ZERO_VEC;
this.prevDropDetected = false;
};
this.nearGrabbing = function (deltaTime, timestamp) {
var dropDetected = this.dropGestureProcess(deltaTime);
if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) {
this.callEntityMethodOnGrabbed("releaseGrab");
this.setState(STATE_OFF, "trigger released");
@ -1975,6 +1970,16 @@ function MyController(hand) {
if (this.state == STATE_HOLD) {
var dropDetected = this.dropGestureProcess(deltaTime);
if (this.triggerSmoothedReleased()) {
this.waitForTriggerRelease = false;
}
if (dropDetected && this.prevDropDetected != dropDetected) {
this.waitForTriggerRelease = true;
}
// highlight the grabbed hotspot when the dropGesture is detected.
if (dropDetected) {
entityPropertiesCache.addEntity(this.grabbedHotspot.entityID);
@ -1982,17 +1987,24 @@ function MyController(hand) {
equipHotspotBuddy.highlightHotspot(this.grabbedHotspot);
}
if (dropDetected && this.triggerSmoothedGrab()) {
if (dropDetected && !this.waitForTriggerRelease && this.triggerSmoothedGrab()) {
this.callEntityMethodOnGrabbed("releaseEquip");
this.setState(STATE_OFF, "drop gesture detected");
return;
}
if (this.thumbPressed()) {
this.callEntityMethodOnGrabbed("releaseEquip");
this.setState(STATE_OFF, "drop via thumb press");
// store the offset attach points into preferences.
if (USE_ATTACH_POINT_SETTINGS && this.grabbedHotspot && this.grabbedEntity) {
var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "localRotation"]);
if (props && props.localPosition && props.localRotation) {
storeAttachPointForHotspotInSettings(this.grabbedHotspot, this.hand, props.localPosition, props.localRotation);
}
}
var grabbedEntity = this.grabbedEntity;
this.release();
this.grabbedEntity = grabbedEntity;
this.setState(STATE_NEAR_GRABBING, "drop gesture detected");
return;
}
this.prevDropDetected = dropDetected;
}
this.heartBeat(this.grabbedEntity);
@ -2088,22 +2100,6 @@ function MyController(hand) {
}
};
this.holdExit = function () {
// store the offset attach points into preferences.
if (USE_ATTACH_POINT_SETTINGS && this.grabbedHotspot && this.grabbedEntity) {
entityPropertiesCache.addEntity(this.grabbedEntity);
var props = entityPropertiesCache.getProps(this.grabbedEntity);
var entityXform = new Xform(props.rotation, props.position);
var avatarXform = new Xform(MyAvatar.orientation, MyAvatar.position);
var handRot = (this.hand === RIGHT_HAND) ? MyAvatar.getRightPalmRotation() : MyAvatar.getLeftPalmRotation();
var avatarHandPos = (this.hand === RIGHT_HAND) ? MyAvatar.rightHandPosition : MyAvatar.leftHandPosition;
var palmXform = new Xform(handRot, avatarXform.xformPoint(avatarHandPos));
var offsetXform = Xform.mul(palmXform.inv(), entityXform);
storeAttachPointForHotspotInSettings(this.grabbedHotspot, this.hand, offsetXform.pos, offsetXform.rot);
}
};
this.nearTriggerEnter = function () {
this.clearEquipHaptics();