Home | History | Annotate | Download | only in alsa_sound

Lines Matching refs:handle

197 static void switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t mode);
199 static void disableDevice(alsa_handle_t *handle);
216 int deviceName(alsa_handle_t *handle, unsigned flags, char **value)
226 strlcat(ident, handle->useCase, sizeof(ident));
227 ret = snd_use_case_get(handle->ucMgr, ident, (const char **)value);
262 status_t setHardwareParams(alsa_handle_t *handle)
267 unsigned int requestedRate = handle->sampleRate;
269 int channels = handle->channels;
278 reqBuffSize = handle->bufferSize;
280 (int) reqBuffSize, handle->channels, handle->sampleRate);
284 if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC))
285 || !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC))) {
286 ALOGV("HWParams: Use 4 channels in kernel for 5.1(%s) recording ", handle->useCase);
295 if (handle->format != SNDRV_PCM_FORMAT_S16_LE) {
296 if (handle->format == AudioSystem::AMR_NB
297 || handle->format == AudioSystem::AMR_WB
299 || handle->format == AudioSystem::EVRC
300 || handle->format == AudioSystem::EVRCB
301 || handle->format == AudioSystem::EVRCWB
316 param_set_int(params, SNDRV_PCM_HW_PARAM_RATE, handle->sampleRate);
317 param_set_hw_refine(handle->handle, params);
319 if (param_set_hw_params(handle->handle, params)) {
325 handle->handle->buffer_size = pcm_buffer_size(params);
326 handle->handle->period_size = pcm_period_size(params);
327 handle->handle->period_cnt = handle->handle->buffer_size/handle->handle->period_size;
329 handle->handle->buffer_size, handle->handle->period_size,
330 handle->handle->period_cnt);
331 handle->handle->rate = handle->sampleRate;
332 handle->handle->channels = handle->channels;
333 handle->periodSize = handle->handle->period_size;
334 if (strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC) &&
335 strcmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC) &&
336 (6 != handle->channels)) {
338 handle->bufferSize = handle->handle->period_size;
344 status_t setSoftwareParams(alsa_handle_t *handle)
347 struct pcm* pcm = handle->handle;
350 int channels = handle->channels;
360 if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC))
361 || !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC))) {
362 ALOGV("SWParams: Use 4 channels in kernel for 5.1(%s) recording ", handle->useCase);
371 if(((!strcmp(handle->useCase,SND_USE_CASE_MOD_PLAY_VOIP)) ||
372 (!strcmp(handle->useCase,SND_USE_CASE_VERB_IP_VOICECALL)))){
374 params->avail_min = handle->channels - 1 ? periodSize/4 : periodSize/2;
385 if (param_set_sw_params(handle->handle, params)) {
392 void switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t mode)
455 if ((devices & AudioSystem::DEVICE_IN_BUILTIN_MIC) && ( 6 == handle->channels)) {
456 if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC))
457 || !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC))) {
458 ALOGV(" switchDevice , use ssr devices for channels:%d usecase:%s",handle->channels,handle->useCase);
489 snd_use_case_get(handle->ucMgr, "_verb", (const char **)&use_case);
490 mods_size = snd_use_case_get_list(handle->ucMgr, "_enamods", &mods_list);
500 snd_use_case_set(handle->ucMgr, "_verb", SND_USE_CASE_VERB_INACTIVE);
510 snd_use_case_set(handle->ucMgr, "_dismod", mods_list[index]);
515 snd_use_case_set(handle->ucMgr, "_disdev", curRxUCMDevice);
527 snd_use_case_set(handle->ucMgr, "_verb", SND_USE_CASE_VERB_INACTIVE);
537 snd_use_case_set(handle->ucMgr, "_dismod", mods_list[index]);
542 snd_use_case_set(handle->ucMgr, "_disdev", curTxUCMDevice);
548 snd_use_case_set(handle->ucMgr, "_enadev", rxDevice);
556 snd_use_case_set(handle->ucMgr, "_enadev", txDevice);
563 snd_use_case_set(handle->ucMgr, "_verb", it->useCase);
565 snd_use_case_set(handle->ucMgr, "_enamod", it->useCase);
581 tx_dev_id = snd_use_case_get(handle->ucMgr, ident, NULL);
587 rx_dev_id = snd_use_case_get(handle->ucMgr, ident, NULL);
629 static status_t s_open(alsa_handle_t *handle)
635 if(handle->devices & AudioSystem::DEVICE_OUT_AUX_DIGITAL) {
643 if((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) || (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA))
644 ||(!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) || (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))) {
649 s_close(handle);
651 ALOGV("s_open: handle %p", handle);
659 if ((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) ||
660 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA)) ||
661 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) ||
662 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))) {
666 } else if ((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI)) ||
667 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI2)) ||
668 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOWLATENCY_MUSIC)) ||
669 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC)) ||
670 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_MUSIC2)) ||
671 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_MUSIC))) {
677 if (handle->channels == 1) {
680 else if (handle->channels == 4 ) {
682 } else if (handle->channels == 6 ) {
684 if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC))
685 || !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC))) {
697 if (deviceName(handle, flags, &devName) < 0) {
702 handle->handle = pcm_open(flags, (char*)devName);
708 if (!handle->handle) {
714 handle->handle->flags = flags;
715 err = setHardwareParams(handle);
718 err = setSoftwareParams(handle);
723 s_standby(handle);
730 static status_t s_start_voip_call(alsa_handle_t *handle)
739 s_close(handle);
742 ALOGV("s_open:s_start_voip_call handle %p", handle);
744 if (deviceName(handle, flags, &devName) < 0) {
750 handle->handle = pcm_open(flags, (char*)devName);
756 if (!handle->handle) {
762 if (!pcm_ready(handle->handle)) {
766 handle->handle->flags = flags;
767 err = setHardwareParams(handle);
770 err = setSoftwareParams(handle);
773 err = pcm_prepare(handle->handle);
780 pcm_write(handle->handle,&voc_pkt,handle->handle->period_size);
781 handle->rxHandle = handle->handle;
786 handle->handle = 0;
788 if (deviceName(handle, flags, &devName1) < 0) {
793 handle->handle = pcm_open(flags, (char*)devName1);
799 if (!handle->handle) {
805 if (!pcm_ready(handle->handle)) {
809 handle->handle->flags = flags;
811 err = setHardwareParams(handle);
814 err = setSoftwareParams(handle);
818 err = pcm_prepare(handle->handle);
825 pcm_read(handle->handle,&voc_pkt,handle->handle->period_size);
829 static status_t s_start_voice_call(alsa_handle_t *handle)
835 ALOGV("s_start_voice_call: handle %p", handle);
841 if (deviceName(handle, flags, &devName) < 0) {
846 handle->handle = pcm_open(flags, (char*)devName);
851 if (!handle->handle) {
856 handle->handle->flags = flags;
857 err = setHardwareParams(handle);
863 err = setSoftwareParams(handle);
869 err = pcm_prepare(handle->handle);
875 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) {
881 handle->rxHandle = handle->handle;
886 if (deviceName(handle, flags, &devName) < 0) {
891 handle->handle = pcm_open(flags, (char*)devName);
896 if (!handle->handle) {
901 handle->handle->flags = flags;
902 err = setHardwareParams(handle);
908 err = setSoftwareParams(handle);
914 err = pcm_prepare(handle->handle);
920 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) {
945 s_close(handle);
949 static status_t s_start_fm(alsa_handle_t *handle)
955 ALOGV("s_start_fm: handle %p", handle);
961 if (deviceName(handle, flags, &devName) < 0) {
966 handle->handle = pcm_open(flags, (char*)devName);
971 if (!handle->handle) {
976 handle->handle->flags = flags;
977 err = setHardwareParams(handle);
983 err = setSoftwareParams(handle);
989 err = pcm_prepare(handle->handle);
995 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) {
1001 handle->rxHandle = handle->handle;
1006 if (deviceName(handle, flags, &devName) < 0) {
1011 handle->handle = pcm_open(flags, (char*)devName);
1016 if (!handle->handle) {
1020 handle->handle->flags = flags;
1021 err = setHardwareParams(handle);
1027 err = setSoftwareParams(handle);
1033 err = pcm_prepare(handle->handle);
1039 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) {
1050 s_close(handle);
1075 static status_t s_start(alsa_handle_t *handle)
1079 if(!handle->handle) {
1084 err = pcm_prepare(handle->handle);
1089 static status_t s_close(alsa_handle_t *handle)
1093 struct pcm *h = handle->rxHandle;
1095 handle->rxHandle = 0;
1096 ALOGV("s_close: handle %p h %p", handle, h);
1098 if ((!strcmp(handle->useCase, SND_USE_CASE_VERB_VOICECALL) ||
1099 !strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_VOICE)) &&
1120 h = handle->handle;
1121 handle->handle = 0;
1124 ALOGV("s_close handle h %p\n", h);
1127 ALOGE("s_close: pcm_close failed for handle with err %d", err);
1130 disableDevice(handle);
1131 } else if((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) ||
1132 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA)) ||
1133 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) ||
1134 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))){
1135 disableDevice(handle);
1147 static status_t s_standby(alsa_handle_t *handle)
1151 struct pcm *h = handle->rxHandle;
1152 handle->rxHandle = 0;
1153 ALOGV("s_standby: handle %p h %p", handle, h);
1162 h = handle->handle;
1163 handle->handle = 0;
1166 ALOGV("s_standby handle h %p\n", h);
1169 ALOGE("s_standby: pcm_close failed for handle with err %d", err);
1171 disableDevice(handle);
1172 } else if((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) ||
1173 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA)) ||
1174 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) ||
1175 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))) {
1176 disableDevice(handle);
1182 static status_t s_route(alsa_handle_t *handle, uint32_t devices, int mode)
1188 switchDevice(handle, devices, mode);
1272 static void disableDevice(alsa_handle_t *handle)
1279 snd_use_case_get(handle->ucMgr, "_verb", (const char **)&useCase);
1281 if (!strncmp(useCase, handle->useCase, MAX_UC_LEN)) {
1282 snd_use_case_set(handle->ucMgr, "_verb", SND_USE_CASE_VERB_INACTIVE);
1284 snd_use_case_set(handle->ucMgr, "_dismod", handle->useCase);
1287 snd_use_case_get(handle->ucMgr, "_verb", (const char **)&useCase);
1291 mods_size = snd_use_case_get_list(handle->ucMgr, "_enamods", &mods_list);
1301 snd_use_case_set(handle->ucMgr, "_disdev", curTxUCMDevice);
1303 snd_use_case_set(handle->ucMgr, "_disdev", curRxUCMDevice);
1789 static void s_set_csd_handle(void* handle)
1791 csd_handle = static_cast<void*>(handle);