From 69ccf0d4e56f073f20a3ae6c70ee1051293138ce Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Apr 2015 21:51:54 -0500 Subject: [PATCH] * VRFS-3118 - refresh latency by start/stopping audio system --- .../dialog/singlePlayerProfileGuard.js.coffee | 26 ++++++++++++++++++- .../javascripts/scheduled_session.js.erb | 6 ----- .../assets/javascripts/wizard/gear_utils.js | 6 +++++ .../dialogs/singlePlayerProfileGuard.css.scss | 9 +++++++ .../_singlePlayerProfileGuard.html.slim | 4 +++ 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/web/app/assets/javascripts/dialog/singlePlayerProfileGuard.js.coffee b/web/app/assets/javascripts/dialog/singlePlayerProfileGuard.js.coffee index 4c54d1a06..4f9375b7e 100644 --- a/web/app/assets/javascripts/dialog/singlePlayerProfileGuard.js.coffee +++ b/web/app/assets/javascripts/dialog/singlePlayerProfileGuard.js.coffee @@ -24,15 +24,34 @@ context.JK.SinglePlayerProfileGuardDialog = class SinglePlayerProfileGuardDialog @audioLatency = @dialog.find('.audio-latency') @btnPrivateSession = @dialog.find('.btn-private-session') @btnGearSetup = @dialog.find('.btn-gear-setup') + @btnRescan = @dialog.find('.btn-rescan') + @rescanningNotice = @dialog.find('.rescanning-notice') @btnPrivateSession.on('click', @onPrivateSessionChoice) @btnGearSetup.on('click', @onGearSetupChoice) + @btnRescan.on('click', @onRescan) beforeShow:() => @dialog.data('result', { choice: null}) - afterShow:() => + onRescan: () => + @gearUtils.scheduleAudioRestart('single-player-guard', 1000, @beforeScan, @afterScan) + + beforeScan: () => + @dialog.find('.action-buttons a').addClass('disabled') + @rescanningNotice.show(); + + afterScan: (canceled) => + @dialog.find('.action-buttons a').removeClass('disabled') + @rescanningNotice.hide(); + + if !canceled + result = context.jamClient.ReloadAudioSystem(true, true, true); + + @refresh(); + + refresh:() => canPlayWithOthers = @gearUtils.canPlayWithOthers() if canPlayWithOthers.isNoInputProfile @@ -46,6 +65,11 @@ context.JK.SinglePlayerProfileGuardDialog = class SinglePlayerProfileGuardDialog @audioLatency.text("#{latency} milliseconds.") + afterShow:() => + @refresh() + + + onPrivateSessionChoice: () => @dialog.data('result', { choice: 'private_session'}) @app.layout.closeDialog(@dialogId) diff --git a/web/app/assets/javascripts/scheduled_session.js.erb b/web/app/assets/javascripts/scheduled_session.js.erb index f2c07b7bc..707d63554 100644 --- a/web/app/assets/javascripts/scheduled_session.js.erb +++ b/web/app/assets/javascripts/scheduled_session.js.erb @@ -937,12 +937,6 @@ } } - if(optionRequiresMultiplayerProfile()) { - if(context.JK.guardAgainstSinglePlayerProfile(app).canPlay == false) { - return false; - } - } - var valid = beforeMoveStep(); if (!valid) { return false; diff --git a/web/app/assets/javascripts/wizard/gear_utils.js b/web/app/assets/javascripts/wizard/gear_utils.js index f69f2411f..2a326ee86 100644 --- a/web/app/assets/javascripts/wizard/gear_utils.js +++ b/web/app/assets/javascripts/wizard/gear_utils.js @@ -34,6 +34,12 @@ // as well have a score below 20 ms gearUtils.canPlayWithOthers = function(profile) { + if(!context.jamClient.IsAudioStarted()) { + context.jamClient.ReloadAudioSystem(true, true, true); + context.jamClient.StopAudio(); + } + + var isNoInputProfile = gearUtils.isNoInputProfile(profile); var expectedLatency = context.jamClient.FTUEGetExpectedLatency(); var audioLatency = expectedLatency ? expectedLatency.latency : null; diff --git a/web/app/assets/stylesheets/dialogs/singlePlayerProfileGuard.css.scss b/web/app/assets/stylesheets/dialogs/singlePlayerProfileGuard.css.scss index 89eedac9a..92e5f451d 100644 --- a/web/app/assets/stylesheets/dialogs/singlePlayerProfileGuard.css.scss +++ b/web/app/assets/stylesheets/dialogs/singlePlayerProfileGuard.css.scss @@ -26,4 +26,13 @@ p { line-height:125%; } + + .rescanning-notice { + display:none; + + span.spinner-small { + display:inline-block; + vertical-align: middle; + } + } } \ No newline at end of file diff --git a/web/app/views/dialogs/_singlePlayerProfileGuard.html.slim b/web/app/views/dialogs/_singlePlayerProfileGuard.html.slim index d7c1628d3..13c8a8945 100644 --- a/web/app/views/dialogs/_singlePlayerProfileGuard.html.slim +++ b/web/app/views/dialogs/_singlePlayerProfileGuard.html.slim @@ -17,6 +17,10 @@ br | With this profile, you can't play with others in real-time. However, you can play with JamTracks and backing tracks by yourself in a private session, or go to the gear setup wizard and add a new audio profile that uses your gear. .right.action-buttons + span.rescanning-notice + span.spinner-small + | Rescanning... a.button-grey.btn-cancel href='#' layout-action="cancel" CANCEL + a.button-grey.btn-rescan.hidden href='#' RESCAN a.button-grey.btn-gear-setup href="/client#/account/audio" GO TO GEAR SETUP a.button-orange.btn-private-session href="#" PRIVATE SESSION \ No newline at end of file