diff options
author | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-12-17 22:15:56 +0100 |
---|---|---|
committer | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-12-18 15:05:19 +0100 |
commit | 43ae0339da06a208271420d8d43a0d84ce94f525 (patch) | |
tree | 446ae58b68ff83fea8b923b374202c21a59531a9 | |
parent | 23cda61198d29010f5a86116b88b8b48eea5e797 (diff) |
streams: inherits parameters from sourcesandbox/tbultel/bluealsa
The capture parameters of a stream must be the ones of
the capture source. The number of channel must typically
match the one of the source microphone, else the configuration
fails
Change-Id: Ie8d0d85a65cb4a94a8698d1015d730e3c2a8b6a5
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
-rw-r--r-- | plugins/alsa/alsa-api-pcm.c | 20 | ||||
-rw-r--r-- | plugins/alsa/alsa-api-streams.c | 27 |
2 files changed, 28 insertions, 19 deletions
diff --git a/plugins/alsa/alsa-api-pcm.c b/plugins/alsa/alsa-api-pcm.c index cc2817d..e1f1710 100644 --- a/plugins/alsa/alsa-api-pcm.c +++ b/plugins/alsa/alsa-api-pcm.c @@ -581,14 +581,6 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm goto fail_pcm_sndcard; } - // check sndcard accepts params - pcm->sndcard->params = ApiPcmSetParams(mixer, pcm->uid, paramsJ); - if (!pcm->sndcard->params) { - AFB_ApiError(mixer->api, "%s: hal=%s Fail to set params sndcard uid=%s params=%s", - __func__, uid, pcm->uid, json_object_get_string(paramsJ)); - goto fail_pcm_sndcard_ctl; - } - if (direction == SND_PCM_STREAM_PLAYBACK) { if (!sinkJ) { AFB_ApiError(mixer->api, "%s: hal=%s SND_PCM_STREAM_PLAYBACK require sinks args=%s", @@ -626,7 +618,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm case json_type_object: channel = ProcessOneChannel(mixer, pcm->uid, channelsJ); if (channel == NULL) { - goto fail_pcm_sndcard_ctl; + goto fail_pcm_channels; } pcm->nbChannels++; @@ -653,6 +645,16 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm } } + // check sndcard accepts params + pcm->sndcard->params = ApiPcmSetParams(mixer, pcm->uid, paramsJ); + if (!pcm->sndcard->params) { + AFB_ApiError(mixer->api, "%s: hal=%s Fail to set params sndcard uid=%s params=%s", + __func__, uid, pcm->uid, json_object_get_string(paramsJ)); + goto fail_pcm_sndcard_ctl; + } + + pcm->sndcard->params->channels = pcm->nbChannels; + if (controlsJ) { json_object *volJ = NULL, *muteJ = NULL; error = wrap_json_unpack(controlsJ, "{s?o,s?o !}" diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c index d9d9667..c4bbbc3 100644 --- a/plugins/alsa/alsa-api-streams.c +++ b/plugins/alsa/alsa-api-streams.c @@ -200,8 +200,8 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT int volNumid = 0; AFB_ApiDebug(mixer->api, - "%s, stream %s %s, source %s, sink %s, mute %d", - __func__,uid, stream->uid, stream->source, stream->sink, stream->mute); + "NEW STREAM stream %s %s, source %s, sink %s, mute %d", + uid, stream->uid, stream->source, stream->sink, stream->mute); loopDev = ApiLoopFindSubdev(mixer, stream->uid, stream->source, &loop); if (loopDev) { @@ -248,10 +248,20 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT goto OnErrorExit; } + if (captureCard->params) { + if (stream->params) { + + AFB_ApiInfo(mixer->api,"%s: Stream %s inherits from capture %s parameters !", + __func__, stream->uid, captureCard->cid.cardid); + + memcpy(stream->params, captureCard->params, sizeof(AlsaPcmHwInfoT)); + } + } + capturePcm->closeAtDeletion = true; capturePcm->mute = stream->mute; - AFB_ApiDebug(mixer->api,"%s: PCM opened !", __func__); + AFB_ApiDebug(mixer->api,"%s: Capture PCM opened !", __func__); // Registry capturePcm PCM for active/pause event if (loopDev && loopDev->numid) { @@ -310,11 +320,6 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT } - - // retrieve channel count from route and push it to stream - - stream->params->channels = zone->ccount; - // create mute control and Registry it as pause/resume ctl) if (asprintf(&runName, "pause-%s", stream->uid) == -1) { SOFTMIXER_NOMEM(mixer->api); @@ -371,14 +376,16 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT if ((zone->params->rate != stream->params->rate) || (zone->params->format != stream->params->format)) { AFB_ApiNotice(mixer->api, - "%s: Instanciate a RATE CONVERTER (stream [%d,%s(%d)], zone [%d,%s(%d)])", + "%s: Instanciate a RATE CONVERTER (stream [%d,%s(%d),%d channels], zone [%d,%s(%d), %d channels])", __func__, stream->params->rate, stream->params->formatS, stream->params->format, + stream->params->channels, zone->params->rate, zone->params->formatS, - zone->params->format); + zone->params->format, + zone->params->channels); char *rateName; if (asprintf(&rateName, "rate-%s", stream->uid) == -1) { |