Lines Matching refs:adev

228 static void dummybuf_thread_close(struct audio_device *adev);
299 struct mixer_card *adev_get_mixer_for_card(struct audio_device *adev, int card) in adev_get_mixer_for_card() argument
304 list_for_each(node, &adev->mixer_list) { in adev_get_mixer_for_card()
325 void free_mixer_list(struct audio_device *adev) in free_mixer_list() argument
331 list_for_each_safe(node, next, &adev->mixer_list) { in free_mixer_list()
339 int mixer_init(struct audio_device *adev) in mixer_init() argument
350 list_init(&adev->mixer_list); in mixer_init()
354 if (adev_get_mixer_for_card(adev, card) == NULL) { in mixer_init()
379 list_add_tail(&adev->mixer_list, &mixer_card->adev_list_node); in mixer_init()
386 free_mixer_list(adev); in mixer_init()
425 static struct audio_usecase *get_usecase_from_id(struct audio_device *adev, in get_usecase_from_id() argument
431 list_for_each(node, &adev->usecase_list) { in get_usecase_from_id()
439 static struct audio_usecase *get_usecase_from_type(struct audio_device *adev, in get_usecase_from_type() argument
445 list_for_each(node, &adev->usecase_list) { in get_usecase_from_type()
454 static int set_voice_volume_l(struct audio_device *adev, float volume) in set_voice_volume_l() argument
459 if (adev->mode == AUDIO_MODE_IN_CALL) { in set_voice_volume_l()
466 snd_device_t get_output_snd_device(struct audio_device *adev, audio_devices_t devices) in get_output_snd_device() argument
469 audio_mode_t mode = adev->mode; in get_output_snd_device()
482 if (adev->tty_mode == TTY_MODE_FULL) in get_output_snd_device()
484 else if (adev->tty_mode == TTY_MODE_VCO) in get_output_snd_device()
486 else if (adev->tty_mode == TTY_MODE_HCO) in get_output_snd_device()
540 snd_device_t get_input_snd_device(struct audio_device *adev, audio_devices_t out_device) in get_input_snd_device() argument
543 audio_mode_t mode = adev->mode; in get_input_snd_device()
550 usecase = get_usecase_from_type(adev, PCM_CAPTURE|VOICE_CALL); in get_input_snd_device()
570 if (adev->tty_mode != TTY_MODE_OFF) { in get_input_snd_device()
573 switch (adev->tty_mode) { in get_input_snd_device()
584 ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->tty_mode); in get_input_snd_device()
606 if (adev->dualmic_config == DUALMIC_CONFIG_1) { in get_input_snd_device()
609 else if (adev->ns_in_voice_rec) in get_input_snd_device()
687 int set_hdmi_channels(struct audio_device *adev, int channel_count) in set_hdmi_channels() argument
691 (void)adev; in set_hdmi_channels()
698 int edid_get_max_channels(struct audio_device *adev) in edid_get_max_channels() argument
702 (void)adev; in edid_get_max_channels()
716 static int enable_snd_device(struct audio_device *adev, in enable_snd_device() argument
728 adev->snd_dev_ref_cnt[snd_device]++; in enable_snd_device()
729 if (adev->snd_dev_ref_cnt[snd_device] > 1) { in enable_snd_device()
748 static int disable_snd_device(struct audio_device *adev, in disable_snd_device() argument
760 if (adev->snd_dev_ref_cnt[snd_device] <= 0) { in disable_snd_device()
764 adev->snd_dev_ref_cnt[snd_device]--; in disable_snd_device()
765 if (adev->snd_dev_ref_cnt[snd_device] == 0) { in disable_snd_device()
778 static int select_devices(struct audio_device *adev, in select_devices() argument
795 usecase = get_usecase_from_type(adev, PCM_CAPTURE|VOICE_CALL); in select_devices()
800 usecase = get_usecase_from_id(adev, uc_id); in select_devices()
808 out_snd_device = get_output_snd_device(adev, active_out->devices); in select_devices()
809 in_snd_device = get_input_snd_device(adev, active_out->devices); in select_devices()
818 if (adev->in_call) { in select_devices()
819 vc_usecase = get_usecase_from_id(adev, USECASE_VOICE_CALL); in select_devices()
831 out_snd_device = get_output_snd_device(adev, active_out->devices); in select_devices()
832 if (active_out == adev->primary_output && in select_devices()
835 select_devices(adev, active_input->usecase); in select_devices()
843 adev->primary_output && !adev->primary_output->standby) { in select_devices()
844 in_snd_device = get_input_snd_device(adev, adev->primary_output->devices); in select_devices()
846 in_snd_device = get_input_snd_device(adev, AUDIO_DEVICE_NONE); in select_devices()
864 pthread_mutex_lock(&adev->tfa9895_lock); in select_devices()
865 disable_snd_device(adev, usecase, usecase->out_snd_device, false); in select_devices()
866 pthread_mutex_unlock(&adev->tfa9895_lock); in select_devices()
870 disable_snd_device(adev, usecase, usecase->in_snd_device, false); in select_devices()
875 enable_snd_device(adev, usecase, out_snd_device, false); in select_devices()
879 enable_snd_device(adev, usecase, in_snd_device, false); in select_devices()
892 if (adev->htc_acoustic_set_rt5506_amp != NULL) in select_devices()
893 adev->htc_acoustic_set_rt5506_amp(adev->mode, usecase->devices); in select_devices()
1109 static void put_echo_reference(struct audio_device *adev, in put_echo_reference() argument
1113 int32_t prev_generation = adev->echo_reference_generation; in put_echo_reference()
1114 struct stream_out *out = adev->primary_output; in put_echo_reference()
1116 if (adev->echo_reference != NULL && in put_echo_reference()
1117 reference == adev->echo_reference) { in put_echo_reference()
1120 adev->echo_reference = NULL; in put_echo_reference()
1121 android_atomic_inc(&adev->echo_reference_generation); in put_echo_reference()
1136 static struct echo_reference_itfe *get_echo_reference(struct audio_device *adev, in get_echo_reference() argument
1142 put_echo_reference(adev, adev->echo_reference); in get_echo_reference()
1145 if (adev->primary_output!= NULL && adev->primary_output->usecase == USECASE_AUDIO_PLAYBACK && in get_echo_reference()
1146 !adev->primary_output->standby) { in get_echo_reference()
1148 &adev->primary_output->stream.common; in get_echo_reference()
1158 &adev->echo_reference); in get_echo_reference()
1160 android_atomic_inc(&adev->echo_reference_generation); in get_echo_reference()
1162 return adev->echo_reference; in get_echo_reference()
1170 struct audio_device *adev = in->dev; in get_hw_echo_reference() local
1174 if (adev->primary_output!= NULL && in get_hw_echo_reference()
1175 !adev->primary_output->standby && in get_hw_echo_reference()
1176 adev->primary_output->usecase == USECASE_AUDIO_PLAYBACK && in get_hw_echo_reference()
1177 adev->primary_output->devices == AUDIO_DEVICE_OUT_SPEAKER) { in get_hw_echo_reference()
1178 struct audio_stream *stream = &adev->primary_output->stream.common; in get_hw_echo_reference()
1890 struct audio_device *adev = in->dev; in stop_input_stream() local
1892 adev->active_input = NULL; in stop_input_stream()
1895 uc_info = get_usecase_from_id(adev, in->usecase); in stop_input_stream()
1903 disable_snd_device(adev, uc_info, uc_info->in_snd_device, true); in stop_input_stream()
1933 struct audio_device *adev = in->dev; in start_input_stream() local
1938 adev->active_input = in; in start_input_stream()
1969 &adev_get_mixer_for_card(adev, in start_input_stream()
1972 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); in start_input_stream()
1974 select_devices(adev, in->usecase); in start_input_stream()
2013 in->echo_reference = get_echo_reference(adev, in start_input_stream()
2042 if (!adev->sound_trigger_open_for_streaming) { in start_input_stream()
2048 pcm_device->sound_trigger_handle = adev->sound_trigger_open_for_streaming(); in start_input_stream()
2093 adev->active_input = NULL; in start_input_stream()
2278 struct audio_device *adev = out->dev; in out_close_pcm_devices() local
2283 adev->sound_trigger_close_for_streaming(pcm_device->sound_trigger_handle); in out_close_pcm_devices()
2351 struct audio_device *adev = out->dev; in disable_output_path_l() local
2354 uc_info = get_usecase_from_id(adev, out->usecase); in disable_output_path_l()
2360 disable_snd_device(adev, uc_info, uc_info->out_snd_device, true); in disable_output_path_l()
2370 struct audio_device *adev = out->dev; in enable_output_path_l() local
2382 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); in enable_output_path_l()
2384 select_devices(adev, out->usecase); in enable_output_path_l()
2390 struct audio_device *adev = out->dev; in stop_output_stream() local
2397 adev->offload_fx_stop_output != NULL) { in stop_output_stream()
2398 adev->offload_fx_stop_output(out->handle); in stop_output_stream()
2415 struct audio_device *adev = out->dev; in start_output_stream() local
2429 out->echo_reference_generation = adev->echo_reference_generation; in start_output_stream()
2430 if (adev->echo_reference != NULL) in start_output_stream()
2431 out->echo_reference = adev->echo_reference; in start_output_stream()
2446 if (adev->offload_fx_start_output != NULL) in start_output_stream()
2447 adev->offload_fx_start_output(out->handle); in start_output_stream()
2457 static int stop_voice_call(struct audio_device *adev) in stop_voice_call() argument
2462 adev->in_call = false; in stop_voice_call()
2466 uc_info = get_usecase_from_id(adev, USECASE_VOICE_CALL); in stop_voice_call()
2473 disable_snd_device(adev, uc_info, uc_info->out_snd_device, false); in stop_voice_call()
2474 disable_snd_device(adev, uc_info, uc_info->in_snd_device, true); in stop_voice_call()
2485 static int start_voice_call(struct audio_device *adev) in start_voice_call() argument
2494 uc_info->stream = (struct audio_stream *)adev->primary_output; in start_voice_call()
2495 uc_info->devices = adev->primary_output->devices; in start_voice_call()
2501 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); in start_voice_call()
2503 select_devices(adev, USECASE_VOICE_CALL); in start_voice_call()
2509 set_voice_volume_l(adev, adev->voice_volume); in start_voice_call()
2511 adev->in_call = true; in start_voice_call()
2618 struct audio_device *adev = out->dev; in do_out_standby_l() local
2628 if (out->echo_reference_generation != adev->echo_reference_generation) { in do_out_standby_l()
2631 out->echo_reference_generation = adev->echo_reference_generation; in do_out_standby_l()
2653 struct audio_device *adev = out->dev; in out_standby() local
2659 pthread_mutex_lock(&adev->lock); in out_standby()
2661 pthread_mutex_unlock(&adev->lock); in out_standby()
2712 struct audio_device *adev = out->dev; in out_set_parameters() local
2727 __func__, out->usecase, use_case_table[out->usecase], kvpairs, out->devices, adev->mode); in out_set_parameters()
2732 pthread_mutex_lock(&adev->lock_inputs); in out_set_parameters()
2734 pthread_mutex_lock(&adev->lock); in out_set_parameters()
2741 … if (adev->active_input && (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION || in out_set_parameters()
2742 adev->active_input->source == AUDIO_SOURCE_MIC)) { in out_set_parameters()
2743 in = adev->active_input; in out_set_parameters()
2751 uc_info = get_usecase_from_id(adev, out->usecase); in out_set_parameters()
2768 select_devices(adev, out->usecase); in out_set_parameters()
2771 if ((adev->mode == AUDIO_MODE_IN_CALL) && !adev->in_call && in out_set_parameters()
2772 (out == adev->primary_output)) { in out_set_parameters()
2773 start_voice_call(adev); in out_set_parameters()
2774 } else if ((adev->mode == AUDIO_MODE_IN_CALL) && adev->in_call && in out_set_parameters()
2775 (out == adev->primary_output)) { in out_set_parameters()
2776 select_devices(adev, USECASE_VOICE_CALL); in out_set_parameters()
2780 if ((adev->mode == AUDIO_MODE_NORMAL) && adev->in_call && in out_set_parameters()
2781 (out == adev->primary_output)) { in out_set_parameters()
2782 stop_voice_call(adev); in out_set_parameters()
2784 pthread_mutex_unlock(&adev->lock); in out_set_parameters()
2790 pthread_mutex_lock(&adev->lock); in out_set_parameters()
2791 LOG_ALWAYS_FATAL_IF(in != adev->active_input); in out_set_parameters()
2793 pthread_mutex_unlock(&adev->lock); in out_set_parameters()
2797 pthread_mutex_unlock(&adev->lock_inputs); in out_set_parameters()
2863 struct audio_device *adev = out->dev; in out_set_volume() local
2904 struct audio_device *adev = (struct audio_device *)context; in tfa9895_config_thread() local
2905 pthread_mutex_lock(&adev->tfa9895_lock); in tfa9895_config_thread()
2906 adev->tfa9895_init = in tfa9895_config_thread()
2907 adev->htc_acoustic_set_amp_mode(adev->mode, AUDIO_DEVICE_OUT_SPEAKER, 0, 0, false); in tfa9895_config_thread()
2908 if (!adev->tfa9895_init) { in tfa9895_config_thread()
2910 adev->tfa9895_mode_change |= 0x1; in tfa9895_config_thread()
2912 ALOGI("@@##tfa9895_config_thread Done!! tfa9895_mode_change=%d", adev->tfa9895_mode_change); in tfa9895_config_thread()
2913 pthread_mutex_unlock(&adev->tfa9895_lock); in tfa9895_config_thread()
2914 dummybuf_thread_close(adev); in tfa9895_config_thread()
2922 struct audio_device *adev = out->dev; in out_write() local
2941 pthread_mutex_lock(&adev->lock_inputs); in out_write()
2944 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
2948 pthread_mutex_lock(&adev->lock); in out_write()
2952 pthread_mutex_unlock(&adev->lock); in out_write()
2954 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
2962 if (adev->active_input && in out_write()
2963 (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION || in out_write()
2964 adev->active_input->source == AUDIO_SOURCE_MIC)) { in out_write()
2965 in = adev->active_input; in out_write()
2969 pthread_mutex_unlock(&adev->lock); in out_write()
2973 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
2984 pthread_mutex_lock(&adev->lock); in out_write()
2986 pthread_mutex_unlock(&adev->lock); in out_write()
3008 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3014 if (android_atomic_acquire_load(&adev->echo_reference_generation) in out_write()
3016 pthread_mutex_lock(&adev->lock); in out_write()
3024 out->echo_reference_generation = adev->echo_reference_generation; in out_write()
3025 out->echo_reference = adev->echo_reference; in out_write()
3028 pthread_mutex_unlock(&adev->lock); in out_write()
3065 if (adev->tfa9895_mode_change == 0x1) { in out_write()
3067 pthread_mutex_lock(&adev->tfa9895_lock); in out_write()
3102 adev->tfa9895_mode_change &= ~0x1; in out_write()
3104 "adev->tfa9895_mode_change=%d", adev->tfa9895_mode_change); in out_write()
3105 adev->tfa9895_init = in out_write()
3106 adev->htc_acoustic_set_amp_mode( in out_write()
3107 adev->mode, AUDIO_DEVICE_OUT_SPEAKER, 0, 0, false); in out_write()
3126 pthread_mutex_unlock(&adev->tfa9895_lock); in out_write()
3132 pthread_mutex_unlock(&adev->tfa9895_lock); in out_write()
3167 pthread_mutex_lock(&adev->lock); in out_write()
3168 LOG_ALWAYS_FATAL_IF(in != adev->active_input); in out_write()
3170 pthread_mutex_unlock(&adev->lock); in out_write()
3173 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3409 struct audio_device *adev = in->dev; in in_close_pcm_devices() local
3418 adev->sound_trigger_close_for_streaming(pcm_device->sound_trigger_handle); in in_close_pcm_devices()
3432 struct audio_device *adev = in->dev; in do_in_standby_l() local
3442 put_echo_reference(adev, in->echo_reference); in do_in_standby_l()
3471 struct audio_device *adev = in->dev; in in_standby_l() local
3475 pthread_mutex_lock(&adev->lock); in in_standby_l()
3477 pthread_mutex_unlock(&adev->lock); in in_standby_l()
3486 struct audio_device *adev = in->dev; in in_standby() local
3489 pthread_mutex_lock(&adev->lock_inputs); in in_standby()
3491 pthread_mutex_unlock(&adev->lock_inputs); in in_standby()
3507 struct audio_device *adev = in->dev; in in_set_parameters() local
3523 pthread_mutex_lock(&adev->lock_inputs); in in_set_parameters()
3525 pthread_mutex_lock(&adev->lock); in in_set_parameters()
3541 uc_info = get_usecase_from_id(adev, in->usecase); in in_set_parameters()
3559 ret = select_devices(adev, in->usecase); in in_set_parameters()
3563 pthread_mutex_unlock(&adev->lock); in in_set_parameters()
3565 pthread_mutex_unlock(&adev->lock_inputs); in in_set_parameters()
3592 struct audio_device *adev = in->dev; in read_bytes_from_dsp() local
3598 return adev->sound_trigger_read_samples(pcm_device->sound_trigger_handle, buffer, bytes); in read_bytes_from_dsp()
3607 struct audio_device *adev = in->dev; in in_read() local
3618 pthread_mutex_lock(&adev->lock_inputs); in in_read()
3621 pthread_mutex_unlock(&adev->lock_inputs); in in_read()
3624 pthread_mutex_lock(&adev->lock); in in_read()
3626 pthread_mutex_unlock(&adev->lock); in in_read()
3627 pthread_mutex_unlock(&adev->lock_inputs); in in_read()
3657 if (read_and_process_successful == true && adev->mic_mute) in in_read()
3684 struct audio_device *adev = in->dev; in add_remove_audio_effect() local
3696 pthread_mutex_lock(&adev->lock_inputs); in add_remove_audio_effect()
3770 pthread_mutex_unlock(&adev->lock_inputs); in add_remove_audio_effect()
3796 struct audio_device *adev = (struct audio_device *)dev; in adev_open_output_stream() local
3811 out->dev = adev; in adev_open_output_stream()
3888 if (adev->primary_output == NULL) in adev_open_output_stream()
3889 adev->primary_output = out; in adev_open_output_stream()
3898 pthread_mutex_lock(&adev->lock); in adev_open_output_stream()
3899 if (get_usecase_from_id(adev, out->usecase) != NULL) { in adev_open_output_stream()
3901 pthread_mutex_unlock(&adev->lock); in adev_open_output_stream()
3905 pthread_mutex_unlock(&adev->lock); in adev_open_output_stream()
3952 struct audio_device *adev = out->dev; in adev_close_output_stream() local
3971 struct audio_device *adev = (struct audio_device *)dev; in adev_set_parameters() local
3996 pthread_mutex_lock(&adev->lock); in adev_set_parameters()
3997 if (tty_mode != adev->tty_mode) { in adev_set_parameters()
3998 adev->tty_mode = tty_mode; in adev_set_parameters()
3999 if (adev->in_call) in adev_set_parameters()
4000 select_devices(adev, USECASE_VOICE_CALL); in adev_set_parameters()
4002 pthread_mutex_unlock(&adev->lock); in adev_set_parameters()
4011 adev->bluetooth_nrec = true; in adev_set_parameters()
4013 adev->bluetooth_nrec = false; in adev_set_parameters()
4019 adev->screen_off = false; in adev_set_parameters()
4021 adev->screen_off = true; in adev_set_parameters()
4041 pthread_mutex_lock(&adev->lock); in adev_set_parameters()
4042 if (adev->speaker_lr_swap != reverse_speakers) { in adev_set_parameters()
4043 adev->speaker_lr_swap = reverse_speakers; in adev_set_parameters()
4047 list_for_each(node, &adev->usecase_list) { in adev_set_parameters()
4050 select_devices(adev, usecase->id); in adev_set_parameters()
4051 if (adev->htc_acoustic_spk_reverse) in adev_set_parameters()
4052 adev->htc_acoustic_spk_reverse(adev->speaker_lr_swap); in adev_set_parameters()
4057 pthread_mutex_unlock(&adev->lock); in adev_set_parameters()
4084 struct audio_device *adev = (struct audio_device *)dev; in adev_set_voice_volume() local
4085 pthread_mutex_lock(&adev->lock); in adev_set_voice_volume()
4087 adev->voice_volume = volume; in adev_set_voice_volume()
4088 ret = set_voice_volume_l(adev, adev->voice_volume); in adev_set_voice_volume()
4089 pthread_mutex_unlock(&adev->lock); in adev_set_voice_volume()
4128 struct audio_device *adev = (struct audio_device *)dev; in adev_set_mode() local
4130 pthread_mutex_lock(&adev->lock); in adev_set_mode()
4131 if (adev->mode != mode) { in adev_set_mode()
4133 adev->mode = mode; in adev_set_mode()
4134 pthread_mutex_lock(&adev->tfa9895_lock); in adev_set_mode()
4135 adev->tfa9895_mode_change |= 0x1; in adev_set_mode()
4136 pthread_mutex_unlock(&adev->tfa9895_lock); in adev_set_mode()
4138 pthread_mutex_unlock(&adev->lock); in adev_set_mode()
4144 struct audio_device *adev = (struct audio_device *)dev; in adev_set_mic_mute() local
4147 pthread_mutex_lock(&adev->lock); in adev_set_mic_mute()
4148 adev->mic_mute = state; in adev_set_mic_mute()
4150 if (adev->mode == AUDIO_MODE_IN_CALL) { in adev_set_mic_mute()
4154 pthread_mutex_unlock(&adev->lock); in adev_set_mic_mute()
4160 struct audio_device *adev = (struct audio_device *)dev; in adev_get_mic_mute() local
4162 *state = adev->mic_mute; in adev_get_mic_mute()
4190 struct audio_device *adev = (struct audio_device *)dev; in adev_open_input_stream() local
4229 in->dev = adev; in adev_open_input_stream()
4255 struct audio_device *adev = (struct audio_device *)dev; in adev_close_input_stream() local
4260 pthread_mutex_lock(&adev->lock_inputs); in adev_close_input_stream()
4298 pthread_mutex_unlock(&adev->lock_inputs); in adev_close_input_stream()
4313 struct audio_device *adev = (struct audio_device *)device; in adev_close() local
4315 free(adev->snd_dev_ref_cnt); in adev_close()
4316 free_mixer_list(adev); in adev_close()
4325 struct audio_device *adev = (struct audio_device *)context; in dummybuf_thread() local
4335 if (adev->dummybuf_thread_devices == AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { in dummybuf_thread()
4346 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4363 adev->dummybuf_thread_active = 1; in dummybuf_thread()
4369 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4373 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4376 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4383 adev->dummybuf_thread_active = 1; in dummybuf_thread()
4400 if (adev->dummybuf_thread_cancel || adev->dummybuf_thread_timeout-- <= 0) { in dummybuf_thread()
4401 adev->dummybuf_thread_active = 0; in dummybuf_thread()
4402 adev->dummybuf_thread_cancel = 0; in dummybuf_thread()
4413 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4418 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4428 static void dummybuf_thread_open(struct audio_device *adev) in dummybuf_thread_open() argument
4430 adev->dummybuf_thread_timeout = 6000; /* in 18 sec */ in dummybuf_thread_open()
4431 adev->dummybuf_thread_cancel = 0; in dummybuf_thread_open()
4432 adev->dummybuf_thread_active = 0; in dummybuf_thread_open()
4433 pthread_mutex_init(&adev->dummybuf_thread_lock, (const pthread_mutexattr_t *) NULL); in dummybuf_thread_open()
4434 if (!adev->dummybuf_thread) in dummybuf_thread_open()
4435 … pthread_create(&adev->dummybuf_thread, (const pthread_attr_t *) NULL, dummybuf_thread, adev); in dummybuf_thread_open()
4438 static void dummybuf_thread_close(struct audio_device *adev) in dummybuf_thread_close() argument
4443 if (adev->dummybuf_thread == 0) in dummybuf_thread_close()
4446 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4447 adev->dummybuf_thread_cancel = 1; in dummybuf_thread_close()
4448 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4451 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4452 if (adev->dummybuf_thread_active == 0) { in dummybuf_thread_close()
4453 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4456 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4461 pthread_join(adev->dummybuf_thread, (void **) NULL); in dummybuf_thread_close()
4462 pthread_mutex_destroy(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4463 adev->dummybuf_thread = 0; in dummybuf_thread_close()
4469 struct audio_device *adev; in adev_open() local
4475 adev = calloc(1, sizeof(struct audio_device)); in adev_open()
4477 adev->device.common.tag = HARDWARE_DEVICE_TAG; in adev_open()
4478 adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0; in adev_open()
4479 adev->device.common.module = (struct hw_module_t *)module; in adev_open()
4480 adev->device.common.close = adev_close; in adev_open()
4482 adev->device.init_check = adev_init_check; in adev_open()
4483 adev->device.set_voice_volume = adev_set_voice_volume; in adev_open()
4484 adev->device.set_master_volume = adev_set_master_volume; in adev_open()
4485 adev->device.get_master_volume = adev_get_master_volume; in adev_open()
4486 adev->device.set_master_mute = adev_set_master_mute; in adev_open()
4487 adev->device.get_master_mute = adev_get_master_mute; in adev_open()
4488 adev->device.set_mode = adev_set_mode; in adev_open()
4489 adev->device.set_mic_mute = adev_set_mic_mute; in adev_open()
4490 adev->device.get_mic_mute = adev_get_mic_mute; in adev_open()
4491 adev->device.set_parameters = adev_set_parameters; in adev_open()
4492 adev->device.get_parameters = adev_get_parameters; in adev_open()
4493 adev->device.get_input_buffer_size = adev_get_input_buffer_size; in adev_open()
4494 adev->device.open_output_stream = adev_open_output_stream; in adev_open()
4495 adev->device.close_output_stream = adev_close_output_stream; in adev_open()
4496 adev->device.open_input_stream = adev_open_input_stream; in adev_open()
4497 adev->device.close_input_stream = adev_close_input_stream; in adev_open()
4498 adev->device.dump = adev_dump; in adev_open()
4501 adev->mode = AUDIO_MODE_NORMAL; in adev_open()
4502 adev->active_input = NULL; in adev_open()
4503 adev->primary_output = NULL; in adev_open()
4504 adev->voice_volume = 1.0f; in adev_open()
4505 adev->tty_mode = TTY_MODE_OFF; in adev_open()
4506 adev->bluetooth_nrec = true; in adev_open()
4507 adev->in_call = false; in adev_open()
4509 adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int)); in adev_open()
4511 adev->dualmic_config = DUALMIC_CONFIG_NONE; in adev_open()
4512 adev->ns_in_voice_rec = false; in adev_open()
4514 list_init(&adev->usecase_list); in adev_open()
4516 if (mixer_init(adev) != 0) { in adev_open()
4517 free(adev->snd_dev_ref_cnt); in adev_open()
4518 free(adev); in adev_open()
4525 adev->offload_fx_lib = dlopen(OFFLOAD_FX_LIBRARY_PATH, RTLD_NOW); in adev_open()
4526 if (adev->offload_fx_lib == NULL) { in adev_open()
4530 adev->offload_fx_start_output = in adev_open()
4531 (int (*)(audio_io_handle_t))dlsym(adev->offload_fx_lib, in adev_open()
4533 adev->offload_fx_stop_output = in adev_open()
4534 (int (*)(audio_io_handle_t))dlsym(adev->offload_fx_lib, in adev_open()
4540 adev->htc_acoustic_lib = dlopen(HTC_ACOUSTIC_LIBRARY_PATH, RTLD_NOW); in adev_open()
4541 if (adev->htc_acoustic_lib == NULL) { in adev_open()
4545 adev->htc_acoustic_init_rt5506 = in adev_open()
4546 (int (*)())dlsym(adev->htc_acoustic_lib, in adev_open()
4548 adev->htc_acoustic_set_rt5506_amp = in adev_open()
4549 (int (*)(int, int))dlsym(adev->htc_acoustic_lib, in adev_open()
4551 adev->htc_acoustic_set_amp_mode = in adev_open()
4552 (int (*)(int , int, int, int, bool))dlsym(adev->htc_acoustic_lib, in adev_open()
4554 adev->htc_acoustic_spk_reverse = in adev_open()
4555 (int (*)(bool))dlsym(adev->htc_acoustic_lib, in adev_open()
4557 if (adev->htc_acoustic_spk_reverse) in adev_open()
4558 adev->htc_acoustic_spk_reverse(adev->speaker_lr_swap); in adev_open()
4563 adev->sound_trigger_lib = dlopen(SOUND_TRIGGER_HAL_LIBRARY_PATH, RTLD_NOW); in adev_open()
4564 if (adev->sound_trigger_lib == NULL) { in adev_open()
4568 adev->sound_trigger_open_for_streaming = in adev_open()
4569 (int (*)(void))dlsym(adev->sound_trigger_lib, in adev_open()
4571 adev->sound_trigger_read_samples = in adev_open()
4572 (int (*)(audio_io_handle_t, int))dlsym(adev->sound_trigger_lib, in adev_open()
4574 adev->sound_trigger_close_for_streaming = in adev_open()
4575 (int (*)(int))dlsym(adev->sound_trigger_lib, in adev_open()
4577 if (!adev->sound_trigger_open_for_streaming || in adev_open()
4578 !adev->sound_trigger_read_samples || in adev_open()
4579 !adev->sound_trigger_close_for_streaming) { in adev_open()
4582 adev->sound_trigger_open_for_streaming = 0; in adev_open()
4583 adev->sound_trigger_read_samples = 0; in adev_open()
4584 adev->sound_trigger_close_for_streaming = 0; in adev_open()
4590 *device = &adev->device.common; in adev_open()
4592 if (adev->htc_acoustic_init_rt5506 != NULL) in adev_open()
4593 adev->htc_acoustic_init_rt5506(); in adev_open()
4597 adev->dummybuf_thread_devices = AUDIO_DEVICE_OUT_WIRED_HEADPHONE; in adev_open()
4598 dummybuf_thread_open(adev); in adev_open()
4601 pthread_mutex_lock(&adev->dummybuf_thread_lock); in adev_open()
4602 if (adev->dummybuf_thread_active != 0) { in adev_open()
4603 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()
4606 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()
4609 dummybuf_thread_close(adev); in adev_open()
4612 if (adev->htc_acoustic_set_amp_mode) { in adev_open()
4614 adev->dummybuf_thread_devices = AUDIO_DEVICE_OUT_SPEAKER; in adev_open()
4615 dummybuf_thread_open(adev); in adev_open()
4616 pthread_mutex_lock(&adev->dummybuf_thread_lock); in adev_open()
4619 if (adev->dummybuf_thread_active) { in adev_open()
4622 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()
4624 pthread_mutex_lock(&adev->dummybuf_thread_lock); in adev_open()
4626 if (adev->dummybuf_thread_active) { in adev_open()
4628 if (pthread_create(&th, NULL, tfa9895_config_thread, (void* )adev) != 0) { in adev_open()
4632 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()