-int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
- bitset_t *client_vmask)
-{
- snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug);
- if (plugin == NULL) {
- return 0;
- } else {
- int schannels = plugin->dst_format.channels;
- bitset_t bs[bitset_size(schannels)];
- bitset_t *srcmask;
- bitset_t *dstmask = bs;
- int err;
- bitset_one(dstmask, schannels);
- if (plugin == NULL) {
- bitset_and(client_vmask, dstmask, schannels);
- return 0;
- }
- while (1) {
- err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
- if (err < 0)
- return err;
- dstmask = srcmask;
- if (plugin->prev == NULL)
- break;
- plugin = plugin->prev;
- }
- bitset_and(client_vmask, dstmask, plugin->src_format.channels);
- return 0;
- }
-}
-
-int snd_pcm_plug_capture_channels_mask(snd_pcm_plug_t *plug,
- bitset_t *client_vmask)
-{
- snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug);
- if (plugin == NULL) {
- return 0;
- } else {
- int schannels = plugin->src_format.channels;
- bitset_t bs[bitset_size(schannels)];
- bitset_t *srcmask = bs;
- bitset_t *dstmask;
- int err;
- bitset_one(srcmask, schannels);
- while (1) {
- err = plugin->dst_channels_mask(plugin, srcmask, &dstmask);
- if (err < 0)
- return err;
- srcmask = dstmask;
- if (plugin->next == NULL)
- break;
- plugin = plugin->next;
- }
- bitset_and(client_vmask, srcmask, plugin->dst_format.channels);
- return 0;
- }
-}
-
-static int snd_pcm_plug_playback_disable_useless_channels(snd_pcm_plug_t *plug,
- snd_pcm_plugin_channel_t *src_channels)
-{
- snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug);
- unsigned int nchannels = plugin->src_format.channels;
- bitset_t bs[bitset_size(nchannels)];
- bitset_t *srcmask = bs;
- int err;
- unsigned int channel;
- for (channel = 0; channel < nchannels; channel++) {
- if (src_channels[channel].enabled)
- bitset_set(srcmask, channel);
- else
- bitset_reset(srcmask, channel);
- }
- err = snd_pcm_plug_playback_channels_mask(plug, srcmask);
- if (err < 0)
- return err;
- for (channel = 0; channel < nchannels; channel++) {
- if (!bitset_get(srcmask, channel))
- src_channels[channel].enabled = 0;
- }
- return 0;
-}
-
-static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug,
- snd_pcm_plugin_channel_t *src_channels,
- snd_pcm_plugin_channel_t *client_channels)
-{
- snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug);
- unsigned int nchannels = plugin->dst_format.channels;
- bitset_t bs[bitset_size(nchannels)];
- bitset_t *dstmask = bs;
- bitset_t *srcmask;
- int err;
- unsigned int channel;
- for (channel = 0; channel < nchannels; channel++) {
- if (client_channels[channel].enabled)
- bitset_set(dstmask, channel);
- else
- bitset_reset(dstmask, channel);
- }
- while (plugin) {
- err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
- if (err < 0)
- return err;
- dstmask = srcmask;
- plugin = plugin->prev;
- }
- plugin = snd_pcm_plug_first(plug);
- nchannels = plugin->src_format.channels;
- for (channel = 0; channel < nchannels; channel++) {
- if (!bitset_get(dstmask, channel))
- src_channels[channel].enabled = 0;
- }
- return 0;
-}
-
-snd_pcm_sframes_t snd_pcm_plug_write_transfer(snd_pcm_plug_t *plug, snd_pcm_plugin_channel_t *src_channels, snd_pcm_uframes_t size)