Lines Matching refs:usbmod
80 static struct usb_module *usbmod = NULL; variable
96 usbmod = calloc(1, sizeof(struct usb_module)); in usb_alloc()
176 usbmod->usb_card); in usb_get_capability()
342 usbmod->adev = (struct audio_device*)adev; in usb_playback_entry()
346 pthread_mutex_lock(&usbmod->usb_playback_lock); in usb_playback_entry()
348 &usbmod->channels_playback, &usbmod->sample_rate_playback); in usb_playback_entry()
352 pthread_mutex_unlock(&usbmod->usb_playback_lock); in usb_playback_entry()
358 pcm_config_usbmod.channels = usbmod->channels_playback; in usb_playback_entry()
359 pcm_config_usbmod.rate = usbmod->sample_rate_playback; in usb_playback_entry()
364 usbmod->usb_pcm_playback_handle = pcm_open(usbmod->usb_card, \ in usb_playback_entry()
365 usbmod->usb_device_id, PCM_OUT | in usb_playback_entry()
368 if ((usbmod->usb_pcm_playback_handle \ in usb_playback_entry()
369 && !pcm_is_ready(usbmod->usb_pcm_playback_handle)) in usb_playback_entry()
370 || (!usbmod->is_playback_running)) { in usb_playback_entry()
372 pcm_get_error(usbmod->usb_pcm_playback_handle)); in usb_playback_entry()
373 pcm_close(usbmod->usb_pcm_playback_handle); in usb_playback_entry()
374 usbmod->usb_pcm_playback_handle = NULL; in usb_playback_entry()
375 pthread_mutex_unlock(&usbmod->usb_playback_lock); in usb_playback_entry()
382 pcm_config_usbmod.rate = usbmod->sample_rate_playback; in usb_playback_entry()
383 pcm_config_usbmod.channels = usbmod->channels_playback; in usb_playback_entry()
385 usbmod->proxy_device_id = AFE_PROXY_PLAYBACK_DEVICE; in usb_playback_entry()
391 usbmod->proxy_pcm_playback_handle = pcm_open(usbmod->proxy_card, in usb_playback_entry()
392 usbmod->proxy_device_id, PCM_IN | in usb_playback_entry()
394 if(usbmod->proxy_pcm_playback_handle in usb_playback_entry()
395 && !pcm_is_ready(usbmod->proxy_pcm_playback_handle)){ in usb_playback_entry()
396 pcm_close(usbmod->proxy_pcm_playback_handle); in usb_playback_entry()
407 if ((usbmod->proxy_pcm_playback_handle in usb_playback_entry()
408 && !pcm_is_ready(usbmod->proxy_pcm_playback_handle)) in usb_playback_entry()
409 || (!usbmod->is_playback_running)) { in usb_playback_entry()
411 pcm_get_error(usbmod->proxy_pcm_playback_handle)); in usb_playback_entry()
412 pcm_close(usbmod->proxy_pcm_playback_handle); in usb_playback_entry()
413 usbmod->proxy_pcm_playback_handle = NULL; in usb_playback_entry()
414 pthread_mutex_unlock(&usbmod->usb_playback_lock); in usb_playback_entry()
418 pthread_mutex_unlock(&usbmod->usb_playback_lock); in usb_playback_entry()
423 while (usbmod->is_playback_running) { in usb_playback_entry()
425 ret = pcm_mmap_read(usbmod->proxy_pcm_playback_handle, in usb_playback_entry()
428 ret = pcm_mmap_write(usbmod->usb_pcm_playback_handle, in usb_playback_entry()
430 if(!usbmod->is_playback_running) in usb_playback_entry()
444 usbmod->is_playback_running = true; in usb_playback_launcher()
449 usbmod->is_playback_running = false; in usb_playback_launcher()
461 usbmod->adev = (struct audio_device*)adev; in usb_record_entry()
465 pthread_mutex_lock(&usbmod->usb_record_lock); in usb_record_entry()
467 &usbmod->channels_record, &usbmod->sample_rate_record); in usb_record_entry()
471 pthread_mutex_unlock(&usbmod->usb_record_lock); in usb_record_entry()
477 pcm_config_usbmod.channels = usbmod->channels_record; in usb_record_entry()
478 pcm_config_usbmod.rate = usbmod->sample_rate_record; in usb_record_entry()
483 usbmod->usb_pcm_record_handle = pcm_open(usbmod->usb_card, \ in usb_record_entry()
484 usbmod->usb_device_id, PCM_IN | in usb_record_entry()
487 if ((usbmod->usb_pcm_record_handle \ in usb_record_entry()
488 && !pcm_is_ready(usbmod->usb_pcm_record_handle)) in usb_record_entry()
489 || (!usbmod->is_record_running)) { in usb_record_entry()
491 pcm_get_error(usbmod->usb_pcm_record_handle)); in usb_record_entry()
492 pcm_close(usbmod->usb_pcm_record_handle); in usb_record_entry()
493 usbmod->usb_pcm_record_handle = NULL; in usb_record_entry()
494 pthread_mutex_unlock(&usbmod->usb_record_lock); in usb_record_entry()
501 pcm_config_usbmod.rate = usbmod->sample_rate_record; in usb_record_entry()
502 pcm_config_usbmod.channels = usbmod->channels_record; in usb_record_entry()
504 usbmod->proxy_device_id = AFE_PROXY_CAPTURE_DEVICE; in usb_record_entry()
510 usbmod->proxy_pcm_record_handle = pcm_open(usbmod->proxy_card, in usb_record_entry()
511 usbmod->proxy_device_id, PCM_OUT | in usb_record_entry()
513 if(usbmod->proxy_pcm_record_handle in usb_record_entry()
514 && !pcm_is_ready(usbmod->proxy_pcm_record_handle)){ in usb_record_entry()
515 pcm_close(usbmod->proxy_pcm_record_handle); in usb_record_entry()
525 if ((usbmod->proxy_pcm_record_handle in usb_record_entry()
526 && !pcm_is_ready(usbmod->proxy_pcm_record_handle)) in usb_record_entry()
527 || (!usbmod->is_record_running)) { in usb_record_entry()
529 pcm_get_error(usbmod->proxy_pcm_record_handle)); in usb_record_entry()
530 pcm_close(usbmod->proxy_pcm_record_handle); in usb_record_entry()
531 usbmod->proxy_pcm_record_handle = NULL; in usb_record_entry()
532 pthread_mutex_unlock(&usbmod->usb_record_lock); in usb_record_entry()
536 pthread_mutex_unlock(&usbmod->usb_record_lock); in usb_record_entry()
539 while (usbmod->is_record_running) { in usb_record_entry()
541 ret = pcm_mmap_read(usbmod->usb_pcm_record_handle, in usb_record_entry()
544 ret = pcm_mmap_write(usbmod->proxy_pcm_record_handle, in usb_record_entry()
546 if(!usbmod->is_record_running) in usb_record_entry()
560 usbmod->is_record_running = true; in usb_capture_launcher()
565 usbmod->is_record_running = false; in usb_capture_launcher()
574 usbmod->is_playback_running = false; in audio_extn_usb_init()
575 usbmod->is_record_running = false; in audio_extn_usb_init()
577 usbmod->usb_pcm_playback_handle = NULL; in audio_extn_usb_init()
578 usbmod->proxy_pcm_playback_handle = NULL; in audio_extn_usb_init()
580 usbmod->usb_pcm_record_handle = NULL; in audio_extn_usb_init()
581 usbmod->proxy_pcm_record_handle = NULL; in audio_extn_usb_init()
583 usbmod->usb_card = 1; in audio_extn_usb_init()
584 usbmod->usb_device_id = 0; in audio_extn_usb_init()
585 usbmod->proxy_card = 0; in audio_extn_usb_init()
586 usbmod->proxy_device_id = AFE_PROXY_PLAYBACK_DEVICE; in audio_extn_usb_init()
587 usbmod->adev = (struct audio_device*)adev; in audio_extn_usb_init()
589 pthread_mutex_init(&usbmod->usb_playback_lock, in audio_extn_usb_init()
591 pthread_mutex_init(&usbmod->usb_record_lock, in audio_extn_usb_init()
597 if (NULL != usbmod){ in audio_extn_usb_deinit()
598 free(usbmod); in audio_extn_usb_deinit()
599 usbmod = NULL; in audio_extn_usb_deinit()
606 if (sndcard_idx == usbmod->usb_card) { in audio_extn_usb_set_proxy_sound_card()
607 usbmod->usb_card = usbmod->proxy_card; in audio_extn_usb_set_proxy_sound_card()
610 usbmod->proxy_card = sndcard_idx; in audio_extn_usb_set_proxy_sound_card()
617 if (NULL == usbmod){ in audio_extn_usb_start_playback()
622 if (usbmod->is_playback_running){ in audio_extn_usb_start_playback()
628 ret = pthread_create(&usbmod->usb_playback_thr, NULL, in audio_extn_usb_start_playback()
640 usbmod->is_playback_running = false; in audio_extn_usb_stop_playback()
641 if (NULL != usbmod->proxy_pcm_playback_handle) in audio_extn_usb_stop_playback()
642 pcm_stop(usbmod->proxy_pcm_playback_handle); in audio_extn_usb_stop_playback()
644 if (NULL != usbmod->usb_pcm_playback_handle) in audio_extn_usb_stop_playback()
645 pcm_stop(usbmod->usb_pcm_playback_handle); in audio_extn_usb_stop_playback()
647 if(usbmod->usb_playback_thr) { in audio_extn_usb_stop_playback()
648 ret = pthread_join(usbmod->usb_playback_thr,NULL); in audio_extn_usb_stop_playback()
650 usbmod->usb_playback_thr = (pthread_t)NULL; in audio_extn_usb_stop_playback()
653 pthread_mutex_lock(&usbmod->usb_playback_lock); in audio_extn_usb_stop_playback()
654 if (NULL != usbmod->usb_pcm_playback_handle){ in audio_extn_usb_stop_playback()
655 pcm_close(usbmod->usb_pcm_playback_handle); in audio_extn_usb_stop_playback()
656 usbmod->usb_pcm_playback_handle = NULL; in audio_extn_usb_stop_playback()
659 if (NULL != usbmod->proxy_pcm_playback_handle){ in audio_extn_usb_stop_playback()
660 pcm_close(usbmod->proxy_pcm_playback_handle); in audio_extn_usb_stop_playback()
661 usbmod->proxy_pcm_playback_handle = NULL; in audio_extn_usb_stop_playback()
663 pthread_mutex_unlock(&usbmod->usb_playback_lock); in audio_extn_usb_stop_playback()
672 if (NULL == usbmod){ in audio_extn_usb_start_capture()
677 if (usbmod->is_record_running){ in audio_extn_usb_start_capture()
683 ret = pthread_create(&usbmod->usb_record_thr, NULL, in audio_extn_usb_start_capture()
695 usbmod->is_record_running = false; in audio_extn_usb_stop_capture()
696 if (NULL != usbmod->proxy_pcm_record_handle) in audio_extn_usb_stop_capture()
697 pcm_stop(usbmod->proxy_pcm_record_handle); in audio_extn_usb_stop_capture()
699 if (NULL != usbmod->usb_pcm_record_handle) in audio_extn_usb_stop_capture()
700 pcm_stop(usbmod->usb_pcm_record_handle); in audio_extn_usb_stop_capture()
702 if(usbmod->usb_record_thr) { in audio_extn_usb_stop_capture()
703 ret = pthread_join(usbmod->usb_record_thr,NULL); in audio_extn_usb_stop_capture()
705 usbmod->usb_record_thr = (pthread_t)NULL; in audio_extn_usb_stop_capture()
708 pthread_mutex_lock(&usbmod->usb_record_lock); in audio_extn_usb_stop_capture()
709 if (NULL != usbmod->usb_pcm_record_handle){ in audio_extn_usb_stop_capture()
710 pcm_close(usbmod->usb_pcm_record_handle); in audio_extn_usb_stop_capture()
711 usbmod->usb_pcm_record_handle = NULL; in audio_extn_usb_stop_capture()
714 if (NULL != usbmod->proxy_pcm_record_handle){ in audio_extn_usb_stop_capture()
715 pcm_close(usbmod->proxy_pcm_record_handle); in audio_extn_usb_stop_capture()
716 usbmod->proxy_pcm_record_handle = NULL; in audio_extn_usb_stop_capture()
718 pthread_mutex_unlock(&usbmod->usb_record_lock); in audio_extn_usb_stop_capture()
725 if( usbmod->is_record_running || usbmod->is_playback_running) in audio_extn_usb_is_proxy_inuse()