Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmap error with alsa::direct::pcm::Status on Raspberry Pi #34

Closed
supercurio opened this issue Apr 12, 2018 · 5 comments
Closed

mmap error with alsa::direct::pcm::Status on Raspberry Pi #34

supercurio opened this issue Apr 12, 2018 · 5 comments

Comments

@supercurio
Copy link

Hi @diwic!
Following on #33 (comment)

Here is a test program:
https://github.com/supercurio/asrc-rs-research/blob/master/src/alsa_direct_status_test.rs

Runs on a amd64 desktop Ubuntu 17.04 with all ALSA cards.

Fails with Error("mmap (of driver memory)", Sys(ENXIO))', libcore/result.rs:945:5 on Raspberry Pi 3+ 4.14.30-v7+ capture and playback with:

  • HDMI out
  • USB audio (AUREON XFIRE8.0 HD)
  • I2S HifiBerry Digi+ I/O
@supercurio supercurio changed the title Mmap with alsa::direct::pcm::Status on Raspberry Pi mmap error with alsa::direct::pcm::Status on Raspberry Pi Apr 12, 2018
@diwic
Copy link
Owner

diwic commented Apr 13, 2018

Found it - apparently this mmap of control and status is only available on X86, ALPHA and PowerPC :-(

@diwic
Copy link
Owner

diwic commented Apr 13, 2018

Ok, so I've made a SyncPtrStatus struct for the other archs. I should probably do something generic across all ways to read status...but for now this will do...

@supercurio
Copy link
Author

supercurio commented Apr 13, 2018

Cool! I'm looking at how to update the alsa_direct_status_test.rs code and just pushed a commit.
It ends up like that: https://github.com/supercurio/asrc-rs-research/blob/5d4b34e487414863086086a9c12fe0284f0c04a5/src/alsa_direct_status_test.rs#L98

let ss = unsafe { SyncPtrStatus::sync_ptr(pcm_to_fd(&pcm).unwrap(), false, None, None).unwrap() };
relies on pcm_to_fd so I made it public to try here.

On both x84_64 and arm, it returns state: Prepared htstamp: 0

@diwic
Copy link
Owner

diwic commented Apr 13, 2018

The syscall is made when you call sync_ptr, you need to do this every time you need a new snapshot of the current status. (This is unlike Status which reads directly from memory that the kernel keeps updated.)

relies on pcm_to_fd so I made it public to try here.

Or just copy-paste pcm_to_fd into your own code as it relies on public stuff only. It's merely a two-line helper.

@supercurio
Copy link
Author

Right!
The test program, relying on SyncPtrStatus and following your suggestions now works on Raspberry Pi 3+, Pi Zero, and also ODROID-C2 which doesn't support mmap I/O!
Looks good 👍 closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants