INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Unable to play to snd-aloop output device  (Read 5602 times)

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Unable to play to snd-aloop output device
« on: February 22, 2018, 08:58:35 am »

I'm attempting to get MC to play to a loopback device. I see the following in the logs

Code: [Select]
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Opened audio device plughw:CARD=Loopback,DEV=0
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Opened device at bitdepth S16_LE
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Failed to get desired sample rate (48000): Invalid argument
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Finish (1 ms)

This log is with the PCM output format explicitly set to S16_LE (hence the 2nd line), I get the same behaviour if I set this to auto.

The error displayed is

Code: [Select]
1289689: 2211079936: Playback: CPlayerZone::JRPlaybackEngine_PlaybackError: Start
1289689: 2211079936: Playback: CPlayerZone::JRPlaybackEngine_PlaybackError: Error: Playback could not be started on the output 'ALSA' using the format
'48 kHz 2ch'.

This output format may not be supported by your hardware.  You can use DSP Studio to change the output to a compatible format.

Also, make sure that your system has a valid sound playback device and that it is properly configured in playback options.
1289689: 2211079936: Playback: CPlayerZone::JRPlaybackEngine_PlaybackError: Finish (0 ms)


the same file plays without issue using aplay

Code: [Select]
$ aplay -D plughw:CARD=Loopback,DEV=0 MeasSweep_48000_0_24000_LR_refL.wav
Playing WAVE 'MeasSweep_48000_0_24000_LR_refL.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

any ideas how to get MC to play to this device?

Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #1 on: February 22, 2018, 09:25:37 am »

I'm attempting to get MC to play to a loopback device. I see the following in the logs

Code: [Select]
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Opened audio device plughw:CARD=Loopback,DEV=0
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Opened device at bitdepth S16_LE
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Failed to get desired sample rate (48000): Invalid argument
1289688: 2166068992: Playback: CALSAPlugin::OpenALSA: Finish (1 ms)

This log is with the PCM output format explicitly set to S16_LE (hence the 2nd line), I get the same behaviour if I set this to auto.

The error displayed is

Code: [Select]
1289689: 2211079936: Playback: CPlayerZone::JRPlaybackEngine_PlaybackError: Start
1289689: 2211079936: Playback: CPlayerZone::JRPlaybackEngine_PlaybackError: Error: Playback could not be started on the output 'ALSA' using the format
'48 kHz 2ch'.

This output format may not be supported by your hardware.  You can use DSP Studio to change the output to a compatible format.

Also, make sure that your system has a valid sound playback device and that it is properly configured in playback options.
1289689: 2211079936: Playback: CPlayerZone::JRPlaybackEngine_PlaybackError: Finish (0 ms)


the same file plays without issue using aplay

Code: [Select]
$ aplay -D plughw:CARD=Loopback,DEV=0 MeasSweep_48000_0_24000_LR_refL.wav
Playing WAVE 'MeasSweep_48000_0_24000_LR_refL.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

any ideas how to get MC to play to this device?
The only thing I see here is that you are using a plughw: device. MC will NOT let ALSA do sample rate manipulation using the plughw devices. You might want to check to see what sample rates your loopback device supports then setup DSP studio to use them and not use a plughw device.

Since I really don't know much about loopback devices, it's possible that it won't work at any rate but you could give this a try.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #2 on: February 22, 2018, 10:31:00 am »

The only thing I see here is that you are using a plughw: device. MC will NOT let ALSA do sample rate manipulation using the plughw devices. You might want to check to see what sample rates your loopback device supports then setup DSP studio to use them and not use a plughw device.

Since I really don't know much about loopback devices, it's possible that it won't work at any rate but you could give this a try.
it's just another device, as far as I can see it supports

S32_LE:44100,48000,88200,96000,176400,192000

and we can see that 48kHz is ok because aplay can play that file without issue. I have tried with MC set to 48kHz or passthrough to no avail.

Which device should I try instead?
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #3 on: February 22, 2018, 12:07:52 pm »

it's just another device, as far as I can see it supports

S32_LE:44100,48000,88200,96000,176400,192000

and we can see that 48kHz is ok because aplay can play that file without issue. I have tried with MC set to 48kHz or passthrough to no avail.

Which device should I try instead?
What does the output of /usr/lib/jriver/Media\ Center\ 23/alsacap look like?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #4 on: February 22, 2018, 12:18:48 pm »

What does the output of /usr/lib/jriver/Media\ Center\ 23/alsacap look like?
it reports 44100 only on that device

Code: [Select]
Card 2, ID `Loopback', name `Loopback'
  Device 0, ID `Loopback PCM', name `Loopback PCM', 8 subdevices (8 available)
    2 channels, sampling rates 44100 Hz
    Sample formats: S32_LE
      Subdevice 0, name `subdevice #0'
      Subdevice 1, name `subdevice #1'
      Subdevice 2, name `subdevice #2'
      Subdevice 3, name `subdevice #3'
      Subdevice 4, name `subdevice #4'
      Subdevice 5, name `subdevice #5'
      Subdevice 6, name `subdevice #6'
      Subdevice 7, name `subdevice #7'
  Device 1, ID `Loopback PCM', name `Loopback PCM', 8 subdevices (8 available)
    1..32 channels, sampling rates 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000 Hz
    Sample formats: S16_LE, S16_BE, S32_LE, S32_BE, FLOAT_LE, FLOAT_BE
      Subdevice 0, name `subdevice #0'
      Subdevice 1, name `subdevice #1'
      Subdevice 2, name `subdevice #2'
      Subdevice 3, name `subdevice #3'
      Subdevice 4, name `subdevice #4'
      Subdevice 5, name `subdevice #5'
      Subdevice 6, name `subdevice #6'
      Subdevice 7, name `subdevice #7'

what is it reading to get that info?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #5 on: February 22, 2018, 12:23:10 pm »

and I can confirm it does play a 44.1kHz file back ok
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #6 on: February 22, 2018, 02:44:47 pm »

it reports 44100 only on that device

Code: [Select]
Card 2, ID `Loopback', name `Loopback'
  Device 0, ID `Loopback PCM', name `Loopback PCM', 8 subdevices (8 available)
    2 channels, sampling rates 44100 Hz
    Sample formats: S32_LE
      Subdevice 0, name `subdevice #0'
      Subdevice 1, name `subdevice #1'
      Subdevice 2, name `subdevice #2'
      Subdevice 3, name `subdevice #3'
      Subdevice 4, name `subdevice #4'
      Subdevice 5, name `subdevice #5'
      Subdevice 6, name `subdevice #6'
      Subdevice 7, name `subdevice #7'
  Device 1, ID `Loopback PCM', name `Loopback PCM', 8 subdevices (8 available)
    1..32 channels, sampling rates 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000 Hz
    Sample formats: S16_LE, S16_BE, S32_LE, S32_BE, FLOAT_LE, FLOAT_BE
      Subdevice 0, name `subdevice #0'
      Subdevice 1, name `subdevice #1'
      Subdevice 2, name `subdevice #2'
      Subdevice 3, name `subdevice #3'
      Subdevice 4, name `subdevice #4'
      Subdevice 5, name `subdevice #5'
      Subdevice 6, name `subdevice #6'
      Subdevice 7, name `subdevice #7'

what is it reading to get that info?
Directly from ALSA. The only thing I added was the test for sample rates.
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #7 on: February 22, 2018, 02:46:35 pm »

and I can confirm it does play a 44.1kHz file back ok
The multirate device could just be a pseudo device reflecting the resampler.

Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #8 on: February 22, 2018, 02:49:53 pm »

The multirate device could just be a pseudo device reflecting the resampler.
FWIW my previous output (which reported all the sample rates) came from https://github.com/ronalde/mpd-configure/blob/master/alsa-capabilities

What does MC do in this case? Does it attempt to play anyway or just report the error?
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #9 on: February 22, 2018, 04:28:03 pm »

FWIW my previous output (which reported all the sample rates) came from https://github.com/ronalde/mpd-configure/blob/master/alsa-capabilities

What does MC do in this case? Does it attempt to play anyway or just report the error?
It depends on the setting of the audio advanced option "Auto configure on playback failure". It will guess a sample rate if playback fails.
Best to use DSP studio to set the rate. The important thing to know is that plughw as a default implies using ALSA resampling which we don't allow.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #10 on: February 22, 2018, 04:52:11 pm »

It depends on the setting of the audio advanced option "Auto configure on playback failure". It will guess a sample rate if playback fails.
Best to use DSP studio to set the rate. The important thing to know is that plughw as a default implies using ALSA resampling which we don't allow.
OK. ALSA devices have confused me for many many years but I'll ask anyway :) Any idea why aplay works to same device?
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #11 on: February 23, 2018, 08:57:17 am »

OK. ALSA devices have confused me for many many years but I'll ask anyway :) Any idea why aplay works to same device?
Because it's not disabling re-sampling when opening the device.
It looks to me from what you've posted that the native sample rate of that device is 44.1k.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #12 on: February 23, 2018, 09:39:40 am »

Because it's not disabling re-sampling when opening the device.
It looks to me from what you've posted that the native sample rate of that device is 44.1k.
I don't think that's true

for example if I do this in one terminal

Code: [Select]
$ aplay -D hw:CARD=Loopback,DEV=0 --disable-resample Sine_1000.wav
Playing WAVE 'Sine_1000.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

then in another one

Code: [Select]
$ cat /proc/asound/card2/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 6000
buffer_size: 24000

I don't see any evidence, apart from in MC, that this is a 44.1kHz device

actually now I try this again I see alsacap reports

Code: [Select]
..32 channels, sampling rates 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000 Hz

no idea what is going on there, anyway at least I now know how to work out how MC sees the device capabilities. Thanks.
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13452
Re: Unable to play to snd-aloop output device
« Reply #13 on: February 23, 2018, 09:52:47 am »

I don't think that's true

for example if I do this in one terminal

Code: [Select]
$ aplay -D hw:CARD=Loopback,DEV=0 --disable-resample Sine_1000.wav
Playing WAVE 'Sine_1000.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

then in another one

Code: [Select]
$ cat /proc/asound/card2/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 6000
buffer_size: 24000

I don't see any evidence, apart from in MC, that this is a 44.1kHz device

actually now I try this again I see alsacap reports

Code: [Select]
..32 channels, sampling rates 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000 Hz

no idea what is going on there, anyway at least I now know how to work out how MC sees the device capabilities. Thanks.

MC simply asks ALSA what the suggestions are for opening the devices. That's where the list of audio devices in MC comes from.
It starts with S32_LE and works it's way down the format list until one is successful when opening the device (auto mode) which you can override by specifying a format.
Sets the period and buffer times (perhaps you need to make those smaller)?
Uses the sample rate of the file when opening the device unless DSP studio is specifying something different and also disables device resampling. It's pretty straightforward.
I don't know why your loopback device shows up twice with different sample rates.
I'm suspicious that aplay with the sample rate disable flag isn't working as advertised on the device you are choosing.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3932
Re: Unable to play to snd-aloop output device
« Reply #14 on: February 23, 2018, 10:16:14 am »

I'm suspicious that aplay with the sample rate disable flag isn't working as advertised on the device you are choosing.
not sure how to tell if that is happening, I guess I could play and record a dirac pulse and see if it comes out untouched
Logged
Pages: [1]   Go Up