void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile, struct pcm_config * config) { ALOGV("proxy_prepare()"); proxy->profile = profile; #ifdef LOG_PCM_PARAMS log_pcm_config(config, "proxy_setup()"); #endif proxy->alsa_config.format = config->format != PCM_FORMAT_INVALID && profile_is_format_valid(profile, config->format) ? config->format : profile->default_config.format; proxy->alsa_config.rate = config->rate != 0 && profile_is_sample_rate_valid(profile, config->rate) ? config->rate : profile->default_config.rate; proxy->alsa_config.channels = config->channels != 0 && profile_is_channel_count_valid(profile, config->channels) ? config->channels : profile->default_config.channels; proxy->alsa_config.period_count = profile->default_config.period_count; proxy->alsa_config.period_size = profile_get_period_size(proxy->profile, proxy->alsa_config.rate); // Hack for USB accessory audio. // Here we set the correct value for period_count if tinyalsa fails to get it from the // f_audio_source driver. if (proxy->alsa_config.period_count == 0) { proxy->alsa_config.period_count = 4; } proxy->pcm = NULL; }
void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile, struct pcm_config * config) { ALOGV("proxy_prepare(c:%d, d:%d)", profile->card, profile->device); proxy->profile = profile; #ifdef LOG_PCM_PARAMS log_pcm_config(config, "proxy_setup()"); #endif proxy->alsa_config.format = config->format != PCM_FORMAT_INVALID && profile_is_format_valid(profile, config->format) ? config->format : profile->default_config.format; proxy->alsa_config.rate = config->rate != 0 && profile_is_sample_rate_valid(profile, config->rate) ? config->rate : profile->default_config.rate; proxy->alsa_config.channels = config->channels != 0 && profile_is_channel_count_valid(profile, config->channels) ? config->channels : profile->default_config.channels; proxy->alsa_config.period_count = profile->default_config.period_count; proxy->alsa_config.period_size = profile_get_period_size(proxy->profile, proxy->alsa_config.rate); // Hack for USB accessory audio. // Here we set the correct value for period_count if tinyalsa fails to get it from the // f_audio_source driver. if (proxy->alsa_config.period_count == 0) { proxy->alsa_config.period_count = 4; } proxy->pcm = NULL; // config format should be checked earlier against profile. if (config->format >= 0 && (size_t)config->format < ARRAY_SIZE(format_byte_size_map)) { proxy->frame_size = format_byte_size_map[config->format] * proxy->alsa_config.channels; } else { proxy->frame_size = 1; } }