<commit_before>/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <alsa/asoundlib.h>
#include <limits.h>
#include <stdlib.h>
#include <syslog.h>

#include "cras_alsa_helpers.h"
#include "cras_types.h"
#include "cras_util.h"

/* Chances to give mmap_begin to work. */
static const size_t MAX_MMAP_BEGIN_ATTEMPTS = 3;
/* Time to sleep between resume attempts. */
static const size_t ALSA_SUSPENDED_SLEEP_TIME_US = 250000;

/* What rates should we check for on this dev?
 * Listed in order of preference. 0 terminalted. */
static const size_t test_sample_rates[] = {
	44100,
	48000,
	32000,
	96000,
	22050,
	8000,
	4000,
	192000,
	0
};

/* What channel counts shoud be checked on this dev?
 * Listed in order of preference. 0 terminalted. */
static const size_t test_channel_counts[] = {
	2,
	1,
	0
};

int cras_alsa_pcm_open(snd_pcm_t **handle, const char *dev,
		       snd_pcm_stream_t stream)
{
	return snd_pcm_open(handle,
			    dev,
			    stream,
			    SND_PCM_NONBLOCK |
			    SND_PCM_NO_AUTO_RESAMPLE |
			    SND_PCM_NO_AUTO_CHANNELS |
			    SND_PCM_NO_AUTO_FORMAT);<commit_msg>CRAS: alsa helper - support 16k sample rate.<commit_after>/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <alsa/asoundlib.h>
#include <limits.h>
#include <stdlib.h>
#include <syslog.h>

#include "cras_alsa_helpers.h"
#include "cras_types.h"
#include "cras_util.h"

/* Chances to give mmap_begin to work. */
static const size_t MAX_MMAP_BEGIN_ATTEMPTS = 3;
/* Time to sleep between resume attempts. */
static const size_t ALSA_SUSPENDED_SLEEP_TIME_US = 250000;

/* What rates should we check for on this dev?
 * Listed in order of preference. 0 terminalted. */
static const size_t test_sample_rates[] = {
	44100,
	48000,
	32000,
	96000,
	22050,
	16000,
	8000,
	4000,
	192000,
	0
};

/* What channel counts shoud be checked on this dev?
 * Listed in order of preference. 0 terminalted. */
static const size_t test_channel_counts[] = {
	2,
	1,
	0
};

int cras_alsa_pcm_open(snd_pcm_t **handle, const char *dev,
		       snd_pcm_stream_t stream)
{
	return snd_pcm_open(handle,
			    dev,
			    stream,
			    SND_PCM_NONBLOCK |
			    SND_PCM_NO_AUTO_RESAMPLE |
			    SND_PCM_NO_AUTO_CHANNELS |
			    SND_PCM_NO_AUTO_FORMAT);
{'fraction_non_alphanumeric': 0.09248090068355448, 'fraction_numerical': 0.04784881383192602, 'mean_word_length': 3.6591760299625467, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326330', 'n_tokens_mistral': 1032, 'n_tokens_neox': 910, 'n_words': 274}