Initial prototyping hackery.
This commit is contained in:
		
							
								
								
									
										32
									
								
								pulsectl/pulsectl.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								pulsectl/pulsectl.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
package pulsectl
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"path"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type PipeSourceConfig struct {
 | 
			
		||||
	PipeName string
 | 
			
		||||
	PipeDir string
 | 
			
		||||
	Encoding string
 | 
			
		||||
	Bitrate int
 | 
			
		||||
	Channels int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func LoadPipeSource(config PipeSourceConfig) error {
 | 
			
		||||
	cmd := exec.Command("pactl", "load-module", "module-pipe-source",
 | 
			
		||||
		fmt.Sprintf("source_name=%s", config.PipeName),
 | 
			
		||||
		fmt.Sprintf("file=%s", path.Join(config.PipeDir, config.PipeName)),
 | 
			
		||||
		fmt.Sprintf("format=%s", config.Encoding),
 | 
			
		||||
		fmt.Sprintf("rate=%d", config.Bitrate),
 | 
			
		||||
		fmt.Sprintf("channels=%d", config.Channels),
 | 
			
		||||
	)
 | 
			
		||||
	return cmd.Run()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func UnloadPipeSource() error {
 | 
			
		||||
	cmd := exec.Command("pactl", "unload-module", "module-pipe-source")
 | 
			
		||||
	return cmd.Run()
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user