Skip to content

Commit 7acffca

Browse files
authored
Merge pull request #824 from ann0see/win_installer
Win installer: Add ASIO detection
2 parents 3d8a213 + f865124 commit 7acffca

2 files changed

Lines changed: 91 additions & 2 deletions

File tree

windows/deploy_windows.ps1

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ Function Get-RedirectedUrl {
6666
}
6767
}
6868

69+
function Load-Module ($m) { # see https://stackoverflow.com/a/51692402
70+
71+
# If module is imported say that and do nothing
72+
if (Get-Module | Where-Object {$_.Name -eq $m}) {
73+
write-host "Module $m is already imported."
74+
}
75+
else {
76+
77+
# If module is not imported, but available on disk then import
78+
if (Get-Module -ListAvailable | Where-Object {$_.Name -eq $m}) {
79+
Import-Module $m
80+
}
81+
else {
82+
83+
# If module is not imported, not available on disk, but is in online gallery then install and import
84+
if (Find-Module -Name $m | Where-Object {$_.Name -eq $m}) {
85+
Install-Module -Name $m -Force -Verbose -Scope CurrentUser
86+
Import-Module $m
87+
}
88+
else {
89+
90+
# If module is not imported, not available and not in online gallery then abort
91+
write-host "Module $m not imported, not available and not in online gallery, exiting."
92+
EXIT 1
93+
}
94+
}
95+
}
96+
}
6997

7098
# Download and uncompress dependency in ZIP format
7199
Function Install-Dependency
@@ -100,8 +128,10 @@ Function Install-Dependency
100128
# Install VSSetup (Visual Studio detection), ASIO SDK and NSIS Installer
101129
Function Install-Dependencies
102130
{
103-
Install-PackageProvider -Name "Nuget" -Scope CurrentUser -Force
104-
Install-Module -Name "VSSetup" -Scope CurrentUser -Force
131+
if (-not (Get-PackageProvider -Name nuget).Name -eq "nuget") {
132+
Install-PackageProvider -Name "Nuget" -Scope CurrentUser -Force
133+
}
134+
Load-Module -m "VSSetup"
105135
Install-Dependency -Uri $AsioSDKUrl `
106136
-Name $AsioSDKName -Destination "ASIOSDK2"
107137
Install-Dependency -Uri $NsisUrl `

windows/installer.nsi

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
!include "MUI2.nsh" ; Modern UI
66
!include "LogicLib.nsh" ; Logical operators
77
!include "Sections.nsh" ; Support for section selection
8+
!include nsDialogs.nsh ; Support custom pages with dialogs
89

910
; Compile-time definitions
1011
!define VC_REDIST32_EXE "vc_redist.x86.exe"
@@ -48,6 +49,9 @@ BrandingText "${APP_NAME} powers your online jam session"
4849
; Installer page configuration
4950
!define MUI_PAGE_CUSTOMFUNCTION_PRE AbortOnRunningApp
5051
!insertmacro MUI_PAGE_WELCOME
52+
53+
Page Custom ASIOCheckInstalled ExitASIOInstalled
54+
5155
!insertmacro MUI_PAGE_LICENSE "${ROOT_PATH}\COPYING"
5256
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ValidateDestinationFolder
5357
!insertmacro MUI_PAGE_DIRECTORY
@@ -89,7 +93,20 @@ LangString OLD_WRONG_VER_FOUND_CONFIRM ${LANG_ENGLISH} \
8993
"If you continue without removing it, your installation might be broken! Are you sure you don't want to remove the old version?"
9094
LangString OLD_VER_REMOVE_FAILED ${LANG_ENGLISH} \
9195
"FATAL: THE UNINSTALLER FAILED. Once you click on OK the old version will remain on your PC and we will try to install the new version too. You can also press cancel and try to remove it on your own."
96+
LangString ASIO_DRIVER_HEADER ${LANG_ENGLISH} \
97+
"ASIO driver"
98+
LangString ASIO_DRIVER_SUB ${LANG_ENGLISH} \
99+
"To use Jamulus, you need an ASIO driver"
100+
LangString ASIO_DRIVER_EXPLAIN ${LANG_ENGLISH} \
101+
"Jamulus needs an ASIO driver to provide low latency audio. You should install one now:"
102+
LangString ASIO_DRIVER_MORE_INFO ${LANG_ENGLISH} \
103+
"More information on jamulus.io"
104+
LangString ASIO_DRIVER_MORE_INFO_URL ${LANG_ENGLISH} \
105+
"https://jamulus.io/wiki/Installation-for-Windows#setting-up-asio4all"
106+
LangString ASIO_EXIT_NO_DRIVER ${LANG_ENGLISH} \
107+
"We couldn't find an ASIO driver on your PC. Jamulus will not work without one. Do you still want to continue?"
92108
; Abort the installer/uninstaller if Jamulus is running
109+
93110
!macro _AbortOnRunningApp
94111

95112
nsProcess::_FindProcess "${APP_EXE}"
@@ -102,6 +119,11 @@ LangString OLD_VER_REMOVE_FAILED ${LANG_ENGLISH} \
102119

103120
!macroend
104121

122+
; Define Dialog variables
123+
124+
Var Dialog
125+
Var Label
126+
Var Button
105127

106128
; Installer
107129
!macro InstallApplication buildArch
@@ -251,6 +273,43 @@ Function createdesktopshortcut
251273
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${APP_EXE}"
252274
FunctionEnd
253275

276+
Function ASIOCheckInstalled
277+
278+
; insert ASIO install page if no ASIO driver was found
279+
ClearErrors
280+
EnumRegKey $0 HKLM "SOFTWARE\ASIO" 0
281+
IfErrors 0 ASIOExists
282+
!insertmacro MUI_HEADER_TEXT "$(ASIO_DRIVER_HEADER)" "$(ASIO_DRIVER_SUB)"
283+
nsDialogs::Create 1018
284+
Pop $Dialog
285+
286+
${If} $Dialog == error
287+
Abort
288+
${Endif}
289+
290+
${NSD_CreateLabel} 0 0 100% 12u "$(ASIO_DRIVER_EXPLAIN)"
291+
Pop $Label
292+
${NSD_CreateButton} 0 13u 100% 13u "$(ASIO_DRIVER_MORE_INFO)"
293+
Pop $Button
294+
${NSD_OnClick} $Button OpenASIOHelpPage
295+
296+
nsDialogs::Show
297+
ASIOExists:
298+
FunctionEnd
299+
300+
Function OpenASIOHelpPage
301+
ExecShell "open" "$(ASIO_DRIVER_MORE_INFO_URL)"
302+
FunctionEnd
303+
304+
Function ExitASIOInstalled
305+
ClearErrors
306+
EnumRegKey $0 HKLM "SOFTWARE\ASIO" 0
307+
IfErrors 0 SkipMessage
308+
MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(ASIO_EXIT_NO_DRIVER)" /sd IDNO IDYES SkipMessage
309+
Abort
310+
SkipMessage:
311+
FunctionEnd
312+
254313
; Uninstaller
255314
!macro un.InstallFiles buildArch
256315

0 commit comments

Comments
 (0)