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

speaker-test: inconsistent behaviour of --buffer option. #224

Closed
AndrewAmmerlaan opened this issue Jul 16, 2023 · 2 comments
Closed

speaker-test: inconsistent behaviour of --buffer option. #224

AndrewAmmerlaan opened this issue Jul 16, 2023 · 2 comments

Comments

@AndrewAmmerlaan
Copy link

AndrewAmmerlaan commented Jul 16, 2023

Without specifying the --buffer option speaker-test returns this:

andrew@andrew-gentoo-pc ~ % speaker-test -c2 -twav -Dplughw:CARD=PCH,DEV=3

speaker-test 1.2.9

Playback device is plughw:CARD=PCH,DEV=3
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 1048576
Period size range from 32 to 524288
Using max buffer size 1048576
Periods = 4
was set period_size = 262144
was set buffer_size = 1048576
0 - Front Left
1 - Front Right
Write error: -77,File descriptor in bad state
xrun_recovery failed: -77,File descriptor in bad state
Transfer failed: File descriptor in bad state

Note that it says Using max buffer size 1048576. But now if we try to explicitly specify this maximum buffer size:

andrew@andrew-gentoo-pc ~ % speaker-test -c2 -twav -Dplughw:CARD=PCH,DEV=3 --buffer 1048576

speaker-test 1.2.9

Playback device is plughw:CARD=PCH,DEV=3
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 1048576
Period size range from 32 to 524288
Requested buffer time 1000000 us
Periods = 4
was set period_size = 12000
was set buffer_size = 48000
0 - Front Left
1 - Front Right
Time per period = 2.251287

Note that now we get Requested buffer time 1000000 us which is less then what we actually specified. In fact this will happen with any --buffer parameter larger then 1000000:

andrew@andrew-gentoo-pc ~ % speaker-test -c2 -twav -Dplughw:CARD=PCH,DEV=3 --buffer 1000001

speaker-test 1.2.9

Playback device is plughw:CARD=PCH,DEV=3
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 1048576
Period size range from 32 to 524288
Requested buffer time 1000000 us
Periods = 4
was set period_size = 12000
was set buffer_size = 48000
0 - Front Left
1 - Front Right
Time per period = 2.251042

Leading me to believe that despite what speaker-test claims, 1000000 is actually the maximum, not 1048576.

Discovered while debugging https://gitlab.freedesktop.org/drm/intel/-/issues/8462
This behaviour of speaker-test is confusing though and feels to me like a separate issue.

perexg added a commit that referenced this issue Aug 13, 2023
…conds

BugLink: #224
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
@perexg
Copy link
Member

perexg commented Aug 13, 2023

There was 1 second wrap for buffer and period time in the code. I increased this in the above commit by 100 to allow tests for the large buffers.

Otherwise, you mix two things - sizes (in frames) and time (in microseconds).

If you have rate 48000Hz, the buffer size 48000 it is equal to 1000000us. There is no issue.

BTW: Buffer size (limited by the driver) 1048576 means 1048576 / 48000 = ~21.81 seconds not 1048576us.

@perexg perexg closed this as completed Aug 13, 2023
@AndrewAmmerlaan
Copy link
Author

Oops, I indeed got the units mixed up.
Thanks for the fix, this should help me further debug my i915 hdmi audio problem.

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