0

For the last few weeks I have been reading into the ALSA documentations, but still cannot figure this out so my question: Is there a function be able to derive the current playback audio?

E.g.: If a new song is played, I want to first get the bitrate before ALSA does anything (set clk dividers etc.).

This is on an am335x embedded board, so with aSoC.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
Lars
  • 23
  • 5
  • "a function be able to derive current playback audio" ? Could you be more explicit about this ? "I want to get the bitrate"… how is this related to your previous question ? what type of file (codec) would you be playing ? + "a function" ? what do you mean ? a plugin ? some alsa-lib function ? – MC68020 Nov 20 '22 at 00:18
  • Additionally : What do you mean when tagging your question "system-programming" ? Are you intending to develop a driver ? For what OS ? – MC68020 Nov 20 '22 at 00:22
  • I don't think you really mean bit rate - that does not make very much sense in this context. Without having set up the hardware in terms of clocking, there would be no sampling rate, or bit rate, because well there is no working audio hardware. It's really not clear what you're asking, which *might* be because you're a little confused about audio hardware and sound systems in general. Can you describe what you need to know, and for what purpose, in other words? – Marcus Müller Nov 20 '22 at 01:14
  • @MC68020 So, what I want to actually do is take a certain action when a bitrate is played. For example, if a 44.1Khz rate playback is going I want to switch a hardware clock, when then playing 48Khz I want to switch a hardware clock again. I am really talking about the kernel programming here, I know it check pcm_open_file and asoc_open_file, but here the rate parameter is not yet filled in, so I cannot derive it. I want to do some additional changes to the kernel under the clause of the bitrate, current problem is I do not know where I can get this from. – Lars Nov 20 '22 at 08:48
  • @MarcusMüller So currently my hardware audio is already setup and playing. It is a WM8776 on a AM335X board. I want now however to change the rate clock which is at startup at 11,96mhz 44.1/88.2/176.4. Now wat I want is when I play a 48/96/192 to change this clock (I have a switching clock which is ~24.5mhz). I now how I need to do this, so this is already out of the way. The problem I am facing now is I am trying to find out where alsa decides not to play this audio (I turned of resampling). If i know where it says: "96khz I cannot play this" I can change clock & gpio here so it can play – Lars Nov 20 '22 at 08:54
  • @MC68020 What I basically mean by function, is there some function for example: snd_pcm_get_playback which returns me the current setup of the playbacked audio, so rate, channels, etc. So a alsa-lib kernel version. The OS is debian, but since changes should be in kernel it should be quite universal and the OS should not matter, any help will really be appreciated, i am kind of lost on this ALSA on an embedded board, as it seems to differ a bit from normal PC platform – Lars Nov 20 '22 at 08:55
  • OK, I see. I had not remembered your username. So this question is a continuation of https://unix.stackexchange.com/questions/724230/change-clock-bitrate-alsa-pcm-at-runtime-am335x isn't it ? – MC68020 Nov 20 '22 at 09:08
  • @MC68020 Yes, indeed I have read the ALSA docs through and at some points I thought ah, this has to be the function, but then it was not in the kernel so I got lost. The asoc_pcm_open has a runtime->rate struct/variable (again a moment where i thought ah this must be it), but this is always empty. – Lars Nov 20 '22 at 09:22

0 Answers0