yobert / alsa Goto Github PK
View Code? Open in Web Editor NEWgolang alsa client implementation
License: MIT License
golang alsa client implementation
License: MIT License
How could I build an arm64 version?
Can I just add a file called types_arm64.go
in the folder alsatype?
Thanks!
I'll be submitting a pull request today to replace fallthrough
statements in swparams.go with more conventional comma-delimited case conditions.
It appears that lengths for data structures vary depending on architecture. Caught here:
https://github.com/yobert/alsa/blob/master/device.go#L233
The native ARM (ie 32-bit, specifically not ARM8/aarch64) ALSA utilities encode an ioctl with a length of 604, not 608. I suspect the length descrepency comes down to this:
https://github.com/yobert/alsa/blob/master/misc/types.go#L4
since snd_pcm_uframes_t
is an unsigned long
according to the API reference and the difference of that datatype between 64 bits and 32 bits is suspiciously close to 4 bytes.
I'll investigate and see about having that value get computed rather than hard-coded.
Hi,
if i change duration in cmd/beep to 10 seconds,
at around 3-4 seconds playing i receive error:
go run test.go
2020/11/27 11:07:37 start
HDA Intel PCH
─── ALC255 Analog
Negotiated parameters: 2 channels, 44100 hz, S16_LE, 2048 period size, 4096 buffer size
Closing device.
2020/11/27 11:07:40 ioctl write (24 bytes) 0x4150 failed: bad file descriptor
error when beeping device: ioctl write (24 bytes) 0x4150 failed: bad file descriptor
─── HDMI 0
Negotiated parameters: 2 channels, 44100 hz, S16_LE, 2048 period size, 4096 buffer size
Closing device.
2020/11/27 11:07:44 ioctl write (24 bytes) 0x4150 failed: bad file descriptor
error when beeping device: ioctl write (24 bytes) 0x4150 failed: bad file descriptor
log lines show timing of errors
In https://github.com/yobert/alsa/blob/master/device.go#L107, the os.OpenFile
call does not have a syscall.O_NONBLOCK
flag. I suspect this is causing the beep
example on my pure ALSA setup to block. (I've tested and nailed it down to the Open()
method). This does not happen with PulseAudio.
Add syscall.O_NONBLOCK
like so:
device.fh, err = os.OpenFile(device.Path, os.O_RDWR | syscall.O_NONBLOCK, 0755)
Docs doesn't describe properly where i need dig to solve this issue.
i run go run ./cmd/beep
and nothing happens. Also, cards are not switching in for cycle as expected.
Currently alsa.NewBufferSeconds
takes an int
to specify the length of the buffer. It would be nice to support sub-second times, and also reflect that the time is a duration by changing the signature to (or adding) NewBuffer(time.Duration)
.
Does this sound reasonable?
root@ubuntu:~# go get -u -x -v github.com/yobert/alsa/cmd/beep
cd /root/go/src/github.com/yobert/alsa
git config remote.origin.url
github.com/yobert/alsa (download)
cd /root/go/src/github.com/yobert/alsa
git pull --ff-only
cd /root/go/src/github.com/yobert/alsa
git submodule update --init --recursive
cd /root/go/src/github.com/yobert/alsa
git show-ref
cd /root/go/src/github.com/yobert/alsa
git submodule update --init --recursive
cd /root/go/src/github.com/yobert/alsa
git config remote.origin.url
cd /root/go/src/github.com/yobert/alsa
git config remote.origin.url
cd /root/go/src/github.com/yobert/alsa
git config remote.origin.url
cd /root/go/src/github.com/yobert/alsa
git config remote.origin.url
cd /root/go/src/github.com/yobert/alsa
git config remote.origin.url
WORK=/tmp/go-build325338770
github.com/yobert/alsa/alsatype
mkdir -p $WORK/b036/
cat >$WORK/b036/importcfg << 'EOF' # internal
# import config
packagefile fmt=/usr/lib/go-1.14/pkg/linux_arm64/fmt.a
packagefile reflect=/usr/lib/go-1.14/pkg/linux_arm64/reflect.a
EOF
cd /root/go/src/github.com/yobert/alsa/alsatype
/usr/lib/go-1.14/pkg/tool/linux_arm64/compile -o $WORK/b036/_pkg_.a -trimpath "$WORK/b036=>" -p github.com/yobert/alsa/alsatype -complete -buildid QkdTK6SZxXLGeNlwwVY9/QkdTK6SZxXLGeNlwwVY9 -goversion go1.14.7 -D "" -importcfg $WORK/b036/importcfg -pack -c=4 ./PVersion.go ./SwParams.go ./uint.go
# github.com/yobert/alsa/alsatype
go/src/github.com/yobert/alsa/alsatype/PVersion.go:5:9: undefined: PVersion
go/src/github.com/yobert/alsa/alsatype/PVersion.go:8:9: undefined: PVersion
go/src/github.com/yobert/alsa/alsatype/PVersion.go:11:9: undefined: PVersion
go/src/github.com/yobert/alsa/alsatype/PVersion.go:14:9: undefined: PVersion
go/src/github.com/yobert/alsa/alsatype/SwParams.go:8:10: undefined: SwParams
go/src/github.com/yobert/alsa/alsatype/SwParams.go:9:17: undefined: SwParams
go/src/github.com/yobert/alsa/alsatype/SwParams.go:12:10: undefined: SwParams
Line 8 in 262cfbb
Can this package be replaced with a globally qualified import path?
Line 256 in d079056
Hi,
sometimes write method write less number of frames, here is how i fixed this:
func (device *Device) write1(buf []byte, frames int) (int, error) {
x := pcm.XferI{
Buf: uintptr(unsafe.Pointer(&buf[0])),
Frames: alsatype.Uframes(frames),
}
err := ioctl(device.fh.Fd(), ioctl_encode_ptr(cmdWrite, &x, cmdPCMWriteIFrames), &x)
written := alsatype.Uframes(frames)
if err == syscall.EAGAIN {
return written, nil
}
return written, err
}
func (device *Device) Write(buf []byte, framesize int) error {
for len(buf) > 0 {
w, err := dev.write1(buf, len(buf)/framesize)
if err != nil {
return err
}
buf = buf[w*framesize:]
}
}
i not going to send PR, please update from this issue,
Regards
PS
May be Read can also read less that requested frames ?
Looking at the recorder example it seems that a continuous monitor could be setup by looping over a select
checking a <-done
channel, else reading more input into a buffer.
It looks like you are doing something related with the echoback example.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.