Home | History | Annotate | Download | only in hal

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);
361 tm.tm_mon + 1, // localtime_r uses months in 0 - 11 range
401 // Dump information in the error log. A mutual exclusion lock
782 // and a new usecase requests one device in this combo pair.
946 * Do not handle stereo output in Multi-channel cases
947 * Stereo case is handled in normal playback path
1059 usecase->devices = usecase->stream.in->device;
1115 * Limitation: While in call, to do a device switch we need to disable
1141 * the devices to reduce in-call device switch time.
1189 static int stop_input_stream(struct stream_in *in)
1193 struct audio_device *adev = in->dev;
1198 in->usecase, use_case_table[in->usecase]);
1199 uc_info = get_usecase_from_list(adev, in->usecase);
1201 ALOGE("%s: Could not find the usecase (%d) in the list",
1202 __func__, in->usecase);
1219 int start_input_stream(struct stream_in *in)
1224 struct audio_device *adev = in->dev;
1226 ALOGV("%s: enter: usecase(%d)", __func__, in->usecase);
1228 if (in->card_status == CARD_STATUS_OFFLINE ||
1230 ALOGW("in->card_status or adev->card_status offline, try again");
1235 in->pcm_device_id = platform_get_pcm_device_id(in->usecase, PCM_CAPTURE);
1236 if (in->pcm_device_id < 0) {
1238 __func__, in->usecase);
1243 adev->active_input = in;
1245 uc_info->id = in->usecase;
1247 uc_info->stream.in = in;
1248 uc_info->devices = in->device;
1256 select_devices(adev, in->usecase);
1259 __func__, adev->snd_card, in->pcm_device_id, in->config.channels);
1264 if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) {
1267 } else if (in->realtime) {
1272 in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
1273 flags, &in->config);
1274 if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
1275 ALOGE("%s: %s", __func__, pcm_get_error(in->pcm));
1276 if (in->pcm != NULL) {
1277 pcm_close(in->pcm);
1278 in->pcm = NULL;
1291 ret = pcm_prepare(in->pcm);
1294 pcm_close(in->pcm);
1295 in->pcm = NULL;
1298 if (in->realtime) {
1299 ret = pcm_start(in->pcm);
1302 pcm_close(in->pcm);
1303 in->pcm = NULL;
1307 register_in_stream(in);
1314 stop_input_stream(in);
1324 void lock_input_stream(struct stream_in *in)
1326 pthread_mutex_lock(&in->pre_lock);
1327 pthread_mutex_lock(&in->lock);
1328 pthread_mutex_unlock(&in->pre_lock);
1501 ALOGV("%s: voice call is active, no change in HDMI channels",
1507 "no change in HDMI channels", __func__);
1522 /* Check if change in HDMI channel config is allowed */
1572 ALOGE("%s: Could not find the usecase (%d) in the list",
1897 // If we're not in standby, we may be blocked on a write.
1985 * backend to the new device. Refer to check_and_route_playback_usecases() in
2141 // removed first in close_output_stream (as is done now).
2380 in case ...
2472 struct stream_in *in = (struct stream_in *)stream;
2474 return in->config.rate;
2484 struct stream_in *in = (struct stream_in *)stream;
2486 return in->config.period_size * in->af_period_multiplier *
2492 struct stream_in *in = (struct stream_in *)stream;
2494 return in->channel_mask;
2499 struct stream_in *in = (struct stream_in *)stream;
2500 return in->format;
2510 struct stream_in *in = (struct stream_in *)stream;
2511 struct audio_device *adev = in->dev;
2515 lock_input_stream(in);
2517 if (!in->standby && in->is_st_session) {
2519 audio_extn_sound_trigger_stop_lab(in);
2520 in->standby = true;
2523 if (!in->standby) {
2525 adev->adm_deregister_stream(adev->adm_data, in->capture_handle);
2528 in->standby = true;
2529 if (in->pcm) {
2530 pcm_close(in->pcm);
2531 in->pcm = NULL;
2535 status = stop_input_stream(in);
2538 pthread_mutex_unlock(&in->lock);
2550 struct stream_in *in = (struct stream_in *)stream;
2551 struct audio_device *adev = in->dev;
2563 lock_input_stream(in);
2569 if ((in->source != val) && (val != 0)) {
2570 in->source = val;
2578 if (((int)in->device != val) && (val != 0)) {
2579 in->device = val;
2580 /* If recording is in progress, change the tx device to new device */
2581 if (!in->standby) {
2583 in->routing_change = true;
2584 select_devices(adev, in->usecase);
2590 pthread_mutex_unlock(&in->lock);
2613 struct stream_in *in = (struct stream_in *)stream;
2614 struct audio_device *adev = in->dev;
2628 lock_input_stream(in);
2629 if (in->card_status != status)
2630 in->card_status = status;
2631 pthread_mutex_unlock(&in->lock);
2634 use_case_table[in->usecase],
2640 in_standby(&in->stream.common);
2648 struct stream_in *in = (struct stream_in *)stream;
2649 struct audio_device *adev = in->dev;
2653 lock_input_stream(in);
2655 if (in->is_st_session) {
2658 audio_extn_sound_trigger_read(in, buffer, bytes);
2659 pthread_mutex_unlock(&in->lock);
2663 if (in->standby) {
2665 ret = start_input_stream(in);
2670 in->standby = 0;
2674 long ns = pcm_bytes_to_frames(in->pcm, bytes)*1000000000LL/
2675 in->config.rate;
2676 request_in_focus(in, ns);
2678 bool use_mmap = is_mmap_usecase(in->usecase) || in->realtime;
2679 if (in->pcm) {
2681 ret = pcm_mmap_read(in->pcm, buffer, bytes);
2683 ret = pcm_read(in->pcm, buffer, bytes);
2689 if (!ret && bytes > 0 && (in->format == AUDIO_FORMAT_PCM_8_24_BIT)) {
2691 /* data from DSP comes in 24_8 format, convert it to 8_24 */
2704 release_in_focus(in, ns);
2711 if (ret == 0 && adev->mic_muted && in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY)
2715 pthread_mutex_unlock(&in->lock);
2718 in_standby(&in->stream.common);
2721 in_get_sample_rate(&in->stream.common));
2725 in->frames_read += bytes / audio_stream_in_frame_size(stream);
2741 struct stream_in *in = (struct stream_in *)stream;
2744 lock_input_stream(in);
2745 if (in->pcm) {
2748 if (pcm_get_htimestamp(in->pcm, &avail, &timestamp) == 0) {
2749 *frames = in->frames_read + avail;
2754 pthread_mutex_unlock(&in->lock);
2762 struct stream_in *in = (struct stream_in *)stream;
2763 struct audio_device *adev = in->dev;
2771 lock_input_stream(in);
2772 pthread_mutex_lock(&in->dev->lock);
2773 if ((in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
2774 in->source == AUDIO_SOURCE_VOICE_RECOGNITION ||
2776 in->enable_aec != enable &&
2778 in->enable_aec = enable;
2780 platform_set_echo_reference(in->dev, enable, AUDIO_DEVICE_NONE);
2781 if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
2794 if (!in->standby)
2795 select_devices(in->dev, in->usecase);
2797 if (in->enable_ns != enable &&
2799 in->enable_ns = enable;
2800 if (!in->standby)
2801 select_devices(in->dev, in->usecase);
2803 pthread_mutex_unlock(&in->dev->lock);
2804 pthread_mutex_unlock(&in->lock);
2983 * and use the one specified in audio_hw layer configuration.
2985 * and is used to set config->format in the code several lines below.
3144 // FIXME: note that the code below assumes that the speakers are in the correct placement
3296 struct stream_in *in;
3306 in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
3308 pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);
3309 pthread_mutex_init(&in->pre_lock, (const pthread_mutexattr_t *) NULL);
3311 in->stream.common.get_sample_rate = in_get_sample_rate;
3312 in->stream.common.set_sample_rate = in_set_sample_rate;
3313 in->stream.common.get_buffer_size = in_get_buffer_size;
3314 in->stream.common.get_channels = in_get_channels;
3315 in->stream.common.get_format = in_get_format;
3316 in->stream.common.set_format = in_set_format;
3317 in->stream.common.standby = in_standby;
3318 in->stream.common.dump = in_dump;
3319 in->stream.common.set_parameters = in_set_parameters;
3320 in->stream.common.get_parameters = in_get_parameters;
3321 in->stream.common.add_audio_effect = in_add_audio_effect;
3322 in->stream.common.remove_audio_effect = in_remove_audio_effect;
3323 in->stream.set_gain = in_set_gain;
3324 in->stream.read = in_read;
3325 in->stream.get_input_frames_lost = in_get_input_frames_lost;
3326 in->stream.get_capture_position = in_get_capture_position;
3328 in->device = devices;
3329 in->source = source;
3330 in->dev = adev;
3331 in->standby = 1;
3332 in->channel_mask = config->channel_mask;
3333 in->capture_handle = handle;
3334 in->flags = flags;
3346 *> In case of UNPROCESSED source, for 24 bit, if format requested is other than
3348 *> In case of any other source requesting 24 bit or float return error
3367 in->format = config->format;
3370 if (in->device == AUDIO_DEVICE_IN_TELEPHONY_RX) {
3386 in->usecase = USECASE_AUDIO_RECORD_AFE_PROXY;
3387 in->config = pcm_config_afe_proxy_record;
3389 in->usecase = USECASE_AUDIO_RECORD;
3394 in->usecase = USECASE_AUDIO_RECORD_LOW_LATENCY;
3396 in->realtime = may_use_noirq_mode(adev, in->usecase, in->flags);
3399 in->config = in->realtime ? pcm_config_audio_capture_rt :
3403 in->config.format = PCM_FORMAT_S24_LE;
3405 if (!in->realtime) {
3406 frame_size = audio_stream_in_frame_size(&in->stream);
3411 in->config.period_size = buffer_size / frame_size;
3415 in->config.channels = channel_count;
3416 if (in->realtime) {
3417 in->af_period_multiplier = af_period_multiplier;
3419 in->config.rate = config->sample_rate;
3420 in->af_period_multiplier = 1;
3425 audio_extn_sound_trigger_check_and_get_session(in);
3427 lock_input_stream(in);
3428 audio_extn_snd_mon_register_listener(in, in_snd_mon_cb);
3430 in->card_status = adev->card_status;
3432 pthread_mutex_unlock(&in->lock);
3434 *stream_in = &in->stream;
3439 free(in);
3472 * in order to power up the devices and read the device parameters.
3480 * In this case there are the following use cases and device ids.
3494 /* should be the usecases enabled in adev_open_input_stream() */
3499 /* should be the usecases enabled in adev_open_output_stream()*/
3534 struct stream_in in;
3552 adev->active_input = &in;
3553 memset(&in, 0, sizeof(in));
3554 in.device = audio_device;
3555 in.source = AUDIO_SOURCE_VOICE_COMMUNICATION;
3556 uc_info.stream.in = &in;
3561 out.devices = audio_device; /* only field needed in select_devices */
3568 /* select device - similar to start_(in/out)put_stream() */
3583 /* deselect device - similar to stop_(in/out)put_stream() */