GithubHelp home page GithubHelp logo

alsa's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

alsa's Issues

[proposal] Use time.Duration for time specification

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?

Q: "beep" example is not working

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.

Minor cleanup in swparams.go

I'll be submitting a pull request today to replace fallthrough statements in swparams.go with more conventional comma-delimited case conditions.

Some ioctls are invalid on arm

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.

Examples are broken

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

Write ioctl is not guaranteed to write requested number of frames

alsa/device.go

Line 256 in d079056

func (device *Device) Write(buf []byte, frames int) error {

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 ?

beep example: bad file descriptor

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

Support arm64

How could I build an arm64 version?

Can I just add a file called types_arm64.go in the folder alsatype?

Thanks!

Open() blocking forever

The issue

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.

Proposal:

Add syscall.O_NONBLOCK like so:

device.fh, err = os.OpenFile(device.Path, os.O_RDWR | syscall.O_NONBLOCK, 0755)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.