void DeviceDescriptor::toAudioPort(struct audio_port *port) const { ALOGV("DeviceDescriptor::toAudioPort() handle %d type %x", mId, mDeviceType); AudioPort::toAudioPort(port); port->id = mId; toAudioPortConfig(&port->active_config); port->ext.device.type = mDeviceType; port->ext.device.hw_module = mModule->mHandle; strncpy(port->ext.device.address, mAddress.string(), AUDIO_DEVICE_MAX_ADDRESS_LEN); }
void SwAudioOutputDescriptor::toAudioPort( struct audio_port *port) const { ALOG_ASSERT(!isDuplicated(), "toAudioPort() called on duplicated output %d", mIoHandle); AudioOutputDescriptor::toAudioPort(port); toAudioPortConfig(&port->active_config); port->ext.mix.handle = mIoHandle; port->ext.mix.latency_class = mFlags & AUDIO_OUTPUT_FLAG_FAST ? AUDIO_LATENCY_LOW : AUDIO_LATENCY_NORMAL; }
status_t AudioPortConfig::applyAudioPortConfig(const struct audio_port_config *config, struct audio_port_config *backupConfig) { struct audio_port_config localBackupConfig; status_t status = NO_ERROR; localBackupConfig.config_mask = config->config_mask; toAudioPortConfig(&localBackupConfig); sp<AudioPort> audioport = getAudioPort(); if (audioport == 0) { status = NO_INIT; goto exit; } status = audioport->checkExactAudioProfile(config->sample_rate, config->channel_mask, config->format); if (status != NO_ERROR) { goto exit; } if (config->config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) { mSamplingRate = config->sample_rate; } if (config->config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) { mChannelMask = config->channel_mask; } if (config->config_mask & AUDIO_PORT_CONFIG_FORMAT) { mFormat = config->format; } if (config->config_mask & AUDIO_PORT_CONFIG_GAIN) { status = audioport->checkGain(&config->gain, config->gain.index); if (status != NO_ERROR) { goto exit; } mGain = config->gain; } exit: if (status != NO_ERROR) { applyAudioPortConfig(&localBackupConfig); } if (backupConfig != NULL) { *backupConfig = localBackupConfig; } return status; }