diff options
Diffstat (limited to 'loopback/loopback.c')
-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); } |