Home | History | Annotate | Download | only in usbaudio

Lines Matching full:profile

61 void profile_init(alsa_device_profile* profile, int direction)
63 profile->card = profile->device = -1;
64 profile->direction = direction;
68 for (index = 0; index < ARRAY_SIZE(profile->formats); index++) {
69 profile->formats[index] = PCM_FORMAT_INVALID;
72 for (index = 0; index < ARRAY_SIZE(profile->sample_rates); index++) {
73 profile->sample_rates[index] = 0;
76 for (index = 0; index < ARRAY_SIZE(profile->channel_counts); index++) {
77 profile->channel_counts[index] = 0;
80 profile->min_period_size = profile->max_period_size = 0;
81 profile->min_channel_count = profile->max_channel_count = DEFAULT_CHANNEL_COUNT;
83 profile->is_valid = false;
86 bool profile_is_initialized(alsa_device_profile* profile)
88 return profile->card >= 0 && profile->device >= 0;
91 bool profile_is_valid(alsa_device_profile* profile) {
92 return profile->is_valid;
95 bool profile_is_cached_for(alsa_device_profile* profile, int card, int device) {
96 return card == profile->card && device == profile->device;
99 void profile_decache(alsa_device_profile* profile) {
100 profile->card = profile->device = -1;
114 unsigned profile_calc_min_period_size(alsa_device_profile* profile, unsigned sample_rate)
116 ALOGV("profile_calc_min_period_size(%p, rate:%d)", profile, sample_rate);
117 if (profile == NULL) {
121 if (num_sample_frames < profile->min_period_size) {
122 num_sample_frames = profile->min_period_size;
128 unsigned int profile_get_period_size(alsa_device_profile* profile, unsigned sample_rate)
130 // return profile->default_config.period_size;
131 unsigned int period_size = profile_calc_min_period_size(profile, sample_rate);
139 unsigned profile_get_default_sample_rate(alsa_device_profile* profile)
145 return profile_is_valid(profile) ? profile->sample_rates[0] : DEFAULT_SAMPLE_RATE;
148 bool profile_is_sample_rate_valid(alsa_device_profile* profile, unsigned rate)
150 if (profile_is_valid(profile)) {
152 for (index = 0; profile->sample_rates[index] != 0; index++) {
153 if (profile->sample_rates[index] == rate) {
167 enum pcm_format profile_get_default_format(alsa_device_profile* profile)
172 return profile_is_valid(profile) ? profile->formats[0] : DEFAULT_SAMPLE_FORMAT;
175 bool profile_is_format_valid(alsa_device_profile* profile, enum pcm_format fmt) {
176 if (profile_is_valid(profile)) {
178 for (index = 0; profile->formats[index] != PCM_FORMAT_INVALID; index++) {
179 if (profile->formats[index] == fmt) {
193 unsigned profile_get_default_channel_count(alsa_device_profile* profile)
195 return profile_is_valid(profile) ? profile->channel_counts[0] : DEFAULT_CHANNEL_COUNT;
198 bool profile_is_channel_count_valid(alsa_device_profile* profile, unsigned count)
200 if (profile_is_initialized(profile)) {
201 return count >= profile->min_channel_count && count <= profile->max_channel_count;
207 static bool profile_test_sample_rate(alsa_device_profile* profile, unsigned rate)
209 struct pcm_config config = profile->default_config;
213 struct pcm * pcm = pcm_open(profile->card, profile->device,
214 profile->direction, &config);
224 static unsigned profile_enum_sample_rates(alsa_device_profile* profile, unsigned min, unsigned max)
230 num_entries < ARRAY_SIZE(profile->sample_rates) - 1;
233 && profile_test_sample_rate(profile, std_sample_rates[index])) {
234 profile->sample_rates[num_entries++] = std_sample_rates[index];
241 static unsigned profile_enum_sample_formats(alsa_device_profile* profile, struct pcm_mask * mask)
261 profile->formats[num_written++] = format;
262 if (num_written == ARRAY_SIZE(profile->formats) - 1) {
276 static unsigned profile_enum_channel_counts(alsa_device_profile* profile, unsigned min, unsigned max)
284 profile->direction == PCM_OUT ? std_out_channel_counts : std_in_channel_counts;
286 profile->direction == PCM_OUT
294 num_counts < ARRAY_SIZE(profile->channel_counts) - 1;
298 profile_test_channel_count(profile, channel_counts[index])*/) {
299 profile->channel_counts[num_counts++] = channel_counts[index];
309 static int read_alsa_device_config(alsa_device_profile * profile, struct pcm_config * config)
312 profile->card, profile->device, profile->direction);
314 if (profile->card < 0 || profile->device < 0) {
319 pcm_params_get(profile->card, profile->device, profile->direction);
324 profile->min_period_size = pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_SIZE);
325 profile->max_period_size = pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_SIZE);
327 profile->min_channel_count = pcm_params_get_min(alsa_hw_params, PCM_PARAM_CHANNELS);
328 profile->max_channel_count = pcm_params_get_max(alsa_hw_params, PCM_PARAM_CHANNELS);
341 config->period_size = profile_calc_min_period_size(profile, config->rate);
356 bool profile_read_device_info(alsa_device_profile* profile)
358 if (!profile_is_initialized(profile)) {
363 read_alsa_device_config(profile, &profile->default_config);
365 profile->default_config.channels, profile->default_config.rate,
366 profile->default_config.format, profile->default_config.period_count,
367 profile->default_config.period_size);
369 struct pcm_params * alsa_hw_params = pcm_params_get(profile->card,
370 profile->device,
371 profile->direction);
378 profile_enum_sample_formats(profile, format_mask);
382 profile, pcm_params_get_min(alsa_hw_params, PCM_PARAM_CHANNELS),
387 profile, pcm_params_get_min(alsa_hw_params, PCM_PARAM_RATE),
390 profile->is_valid = true;
395 char * profile_get_sample_rate_strs(alsa_device_profile* profile)
405 for (index = 0; profile->sample_rates[index] != 0; index++) {
409 snprintf(numBuffer, sizeof(numBuffer), "%u", profile->sample_rates[index]);
416 char * profile_get_format_strs(alsa_device_profile* profile)
419 if (profile->direction == PCM_IN) {
429 for (index = 0; profile->formats[index] != PCM_FORMAT_INVALID; index++) {
433 strncat(buffer, format_string_map[profile->formats[index]], buffSize);
439 char * profile_get_channel_count_strs(alsa_device_profile* profile)
461 const bool isOutProfile = profile->direction == PCM_OUT;
474 for (index = 0; (channel_count = profile->channel_counts[index]) != 0; index++) {