mirror of
https://github.com/nonoo/kappanhang.git
synced 2026-01-09 02:09:57 +01:00
Use some constants
This commit is contained in:
parent
94a84ace86
commit
f42efc1f04
|
|
@ -11,6 +11,8 @@ import (
|
|||
"github.com/akosmarton/papipes"
|
||||
)
|
||||
|
||||
const audioSampleRate = 48000
|
||||
|
||||
type audioStruct struct {
|
||||
source papipes.Source
|
||||
sink papipes.Sink
|
||||
|
|
@ -154,18 +156,18 @@ func (a *audioStruct) loop() {
|
|||
func (a *audioStruct) init(devName string) error {
|
||||
a.source.Name = "kappanhang-" + devName
|
||||
a.source.Filename = "/tmp/kappanhang-" + devName + ".source"
|
||||
a.source.Rate = 48000
|
||||
a.source.Rate = audioSampleRate
|
||||
a.source.Format = "s16le"
|
||||
a.source.Channels = 1
|
||||
a.source.SetProperty("device.buffering.buffer_size", (48000*16)/10) // 100 ms
|
||||
a.source.SetProperty("device.buffering.buffer_size", (audioSampleRate*16)/10) // 100 ms
|
||||
a.source.SetProperty("device.description", "kappanhang: "+devName)
|
||||
|
||||
a.sink.Name = "kappanhang-" + devName
|
||||
a.sink.Filename = "/tmp/kappanhang-" + devName + ".sink"
|
||||
a.sink.Rate = 48000
|
||||
a.sink.Rate = audioSampleRate
|
||||
a.sink.Format = "s16le"
|
||||
a.sink.Channels = 1
|
||||
a.sink.SetProperty("device.buffering.buffer_size", (48000*16)/10)
|
||||
a.sink.SetProperty("device.buffering.buffer_size", (audioSampleRate*16)/10)
|
||||
a.sink.SetProperty("device.description", "kappanhang: "+devName)
|
||||
|
||||
if err := a.source.Open(); err != nil {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ func (s *audioStream) loop() {
|
|||
}
|
||||
|
||||
func (s *audioStream) init(devName string) error {
|
||||
if err := s.common.init("audio", 50003); err != nil {
|
||||
if err := s.common.init("audio", audioStreamPort); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const controlStreamPort = 50001
|
||||
const serialStreamPort = 50002
|
||||
const audioStreamPort = 50003
|
||||
|
||||
type controlStream struct {
|
||||
common streamCommon
|
||||
serial serialStream
|
||||
|
|
@ -91,6 +95,7 @@ func (s *controlStream) sendPktAuth(magic byte) error {
|
|||
|
||||
func (s *controlStream) sendRequestSerialAndAudio() error {
|
||||
log.Debug("requesting serial and audio stream")
|
||||
|
||||
p := []byte{0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID),
|
||||
byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID),
|
||||
|
|
@ -106,9 +111,10 @@ func (s *controlStream) sendRequestSerialAndAudio() error {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x2b, 0x3f, 0x55, 0x5c, 0x00, 0x00, 0x00, 0x00, // username: beer
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x01, 0x04, 0x04, 0x00, 0x00, 0xbb, 0x80,
|
||||
0x00, 0x00, 0xbb, 0x80, 0x00, 0x00, 0xc3, 0x52,
|
||||
0x00, 0x00, 0xc3, 0x53, 0x00, 0x00, 0x00, 0xa0,
|
||||
0x01, 0x01, 0x04, 0x04, 0x00, 0x00, byte(audioSampleRate >> 8), byte(audioSampleRate & 0xff),
|
||||
0x00, 0x00, byte(audioSampleRate >> 8), byte(audioSampleRate & 0xff),
|
||||
0x00, 0x00, byte(serialStreamPort >> 8), byte(serialStreamPort & 0xff),
|
||||
0x00, 0x00, byte(audioStreamPort >> 8), byte(audioStreamPort & 0xff), 0x00, 0x00, 0x00, 0xa0,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
if err := s.common.pkt0.sendTrackedPacket(&s.common, p); err != nil {
|
||||
return err
|
||||
|
|
@ -181,7 +187,7 @@ func (s *controlStream) handleRead(r []byte) error {
|
|||
// 0x80, 0x00, 0x00, 0x90, 0xc7, 0x0e, 0x86, 0x01,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x49, 0x43, 0x2d, 0x37, 0x30, 0x35, 0x00, 0x00,
|
||||
// 0x49, 0x43, 0x2d, 0x37, 0x30, 0x35, 0x00, 0x00, // IC-705 in plain text
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
@ -257,7 +263,7 @@ func (s *controlStream) loop() {
|
|||
func (s *controlStream) init() error {
|
||||
log.Debug("init")
|
||||
|
||||
if err := s.common.init("control", 50001); err != nil {
|
||||
if err := s.common.init("control", controlStreamPort); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ func (s *serialStream) loop() {
|
|||
}
|
||||
|
||||
func (s *serialStream) init(devName string) error {
|
||||
if err := s.common.init("serial", 50002); err != nil {
|
||||
if err := s.common.init("serial", serialStreamPort); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue