Lines Matching refs:patch

69 /* Connect a patch between several source and sink ports */
70 status_t AudioFlinger::createAudioPatch(const struct audio_patch *patch,
75 return mPatchPanel->createAudioPatch(patch, handle);
80 /* Disconnect a patch */
138 /* Connect a patch between several source and sink ports */
139 status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *patch,
145 if (handle == NULL || patch == NULL) {
149 patch->num_sources, patch->num_sinks, *handle);
154 if (patch->num_sources == 0 || patch->num_sources > AUDIO_PATCH_PORTS_MAX ||
155 (patch->num_sinks == 0 && patch->num_sources != 2) ||
156 patch->num_sinks > AUDIO_PATCH_PORTS_MAX) {
160 // only the audio policy manager can request a patch creation with 2 sources.
161 if (patch->num_sources > 2) {
168 ALOGV("createAudioPatch() removing patch handle %d", *handle);
171 // free resources owned by the removed patch if applicable
172 // 1) if a software patch is present, release the playback and capture threads and
180 // 2) if the new patch and old patch source or sink are devices from different
186 ((patch->sources[0].type != AUDIO_PORT_TYPE_DEVICE) ||
188 patch->sources[0].ext.device.hw_module))) {
190 } else if ((patch->num_sinks == 0) ||
192 ((patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE) ||
194 patch->sinks[0].ext.device.hw_module)))) {
195 // Note on (patch->num_sinks == 0): this situation should not happen as
197 // in case, systematically clear the HAL patch.
218 Patch *newPatch = new Patch(patch);
220 switch (patch->sources[0].type) {
222 audio_module_handle_t srcModule = patch->sources[0].ext.device.hw_module;
230 for (unsigned int i = 0; i < patch->num_sinks; i++) {
232 if ((patch->sinks[i].type == AUDIO_PORT_TYPE_MIX ||
233 patch->sinks[i].ext.mix.hw_module != srcModule) &&
234 patch->num_sinks > 1) {
239 if (patch->sinks[i].type != patch->sinks[0].type) {
240 ALOGW("createAudioPatch() different sink types in same patch not supported");
247 // - special patch request with 2 sources (reuse one existing output mix) OR
251 if ((patch->num_sources == 2) ||
252 ((patch->sinks[0].type == AUDIO_PORT_TYPE_DEVICE) &&
253 ((patch->sinks[0].ext.device.hw_module != srcModule) ||
255 if (patch->num_sources == 2) {
256 if (patch->sources[1].type != AUDIO_PORT_TYPE_MIX ||
257 (patch->num_sinks != 0 && patch->sinks[0].ext.device.hw_module !=
258 patch->sources[1].ext.mix.hw_module)) {
265 audioflinger->checkPlaybackThread_l(patch->sources[1].ext.mix.handle);
274 audio_devices_t device = patch->sinks[0].ext.device.type;
275 String8 address = String8(patch->sinks[0].ext.device.address);
278 patch->sinks[0].ext.device.hw_module,
291 audio_devices_t device = patch->sources[0].ext.device.type;
292 String8 address = String8(patch->sources[0].ext.device.address);
296 if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) {
297 config.sample_rate = patch->sources[0].sample_rate;
301 if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
302 config.channel_mask = patch->sources[0].channel_mask;
307 if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_FORMAT) {
308 config.format = patch->sources[0].format;
326 status = createPatchConnections(newPatch, patch);
331 if (patch->sinks[0].type == AUDIO_PORT_TYPE_MIX) {
333 patch->sinks[0].ext.mix.handle);
336 patch->sinks[0].ext.mix.handle);
340 status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle);
349 patch->num_sources,
350 patch->sources,
351 patch->num_sinks,
352 patch->sinks,
358 audio_module_handle_t srcModule = patch->sources[0].ext.mix.hw_module;
367 for (unsigned int i = 0; i < patch->num_sinks; i++) {
368 if (patch->sinks[i].type != AUDIO_PORT_TYPE_DEVICE) {
370 patch->sinks[i].type);
375 if (patch->sinks[i].ext.device.hw_module != srcModule) {
379 type |= patch->sinks[i].ext.device.type;
382 audioflinger->checkPlaybackThread_l(patch->sources[0].ext.mix.handle);
385 patch->sources[0].ext.mix.handle);
396 status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle);
409 ALOGV("createAudioPatch() added new patch handle %d halHandle %d", *handle, halHandle);
417 status_t AudioFlinger::PatchPanel::createPatchConnections(Patch *patch,
420 // create patch from source device to record thread input
426 patch->mRecordThread->getAudioPortConfig(&subPatch.sinks[0]);
429 status_t status = createAudioPatch(&subPatch, &patch->mRecordPatchHandle);
431 patch->mRecordPatchHandle = AUDIO_PATCH_HANDLE_NONE;
435 // create patch from playback thread output to sink device
437 patch->mPlaybackThread->getAudioPortConfig(&subPatch.sources[0]);
439 status = createAudioPatch(&subPatch, &patch->mPlaybackPatchHandle);
441 patch->mPlaybackPatchHandle = AUDIO_PATCH_HANDLE_NONE;
445 patch->mPlaybackPatchHandle = AUDIO_PATCH_HANDLE_NONE;
449 size_t playbackFrameCount = patch->mPlaybackThread->frameCount();
451 size_t recordFramecount = patch->mRecordThread->frameCount();
461 uint32_t channelCount = patch->mPlaybackThread->channelCount();
463 audio_channel_mask_t outChannelMask = patch->mPlaybackThread->channelMask();
464 uint32_t sampleRate = patch->mPlaybackThread->sampleRate();
465 audio_format_t format = patch->mPlaybackThread->format();
467 patch->mPatchRecord = new RecordThread::PatchRecord(
468 patch->mRecordThread.get(),
475 if (patch->mPatchRecord == 0) {
478 status = patch->mPatchRecord->initCheck();
482 patch->mRecordThread->addPatchRecord(patch->mPatchRecord);
486 patch->mPatchTrack = new PlaybackThread::PatchTrack(
487 patch->mPlaybackThread.get(),
493 patch->mPatchRecord->buffer(),
495 if (patch->mPatchTrack == 0) {
498 status = patch->mPatchTrack->initCheck();
502 patch->mPlaybackThread->addPatchTrack(patch->mPatchTrack);
505 patch->mPatchRecord->setPeerProxy(patch->mPatchTrack.get());
506 patch->mPatchTrack->setPeerProxy(patch->mPatchRecord.get());
509 patch->mPatchRecord->start(AudioSystem::SYNC_EVENT_NONE, AUDIO_SESSION_NONE);
510 patch->mPatchTrack->start();
515 void AudioFlinger::PatchPanel::clearPatchConnections(Patch *patch)
522 ALOGV("clearPatchConnections() patch->mRecordPatchHandle %d patch->mPlaybackPatchHandle %d",
523 patch->mRecordPatchHandle, patch->mPlaybackPatchHandle);
525 if (patch->mPatchRecord != 0) {
526 patch->mPatchRecord->stop();
528 if (patch->mPatchTrack != 0) {
529 patch->mPatchTrack->stop();
531 if (patch->mRecordPatchHandle != AUDIO_PATCH_HANDLE_NONE) {
532 releaseAudioPatch(patch->mRecordPatchHandle);
533 patch->mRecordPatchHandle = AUDIO_PATCH_HANDLE_NONE;
535 if (patch->mPlaybackPatchHandle != AUDIO_PATCH_HANDLE_NONE) {
536 releaseAudioPatch(patch->mPlaybackPatchHandle);
537 patch->mPlaybackPatchHandle = AUDIO_PATCH_HANDLE_NONE;
539 if (patch->mRecordThread != 0) {
540 if (patch->mPatchRecord != 0) {
541 patch->mRecordThread->deletePatchRecord(patch->mPatchRecord);
543 audioflinger->closeInputInternal_l(patch->mRecordThread);
545 if (patch->mPlaybackThread != 0) {
546 if (patch->mPatchTrack != 0) {
547 patch->mPlaybackThread->deletePatchTrack(patch->mPatchTrack);
550 if (patch->mAudioPatch.num_sources != 2) {
551 audioflinger->closeOutputInternal_l(patch->mPlaybackThread);
554 if (patch->mRecordThread != 0) {
555 if (patch->mPatchRecord != 0) {
556 patch->mPatchRecord.clear();
558 patch->mRecordThread.clear();
560 if (patch->mPlaybackThread != 0) {
561 if (patch->mPatchTrack != 0) {
562 patch->mPatchTrack.clear();
564 patch->mPlaybackThread.clear();
569 /* Disconnect a patch */
592 struct audio_patch *patch = &removedPatch->mAudioPatch;
594 switch (patch->sources[0].type) {
596 audio_module_handle_t srcModule = patch->sources[0].ext.device.hw_module;
610 if (patch->sinks[0].type == AUDIO_PORT_TYPE_MIX) {
612 patch->sinks[0].ext.mix.handle);
615 patch->sinks[0].ext.mix.handle);
631 audio_module_handle_t srcModule = patch->sources[0].ext.mix.hw_module;
639 audioflinger->checkPlaybackThread_l(patch->sources[0].ext.mix.handle);
642 patch->sources[0].ext.mix.handle);