Compare commits
No commits in common. "main" and "1.0.0" have entirely different histories.
@ -4,7 +4,7 @@ INSTALLDIR = ~/Library/Application\ Support/com.elgato.StreamDeck/Plugins/com.dl
|
|||||||
#SDPLUGINDIR = "./com.dlprows.macvolumecontrol.sdPlugin"
|
#SDPLUGINDIR = "./com.dlprows.macvolumecontrol.sdPlugin"
|
||||||
|
|
||||||
update:
|
update:
|
||||||
killall Stream\ Deck || true
|
killall Stream\ Deck.app || true
|
||||||
go build -o $(INSTALLDIR) .
|
go build -o $(INSTALLDIR) .
|
||||||
open -a Elgato\ Stream\ Deck
|
open -a Elgato\ Stream\ Deck
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.5 KiB |
22
src/main.go
22
src/main.go
@ -95,7 +95,7 @@ func setup(client *streamdeck.Client) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return setFeedback(ctx, client, newSettings)
|
return setFeedbackIfNeeded(ctx, client, newSettings)
|
||||||
})
|
})
|
||||||
|
|
||||||
action.RegisterHandler(streamdeck.WillDisappear, func(ctx context.Context, client *streamdeck.Client, event streamdeck.Event) error {
|
action.RegisterHandler(streamdeck.WillDisappear, func(ctx context.Context, client *streamdeck.Client, event streamdeck.Event) error {
|
||||||
@ -119,14 +119,17 @@ func setup(client *streamdeck.Client) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = sdcontext.WithContext(ctx, ctxStr)
|
ctx = sdcontext.WithContext(ctx, ctxStr)
|
||||||
|
|
||||||
setFeedback(ctx, client, newSettings)
|
setFeedbackIfNeeded(ctx, client, newSettings)
|
||||||
}
|
}
|
||||||
_currentSettings = newSettings
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFeedback(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
|
func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
|
||||||
|
|
||||||
|
if _currentSettings.OutputVolume == newSettings.OutputVolume && _currentSettings.OutputMuted == newSettings.OutputMuted {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
payload := FeedbackPayload{}
|
payload := FeedbackPayload{}
|
||||||
|
|
||||||
@ -148,17 +151,8 @@ func setFeedback(ctx context.Context, client *streamdeck.Client, newSettings *vo
|
|||||||
|
|
||||||
payload.Icon = ValueWithOpacity[any]{nil, opacity}
|
payload.Icon = ValueWithOpacity[any]{nil, opacity}
|
||||||
|
|
||||||
return client.SetFeedback(ctx, payload)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
|
|
||||||
|
|
||||||
if _currentSettings.OutputVolume == newSettings.OutputVolume && _currentSettings.OutputMuted == newSettings.OutputMuted {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentSettings = newSettings
|
_currentSettings = newSettings
|
||||||
return setFeedback(ctx, client, newSettings)
|
return client.SetFeedback(ctx, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FeedbackPayload struct {
|
type FeedbackPayload struct {
|
||||||
|
@ -2,9 +2,8 @@ package volume
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo CFLAGS: -x objective-c
|
#cgo CFLAGS: -x objective-c
|
||||||
#cgo LDFLAGS: -framework CoreAudio -framework AudioToolbox
|
#cgo LDFLAGS: -framework CoreAudio
|
||||||
#include <CoreAudio/CoreAudio.h>
|
#include <CoreAudio/CoreAudio.h>
|
||||||
#include <AudioToolbox/AudioToolbox.h>
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
@ -44,17 +43,10 @@ func GetDefaultOutputDevice() (AudioObjectID, OSStatus) {
|
|||||||
func GetVolume(objectID AudioObjectID) (float32, OSStatus) {
|
func GetVolume(objectID AudioObjectID) (float32, OSStatus) {
|
||||||
|
|
||||||
properties := C.AudioObjectPropertyAddress{
|
properties := C.AudioObjectPropertyAddress{
|
||||||
C.kAudioHardwareServiceDeviceProperty_VirtualMainVolume,
|
C.kAudioDevicePropertyVolumeScalar,
|
||||||
C.kAudioDevicePropertyScopeOutput,
|
C.kAudioDevicePropertyScopeOutput,
|
||||||
C.kAudioObjectPropertyElementMain,
|
0, //main channel
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
properties := C.AudioObjectPropertyAddress{
|
|
||||||
C.kAudioDevicePropertyVolumeScalar,
|
|
||||||
C.kAudioDevicePropertyScopeOutput,
|
|
||||||
0, //main channel
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var data C.Float32
|
var data C.Float32
|
||||||
dataSize := C.UInt32(unsafe.Sizeof(data))
|
dataSize := C.UInt32(unsafe.Sizeof(data))
|
||||||
@ -74,17 +66,10 @@ func GetVolume(objectID AudioObjectID) (float32, OSStatus) {
|
|||||||
func SetVolume(objectID AudioObjectID, volume float32) OSStatus {
|
func SetVolume(objectID AudioObjectID, volume float32) OSStatus {
|
||||||
|
|
||||||
properties := C.AudioObjectPropertyAddress{
|
properties := C.AudioObjectPropertyAddress{
|
||||||
C.kAudioHardwareServiceDeviceProperty_VirtualMainVolume,
|
C.kAudioDevicePropertyVolumeScalar,
|
||||||
C.kAudioDevicePropertyScopeOutput,
|
C.kAudioDevicePropertyScopeOutput,
|
||||||
C.kAudioObjectPropertyElementMain,
|
0, //main channel
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
properties := C.AudioObjectPropertyAddress{
|
|
||||||
C.kAudioDevicePropertyVolumeScalar,
|
|
||||||
C.kAudioDevicePropertyScopeOutput,
|
|
||||||
0, //main channel
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
data := C.Float32(volume)
|
data := C.Float32(volume)
|
||||||
|
|
||||||
|
@ -49,6 +49,9 @@ type VolumeSettings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetVolumeSettings() (*VolumeSettings, error) {
|
func GetVolumeSettings() (*VolumeSettings, error) {
|
||||||
|
//osascript -e "get volume settings"
|
||||||
|
//output volume:81, input volume:50, alert volume:100, output muted:false
|
||||||
|
|
||||||
device, result := GetDefaultOutputDevice()
|
device, result := GetDefaultOutputDevice()
|
||||||
|
|
||||||
if result != AudioHardwareNoError {
|
if result != AudioHardwareNoError {
|
||||||
@ -207,6 +210,3 @@ const (
|
|||||||
|
|
||||||
//script := "set volume output muted (not output muted of (get volume settings))"
|
//script := "set volume output muted (not output muted of (get volume settings))"
|
||||||
//return exec.Command("osascript", "-e", "set volume output muted (not output muted of (get volume settings))").Run()
|
//return exec.Command("osascript", "-e", "set volume output muted (not output muted of (get volume settings))").Run()
|
||||||
|
|
||||||
//osascript -e "get volume settings"
|
|
||||||
//output volume:81, input volume:50, alert volume:100, output muted:false
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user