static void* svc_context(void *__u) { SVCXPRT *xprt = (SVCXPRT *)__u; int n; struct timeval tv; volatile fd_set rfds; while(xprt->num_servers) { rfds = xprt->fdset; tv.tv_sec = 1; tv.tv_usec = 0; n = select(xprt->max_fd + 1, (fd_set *)&rfds, NULL, NULL, &tv); if (n < 0) { E("select() error %s (%d)\n", strerror(errno), errno); continue; } if (n) { grabPartialWakeLock(); for (n = 0; n <= xprt->max_fd; n++) { if (FD_ISSET(n, &rfds)) { /* the file descriptor points to the service instance; we simply look that service by its file descriptor, and call its service function. */ /* FIXME: need to take xprt->lock */ registered_server *trav = xprt->servers; for (; trav; trav = trav->next) if ((trav->xdr) && (trav->xdr->fd == n)) { /* read the entire RPC */ if (trav->xdr->xops->read(trav->xdr) == 0) { E("%08x:%08x ONCRPC read error: aborting!\n", trav->xdr->x_prog, trav->xdr->x_vers); abort(); } svc_dispatch(trav, xprt); break; } } /* if fd is set */ } /* for each fd */ releaseWakeLock(); } } D("RPC-server thread exiting!\n"); return NULL; }
static int set_phone_path(struct codec_client *client, int path) { int ret = -1; int earpiece_on=0, headset_on=0, headphone_on=0, bt_on=0, speaker_on=0; int pa_should_on=0; headset_on = path & AUDIO_DEVICE_OUT_WIRED_HEADSET; // hp4p headphone_on = path & AUDIO_DEVICE_OUT_WIRED_HEADPHONE; // hp3p speaker_on = path & AUDIO_DEVICE_OUT_SPEAKER; earpiece_on = path & AUDIO_DEVICE_OUT_EARPIECE; bt_on = path & AUDIO_DEVICE_OUT_ALL_SCO; ALOGV("mode= phone mode 4, devices is 0x%x, ****LINE:%d,FUNC:%s", path, __LINE__,__FUNCTION__); in_call = true; if(last_path_is_bt){ plan_one_stop_bt_voice(); if (bluetooth_in_record == true){ plan_one_stop_bt_record(); bluetooth_in_record = false; } last_path_is_bt = false; if(mixer_ctl_get_value(client->mixer_ctls->audio_adc_phone_in, 0) == 1 ){ mixer_ctl_set_value(client->mixer_ctls->audio_adc_phone_in, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_dac_phone_out, 0, 0); } } if (is_in_record){ client->record_ops->set_record_source(!bt_on); } if(mixer_ctl_get_value(client->mixer_ctls->audio_linein_in,0)){ mixer_ctl_set_value(client->mixer_ctls->audio_linein_in, 0, 0); //turn off fm } if (bt_on){ mixer_ctl_set_value(client->mixer_ctls->audio_phone_in, 0,0); } else { mixer_ctl_set_value(client->mixer_ctls->audio_phone_in, 0,1); } #if 1 mixer_ctl_set_value(client->mixer_ctls->audio_phone_out, 0,1); if(earpiece_on && (no_earpiece == 0)){ mixer_ctl_set_value(client->mixer_ctls->audio_speaker_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_headphone_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_earpiece_out, 0, 1); mixer_ctl_set_value(client->mixer_ctls->audio_phone_headset_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_phone_main_mic, 0, 1); ALOGV("in earpiece ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if(speaker_on || (earpiece_on && (no_earpiece == 1))) { mixer_ctl_set_value(client->mixer_ctls->audio_earpiece_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_headphone_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_speaker_out, 0, 1); mixer_ctl_set_value(client->mixer_ctls->audio_phone_headset_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_phone_main_mic, 0, 1); ALOGV("in speaker pa ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if (headphone_on) { //no mic hp3p mixer_ctl_set_value(client->mixer_ctls->audio_earpiece_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_speaker_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_headphone_out, 0, 1); mixer_ctl_set_value(client->mixer_ctls->audio_phone_headset_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_phone_main_mic, 0, 1); ALOGV("in wire head with no mic ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if (headset_on) { //mic // hp4p mixer_ctl_set_value(client->mixer_ctls->audio_earpiece_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_speaker_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_headphone_out, 0, 1); mixer_ctl_set_value(client->mixer_ctls->audio_phone_main_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_phone_headset_mic, 0, 1); ALOGV("in wire head with mic ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if (bt_on) { if(!wake_lock){ grabPartialWakeLock(); wake_lock=true; } mixer_ctl_set_value(client->mixer_ctls->audio_earpiece_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_headphone_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_speaker_out, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_phone_main_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_phone_headset_mic, 0, 0); ALOGV("in bluetooth ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); mixer_ctl_set_value(client->mixer_ctls->audio_adc_phone_in, 0, 1); mixer_ctl_set_value(client->mixer_ctls->audio_dac_phone_out, 0, 1); plan_one_start_bt_voice(client->vol_array->up_pcm_gain); last_path_is_bt = true; if (is_in_record && (bluetooth_in_record == false)){ plan_one_start_bt_record(); bluetooth_in_record = true; } } #endif return 0; }
static int set_phone_path(struct codec_client *client, int path) { int ret = -1; int earpiece_on=0, headset_on=0, headphone_on=0, bt_on=0, speaker_on=0; int pa_should_on=0; headset_on = path & AUDIO_DEVICE_OUT_WIRED_HEADSET; // hp4p headphone_on = path & AUDIO_DEVICE_OUT_WIRED_HEADPHONE; // hp3p speaker_on = path & AUDIO_DEVICE_OUT_SPEAKER; earpiece_on = path & AUDIO_DEVICE_OUT_EARPIECE; bt_on = path & AUDIO_DEVICE_OUT_ALL_SCO; ALOGV("mode= phone mode 4, devices is 0x%x, ****LINE:%d,FUNC:%s", path, __LINE__,__FUNCTION__); #if 0 if(!wake_lock){ grabPartialWakeLock(); wake_lock=true; } if(last_path_is_bt){ last_path_is_bt = false; plan_two_stop_bt_voice(); #if 1 if(mixer_ctl_get_value(client->mixer_ctls->audio_adc_phone_in, 0) == 1 ){ ALOGV("mode= phone audio_adc_phone_in=1"); mixer_ctl_set_value(client->mixer_ctls->audio_adc_phone_in, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_dac_phone_out, 0, 0); } #endif } if (g_is_bp_thread_running == false){ plan_two_start_voice(); g_is_bp_thread_running = true; } #endif if(mixer_ctl_get_value(client->mixer_ctls->audio_linein_in,0)){ mixer_ctl_set_value(client->mixer_ctls->audio_linein_in, 0, 0); //turn off fm } #if 1 if(earpiece_on && (no_earpiece == 0)) { mixer_ctl_set_value(client->mixer_ctls->audio_digital_headset_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_digital_main_mic, 0, 1); mixer_ctl_set_enum_by_string(client->mixer_ctls->audio_spk_headset_switch, "earpiece");// "spk" : "headset"); ALOGV("in earpiece ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if(speaker_on || (earpiece_on && (no_earpiece == 1))) { mixer_ctl_set_value(client->mixer_ctls->audio_digital_headset_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_digital_main_mic, 0, 1); mixer_ctl_set_enum_by_string(client->mixer_ctls->audio_spk_headset_switch, "spk");// "spk" : "headset"); ALOGV("in speaker pa ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if (headphone_on) { //no mic hp3p mixer_ctl_set_value(client->mixer_ctls->audio_digital_headset_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_digital_main_mic, 0, 1); mixer_ctl_set_enum_by_string(client->mixer_ctls->audio_spk_headset_switch, "headset");// "spk" : "headset"); ALOGV("in wire head with no mic ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if (headset_on) { //mic // hp4p mixer_ctl_set_value(client->mixer_ctls->audio_digital_main_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_digital_headset_mic, 0, 1); mixer_ctl_set_enum_by_string(client->mixer_ctls->audio_spk_headset_switch, "headset");// "spk" : "headset"); ALOGV("in wire head with mic ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); } else if (bt_on) { if (g_is_bp_thread_running == true){ plan_two_stop_voice(); g_is_bp_thread_running = false; } mixer_ctl_set_value(client->mixer_ctls->audio_digital_main_mic, 0, 0); mixer_ctl_set_value(client->mixer_ctls->audio_digital_headset_mic, 0, 0); #if 0 // for a23 ALOGV("in bluetooth ****LINE:%d,FUNC:%s",__LINE__,__FUNCTION__); mixer_ctl_set_value(client->mixer_ctls->audio_adc_phone_in, 0, 1); mixer_ctl_set_value(client->mixer_ctls->audio_dac_phone_out, 0, 1); plan_two_start_bt_voice(client->vol_array->up_pcm_gain); last_path_is_bt = true; //property_set(BLUETOOTH_VOICE, "on"); //adev->bluetooth_voice = true; #endif } #endif return 0; }