diff options
author | Mark Farrugia <mark.farrugia@fiberdyne.com.au> | 2018-11-01 12:17:10 +1100 |
---|---|---|
committer | Mark Farrugia <mark.farrugia@fiberdyne.com.au> | 2018-11-01 14:57:07 +1100 |
commit | 52db7a23a234080d3a28dfe60191c239cc04613b (patch) | |
tree | a7b2332b51d6fee70f0f8cfec245fe4ca9e8d6dc /loopback | |
parent | 0765c6c497379a9f850d15be3b3cbdaba59fe7fc (diff) |
Only expose streams mapped to audiopaths on configure() cb
When the configure() callback occurs for each audiopath, we only want
those streams that are mapped to the given audiopath to be exposed to
the audiopath. E.g. only streams mapped to loopback should be
propagated to loopback via configure() callback, rather than
all streams.
Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'loopback')
-rw-r--r-- | loopback/loopback.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/loopback/loopback.c b/loopback/loopback.c index c3e06be..9646706 100644 --- a/loopback/loopback.c +++ b/loopback/loopback.c @@ -78,6 +78,8 @@ struct loopback { struct loopback_cable *cables[MAX_STREAMS]; struct snd_pcm *pcm[MAX_STREAMS]; struct loopback_setup setup[MAX_STREAMS]; + int playback_count; + int capture_count; }; struct loopback_pcm { @@ -932,13 +934,13 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) struct snd_pcm *pcm; struct snd_kcontrol *kctl; struct loopback_setup *setup; - int dev, dev_count, idx, err; + int dev_idx, dev_count, idx, err; strcpy(card->mixername, "Loopback Mixer"); - dev_count = snd_avirt_stream_count(SNDRV_PCM_STREAM_PLAYBACK); - for (dev = 0; dev < dev_count; dev++) { - pcm = loopback->pcm[dev]; - setup = &loopback->setup[dev]; + dev_count = loopback->playback_count + loopback->capture_count; + for (dev_idx = 0; dev_idx < dev_count; dev_idx++) { + pcm = loopback->pcm[dev_idx]; + setup = &loopback->setup[dev_idx]; setup->notify = notify; setup->rate_shift = NO_PITCH; setup->format = SNDRV_PCM_FORMAT_S16_LE; @@ -948,7 +950,7 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) kctl = snd_ctl_new1(&loopback_controls[idx], loopback); if (!kctl) return -ENOMEM; - kctl->id.device = dev; + kctl->id.device = pcm->device; kctl->id.subdevice = 0; switch (idx) { case ACTIVE_IDX: @@ -1043,25 +1045,29 @@ static int loopback_proc_new(struct loopback *loopback, int cidx) } static int loopbackap_configure(struct snd_card *card, - struct config_group *snd_avirt_stream_group, - unsigned int stream_count) + struct snd_avirt_stream_array *stream_array) { - int err; - struct list_head *entry; + int err, idx; + struct snd_avirt_stream *stream; loopback = kzalloc(sizeof(struct loopback), GFP_KERNEL); if (!loopback) return -ENOMEM; loopback->card = card; + loopback->playback_count = 0; + loopback->capture_count = 0; mutex_init(&loopback->cable_lock); - list_for_each (entry, &snd_avirt_stream_group->cg_children) { - struct config_item *item = - container_of(entry, struct config_item, ci_entry); - struct snd_avirt_stream *stream = - snd_avirt_stream_from_config_item(item); - loopback->pcm[stream->device] = stream->pcm; - + for (idx = 0; idx < stream_array->count; idx++) { + stream = stream_array->streams[idx]; + if (!stream) + return -EFAULT; + loopback->pcm[loopback->playback_count + + loopback->capture_count] = stream->pcm; + if (stream->direction) + loopback->playback_count++; + else + loopback->capture_count++; AP_INFOK("stream name:%s device:%d channels:%d", stream->name, stream->device, stream->channels); } |