mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-03-20 08:59:10 +00:00
Revert "revert to user folder"
This reverts commit d1dfe2de52542025a0bb677d139146b654be273e.
This commit is contained in:
parent
d1dfe2de52
commit
91e798caa1
@ -20,15 +20,11 @@ class Remote {
|
|||||||
[String]$vmpath
|
[String]$vmpath
|
||||||
[Hashtable]$kind
|
[Hashtable]$kind
|
||||||
[Object]$profiles
|
[Object]$profiles
|
||||||
[String]$userpath
|
|
||||||
[String]$workingconfig
|
|
||||||
|
|
||||||
Remote ([String]$kindId) {
|
Remote ([String]$kindId) {
|
||||||
$this.vmpath = Setup_DLL
|
$this.vmpath = Setup_DLL
|
||||||
$this.kind = GetKind($kindId)
|
$this.kind = GetKind($kindId)
|
||||||
$this.profiles = Get_Profiles($this.kind.name)
|
$this.profiles = Get_Profiles($this.kind.name)
|
||||||
$this.userpath = Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'Voicemeeter'
|
|
||||||
$this.workingconfig = Join-Path $this.userpath ('vm' + $this.kind.name + '_working.xml')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] ToString() {
|
[string] ToString() {
|
||||||
|
|||||||
22
lib/io.ps1
22
lib/io.ps1
@ -171,31 +171,33 @@ class IODevice : IRemote {
|
|||||||
{
|
{
|
||||||
if ([string]::IsNullOrEmpty($this.name)) { return '' }
|
if ([string]::IsNullOrEmpty($this.name)) { return '' }
|
||||||
|
|
||||||
$path = $this.remote.workingconfig
|
$type = $null
|
||||||
$oldTime = if (Test-Path $path) { (Get-Item $path).LastWriteTime } else { [DateTime]::MinValue }
|
try {
|
||||||
$this.remote.Setter('Command.Save', $path)
|
$tmp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), "vmrtmp-$(New-Guid).xml")
|
||||||
|
$this.remote.Setter('Command.Save', $tmp)
|
||||||
|
|
||||||
$timeout = New-TimeSpan -Seconds 2
|
$timeout = New-TimeSpan -Seconds 2
|
||||||
$sw = [Diagnostics.Stopwatch]::StartNew()
|
$sw = [Diagnostics.Stopwatch]::StartNew()
|
||||||
$line = $null
|
$line = $null
|
||||||
do {
|
do {
|
||||||
if (Test-Path $path) {
|
if (Test-Path $tmp) {
|
||||||
$newTime = (Get-Item $path).LastWriteTime
|
|
||||||
if ($newTime -gt $oldTime) {
|
|
||||||
try {
|
try {
|
||||||
$line = Get-Content $path | Select-String -Pattern "<$($this.kindOfDevice)Dev index='$($this.index + 1)'" -List
|
$line = Get-Content $tmp | Select-String -Pattern "<$($this.kindOfDevice)Dev index='$($this.index + 1)'" -List
|
||||||
if ($line) { break }
|
if ($line) { break }
|
||||||
}
|
}
|
||||||
catch {}
|
catch {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Start-Sleep -Milliseconds 20
|
Start-Sleep -Milliseconds 20
|
||||||
} while ($sw.elapsed -lt $timeout)
|
} while ($sw.elapsed -lt $timeout)
|
||||||
|
|
||||||
$type = $null
|
|
||||||
if ($line -and $line.ToString() -match "type='(?<type>\d+)'") {
|
if ($line -and $line.ToString() -match "type='(?<type>\d+)'") {
|
||||||
$type = $matches['type']
|
$type = $matches['type']
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (Test-Path $tmp) {
|
||||||
|
Remove-Item $tmp -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($type -notin $this.drivers.Keys) { return 'unknown' }
|
if ($type -notin $this.drivers.Keys) { return 'unknown' }
|
||||||
return $this.drivers[$type]
|
return $this.drivers[$type]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user