Frosthaven / voicemeeter-windows-volume

Tray app that allows you to sync windows volume and mute state to Voicemeeter volume controls
265 stars 9 forks source link

script shuts itself down randomly #52

Open mashakos opened 6 months ago

mashakos commented 6 months ago

VMWV randomly exits (crashes?) in a pattern I cannot discern. My best guess is when I unplug my headphones, it exits. I basically have to run it from a shortcut every time I have my headphones on. Don't have anything more unfortunately, unless there is a method to generating log files I don't know about.

Jerrk commented 6 months ago

i would guess its the same issue as https://github.com/Frosthaven/voicemeeter-windows-volume/issues/39

do you have the "restart audio device on..." "audio device connection changes" option enabled? try turning that off and see if that fixes it for you

mashakos commented 6 months ago

it fixed it, kinda? VMWV no longer crashes which is great. only problem is that the fix negates one of the best features of the utility, which is auto detecting plugged in audio gear + restarting voicemeeter engine + tracking volume. Now I have to manually restart voicemeeter every time I plug in a pair of headphones

Jerrk commented 6 months ago

Yeah that is indeed a problem, just gotta wait for @Frosthaven to get some free time.

or if you're well-versed in javascript maybe you can create a pull request to fix the issue yourself.

XxLegitOPxX commented 3 weeks ago

I managed to somewhat fix this for myself by modifying the auto-start-task.ps1 script to also detect if VMWV would exit and automatically restart it.

  1. Go to where you installed VMWV and create a powershell script called auto-start-task-v2.ps1 containing the following:
    
    $scriptpath = $MyInvocation.MyCommand.Path
    $dir = Split-Path $scriptpath
    $vmwvPath = Join-Path $dir "required\VMWV.exe"
    Set-Location $dir

function Start-VMWV {

Kill any existing VMWV processes

try {
    taskkill /im "VMWV.exe" /t /f
    Get-Process -Name "VMWV" -ErrorAction SilentlyContinue | Stop-Process -Force
} catch {}

# Start a fresh VMWV process
Start-Process -FilePath $vmwvPath -WindowStyle Hidden
# Wait for the process to start and become accessible
Start-Sleep -Seconds 2

$vmwv = Get-Process -Name "VMWV" -ErrorAction SilentlyContinue
while (-not $vmwv) {
    Start-Sleep -Seconds 1
    $vmwv = Get-Process -Name "VMWV" -ErrorAction SilentlyContinue
}

# Poll for child processes to ensure VMWV has access to cmd.exe
$polling_for_children = $true
$polling_count = 0
while ($polling_for_children) {
    $childProcesses = Get-WmiObject Win32_Process -Filter "ParentProcessId=$($vmwv.Id)"
    if ($childProcesses | Where-Object {$_.Name -eq "cmd.exe"}) {
        $polling_for_children = $false
        return $vmwv
    }

    $polling_count++
    if ($polling_count -gt 10) {
        $polling_for_children = $false
    }
    Start-Sleep -Seconds 1
}

return $null

}

Initial start

$vmwv = Start-VMWV

while ($true) { if (-not $vmwv) { Write-Host "VMWV failed to start, retrying..." $vmwv = Start-VMWV continue }

try {
    if ($vmwv.HasExited) {
        Write-Host "VMWV exited, restarting..."
        $vmwv = Start-VMWV
    }
} catch {
    Write-Host "Error checking VMWV process, restarting..."
    $vmwv = Start-VMWV
}

Start-Sleep -Seconds 5

}


2. Create a shortcut by rightclicking `auto-start-task-v2.ps1`, go to the shortcut's properties and add the following in the "Target" field (make sure you have the path below set to where *your* VMWV is installed, this is just where I installed it manually):

powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "D:\Program Files (x86)\Voicemeeter Windows Volume\auto-start-task-v2.ps1"



3. (optional) Put the shortcut in a startup folder e.g. in `shell:common startup` (Win + R)

it's a bit hacky (and made partly with chatgpt) but it worked for me. hope this helps to anyone reading.