At Tue, 21 Aug 2012 13:37:58 +0200, Clemens Ladisch wrote:
Takashi Iwai wrote:
this is a progress report of my longstanding TODO, the channel map API implementation. I'm going to cover this at Plumbers audio uconf, so we can discuss details there, too.
I won't be there, so ...
It's a pity.
The channel mapping API provides a method for user-space to query, get and set the channel map of a PCM stream. It's required for assigning channels properly for multi-channel streams.
This doesn't handle devices with simply numbered outputs (such as many ICE1712-based devices), or cases where one PCM channel can be routed to multiple outputs. However, those devices typically have their own mixer applets, and generic applications aren't interested in configuring them.
For such devices, this is a bit hard, indeed. In theory, query should return all possible channel maps the PCM stream covers. This can be calculated somehow statically.
For getting the channel map, the driver could send a notification once when routing is changed.
snd_pcm_get_chmap() returns the currently assigned channel map for the given PCM stream. If the PCM is before prepared, it fills UNKNOWN.
So channel maps are reset when a device is reopened?
The behavior isn't defined, so far, and I don't think it has to be reset.
- WRITE OPERATION
This operation is allowed only at PCM PREPARED state. When called in other states, it shall return an error.
This sounds like an hda-intel HDMI restriction; other chips allow rerouting at any time. (And the route plugin could allow that, too.)
The only reason get/set doesn't work before hw_params is that the number of channels isn't set. In other words, before hw_params, the hardware state is still undetermined. Thus the channel map should be undetermined either.
Strictly speaking, the function can check whether hw_params channels parameter is already set to single. But, from the practical POV, it becomes easier by checking PREPARED state in the end.
thanks,
Takashi