mirror of
https://github.com/nonoo/kappanhang.git
synced 2025-12-06 08:02:00 +01:00
Cleanup previous audio pipes
This commit is contained in:
parent
c5d1839ccf
commit
edb20dda86
|
|
@ -168,6 +168,16 @@ func (a *audioStruct) init(devName string) error {
|
|||
a.source.SetProperty("device.buffering.buffer_size", (audioSampleRate*16)/10) // 100 ms
|
||||
a.source.SetProperty("device.description", "kappanhang: "+devName)
|
||||
|
||||
// Cleanup previous pipes.
|
||||
sources, err := papipes.GetActiveSources()
|
||||
if err == nil {
|
||||
for _, i := range sources {
|
||||
if i.Filename == a.source.Filename {
|
||||
i.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a.sink.Name = "kappanhang-" + devName
|
||||
a.sink.Filename = "/tmp/kappanhang-" + devName + ".sink"
|
||||
a.sink.Rate = audioSampleRate
|
||||
|
|
@ -177,6 +187,16 @@ func (a *audioStruct) init(devName string) error {
|
|||
a.sink.SetProperty("device.buffering.buffer_size", (audioSampleRate*16)/10)
|
||||
a.sink.SetProperty("device.description", "kappanhang: "+devName)
|
||||
|
||||
// Cleanup previous pipes.
|
||||
sinks, err := papipes.GetActiveSinks()
|
||||
if err != nil {
|
||||
for _, i := range sinks {
|
||||
if i.Filename == a.source.Filename {
|
||||
i.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.source.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -3,7 +3,7 @@ module github.com/nonoo/kappanhang
|
|||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/akosmarton/papipes v0.0.0-20201020060136-a13951732479
|
||||
github.com/akosmarton/papipes v0.0.0-20201027113853-3c63b4919c76
|
||||
github.com/google/goterm v0.0.0-20200907032337-555d40f16ae2
|
||||
github.com/pborman/getopt v1.1.0
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -1,7 +1,7 @@
|
|||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/akosmarton/papipes v0.0.0-20201020060136-a13951732479 h1:YUUKO1V9gTQWqqKc7pOJdmeXwmdeVodiOjR2tkPoSkM=
|
||||
github.com/akosmarton/papipes v0.0.0-20201020060136-a13951732479/go.mod h1:mdvQ399enti+OdGDfk21dAR0/nkd9oUak/wiEbwowtc=
|
||||
github.com/akosmarton/papipes v0.0.0-20201027113853-3c63b4919c76 h1:JxmEAp9MVbC4up4TAt6UXEPzfb+S90Uji1SKehF3B00=
|
||||
github.com/akosmarton/papipes v0.0.0-20201027113853-3c63b4919c76/go.mod h1:mdvQ399enti+OdGDfk21dAR0/nkd9oUak/wiEbwowtc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
|
|||
Loading…
Reference in a new issue