Lines Matching full:handle
104 void (*thermal_client_unregister_callback)(int handle);
122 static struct speaker_prot_session handle;
129 handle.spkr_in_use = true;
131 handle.spkr_in_use = false;
132 clock_gettime(CLOCK_BOOTTIME, &handle.spkr_last_time_used);
143 if (pthread_equal(handle.speaker_prot_threadid, threadid) || !adev) {
149 pthread_mutex_lock(&handle.mutex_spkr_prot);
150 pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex);
151 handle.cancel_spkr_calib = 1;
152 pthread_cond_signal(&handle.spkr_calib_cancel);
153 pthread_mutex_unlock(&handle.mutex_spkr_prot);
154 pthread_cond_wait(&handle.spkr_calibcancel_ack,
155 &handle.spkr_calib_cancelack_mutex);
156 pthread_mutex_unlock(&handle.spkr_calib_cancelack_mutex);
168 if (handle.spkr_in_use) {
173 *sec = temp.tv_sec - handle.spkr_last_time_used.tv_sec;
296 struct audio_device *adev = handle.adev_handle;
352 handle.pcm_rx = handle.pcm_tx = NULL;
353 handle.pcm_rx = pcm_open(adev->snd_card,
356 if (handle.pcm_rx && !pcm_is_ready(handle.pcm_rx)) {
357 ALOGE("%s: %s", __func__, pcm_get_error(handle.pcm_rx));
384 handle.pcm_tx = pcm_open(adev->snd_card,
387 if (handle.pcm_tx && !pcm_is_ready(handle.pcm_tx)) {
388 ALOGE("%s: %s", __func__, pcm_get_error(handle.pcm_tx));
392 if (pcm_start(handle.pcm_rx) < 0) {
397 if (pcm_start(handle.pcm_tx) < 0) {
406 pthread_mutex_lock(&handle.mutex_spkr_prot);
409 (void)pthread_cond_timedwait(&handle.spkr_calib_cancel,
410 &handle.mutex_spkr_prot, &ts);
412 pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex);
413 if (handle.cancel_spkr_calib) {
464 if (handle.pcm_rx)
465 pcm_close(handle.pcm_rx);
466 handle.pcm_rx = NULL;
468 if (handle.pcm_tx)
469 pcm_close(handle.pcm_tx);
470 handle.pcm_tx = NULL;
481 handle.spkr_prot_mode = MSM_SPKR_PROT_CALIBRATED;
484 handle.spkr_prot_mode = MSM_SPKR_PROT_NOT_CALIBRATED;
491 if (!handle.cancel_spkr_calib && cleanup) {
492 handle.spkr_calib_cancelack_mutex);
493 pthread_cond_wait(&handle.spkr_calib_cancel, &handle.mutex_spkr_prot);
494 pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex);
509 if (handle.cancel_spkr_calib)
510 pthread_cond_signal(&handle.spkr_calibcancel_ack);
511 handle.cancel_spkr_calib = 0;
512 pthread_mutex_unlock(&handle.spkr_calib_cancelack_mutex);
513 pthread_mutex_unlock(&handle.mutex_spkr_prot);
528 struct audio_device *adev = handle.adev_handle;
540 handle.speaker_prot_threadid = pthread_self();
548 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED;
551 handle.spkr_prot_mode = MSM_SPKR_PROT_NOT_CALIBRATED;
553 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED;
556 if (handle.spkr_prot_mode == MSM_SPKR_PROT_DISABLED) {
598 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED;
600 handle.spkr_prot_mode = MSM_SPKR_PROT_CALIBRATED;
610 if (!handle.thermal_client_request("spkr",1)) {
612 pthread_mutex_lock(&handle.spkr_prot_thermalsync_mutex);
613 pthread_cond_wait(&handle.spkr_prot_thermalsync,
614 &handle.spkr_prot_thermalsync_mutex);
616 t0 = (handle.spkr_prot_t0 * (1 << 6));
617 pthread_mutex_unlock(&handle.spkr_prot_thermalsync_mutex);
620 handle.spkr_prot_t0);
624 handle.spkr_prot_t0);
665 if (handle.thermal_client_handle)
666 handle.thermal_client_unregister_callback(handle.thermal_client_handle);
667 handle.thermal_client_handle = 0;
668 if (handle.thermal_handle)
669 dlclose(handle.thermal_handle);
670 handle.thermal_handle = NULL;
677 pthread_mutex_lock(&handle.spkr_prot_thermalsync_mutex);
679 if (handle.spkr_prot_mode == MSM_SPKR_PROT_NOT_CALIBRATED)
680 handle.spkr_prot_t0 = temp;
681 pthread_cond_signal(&handle.spkr_prot_thermalsync);
682 pthread_mutex_unlock(&handle.spkr_prot_thermalsync_mutex);
690 memset(&handle, 0, sizeof(handle));
696 handle.spkr_prot_enable = false;
698 handle.spkr_prot_enable = true;
699 if (!handle.spkr_prot_enable) {
703 handle.adev_handle = adev;
704 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED;
705 handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE;
706 handle.spkr_prot_t0 = -1;
707 pthread_cond_init(&handle.spkr_prot_thermalsync, NULL);
708 pthread_cond_init(&handle.spkr_calib_cancel, NULL);
709 pthread_cond_init(&handle.spkr_calibcancel_ack, NULL);
710 pthread_mutex_init(&handle.mutex_spkr_prot, NULL);
711 pthread_mutex_init(&handle.spkr_calib_cancelack_mutex, NULL);
712 pthread_mutex_init(&handle.spkr_prot_thermalsync_mutex, NULL);
713 handle.thermal_handle = dlopen("/vendor/lib/libthermalclient.so",
715 if (!handle.thermal_handle) {
719 handle.thermal_client_register_callback =
721 dlsym(handle.thermal_handle, "thermal_client_register_callback");
722 handle.thermal_client_unregister_callback =
724 dlsym(handle.thermal_handle, "thermal_client_unregister_callback");
725 if (!handle.thermal_client_register_callback ||
726 !handle.thermal_client_unregister_callback) {
730 handle.thermal_client_handle =
731 handle.thermal_client_register_callback("spkr", thermal_client_callback, NULL);
732 if (!handle.thermal_client_handle) {
736 handle.thermal_client_request = (int (*)(char *, int))
737 dlsym(handle.thermal_handle, "thermal_client_request");
741 if (handle.thermal_client_request) {
743 (void)pthread_create(&handle.spkr_calibration_thread,
744 (const pthread_attr_t *) NULL, spkr_calibration_thread, &handle);
747 if (handle.thermal_client_handle &&
748 handle.thermal_client_unregister_callback)
749 handle.thermal_client_unregister_callback(handle.thermal_client_handle);
750 if (handle.thermal_handle)
751 dlclose(handle.thermal_handle);
752 handle.thermal_handle = NULL;
753 handle.spkr_prot_enable = false;
756 if (handle.spkr_prot_enable) {
787 if (!handle.spkr_prot_enable)
803 struct audio_device *adev = handle.adev_handle;
822 pthread_mutex_lock(&handle.mutex_spkr_prot);
823 if (handle.spkr_processing_state == SPKR_PROCESSING_IN_IDLE) {
828 handle.pcm_tx = NULL;
840 handle.pcm_tx = pcm_open(adev->snd_card,
843 if (handle.pcm_tx && !pcm_is_ready(handle.pcm_tx)) {
844 ALOGE("%s: %s", __func__, pcm_get_error(handle.pcm_tx));
848 if (pcm_start(handle.pcm_tx) < 0) {
858 if (handle.pcm_tx)
859 pcm_close(handle.pcm_tx);
860 handle.pcm_tx = NULL;
866 handle.spkr_processing_state = SPKR_PROCESSING_IN_PROGRESS;
867 pthread_mutex_unlock(&handle.mutex_spkr_prot);
875 struct audio_device *adev = handle.adev_handle;
880 pthread_mutex_lock(&handle.mutex_spkr_prot);
881 if (adev && handle.spkr_processing_state == SPKR_PROCESSING_IN_PROGRESS) {
883 if (handle.pcm_tx)
884 pcm_close(handle.pcm_tx);
885 handle.pcm_tx = NULL;
893 handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE;
894 pthread_mutex_unlock(&handle.mutex_spkr_prot);
903 return handle.spkr_prot_enable;