Skip to content

Commit

Permalink
Fix mic array not updated when new mics are added
Browse files Browse the repository at this point in the history
Fixes #71
  • Loading branch information
SaifAqqad committed Sep 27, 2022
1 parent 66e6b52 commit 6a18c5d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/MicrophoneController.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Class MicrophoneController {
this.isMicrophoneArray:= 1
this.force_current_state:= 1
this.friendly_name:= "Microphones"
this.updateMicMethod := ObjBindMethod(this, "UpdateMicArray")
;WM_DEVICECHANGE := 0x0219
OnMessage(0x0219, this.updateMicMethod)
case "default":
this.microphone:= "capture"
try this.friendly_name:= VA_GetDeviceName(VA_GetDevice("capture"))
Expand Down Expand Up @@ -144,6 +147,19 @@ Class MicrophoneController {
util_log(Format("[MicrophoneController] Enabled: {}", util_toString(this.microphoneName)))
}

UpdateMicArray(wParam:="", lParam:=""){
if(wParam != 0x0007 || !this.isMicrophoneArray)
return
util_log("[MicrophoneController] Updating Microphones")
this.microphone:= Array()
for i, mic in VA_GetDeviceList("capture") {
micName:= mic . ":capture"
this.microphone.Push(micName)
; reapply current state on any new mic
VA_SetMasterMute(this.state, micName)
}
}

disableController(){
HotkeyManager.unregister(this.muteHotkey,this.muteHotkeyId)
HotkeyManager.unregister(this.unmuteHotkey,this.unmuteHotkeyId)
Expand Down Expand Up @@ -172,6 +188,7 @@ Class MicrophoneController {
Try VA_ReleaseAudioEndpointCallback(VA_GetDevice(this.microphone),this.va_callback)
this.va_callback:=""
}
OnMessage(0x0219, this.updateMicMethod, 0)
}
resetHotkeySet(){
MicrophoneController.hotkeys_set:= new StackSet()
Expand Down

0 comments on commit 6a18c5d

Please sign in to comment.