• Home
  • Raw
  • Download

Lines Matching refs:profile

61 static void profile_reset(alsa_device_profile* profile)  in profile_reset()  argument
63 profile->card = profile->device = -1; in profile_reset()
66 profile->formats[0] = PCM_FORMAT_INVALID; in profile_reset()
67 profile->sample_rates[0] = 0; in profile_reset()
68 profile->channel_counts[0] = 0; in profile_reset()
70 profile->min_period_size = profile->max_period_size = 0; in profile_reset()
71 profile->min_channel_count = profile->max_channel_count = DEFAULT_CHANNEL_COUNT; in profile_reset()
73 profile->is_valid = false; in profile_reset()
76 void profile_init(alsa_device_profile* profile, int direction) in profile_init() argument
78 profile->direction = direction; in profile_init()
79 profile_reset(profile); in profile_init()
82 bool profile_is_initialized(const alsa_device_profile* profile) in profile_is_initialized() argument
84 return profile->card >= 0 && profile->device >= 0; in profile_is_initialized()
87 bool profile_is_valid(const alsa_device_profile* profile) { in profile_is_valid() argument
88 return profile->is_valid; in profile_is_valid()
91 bool profile_is_cached_for(const alsa_device_profile* profile, int card, int device) { in profile_is_cached_for() argument
92 return card == profile->card && device == profile->device; in profile_is_cached_for()
95 void profile_decache(alsa_device_profile* profile) { in profile_decache() argument
96 profile_reset(profile); in profile_decache()
110 unsigned profile_calc_min_period_size(const alsa_device_profile* profile, unsigned sample_rate) in profile_calc_min_period_size() argument
112 ALOGV("profile_calc_min_period_size(%p, rate:%d)", profile, sample_rate); in profile_calc_min_period_size()
113 if (profile == NULL) { in profile_calc_min_period_size()
119 if (num_sample_frames < profile->min_period_size) { in profile_calc_min_period_size()
120 num_sample_frames = profile->min_period_size; in profile_calc_min_period_size()
126 unsigned int profile_get_period_size(const alsa_device_profile* profile, unsigned sample_rate) in profile_get_period_size() argument
128 unsigned int period_size = profile_calc_min_period_size(profile, sample_rate); in profile_get_period_size()
136 unsigned profile_get_default_sample_rate(const alsa_device_profile* profile) in profile_get_default_sample_rate() argument
147 return profile_is_valid(profile) ? profile->sample_rates[0] : DEFAULT_SAMPLE_RATE; in profile_get_default_sample_rate()
150 unsigned profile_get_highest_sample_rate(const alsa_device_profile* profile) { in profile_get_highest_sample_rate() argument
155 return profile->sample_rates[0]; in profile_get_highest_sample_rate()
158 bool profile_is_sample_rate_valid(const alsa_device_profile* profile, unsigned rate) in profile_is_sample_rate_valid() argument
160 if (profile_is_valid(profile)) { in profile_is_sample_rate_valid()
162 for (index = 0; profile->sample_rates[index] != 0; index++) { in profile_is_sample_rate_valid()
163 if (profile->sample_rates[index] == rate) { in profile_is_sample_rate_valid()
178 enum pcm_format profile_get_default_format(const alsa_device_profile* profile) in profile_get_default_format() argument
183 return profile_is_valid(profile) ? profile->formats[0] : DEFAULT_SAMPLE_FORMAT; in profile_get_default_format()
186 bool profile_is_format_valid(const alsa_device_profile* profile, enum pcm_format fmt) { in profile_is_format_valid() argument
187 if (profile_is_valid(profile)) { in profile_is_format_valid()
189 for (index = 0; profile->formats[index] != PCM_FORMAT_INVALID; index++) { in profile_is_format_valid()
190 if (profile->formats[index] == fmt) { in profile_is_format_valid()
204 unsigned profile_get_default_channel_count(const alsa_device_profile* profile) in profile_get_default_channel_count() argument
206 return profile_is_valid(profile) ? profile->channel_counts[0] : DEFAULT_CHANNEL_COUNT; in profile_get_default_channel_count()
209 unsigned profile_get_closest_channel_count(const alsa_device_profile* profile, unsigned count) in profile_get_closest_channel_count() argument
211 if (profile_is_valid(profile)) { in profile_get_closest_channel_count()
212 if (count < profile->min_channel_count) { in profile_get_closest_channel_count()
213 return profile->min_channel_count; in profile_get_closest_channel_count()
214 } else if (count > profile->max_channel_count) { in profile_get_closest_channel_count()
215 return profile->max_channel_count; in profile_get_closest_channel_count()
224 bool profile_is_channel_count_valid(const alsa_device_profile* profile, unsigned count) in profile_is_channel_count_valid() argument
226 if (profile_is_initialized(profile)) { in profile_is_channel_count_valid()
227 return count >= profile->min_channel_count && count <= profile->max_channel_count; in profile_is_channel_count_valid()
233 static bool profile_test_sample_rate(const alsa_device_profile* profile, unsigned rate) in profile_test_sample_rate() argument
235 struct pcm_config config = profile->default_config; in profile_test_sample_rate()
239 struct pcm * pcm = pcm_open(profile->card, profile->device, in profile_test_sample_rate()
240 profile->direction, &config); in profile_test_sample_rate()
250 static unsigned profile_enum_sample_rates(alsa_device_profile* profile, unsigned min, unsigned max) in profile_enum_sample_rates() argument
256 num_entries < ARRAY_SIZE(profile->sample_rates) - 1; in profile_enum_sample_rates()
259 && profile_test_sample_rate(profile, std_sample_rates[index])) { in profile_enum_sample_rates()
260 profile->sample_rates[num_entries++] = std_sample_rates[index]; in profile_enum_sample_rates()
263 profile->sample_rates[num_entries] = 0; /* terminate */ in profile_enum_sample_rates()
267 static unsigned profile_enum_sample_formats(alsa_device_profile* profile, struct pcm_mask * mask) in profile_enum_sample_formats() argument
287 profile->formats[num_written++] = format; in profile_enum_sample_formats()
288 if (num_written == ARRAY_SIZE(profile->formats) - 1) { in profile_enum_sample_formats()
299 profile->formats[num_written] = PCM_FORMAT_INVALID; in profile_enum_sample_formats()
303 static unsigned profile_enum_channel_counts(alsa_device_profile* profile, unsigned min, in profile_enum_channel_counts() argument
314 num_counts < ARRAY_SIZE(profile->channel_counts) - 1; in profile_enum_channel_counts()
319 profile->channel_counts[num_counts++] = std_channel_counts[index]; in profile_enum_channel_counts()
326 profile->channel_counts[num_counts++] = std_channel_counts[0]; in profile_enum_channel_counts()
328 profile->channel_counts[num_counts] = 0; in profile_enum_channel_counts()
335 static int read_alsa_device_config(alsa_device_profile * profile, struct pcm_config * config) in read_alsa_device_config() argument
338 profile->card, profile->device, profile->direction); in read_alsa_device_config()
340 if (profile->card < 0 || profile->device < 0) { in read_alsa_device_config()
345 pcm_params_get(profile->card, profile->device, profile->direction); in read_alsa_device_config()
350 profile->min_period_size = pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_SIZE); in read_alsa_device_config()
351 profile->max_period_size = pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_SIZE); in read_alsa_device_config()
353 profile->min_channel_count = pcm_params_get_min(alsa_hw_params, PCM_PARAM_CHANNELS); in read_alsa_device_config()
354 profile->max_channel_count = pcm_params_get_max(alsa_hw_params, PCM_PARAM_CHANNELS); in read_alsa_device_config()
368 if (profile->direction == PCM_OUT && in read_alsa_device_config()
381 config->period_size = profile_calc_min_period_size(profile, config->rate); in read_alsa_device_config()
396 bool profile_read_device_info(alsa_device_profile* profile) in profile_read_device_info() argument
398 if (!profile_is_initialized(profile)) { in profile_read_device_info()
403 read_alsa_device_config(profile, &profile->default_config); in profile_read_device_info()
405 profile->default_config.channels, profile->default_config.rate, in profile_read_device_info()
406 profile->default_config.format, profile->default_config.period_count, in profile_read_device_info()
407 profile->default_config.period_size); in profile_read_device_info()
409 struct pcm_params * alsa_hw_params = pcm_params_get(profile->card, in profile_read_device_info()
410 profile->device, in profile_read_device_info()
411 profile->direction); in profile_read_device_info()
418 profile_enum_sample_formats(profile, format_mask); in profile_read_device_info()
422 profile, pcm_params_get_min(alsa_hw_params, PCM_PARAM_CHANNELS), in profile_read_device_info()
427 profile, pcm_params_get_min(alsa_hw_params, PCM_PARAM_RATE), in profile_read_device_info()
430 profile->is_valid = true; in profile_read_device_info()
436 char * profile_get_sample_rate_strs(const alsa_device_profile* profile) in profile_get_sample_rate_strs() argument
451 for (index = 0; profile->sample_rates[index] != 0; index++) { in profile_get_sample_rate_strs()
452 snprintf(numBuffer, sizeof(numBuffer), "%u", profile->sample_rates[index]); in profile_get_sample_rate_strs()
469 char * profile_get_format_strs(const alsa_device_profile* profile) in profile_get_format_strs() argument
482 for (index = 0; profile->formats[index] != PCM_FORMAT_INVALID; index++) { in profile_get_format_strs()
484 if (buffSize - curStrLen < strlen(format_string_map[profile->formats[index]]) in profile_get_format_strs()
494 curStrLen = strlcat(buffer, format_string_map[profile->formats[index]], buffSize); in profile_get_format_strs()
500 char * profile_get_channel_count_strs(const alsa_device_profile* profile) in profile_get_channel_count_strs() argument
536 const bool isOutProfile = profile->direction == PCM_OUT; in profile_get_channel_count_strs()
565 (channel_count = profile->channel_counts[index]) != 0; in profile_get_channel_count_strs()
600 void profile_dump(const alsa_device_profile* profile, int fd) in profile_dump() argument
602 if (profile == NULL) { in profile_dump()
607 if (!profile->is_valid) { in profile_dump()
613 profile->card, profile->device, profile->direction == PCM_OUT ? "OUT" : "IN"); in profile_dump()
618 profile->formats[fmtIndex] != PCM_FORMAT_INVALID && fmtIndex < MAX_PROFILE_FORMATS; in profile_dump()
620 dprintf(fd, "%d ", profile->formats[fmtIndex]); in profile_dump()
627 profile->sample_rates[rateIndex] != 0 && rateIndex < MAX_PROFILE_SAMPLE_RATES; in profile_dump()
629 dprintf(fd, "%u ", profile->sample_rates[rateIndex]); in profile_dump()
636 profile->channel_counts[cntIndex] != 0 && cntIndex < MAX_PROFILE_CHANNEL_COUNTS; in profile_dump()
638 dprintf(fd, "%u ", profile->channel_counts[cntIndex]); in profile_dump()
643 profile->min_period_size,profile-> max_period_size); in profile_dump()
645 profile->min_channel_count, profile->max_channel_count); in profile_dump()
649 dprintf(fd, " channels: %d\n", profile->default_config.channels); in profile_dump()
650 dprintf(fd, " rate: %d\n", profile->default_config.rate); in profile_dump()
651 dprintf(fd, " period_size: %d\n", profile->default_config.period_size); in profile_dump()
652 dprintf(fd, " period_count: %d\n", profile->default_config.period_count); in profile_dump()
653 dprintf(fd, " format: %d\n", profile->default_config.format); in profile_dump()