Lines Matching defs:in
5 * you may not use this file except in compliance with the License.
10 * Unless required by applicable law or agreed to in writing, software
62 /* ToDo: Check and update a proper value in msec */
283 static void register_in_stream(struct stream_in *in)
285 struct audio_device *adev = in->dev;
290 in->capture_handle,
291 in->flags);
296 if (in->realtime) {
298 in->capture_handle,
299 in->pcm,
300 &in->config);
321 static void request_in_focus(struct stream_in *in, long ns)
323 struct audio_device *adev = in->dev;
325 if (in->routing_change) {
326 in->routing_change = false;
328 adev->adm_on_routing_change(adev->adm_data, in->capture_handle);
332 adev->adm_request_focus_v2(adev->adm_data, in->capture_handle, ns);
334 adev->adm_request_focus(adev->adm_data, in->capture_handle);
346 static void release_in_focus(struct stream_in *in, long ns __unused)
348 struct audio_device *adev = in->dev;
350 adev->adm_abandon_focus(adev->adm_data, in->capture_handle);
758 * Do not handle stereo output in Multi-channel cases
759 * Stereo case is handled in normal playback path
871 usecase->devices = usecase->stream.in->device;
927 * Limitation: While in call, to do a device switch we need to disable
953 * the devices to reduce in-call device switch time.
1001 static int stop_input_stream(struct stream_in *in)
1005 struct audio_device *adev = in->dev;
1010 in->usecase, use_case_table[in->usecase]);
1011 uc_info = get_usecase_from_list(adev, in->usecase);
1013 ALOGE("%s: Could not find the usecase (%d) in the list",
1014 __func__, in->usecase);
1031 int start_input_stream(struct stream_in *in)
1036 struct audio_device *adev = in->dev;
1038 ALOGV("%s: enter: usecase(%d)", __func__, in->usecase);
1040 if (in->card_status == CARD_STATUS_OFFLINE ||
1042 ALOGW("in->card_status or adev->card_status offline, try again");
1047 in->pcm_device_id = platform_get_pcm_device_id(in->usecase, PCM_CAPTURE);
1048 if (in->pcm_device_id < 0) {
1050 __func__, in->usecase);
1055 adev->active_input = in;
1057 uc_info->id = in->usecase;
1059 uc_info->stream.in = in;
1060 uc_info->devices = in->device;
1068 select_devices(adev, in->usecase);
1071 __func__, adev->snd_card, in->pcm_device_id, in->config.channels);
1076 if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) {
1079 } else if (in->realtime) {
1084 in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
1085 flags, &in->config);
1086 if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
1087 ALOGE("%s: %s", __func__, pcm_get_error(in->pcm));
1088 if (in->pcm != NULL) {
1089 pcm_close(in->pcm);
1090 in->pcm = NULL;
1103 ret = pcm_prepare(in->pcm);
1106 pcm_close(in->pcm);
1107 in->pcm = NULL;
1110 if (in->realtime) {
1111 ret = pcm_start(in->pcm);
1114 pcm_close(in->pcm);
1115 in->pcm = NULL;
1119 register_in_stream(in);
1126 stop_input_stream(in);
1136 void lock_input_stream(struct stream_in *in)
1138 pthread_mutex_lock(&in->pre_lock);
1139 pthread_mutex_lock(&in->lock);
1140 pthread_mutex_unlock(&in->pre_lock);
1313 ALOGV("%s: voice call is active, no change in HDMI channels",
1319 "no change in HDMI channels", __func__);
1334 /* Check if change in HDMI channel config is allowed */
1384 ALOGE("%s: Could not find the usecase (%d) in the list",
1780 * backend to the new device. Refer to check_and_route_playback_usecases() in
1936 // removed first in close_output_stream (as is done now).
2158 // It would be unusual for this value to be negative, but check just in case ...
2250 struct stream_in *in = (struct stream_in *)stream;
2252 return in->config.rate;
2262 struct stream_in *in = (struct stream_in *)stream;
2264 return in->config.period_size * in->af_period_multiplier *
2270 struct stream_in *in = (struct stream_in *)stream;
2272 return in->channel_mask;
2277 struct stream_in *in = (struct stream_in *)stream;
2278 return in->format;
2288 struct stream_in *in = (struct stream_in *)stream;
2289 struct audio_device *adev = in->dev;
2293 lock_input_stream(in);
2295 if (!in->standby && in->is_st_session) {
2297 audio_extn_sound_trigger_stop_lab(in);
2298 in->standby = true;
2301 if (!in->standby) {
2303 adev->adm_deregister_stream(adev->adm_data, in->capture_handle);
2306 in->standby = true;
2307 if (in->pcm) {
2308 pcm_close(in->pcm);
2309 in->pcm = NULL;
2313 status = stop_input_stream(in);
2316 pthread_mutex_unlock(&in->lock);
2328 struct stream_in *in = (struct stream_in *)stream;
2329 struct audio_device *adev = in->dev;
2341 lock_input_stream(in);
2347 if ((in->source != val) && (val != 0)) {
2348 in->source = val;
2356 if (((int)in->device != val) && (val != 0)) {
2357 in->device = val;
2358 /* If recording is in progress, change the tx device to new device */
2359 if (!in->standby) {
2361 in->routing_change = true;
2362 select_devices(adev, in->usecase);
2368 pthread_mutex_unlock(&in->lock);
2391 struct stream_in *in = (struct stream_in *)stream;
2392 struct audio_device *adev = in->dev;
2406 lock_input_stream(in);
2407 if (in->card_status != status)
2408 in->card_status = status;
2409 pthread_mutex_unlock(&in->lock);
2412 use_case_table[in->usecase],
2418 in_standby(&in->stream.common);
2426 struct stream_in *in = (struct stream_in *)stream;
2427 struct audio_device *adev = in->dev;
2431 lock_input_stream(in);
2433 if (in->is_st_session) {
2436 audio_extn_sound_trigger_read(in, buffer, bytes);
2437 pthread_mutex_unlock(&in->lock);
2441 if (in->standby) {
2443 ret = start_input_stream(in);
2448 in->standby = 0;
2452 long ns = pcm_bytes_to_frames(in->pcm, bytes)*1000000000LL/
2453 in->config.rate;
2454 request_in_focus(in, ns);
2456 bool use_mmap = is_mmap_usecase(in->usecase) || in->realtime;
2457 if (in->pcm) {
2459 ret = pcm_mmap_read(in->pcm, buffer, bytes);
2461 ret = pcm_read(in->pcm, buffer, bytes);
2467 if (!ret && bytes > 0 && (in->format == AUDIO_FORMAT_PCM_8_24_BIT)) {
2469 /* data from DSP comes in 24_8 format, convert it to 8_24 */
2482 release_in_focus(in, ns);
2489 if (ret == 0 && adev->mic_muted && in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY)
2493 pthread_mutex_unlock(&in->lock);
2496 in_standby(&in->stream.common);
2499 in_get_sample_rate(&in->stream.common));
2503 in->frames_read += bytes / audio_stream_in_frame_size(stream);
2519 struct stream_in *in = (struct stream_in *)stream;
2522 lock_input_stream(in);
2523 if (in->pcm) {
2526 if (pcm_get_htimestamp(in->pcm, &avail, ×tamp) == 0) {
2527 *frames = in->frames_read + avail;
2532 pthread_mutex_unlock(&in->lock);
2540 struct stream_in *in = (struct stream_in *)stream;
2541 struct audio_device *adev = in->dev;
2549 lock_input_stream(in);
2550 pthread_mutex_lock(&in->dev->lock);
2551 if ((in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
2552 in->source == AUDIO_SOURCE_VOICE_RECOGNITION ||
2554 in->enable_aec != enable &&
2556 in->enable_aec = enable;
2558 platform_set_echo_reference(in->dev, enable, AUDIO_DEVICE_NONE);
2559 if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
2572 if (!in->standby)
2573 select_devices(in->dev, in->usecase);
2575 if (in->enable_ns != enable &&
2577 in->enable_ns = enable;
2578 if (!in->standby)
2579 select_devices(in->dev, in->usecase);
2581 pthread_mutex_unlock(&in->dev->lock);
2582 pthread_mutex_unlock(&in->lock);
2761 * and use the one specified in audio_hw layer configuration.
2763 * and is used to set config->format in the code several lines below.
2922 // FIXME: note that the code below assumes that the speakers are in the correct placement
3074 struct stream_in *in;
3084 in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
3086 pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);
3087 pthread_mutex_init(&in->pre_lock, (const pthread_mutexattr_t *) NULL);
3089 in->stream.common.get_sample_rate = in_get_sample_rate;
3090 in->stream.common.set_sample_rate = in_set_sample_rate;
3091 in->stream.common.get_buffer_size = in_get_buffer_size;
3092 in->stream.common.get_channels = in_get_channels;
3093 in->stream.common.get_format = in_get_format;
3094 in->stream.common.set_format = in_set_format;
3095 in->stream.common.standby = in_standby;
3096 in->stream.common.dump = in_dump;
3097 in->stream.common.set_parameters = in_set_parameters;
3098 in->stream.common.get_parameters = in_get_parameters;
3099 in->stream.common.add_audio_effect = in_add_audio_effect;
3100 in->stream.common.remove_audio_effect = in_remove_audio_effect;
3101 in->stream.set_gain = in_set_gain;
3102 in->stream.read = in_read;
3103 in->stream.get_input_frames_lost = in_get_input_frames_lost;
3104 in->stream.get_capture_position = in_get_capture_position;
3106 in->device = devices;
3107 in->source = source;
3108 in->dev = adev;
3109 in->standby = 1;
3110 in->channel_mask = config->channel_mask;
3111 in->capture_handle = handle;
3112 in->flags = flags;
3124 *> In case of UNPROCESSED source, for 24 bit, if format requested is other than
3126 *> In case of any other source requesting 24 bit or float return error
3145 in->format = config->format;
3148 if (in->device == AUDIO_DEVICE_IN_TELEPHONY_RX) {
3164 in->usecase = USECASE_AUDIO_RECORD_AFE_PROXY;
3165 in->config = pcm_config_afe_proxy_record;
3167 in->usecase = USECASE_AUDIO_RECORD;
3172 in->usecase = USECASE_AUDIO_RECORD_LOW_LATENCY;
3174 in->realtime = may_use_noirq_mode(adev, in->usecase, in->flags);
3177 in->config = in->realtime ? pcm_config_audio_capture_rt :
3181 in->config.format = PCM_FORMAT_S24_LE;
3183 if (!in->realtime) {
3184 frame_size = audio_stream_in_frame_size(&in->stream);
3189 in->config.period_size = buffer_size / frame_size;
3193 in->config.channels = channel_count;
3194 if (in->realtime) {
3195 in->af_period_multiplier = af_period_multiplier;
3197 in->config.rate = config->sample_rate;
3198 in->af_period_multiplier = 1;
3203 audio_extn_sound_trigger_check_and_get_session(in);
3205 lock_input_stream(in);
3206 audio_extn_snd_mon_register_listener(in, in_snd_mon_cb);
3208 in->card_status = adev->card_status;
3210 pthread_mutex_unlock(&in->lock);
3212 *stream_in = &in->stream;
3217 free(in);
3250 * in order to power up the devices and read the device parameters.
3258 * In this case there are the following use cases and device ids.
3272 /* should be the usecases enabled in adev_open_input_stream() */
3277 /* should be the usecases enabled in adev_open_output_stream()*/
3312 struct stream_in in;
3330 adev->active_input = ∈
3331 memset(&in, 0, sizeof(in));
3332 in.device = audio_device;
3333 in.source = AUDIO_SOURCE_VOICE_COMMUNICATION;
3334 uc_info.stream.in = ∈
3339 out.devices = audio_device; /* only field needed in select_devices */
3346 /* select device - similar to start_(in/out)put_stream() */
3361 /* deselect device - similar to stop_(in/out)put_stream() */