title: Android microphone input fails while in bluetooth on some devices
body: <p>I'm working on doing voice recognition using the device microphone while connected to a bluetooth speaker.  This works in most cases, but in a few devices I'm getting some failures.</p>
  
  <p>After a few days of debugging, the best I can find is the following log difference:</p>
  
  <p>Failure Log:</p>
  
  <pre><code>V/audio_hw_primary(  270): start_input_stream: enter: usecase(7)
  V/voice   (  270): voice_check_and_set_incall_rec_usecase: voice call not active
  V/audio_hw_primary(  270): start_input_stream: usecase(7)
  D/PreProcess(  270): new SamsungRecord
  D/PreProcess(  270): new NS
  I/samsungRecord(  270): [samsungrecord] SamsungRecInit 
  I/samsungRecord(  270): [samsungrecordMIC]Use HardCoding Values
  E/samsungRecord(  270): miccalib file can't created. (/data/snd/miccalib.txt)
  I/samsungRecord(  270): 1
  D/SamsungRecord_NS(  270): [SamsungRecord_NS] Init SR 8000
  D/SamsungRecord_NS(  270): [SamsungRecord_NS] getLevel inputsource 6, ret_level 3
  V/audio_hw_primary(  270): select_devices: ENTER
  V/audio_hw_primary(  270): select_devices: usecase(normal)
  V/audio_hw_primary(  270): select_devices: usecase(PCM_CAPTURE)
  V/msm8974_platform(  270): platform_get_input_snd_device: enter: out_device(0) in_device(0x8)
  V/msm8974_platform(  270): get_INPUT_snd_device: AUDIO_MODE_IN_CALL
  E/msm8974_platform(  270): platform_get_input_snd_device: No output device set for voice call
  V/msm8974_platform(  270): platform_get_input_snd_device: exit: in_snd_device(none)
  V/audio_hw_primary(  270): start_input_stream: Opening PCM device card_id(0) device_id(0), channels 1
  E/audio_hw_primary(  270): start_input_stream: cannot open device '/dev/snd/pcmC0D0c': Invalid argument
  V/audio_hw_primary(  270): stop_input_stream: enter: usecase(7: audio-record)
  V/audio_hw_primary(  270): disable_audio_route: enter: usecase(7)
  V/audio_hw_primary(  270): disable_audio_route: reset mixer path: audio-record
  D/audio_route(  270): ++++ audio_route_update_mixer ==============
  D/audio_route(  270): ------ audio_route_update_mixer ==============
  V/audio_hw_primary(  270): disable_audio_route: exit
  E/audio_hw_primary(  270): disable_snd_device: Invalid sound device 0
  V/audio_hw_primary(  270): stop_input_stream: exit: status(0)
  D/audio_hw_primary(  270): start_input_stream: exit: status(-5)
  V/audio_hw_primary(  270): in_standby: enter
  V/audio_hw_primary(  270): in_standby: exit:  status(0)
  V/audio_hw_primary(  270): in_read: read failed - sleeping for buffer duration
  </code></pre>
  
  <p>Successful Log:</p>
  
  <pre><code>V/audio_hw_primary(  387): start_input_stream: enter: usecase(7)
  V/voice   (  387): voice_check_and_set_incall_rec_usecase: voice call not active
  V/audio_hw_primary(  387): start_input_stream: usecase(7)
  D/PreProcess(  387): new SamsungRecord
  D/PreProcess(  387): new NS
  I/samsungRecord(  387): [samsungrecord] SamsungRecInit 
  I/samsungRecord(  387): [samsungrecordMIC]Use HardCoding Values
  E/samsungRecord(  387): miccalib file can't created. (/data/snd/miccalib.txt)
  I/samsungRecord(  387): 1
  D/SamsungRecord_NS(  387): [SamsungRecord_NS] Init SR 8000
  D/SamsungRecord_NS(  387): [SamsungRecord_NS] getLevel inputsource 6, ret_level 3
  V/audio_hw_primary(  387): select_devices: ENTER
  V/audio_hw_primary(  387): select_devices: usecase(normal)
  V/audio_hw_primary(  387): select_devices: usecase(PCM_CAPTURE)
  V/msm8974_platform(  387): platform_get_input_snd_device: enter: out_device(0) in_device(0x8)
  V/msm8974_platform(  387): get_INPUT_snd_device: check by Input_source(6)
  V/msm8974_platform(  387): platform_get_input_snd_device_by_source: enter: out_device(0) in_device(0x8)
  V/msm8974_platform(  387): get_INPUT_snd_device: AUDIO_SOURCE_VOICE_RECOGNITION
  V/msm8974_platform(  387): platform_get_input_snd_device: exit: in_snd_device(dummy)
  D/audio_hw_primary(  387): select_devices: out_snd_device(0: dummy)
  D/audio_hw_primary(  387): select_devices: in_snd_device(124: dummy)
  D/ACDB-LOADER(  387): ACDB -&gt; send_audio_cal, acdb_id = 49, path =  1
  D/ACDB-LOADER(  387): ACDB -&gt; send_adm_topology
  D/ACDB-LOADER(  387): ACDB -&gt; ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
  D/ACDB-LOADER(  387): ACDB -&gt; send_audtable
  D/ACDB-LOADER(  387): ACDB -&gt; ACDB_CMD_GET_AUDPROC_COMMON_TABLE
  D/ACDB-LOADER(  387): ACDB -&gt; AUDIO_SET_AUDPROC_CAL
  D/ACDB-LOADER(  387): ACDB -&gt; send_audvoltable
  D/ACDB-LOADER(  387): ACDB -&gt; ACDB_CMD_GET_AUDPROC_GAIN_DEP_STEP_TABLE
  D/        (  387): Failed to fetch the lookup information of the device 00000031 
  E/ACDB-LOADER(  387): Error: ACDB AudProc vol returned = -19
  D/ACDB-LOADER(  387): ACDB -&gt; AUDIO_SET_AUDPROC_VOL_CAL
  D/ACDB-LOADER(  387): ACDB -&gt; AUDIO_SET_AFE_CAL
  V/audio_hw_primary(  387): enable_snd_device: snd_device(124: dummy, dummy)
  D/audio_route(  387): ++++ audio_route_update_mixer ==============
  D/audio_route(  387): ------ audio_route_update_mixer ==============
  V/audio_hw_primary(  387): enable_audio_route: enter: usecase(7)
  V/audio_hw_primary(  387): enable_audio_route: apply mixer path: audio-record bt-sco
  D/audio_route(  387): ++++ audio_route_update_mixer ==============
  D/audio_route(  387): Setting mixer control: MultiMedia1 Mixer AUX_PCM_UL_TX, value: 1
  D/audio_route(  387): ------ audio_route_update_mixer ==============
  V/audio_hw_primary(  387): enable_audio_route: exit
  V/audio_hw_primary(  387): start_input_stream: Opening PCM device card_id(0) device_id(0), channels 1
  V/xappmedia.sdk.service.GoogleSpeechRecognizer(18053): Adjusted volume level: 0.0. RMSDB: -2.12
  E/Global isDisableMicrophone(18053): isDisableMixrophone:true
  E/MusicService(18053): XappAds VolumeLevel Callback OnRmsChanged: rmsDb: -2.12 adjustFol: 0.0
  E/NowPlayingFragment OnReceive:(18053): onReceive 1
  E/NowPlayingFragment OnReceive:(18053): Mic Animation 1
  E/NowPlayingFragment OnReceive:(18053): Volume Change 1
  E/NowPlayingFragment OnReceive:(18053): Volume Change 2:  Mic Size: 300.0
  E/NowPlayingFragment OnReceive:(18053): Volume Change 2:  VOl: 0.0
  E/NowPlayingFragment OnReceive:(18053): Draw Mic 1
  V/audio_hw_primary(  387): start_input_stream: exit
  </code></pre>
  
  <p>It looks to me like its failing to open an input stream off of the mic.  I can't find much information on this, but I think it's probably something to do with how i'm using audio focus.  Anyone have any insights?</p>