To be honest I don’t know, this audio stuff is kind of mystic area. Maybe @TheCoolest have more idea about it.
i tried aplay -D default:CARD=USBStreamer --dump-hw-params ~/downloads/test.wav
HW Params of device “default:CARD=USBStreamer”:
ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
SUBFORMAT: STD
SAMPLE_BITS: [4 64]
FRAME_BITS: [4 640000]
CHANNELS: [1 10000]
RATE: [4000 4294967295)
PERIOD_TIME: (21333 21334)
PERIOD_SIZE: (85 91628833)
PERIOD_BYTES: (42 4294967295)
PERIODS: (0 17247242)
BUFFER_TIME: [1 4294967295]
BUFFER_SIZE: [170 1466015503]
BUFFER_BYTES: [85 4294967295]
TICK_TIME: ALL
It seems like the devices accepts everything
There is also a small tool alsa-query: Print hardware capabilities of ALSA device · GitHub maybe someone can compile it for my Amlogic S912 box with CoreELEC 9.2.8 but i think it will report the same.
AESinkALSA.cpp is trying all formats on the hardware with snd_pcm_hw_params_set_format(m_pcm, hw_params, fmt):
switch (format)
{
case AE_FMT_U8 : return SND_PCM_FORMAT_U8;
case AE_FMT_S16NE : return SND_PCM_FORMAT_S16;
case AE_FMT_S16LE : return SND_PCM_FORMAT_S16_LE;
case AE_FMT_S16BE : return SND_PCM_FORMAT_S16_BE;
case AE_FMT_S24NE4: return SND_PCM_FORMAT_S24;
#ifdef BIG_ENDIAN
case AE_FMT_S24NE3: return SND_PCM_FORMAT_S24_3BE;
#else
case AE_FMT_S24NE3: return SND_PCM_FORMAT_S24_3LE;
#endif
case AE_FMT_S32NE : return SND_PCM_FORMAT_S32;
case AE_FMT_FLOAT : return SND_PCM_FORMAT_FLOAT;default: return SND_PCM_FORMAT_UNKNOWN;
}
I tried all formats on the console with speaker-test. You can see that speaker-test will call snd_pcm_hw_params_set_format too here: https://github.com/bear24rw/alsa-utils/blob/master/speaker-test/speaker-test.c. Only formats U8 and S24 are not working on my usb device with speaker-test. I think that snd_pcm_hw_params_set_format(m_pcm, hw_params, fmt) in AESinkALSA.cpp is passing a parameter in hw_params that my device don’t likes.
Sorry for so many posts When i run speaker-test to the device surround71:CARD:USBStreamer,DEV=0 it fails.
speaker-test 1.1.9
Playback device is surround71:CARD=USBStreamer,DEV=0
Stream parameters are 96000Hz, S24_3LE, 8 channels
Sine wave rate is 440.0000Hz
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument
Maybe snd_pcm_hw_params_set_format(m_pcm, hw_params, fmt) in speaker-test is passing DEV=0 as parameter. If audioengine in KODI is doing the same i found the problem.
aplay -L is showing all alsa audio devices. I have to modify a config to remove the DEV=0 parameter so that all device with surroundXX:CARD=USBStreamer,DEV=0 are changed to surroundXX:CARD=USBStreamer. How can i achieve that?
I downloaded, modified and compiled the source code of CoreELEC. What’s the best way to try kodi.bin without flashing the firmware?
I found a solution and will post a patch for Kodi AudioEngine asap. AESinkALSA.cpp is doing some channel remapping for symmetrical layouts but my device has an asymmetrical layout because of the BC channel. So i have to modify GetAlternateLayoutForm function
/* asymmetrical layouts */
else if (info.HasChannel(AE_CH_BC) && !info.HasChannel(AE_CH_SR))
{
altLayout = info;
altLayout.ReplaceChannel(AE_CH_BC, AE_CH_SR);
}
else if (info.HasChannel(AE_CH_BC) && !info.HasChannel(AE_CH_SL))
{
altLayout = info;
altLayout.ReplaceChannel(AE_CH_BC, AE_CH_SL);
}
With this patch everything works!!! I also asked the USBStreamer device developers to replace the channel layout in the next firmware.
Ok, here is the final patch. I also have to remap some channels because last two channels are on the toslink output and i want channels 0-7 on the is2 outputs. Additional i had to block surroundXX devices in ~/config/asound.conf so that kodi falls back to “sysdefault:CARD=USBStreamer”.
--- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2020-10-25 10:03:27.000000000 +0100
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2020-10-25 10:03:27.000000000 +0100
@@ -162,7 +162,7 @@
// According to CEA-861-D only RL and RR are known. In case of a format having SL and SR channels
// but no BR BL channels, we use the wide map in order to open only the num of channels really
// needed.
- if (format.m_channelLayout.HasChannel(AE_CH_SL) && !format.m_channelLayout.HasChannel(AE_CH_BL))
+ if (format.m_channelLayout.HasChannel(AE_CH_SL) && !format.m_channelLayout.HasChannel(AE_CH_BL) && format.m_channelLayout.HasChannel(AE_CH_SR) && !format.m_channelLayout.HasChannel(AE_CH_BR))
{
channelMap = LegacyALSAChannelMap51Wide;
}
@@ -387,6 +387,20 @@
altLayout.ReplaceChannel(AE_CH_BR, AE_CH_SR);
}
}
+ /* asymmetrical layouts */
+ else
+ {
+ /* miniDSP USB-Streamer 10 channels (CH0 - CH9) has a back center and no side-right, fix it. set side-left and side right to CH6 and CH7, set FROC and FLOC to CH8 and CH9 (CH8 and CH9 is toslink output!) */
+ if (info.HasChannel(AE_CH_BC) && !info.HasChannel(AE_CH_SR))
+ {
+ altLayout = info;
+ altLayout.ReplaceChannel(AE_CH_BC, AE_CH_FROC);
+ altLayout.ReplaceChannel(AE_CH_SL, AE_CH_FLOC);
+ altLayout.ReplaceChannel(AE_CH_FROC, AE_CH_SR);
+ altLayout.ReplaceChannel(AE_CH_FLOC, AE_CH_SL);
+ }
+ }
+
return altLayout;
}
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.