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

ALSA back end is not working #40

Open
jsharma80 opened this issue Sep 6, 2022 · 10 comments
Open

ALSA back end is not working #40

jsharma80 opened this issue Sep 6, 2022 · 10 comments

Comments

@jsharma80
Copy link

jsharma80 commented Sep 6, 2022

Hello,

I am trying to play audio from a HVM guest (ubuntu). My Dom 0 is also ubuntu. I am using snd_be for this purpose.
Current status:

  1. Audio playback from Dom 0 works fine (aplay music.wav)
  2. Audio playback from Dom U works fine with pulse audio as back end
  3. Audio playback from Dom U does not work with ALSA as back end

Here is my vsnd config:
vsnd = [[ 'card, backend=Domain-0, buffer-size=22050, short-name=VCard, long-name=Virtual sound card, sample-rates=8000;11025;16000;22050;32000;44100;48000, sample-formats=s16_le', 'pcm, name=dev1', 'stream, unique-id=alsa, type=P' ]]

Following are the output of aplya -v and aplay --dump-hw-params respectively. Can you please help me understand what is going wrong here?

================================================================
axx@axx-xxx-RV2:~$ aplay -v ~/SampleAudio/music.wav
Playing WAVE '/home/amd/SampleAudio/music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 22050
period_size : 5512
period_time : 125000
tstamp_mode : NONE
tstamp_type : GETTIMEOFDAY
period_step : 1
avail_min : 5512
period_event : 0
start_threshold : 22050
stop_threshold : 22050
silence_threshold: 0
silence_size : 0
boundary : 6206523236469964800

================================================================

amd@amd-Bilby-RV2:~$ aplay ~/SampleAudio/music.wav --dump-hw-params
Playing WAVE '/home/amd/SampleAudio/music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
HW Params of device "default":

ACCESS: RW_INTERLEAVED
FORMAT: U8 S16_LE S16_BE S24_LE S24_BE S32_LE S32_BE FLOAT_LE FLOAT_BE MU_LAW A_LAW S24_3LE S24_3BE
SUBFORMAT: STD
SAMPLE_BITS: [8 32]
FRAME_BITS: [8 1024]
CHANNELS: [1 32]
RATE: [1 384000]
PERIOD_TIME: (2 4294967295)
PERIOD_SIZE: [1 1398102)
PERIOD_BYTES: [128 1398102)
PERIODS: [3 1024]
BUFFER_TIME: (7 4294967295]
BUFFER_SIZE: [3 4194304]
BUFFER_BYTES: [384 4194304]
TICK_TIME: ALL

================================================================

Regards,
Jyotirmoy

@jsharma80
Copy link
Author

I am continuously getting following log when I play a file in Dom U:

06.09.22 16:16:38.071 | XenEvtchn | DBG - Notify event channel, port: 76
06.09.22 16:16:38.096 | AlsaPcm | DBG - Frame: 0, bytes: 0, state: 3
06.09.22 16:16:38.096 | RingBuffer | DBG - Send event, port: 32, prod: 704, cons: 704, num event

Frame and bytes cannot be 0 for every frame, right? Can this be the issue? What could be the reason for this?

@al1img
Copy link
Collaborator

al1img commented Sep 6, 2022

Hello,

  1. Could you provide the output of the following commands:
aplay -L
aplay -l
  1. Could you provide the full snd_be log of playing short sound?
  2. Could you try to increase buffer-size value (65536 for example)?

@jsharma80
Copy link
Author

jsharma80 commented Sep 7, 2022

Dom 0:

axx@axx-xxx-RV2:~/jkm/back_end/snd_be/build$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default
Playback/recording through the PulseAudio sound server
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=Generic,DEV=3
HD-Audio Generic, HDMI 0
Direct hardware device without any conversions
hw:CARD=Generic,DEV=7
HD-Audio Generic, HDMI 1
Direct hardware device without any conversions
hw:CARD=Generic,DEV=8
HD-Audio Generic, HDMI 2
Direct hardware device without any conversions
hw:CARD=Generic,DEV=9
HD-Audio Generic, HDMI 3
Direct hardware device without any conversions
plughw:CARD=Generic,DEV=3
HD-Audio Generic, HDMI 0
Hardware device with all software conversions
plughw:CARD=Generic,DEV=7
HD-Audio Generic, HDMI 1
Hardware device with all software conversions
plughw:CARD=Generic,DEV=8
HD-Audio Generic, HDMI 2
Hardware device with all software conversions
plughw:CARD=Generic,DEV=9
HD-Audio Generic, HDMI 3
Hardware device with all software conversions
hdmi:CARD=Generic,DEV=0
HD-Audio Generic, HDMI 0
HDMI Audio Output
hdmi:CARD=Generic,DEV=1
HD-Audio Generic, HDMI 1
HDMI Audio Output
hdmi:CARD=Generic,DEV=2
HD-Audio Generic, HDMI 2
HDMI Audio Output
hdmi:CARD=Generic,DEV=3
HD-Audio Generic, HDMI 3
HDMI Audio Output
dmix:CARD=Generic,DEV=3
HD-Audio Generic, HDMI 0
Direct sample mixing device
dmix:CARD=Generic,DEV=7
HD-Audio Generic, HDMI 1
Direct sample mixing device
dmix:CARD=Generic,DEV=8
HD-Audio Generic, HDMI 2
Direct sample mixing device
dmix:CARD=Generic,DEV=9
HD-Audio Generic, HDMI 3
Direct sample mixing device
usbstream:CARD=Generic
HD-Audio Generic
USB Stream Output
hw:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
Direct hardware device without any conversions
hw:CARD=Generic_1,DEV=1
HD-Audio Generic, ALC898 Digital
Direct hardware device without any conversions
plughw:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
Hardware device with all software conversions
plughw:CARD=Generic_1,DEV=1
HD-Audio Generic, ALC898 Digital
Hardware device with all software conversions
sysdefault:CARD=Generic_1
HD-Audio Generic, ALC898 Analog
Default Audio Device
front:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
Front output / input
surround21:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
3.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Digital
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC898 Analog
Direct sample mixing device
dmix:CARD=Generic_1,DEV=1
HD-Audio Generic, ALC898 Digital
Direct sample mixing device
usbstream:CARD=Generic_1
HD-Audio Generic
USB Stream Output

axx@axx-xxx-RV2:~/jkm/back_end/snd_be/build$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: ALC898 Analog [ALC898 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 1: ALC898 Digital [ALC898 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0

Dom U:

axx@axx-HVM-domU:~$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default
Playback/recording through the PulseAudio sound server
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=vsnd,DEV=0
, Virtual card PCM
Direct hardware device without any conversions
plughw:CARD=vsnd,DEV=0
, Virtual card PCM
Hardware device with all software conversions
sysdefault:CARD=vsnd
, Virtual card PCM
Default Audio Device
dmix:CARD=vsnd,DEV=0
, Virtual card PCM
Direct sample mixing device
usbstream:CARD=vsnd

USB Stream Output

axx@axx-HVM-domU:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vsnd [], device 0: dev1 [Virtual card PCM]
Subdevices: 1/1
Subdevice #0: subdevice #0

  1. snd_be log: attached
    MobaXterm_Dom0_20220907_152006.txt

I have played only a 1 sec long wave file. However, log does not stop and towards the end, I can see "Ring buffer overflow"

  1. I have tried with higher buffer-size, but audio is still not coming

@jsharma80
Copy link
Author

Any pointers for this issue? What should I look at for debugging?

@al1img
Copy link
Collaborator

al1img commented Sep 14, 2022

Could you provide pulseaudio log? It can be obtained by the following document https://fedoraproject.org/wiki/How_to_debug_PulseAudio_problems.
You may need to redirect log on file or display, use --log-target parameter for pulseaudio.

Also pulseaudio config would be helpful: pulseaudio --dump-conf .

@jsharma80
Copy link
Author

Hi,

I tried snd_be in another board (which has a different SoC) and followed the same method. In this board audio is coming using alsa back end, but audio is choppy and I keep getting following log:

14.09.22 18:51:15.501 | AlsaPcm | DBG - Write to pcm device: default, size: -32
14.09.22 18:51:15.501 | AlsaPcm | WRN - Device: default, message: Broken pipe
ALSA lib pcm.c:8568:(snd_pcm_recover) underrun occurred

This issue is similar to issue #34

I have matched the buffer-size as you had suggested, but audio is still choppy. Below is the ALSA output on Dom 0 when same file is played. I have set buffer-size to 96000 (= 24000 * 2 channels * 2 bytes per sample).

amd@amd:~/Dom_U1$ sudo aplay -vv ../music.wav
Playing WAVE '../music.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 24000
period_size : 6000
period_time : 125000
tstamp_mode : NONE
tstamp_type : GETTIMEOFDAY
period_step : 1
avail_min : 6000
period_event : 0
start_threshold : 24000
stop_threshold : 24000
silence_threshold: 0
silence_size : 0
boundary : 6755399441055744000

Is the buffer-size setting correct?

@jsharma80
Copy link
Author

Could you provide pulseaudio log? It can be obtained by the following document

Sure, I will provide in the issue #42

@jsharma80
Copy link
Author

Hello,

I am able to play audio perfectly from Dom U using ALSA back end now. This is using a different codec than previously used. I had to use "sudo aplay" instead of just "aplay" in Dom U. I am currently checking why sudo is required.

Thank you for all your help.

@sj168
Copy link

sj168 commented Oct 14, 2022

Have you tried playing music with multimedia player like Rhythmbox which installed defaultly on your guest (ubuntu) system ? Is it normal?
I am trying to play music from my HVM guest (ubuntu) with Rhythmbox player (Dom 0 is also ubuntu), the music start playing with 10+ seconds delay after I click the start pushbutton, the same to stop playing. But when the DomU is android, everything seems to work fine.
But it is normal when I playing audio with hw:0,0 refers to vsnd on my guest ubuntu system instead of pulseaudio, the command is: aplay -D hw:0,0 music.wav.

@sj168
Copy link

sj168 commented Oct 14, 2022

Have you tried playing music with multimedia player like Rhythmbox which installed defaultly on your guest (ubuntu) system ? Is it normal? I am trying to play music from my HVM guest (ubuntu) with Rhythmbox player (Dom 0 is also ubuntu), the music start playing with 10+ seconds delay after I click the start pushbutton, the same to stop playing. But when the DomU is android, everything seems to work fine. But it is normal when I playing audio with hw:0,0 refers to vsnd on my guest ubuntu system instead of pulseaudio, the command is: aplay -D hw:0,0 music.wav.

Supplementary:
The snd_be compiled and communicate with alsa backend, not pulse.
vsnd = [ [ 'CARD, buffer-size=262144, short-name=VCard, long-name=Virtual sound card, sample-rates=44100, sample-formats=s16_le', 'PCM, name=vsnd', 'STREAM, unique-id=alsa<hw:1;0>, type=p', 'STREAM, unique-id=alsa<hw:1;0>, type=c' ] ]

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

3 participants