Merged in lindenlab/viewer-bear

meow-7.2.2
AndreyL ProductEngine 2016-04-23 02:45:44 +03:00
commit d424033bd4
8 changed files with 161 additions and 123 deletions

View File

@ -331,6 +331,7 @@ Cinder Roxley
STORM-2037
STORM-2053
STORM-2113
STORM-2127
Clara Young
Coaldust Numbers
VWR-1095

View File

@ -229,6 +229,15 @@ LLSD llcoro::postAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requ
return value;
}
LLSD llcoro::suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& pump, F32 timeoutin, const LLSD &timeoutResult)
{
LLEventTimeout timeoutPump(pump);
timeoutPump.eventAfter(timeoutin, timeoutResult);
return llcoro::suspendUntilEventOn(timeoutPump);
}
namespace
{

View File

@ -147,6 +147,8 @@ LLSD suspendUntilEventOn(const LLEventPumpOrPumpName& pump)
return postAndSuspend(LLSD(), LLEventPumpOrPumpName(), pump);
}
LLSD suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& pump, F32 timeoutin, const LLSD &timeoutResult);
} // namespace llcoro
/// return type for two-pump variant of suspendUntilEventOn()

View File

@ -39,9 +39,9 @@
#include "llsdutil.h" // llsd_matches()
LLEventFilter::LLEventFilter(LLEventPump& source, const std::string& name, bool tweak):
LLEventStream(name, tweak)
LLEventStream(name, tweak),
mSource(source.listen(getName(), boost::bind(&LLEventFilter::post, this, _1)))
{
source.listen(getName(), boost::bind(&LLEventFilter::post, this, _1));
}
LLEventMatching::LLEventMatching(const LLSD& pattern):

View File

@ -49,6 +49,9 @@ public:
/// Post an event to all listeners
virtual bool post(const LLSD& event) = 0;
private:
LLTempBoundListener mSource;
};
/**
@ -181,7 +184,7 @@ protected:
private:
bool tick(const LLSD&);
LLBoundListener mMainloop;
LLTempBoundListener mMainloop;
Action mAction;
};

View File

@ -25,13 +25,69 @@
*/
#import "llopenglview-objc.h"
#include "llwindowmacosx-objc.h"
#import "llwindowmacosx-objc.h"
#import "llappdelegate-objc.h"
#pragma mark local functions
NativeKeyEventData extractKeyDataFromKeyEvent(NSEvent* theEvent)
{
NativeKeyEventData eventData;
eventData.mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
eventData.mEventType = [theEvent type];
eventData.mEventModifiers = [theEvent modifierFlags];
eventData.mEventKeyCode = [theEvent keyCode];
NSString *strEventChars = [theEvent characters];
eventData.mEventChars = (strEventChars.length) ? [strEventChars characterAtIndex:0] : 0;
NSString *strEventUChars = [theEvent charactersIgnoringModifiers];
eventData.mEventUnmodChars = (strEventUChars.length) ? [strEventUChars characterAtIndex:0] : 0;
eventData.mEventRepeat = [theEvent isARepeat];
return eventData;
}
NativeKeyEventData extractKeyDataFromModifierEvent(NSEvent* theEvent)
{
NativeKeyEventData eventData;
eventData.mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
eventData.mEventType = [theEvent type];
eventData.mEventModifiers = [theEvent modifierFlags];
eventData.mEventKeyCode = [theEvent keyCode];
return eventData;
}
//---------------------------
attributedStringInfo getSegments(NSAttributedString *str)
{
attributedStringInfo segments;
segment_lengths seg_lengths;
segment_standouts seg_standouts;
NSRange effectiveRange;
NSRange limitRange = NSMakeRange(0, [str length]);
while (limitRange.length > 0) {
NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];
limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
if (effectiveRange.length <= 0)
{
effectiveRange.length = 1;
}
if ([attr integerValue] == 2)
{
seg_lengths.push_back(effectiveRange.length);
seg_standouts.push_back(true);
} else
{
seg_lengths.push_back(effectiveRange.length);
seg_standouts.push_back(false);
}
}
segments.seg_lengths = seg_lengths;
segments.seg_standouts = seg_standouts;
return segments;
}
#pragma mark class implementations
@implementation NSScreen (PointConversion)
@ -63,53 +119,6 @@
@end
void extractKeyDataFromEvent (NSEvent *theEvent, NativeKeyEventData * eventData)
{
eventData->mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
eventData->mEventType = [theEvent type];
eventData->mEventModifiers = [theEvent modifierFlags];
eventData->mEventKeyCode = [theEvent keyCode];
NSString *strEventChars = [theEvent characters];
eventData->mEventChars = (strEventChars.length) ? [strEventChars characterAtIndex:0] : 0;
NSString *strEventUChars = [theEvent charactersIgnoringModifiers];
eventData->mEventUnmodChars = (strEventUChars.length) ? [strEventUChars characterAtIndex:0] : 0;
eventData->mEventRepeat = [theEvent isARepeat];
}
attributedStringInfo getSegments(NSAttributedString *str)
{
attributedStringInfo segments;
segment_lengths seg_lengths;
segment_standouts seg_standouts;
NSRange effectiveRange;
NSRange limitRange = NSMakeRange(0, [str length]);
while (limitRange.length > 0) {
NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];
limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
if (effectiveRange.length <= 0)
{
effectiveRange.length = 1;
}
if ([attr integerValue] == 2)
{
seg_lengths.push_back(effectiveRange.length);
seg_standouts.push_back(true);
} else
{
seg_lengths.push_back(effectiveRange.length);
seg_standouts.push_back(false);
}
}
segments.seg_lengths = seg_lengths;
segments.seg_standouts = seg_standouts;
return segments;
}
@implementation LLOpenGLView
// Force a high quality update after live resizing
@ -426,18 +435,14 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) keyUp:(NSEvent *)theEvent
{
NativeKeyEventData eventData;
extractKeyDataFromEvent( theEvent, &eventData );
NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);
eventData.mKeyEvent = NativeKeyEventData::KEYUP;
callKeyUp(&eventData, [theEvent keyCode], [theEvent modifierFlags]);
}
- (void) keyDown:(NSEvent *)theEvent
{
NativeKeyEventData eventData;
extractKeyDataFromEvent( theEvent, &eventData );
NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
uint keycode = [theEvent keyCode];
@ -475,9 +480,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)flagsChanged:(NSEvent *)theEvent
{
NativeKeyEventData eventData;
extractKeyDataFromEvent( theEvent, &eventData );
NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent);
mModifiers = [theEvent modifierFlags];
callModifier([theEvent modifierFlags]);

View File

@ -55,13 +55,13 @@ struct NativeKeyEventData {
KEYCHAR
};
EventType mKeyEvent;
uint32_t mEventType;
uint32_t mEventModifiers;
uint32_t mEventKeyCode;
uint32_t mEventChars;
uint32_t mEventUnmodChars;
bool mEventRepeat;
EventType mKeyEvent = KEYUNKNOWN;
uint32_t mEventType = 0;
uint32_t mEventModifiers = 0;
uint32_t mEventKeyCode = 0;
uint32_t mEventChars = 0;
uint32_t mEventUnmodChars = 0;
bool mEventRepeat = false;
};
typedef const NativeKeyEventData * NSKeyEventRef;

View File

@ -80,39 +80,49 @@
extern LLMenuBarGL* gMenuBarView;
extern void handle_voice_morphing_subscribe();
const F32 VOLUME_SCALE_VIVOX = 0.01f;
namespace {
const F32 VOLUME_SCALE_VIVOX = 0.01f;
const F32 SPEAKING_TIMEOUT = 1.f;
const F32 SPEAKING_TIMEOUT = 1.f;
static const std::string VOICE_SERVER_TYPE = "Vivox";
static const std::string VOICE_SERVER_TYPE = "Vivox";
// Don't retry connecting to the daemon more frequently than this:
const F32 CONNECT_THROTTLE_SECONDS = 1.0f;
// Don't retry connecting to the daemon more frequently than this:
const F32 CONNECT_THROTTLE_SECONDS = 1.0f;
// Don't send positional updates more frequently than this:
const F32 UPDATE_THROTTLE_SECONDS = 0.5f;
// Don't send positional updates more frequently than this:
const F32 UPDATE_THROTTLE_SECONDS = 0.5f;
const F32 LOGIN_RETRY_SECONDS = 10.0f;
const int MAX_LOGIN_RETRIES = 12;
const F32 LOGIN_ATTEMPT_TIMEOUT = 5.0f;
const int LOGIN_RETRY_MAX = 5;
const F32 LOGIN_RETRY_TIMEOUT = 4.0f;
// Cosine of a "trivially" small angle
const F32 MINUSCULE_ANGLE_COS = 0.999f;
const int PROVISION_RETRY_MAX = 5;
const F32 PROVISION_RETRY_TIMEOUT = 2.0;
// Defines the maximum number of times(in a row) "stateJoiningSession" case for spatial channel is reached in stateMachine()
// which is treated as normal. The is the number of frames to wait for a channel join before giving up. This was changed
// from the original count of 50 for two reason. Modern PCs have higher frame rates and sometimes the SLVoice process
// backs up processing join requests. There is a log statement that records when channel joins take longer than 100 frames.
const int MAX_NORMAL_JOINING_SPATIAL_NUM = 1500;
// Cosine of a "trivially" small angle
const F32 MINUSCULE_ANGLE_COS = 0.999f;
// How often to check for expired voice fonts in seconds
const F32 VOICE_FONT_EXPIRY_INTERVAL = 10.f;
// Time of day at which Vivox expires voice font subscriptions.
// Used to replace the time portion of received expiry timestamps.
static const std::string VOICE_FONT_EXPIRY_TIME = "T05:00:00Z";
const F32 SESSION_JOIN_TIMEOUT = 10.0f;
// Maximum length of capture buffer recordings in seconds.
const F32 CAPTURE_BUFFER_MAX_TIME = 10.f;
// Defines the maximum number of times(in a row) "stateJoiningSession" case for spatial channel is reached in stateMachine()
// which is treated as normal. The is the number of frames to wait for a channel join before giving up. This was changed
// from the original count of 50 for two reason. Modern PCs have higher frame rates and sometimes the SLVoice process
// backs up processing join requests. There is a log statement that records when channel joins take longer than 100 frames.
const int MAX_NORMAL_JOINING_SPATIAL_NUM = 1500;
// How often to check for expired voice fonts in seconds
const F32 VOICE_FONT_EXPIRY_INTERVAL = 10.f;
// Time of day at which Vivox expires voice font subscriptions.
// Used to replace the time portion of received expiry timestamps.
static const std::string VOICE_FONT_EXPIRY_TIME = "T05:00:00Z";
// Maximum length of capture buffer recordings in seconds.
const F32 CAPTURE_BUFFER_MAX_TIME = 10.f;
const int ERROR_VIVOX_OBJECT_NOT_FOUND = 1001;
const int ERROR_VIVOX_NOT_LOGGED_IN = 1007;
}
static int scale_mic_volume(float volume)
{
@ -129,8 +139,6 @@ static int scale_speaker_volume(float volume)
}
const int ERROR_VIVOX_OBJECT_NOT_FOUND = 1001;
const int ERROR_VIVOX_NOT_LOGGED_IN = 1007;
///////////////////////////////////////////////////////////////////////////////////////////////
@ -546,7 +554,7 @@ void LLVivoxVoiceClient::voiceControlCoro()
// if we hit this and mRelogRequested is true, that indicates
// that we attempted to relog into Vivox and were rejected.
// Rather than just quit out of voice, we will tear it down (above)
// and then reconstruct the voice connecino from scratch.
// and then reconstruct the voice connecion from scratch.
if (mRelogRequested)
{
while (isGatewayRunning())
@ -784,13 +792,15 @@ bool LLVivoxVoiceClient::provisionVoiceAccount()
if (status == LLCore::HttpStatus(404))
{
if (++retryCount > 5)
if (++retryCount > PROVISION_RETRY_MAX)
{
LL_WARNS("Voice") << "Could not access voice provision cap after 5 attempts." << LL_ENDL;
LL_WARNS("Voice") << "Could not access voice provision cap after " << PROVISION_RETRY_MAX << " attempts." << LL_ENDL;
return false;
}
LL_WARNS("Voice") << "Provision CAP 404. Retrying in 1.0" << LL_ENDL;
llcoro::suspendUntilTimeout(1.0);
F32 timeout = pow(PROVISION_RETRY_TIMEOUT, static_cast<float>(retryCount));
LL_WARNS("Voice") << "Provision CAP 404. Retrying in " << timeout << " seconds." << LL_ENDL;
llcoro::suspendUntilTimeout(timeout);
continue;
}
@ -888,38 +898,43 @@ bool LLVivoxVoiceClient::breakVoiceConnection(bool corowait)
bool LLVivoxVoiceClient::loginToVivox()
{
int loginRetryCount(0);
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
LLSD timeoutResult;
timeoutResult["login"] = LLSD::String("timeout");
int loginRetryCount(0);
bool response_ok(false);
bool account_login(false);
bool send_login(true);
do
{
mIsLoggingIn = true;
if (send_login)
loginSendMessage();
send_login = false;
LLSD result = llcoro::suspendUntilEventOn(voicePump);
LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
if (result.has("login"))
{
std::string loginresp = result["login"];
if (loginresp == "retry")
if ((loginresp == "retry") || (loginresp == "timeout"))
{
if (!loginRetryCount)
if ((!loginRetryCount) && (loginresp != "timeout"))
{ // on first retry notify user
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LOGIN_RETRY);
}
if ((++loginRetryCount > MAX_LOGIN_RETRIES) || (!result["login_retry"]))
if ((++loginRetryCount > LOGIN_RETRY_MAX) || (loginresp == "timeout"))
{
LL_WARNS("Voice") << "too many login retries, giving up." << LL_ENDL;
LL_WARNS("Voice") << "too many login retries or timeout connecting, giving up." << LL_ENDL;
LLSD args;
std::stringstream errs;
errs << mVoiceAccountServerURI << "\n:UDP: 3478, 3479, 5060, 5062, 12000-17000";
@ -942,8 +957,10 @@ bool LLVivoxVoiceClient::loginToVivox()
account_login = false;
send_login = true;
LL_INFOS("Voice") << "will retry login in " << LOGIN_RETRY_SECONDS << " seconds." << LL_ENDL;
llcoro::suspendUntilTimeout(LOGIN_RETRY_SECONDS);
F32 timeout = pow(LOGIN_RETRY_TIMEOUT, static_cast<float>(loginRetryCount)) - 1.0f;
LL_INFOS("Voice") << "will retry login in " << timeout << " seconds." << LL_ENDL;
llcoro::suspendUntilTimeout(timeout);
}
else if (loginresp == "failed")
{
@ -982,7 +999,6 @@ bool LLVivoxVoiceClient::loginToVivox()
void LLVivoxVoiceClient::logoutOfVivox(bool wait)
{
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
if (!mIsLoggedIn)
return;
@ -995,7 +1011,11 @@ void LLVivoxVoiceClient::logoutOfVivox(bool wait)
if (wait)
{
LLSD result = llcoro::suspendUntilEventOn(voicePump);
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
LLSD timeoutResult;
timeoutResult["logout"] = LLSD::String("timeout");
LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
@ -1169,6 +1189,7 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
if (!mVoiceEnabled && mIsInitialized)
{
LL_DEBUGS("Voice") << "Voice no longer enabled. Exiting." << LL_ENDL;
mIsJoiningSession = false;
// User bailed out during connect -- jump straight to teardown.
terminateAudioSession(true);
@ -1177,6 +1198,7 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
}
else if (mSessionTerminateRequested)
{
LL_DEBUGS("Voice") << "Terminate requested" << LL_ENDL;
if (mAudioSession && !mAudioSession->mHandle.empty())
{
// Only allow direct exits from this state in p2p calls (for cancelling an invite).
@ -1194,15 +1216,18 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
bool added(true);
bool joined(false);
LLSD timeoutResult;
timeoutResult["session"] = LLSD::String("timeout");
// It appears that I need to wait for BOTH the SessionGroup.AddSession response and the SessionStateChangeEvent with state 4
// before continuing from this state. They can happen in either order, and if I don't wait for both, things can get stuck.
// For now, the SessionGroup.AddSession response handler sets mSessionHandle and the SessionStateChangeEvent handler transitions to stateSessionJoined.
// This is a cheap way to make sure both have happened before proceeding.
do
{
result = llcoro::suspendUntilEventOn(voicePump);
result = llcoro::suspendUntilEventOnWithTimeout(voicePump, SESSION_JOIN_TIMEOUT, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
LL_INFOS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
if (result.has("session"))
{
if (result.has("handle"))
@ -1215,14 +1240,15 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
}
std::string message = result["session"].asString();
if ((message == "added") || (message == "created"))
added = true;
else if (message == "joined")
joined = true;
else if ((message == "failed") || (message == "removed"))
else if ((message == "failed") || (message == "removed") || (message == "timeout"))
{ // we will get a removed message if a voice call is declined.
if (message == "failed")
if (message == "failed")
{
int reason = result["reason"].asInteger();
LL_WARNS("Voice") << "Add and join failed for reason " << reason << LL_ENDL;
@ -1230,7 +1256,7 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
if ((reason == ERROR_VIVOX_NOT_LOGGED_IN) ||
(reason == ERROR_VIVOX_OBJECT_NOT_FOUND))
{
LL_INFOS("Voice") << "Requesting reprovision and login." << LL_ENDL;
LL_DEBUGS("Voice") << "Requesting reprovision and login." << LL_ENDL;
requestRelog();
}
@ -1476,7 +1502,6 @@ bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session)
timeoutEvent["timeout"] = LLSD::Boolean(true);
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
LLEventTimeout timeout(voicePump);
mIsInChannel = true;
mMuteMicDirty = true;
@ -1528,8 +1553,7 @@ bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session)
sendLocalAudioUpdates();
mIsInitialized = true;
timeout.eventAfter(UPDATE_THROTTLE_SECONDS, timeoutEvent);
LLSD result = llcoro::suspendUntilEventOn(timeout);
LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, UPDATE_THROTTLE_SECONDS, timeoutEvent);
if (!result.has("timeout")) // logging the timeout event spams the log
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
if (result.has("session"))
@ -1633,16 +1657,14 @@ int LLVivoxVoiceClient::voiceRecordBuffer()
LL_INFOS("Voice") << "Recording voice buffer" << LL_ENDL;
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
LLEventTimeout timeout(voicePump);
timeout.eventAfter(CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LLSD result;
captureBufferRecordStartSendMessage();
notifyVoiceFontObservers();
do
{
result = llcoro::suspendUntilEventOn(voicePump);
result = llcoro::suspendUntilEventOnWithTimeout(voicePump, CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
} while (!result.has("recplay"));
@ -1666,8 +1688,6 @@ int LLVivoxVoiceClient::voicePlaybackBuffer()
LL_INFOS("Voice") << "Playing voice buffer" << LL_ENDL;
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
LLEventTimeout timeout(voicePump);
timeout.eventAfter(CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LLSD result;
do
@ -1682,7 +1702,7 @@ int LLVivoxVoiceClient::voicePlaybackBuffer()
// Update UI, should really use a separate callback.
notifyVoiceFontObservers();
result = llcoro::suspendUntilEventOn(voicePump);
result = llcoro::suspendUntilEventOnWithTimeout(voicePump, CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
} while (!result.has("recplay"));