summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykhailo Lysenko2013-06-14 07:17:21 -0500
committerMykhailo Lysenko2013-06-14 08:21:20 -0500
commit75d057d9157f33a99691dc70b9498e2e76bf69ef (patch)
tree510b17df73d9285234e75d7009edf7a0159da8ab
parent5d355bd7506a78019435846e51d1b52834d7adb8 (diff)
downloaddevice-ti-common-open-75d057d9157f33a99691dc70b9498e2e76bf69ef.tar.gz
device-ti-common-open-75d057d9157f33a99691dc70b9498e2e76bf69ef.tar.xz
device-ti-common-open-75d057d9157f33a99691dc70b9498e2e76bf69ef.zip
HAL: Fix recording when USB device got no capture capabilities
If connected USB device got no input capabilities, there was error while capturing sound. Now checking if USB device can capture; if no, use built-in mic. Change-Id: I7ec450e5e24c719b299939bf381f0232f083fb93 Signed-off-by: Mykhailo Lysenko <x0200985@ti.com>
-rw-r--r--audio/audio_hw.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 774aecd..af82821 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -32,6 +32,7 @@
32#include <pthread.h> 32#include <pthread.h>
33#include <stdint.h> 33#include <stdint.h>
34#include <sys/time.h> 34#include <sys/time.h>
35#include <unistd.h>
35#include <stdlib.h> 36#include <stdlib.h>
36 37
37#include <cutils/log.h> 38#include <cutils/log.h>
@@ -2523,6 +2524,16 @@ static int start_input_stream(struct omap_stream_in *in)
2523 if (adev->mode != AUDIO_MODE_IN_CALL) { 2524 if (adev->mode != AUDIO_MODE_IN_CALL) {
2524 adev->devices.in_devices &= ~AUDIO_DEVICE_IN_ALL; 2525 adev->devices.in_devices &= ~AUDIO_DEVICE_IN_ALL;
2525 adev->devices.in_devices |= in->device & ~AUDIO_DEVICE_BIT_IN;; 2526 adev->devices.in_devices |= in->device & ~AUDIO_DEVICE_BIT_IN;;
2527
2528 if(adev->devices.in_devices & AUDIO_DEVICE_IN_USB_HEADSET) {
2529 char usb_in_device [20];
2530 int n = sprintf(usb_in_device, "/dev/snd/pcmC%uD%uc", CARD_OMAP_USB, PORT_MM);
2531 if (!(n > 0 && access(usb_in_device, F_OK) == 0)) {
2532 adev->devices.in_devices &= ~(AUDIO_DEVICE_IN_USB_HEADSET & ~AUDIO_DEVICE_BIT_IN);
2533 adev->devices.in_devices |= AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN;
2534 }
2535 }
2536
2526 select_input_device(adev); 2537 select_input_device(adev);
2527 adev->vx_rec_on = false; 2538 adev->vx_rec_on = false;
2528 } else { 2539 } else {
@@ -2551,13 +2562,13 @@ static int start_input_stream(struct omap_stream_in *in)
2551 if (in->remix_at_driver) 2562 if (in->remix_at_driver)
2552 in->config.channels = in->remix_at_driver->in_chans; 2563 in->config.channels = in->remix_at_driver->in_chans;
2553 2564
2554 if(adev->devices.in_devices & AUDIO_DEVICE_IN_USB_HEADSET) { 2565 if (adev->devices.in_devices & AUDIO_DEVICE_IN_USB_HEADSET) {
2555 card = CARD_OMAP_USB; 2566 card = CARD_OMAP_USB;
2556 /*device should be 0 for usb headset capture */ 2567 /*device should be 0 for usb headset capture */
2557 device = PORT_MM; 2568 device = PORT_MM;
2558 } 2569 }
2559 2570
2560 if(adev->devices.in_devices & AUDIO_DEVICE_IN_FM_RADIO_RX) { 2571 if (adev->devices.in_devices & AUDIO_DEVICE_IN_FM_RADIO_RX) {
2561 card = CARD_OMAP_DEFAULT; 2572 card = CARD_OMAP_DEFAULT;
2562 /*device should be PORT_MM2_UL for FM capture */ 2573 /*device should be PORT_MM2_UL for FM capture */
2563 device = PORT_MM2_UL; 2574 device = PORT_MM2_UL;