I'm looping and audiotrack with...
audioTrack.setLoopPoints(0, length, -1);
audioTrack.play();
But after random time (several minutes), it stop sounding, but state is STATE_INITIALIZED and PLAYSTATE_PLAYING.
In that moment, I get this message ...
09-20 19:32:27.989: D/audio_hw_primary(176): out_standby: enter: usecase(1: low-latency_playback)
09-20 19:32:28.039: D/audio_hw_primary(176): stop_output_stream: enter: usecase(1: low- latency-playback)
09-20 19:32:28.049: D/audio_hw_primary(176): disable_audio_route: reset mixer path: low-latency-playback
09-20 19:32:28.049: D/audio_hw_primary(176): disable_snd_device: snd_device(2: speaker)
09-20 19:32:28.049: D/audio_hw_primary(176): stop_output_stream: exit: status(0)
09-20 19:32:28.049: D/audio_hw_primary(176): out_standby: exit
I need to loop audiotrack limitless, please, anyone knows how to solve it ?
PD: The stop seems to happen only in versions 4.1 and later.
Seems like the phone is entering stand by, when you configured your MediaPlayer, did you get a wakelock?
yourMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
Don't forget to release your mplayer later.
Related
When click the dialerpad, play the ToneGenerator, but cause ANR。
The log:
01-02 04:02:48.209 392 2548 E audio_hw_primary: out_write: error -5, cannot write stream data: I/O error
01-02 04:02:48.209 392 2548 D audio_hw_primary: out_standby: enter: stream (0xae38a800) usecase(0: deep-buffer-playback)
01-02 04:02:48.249 392 3038 E audio_hw_primary: out_write: error -5, cannot write stream data: I/O error
01-02 04:02:48.249 392 3038 D audio_hw_primary: out_standby: enter: stream (0xae3ed000) usecase(1: low-latency-playback)
01-02 04:02:48.772 423 1116 W AudioFlinger: write blocked for 10554 msecs, 50 delayed writes, thread 0xae883ec0
01-02 04:02:48.772 423 1116 D AudioFlinger: mixer(0xae883ec0) throttle end: throttle time(19)
01-02 04:02:49.579 1767 1767 E ToneGenerator: — Stop timed out
01-02 04:02:52.639 1767 1767 E ToneGenerator: — Delayed start timed out, status -110
01-02 04:02:52.639 1767 1767 W ToneGenerator: Tone start failed!!!, time 8178550
You can check the code: DialpadFragment.java--ToneGenerator:
private void playTone(int tone, int durationMs)
private void stopTone()
The ToneGenerator stop timed out cause the ANR. But what did ToneGenerator cause to stop timed out? How to analyze and fix this issue?
you can simply use and its work for me
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
I'm using this code snippet to activate voice command on android.
Intent newIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().sendBroadcast(newIntent);
it doesn't do anything, not even an error in my log cat:
06-03 13:26:24.325 203-822/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
06-03 13:26:24.335 203-822/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
06-03 13:26:24.335 203-822/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
06-03 13:26:24.335 203-822/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
06-03 13:26:24.338 203-822/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
--------- beginning of system
06-03 13:26:26.277 786-892/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 100]
06-03 13:26:27.551 203-822/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
disable_snd_device: snd_device(2: speaker)
when I run this in ADB, it brings the google assistant up:
adb shell am start -a android.intent.action.VOICE_COMMAND
which is weird, it's technically the very same thing.
is there permission i'm missing or something?
From Docs
Activity Action: Start Voice Command.
So to bring up the voice command assistant activity, Use startActivityas
getApplicationContext().startActivity(newIntent);
instead of
getApplicationContext().sendBroadcast(newIntent);
like
Intent newIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(newIntent);
// ^^^^^^^^^^^^
is there a way for the UI not to come up and cover my UI? or at least
for google assistant to go away after it listened and acted on my
voice command?
You can use Google Assistant Service sdk and here is the android quick start guide
I need to force an Android phone to use oob data for pairing. That means I want the Android phone to have the "OOB Data Flag" being set, when the phone sends a Pairing Request to a device.
What I've tried so far: I've identified platform/system/bt to be the current (6.0.1) Android Bluetooth implementation and platform/packages/apps/Bluetooth being a Java wrapper around BT.
platform/system/bt exposes it's interface through a bt_interface_t structure. That structure contains a function named create_bond_out_of_bandthat should do what I need. Unfortunately, that function is not exposed by the Java Wrapper.
First I've tried to use the JNI function const bt_interface_t* android::getBluetoothInterface() from libbluetooth_jni.so. I managed to lookup that function during runtime, but when I call it, it returns 0. At that point, the app used already a lot of the bluetooth API.
This led me to the conclusion, that either, the shared object was loaded a second time, or that the bluetooth library is not part of my application, but somehow implemented in a different process.
Second, I've tried to use the Android libhardware API. I've managed to get the BT module, a BT device and finally call the create_bond_out_of_band() from the bt_interface_t. The function returns 0, which indicates success, but no Pairing Request is send out. I see following messages in the logs:
02-02 15:24:38.083 5791-5824/? E/bt_btif: btif_hh_virtual_unplug: Error, device C4:BE:84:BA:DA:0B not opened.
02-02 15:24:38.083 5791-5791/? E/Gatt: createBondOutOfBand: create_bond_out_of_band(0)
02-02 15:24:38.086 490-2881/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
02-02 15:24:38.101 490-2881/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
02-02 15:24:38.101 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(101)
02-02 15:24:38.101 490-2881/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 1
02-02 15:24:38.108 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(69) acdb_id(102)
02-02 15:24:38.108 490-2881/? D/audio_hw_primary: enable_snd_device: snd_device(69: vi-feedback)
02-02 15:24:38.108 490-2881/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: spkr-vi-record
02-02 15:24:38.132 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(27) acdb_id(4)
02-02 15:24:38.132 490-2881/? I/ACDB-LOADER: ACDB AFE returned = -19
02-02 15:24:38.133 490-2881/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
02-02 15:24:38.672 490-2881/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
02-02 15:24:38.674 490-2881/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
02-02 15:24:38.690 600-600/? E/QCALOG: [MessageQ] ProcessNewMessage: [LOWI-SERVER] unknown deliver target [OS-Agent]
02-02 15:24:38.693 490-2881/? D/audio_hw_primary: disable_snd_device: snd_device(69: vi-feedback)
02-02 15:24:38.693 490-2881/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: spkr-vi-record
02-02 15:24:38.696 490-2881/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 0
C4:BE:84:BA:DA:0B is the device, I try to pair with.
Any ideas? How I can archive my goal or at least some pointers to where an active Android community can be found?
Thanks in advance,
Torsten
I've implemented an app that streams audio and video. The app also has chromecast support. Here's my issue: If I'm streaming audio to a connected bluetooth device, then I browse to an activity that attempts to discover chromecast devices, the bluetooth connection gets into a bad state (playback switches back to my device but the bluetooth connection says the bluetooth device is still connected). If I comment out the code that does chromecast device discovery, the bluetooth connection is fine. Here's the line of code that, when uncommented, causes the connect to terminate:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
Here's what I'm seeing in the logs:
10-29 18:30:31.098 843-10255/? D/NetlinkSocketObserver﹕ NeighborEvent{elapsedMs=1128444524, 10.0.0.1, [CCA4620B2A21], RTM_NEWNEIGH, NUD_REACHABLE}
10-29 18:30:31.429 843-1680/? W/ActivityManager﹕ Permission Denial: Accessing service ComponentInfo{com.google.android.music/com.google.android.music.dial.DialMediaRouteProviderService} from pid=12704, uid=10386 that is not exported from uid 10060
10-29 18:30:31.436 1805-1805/? I/Keyboard.Facilitator﹕ onFinishInput()
10-29 18:30:31.450 198-14249/? I/bt_a2dp_hw﹕ out_set_parameters: state 1
10-29 18:30:31.450 198-14249/? I/str_params﹕ key: 'routing' value: '128'
10-29 18:30:31.450 198-14249/? I/str_params﹕ key: 'a2dp_sink_address' value: 'BC:85:56:38:15:B2'
10-29 18:30:31.459 12704-13205/com.testapp.android W/AudioTrack﹕ dead IAudioTrack, PCM, creating a new one from obtainBuffer()
10-29 18:30:31.470 198-835/? D/audio_hw_primary﹕ out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-29 18:30:31.480 198-834/? D/audio_hw_primary﹕ select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
10-29 18:30:31.480 198-834/? D/msm8974_platform﹕ platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
10-29 18:30:31.480 198-834/? D/audio_hw_primary﹕ enable_snd_device: snd_device(2: speaker)
10-29 18:30:31.483 198-834/? D/audio_hw_primary﹕ enable_audio_route: apply and update mixer path: low-latency-playback
10-29 18:30:31.535 843-1911/? W/AudioTrack﹕ dead IAudioTrack, PCM, creating a new one from processAudioBuffer()
10-29 18:30:31.565 198-835/? D/audio_hw_primary﹕ out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-29 18:30:31.961 14798-14798/? D/ChimeraCfgMgr﹕ Loading module com.google.android.gms.cast from APK com.google.android.gms
10-29 18:30:31.966 14798-14340/? D/MdnsClient﹕ Multicast lock held. Releasing
10-29 18:30:31.967 14798-14340/? D/MdnsClient﹕ #acquireLock. Multicast lock not held. Acquiring
10-29 18:30:33.424 12704-13190/com.testapp.android D/com.testapp.android.sqlite.LocalPlaybackPositionTableHelper﹕ - updated playback position to 23
10-29 18:30:34.530 198-14249/? I/bt_a2dp_hw﹕ suspend_audio_datapath: state 1
10-29 18:30:34.533 14175-14200/? E/bt_btif﹕ bta_av_str_stopped:audio_open_cnt=1, p_data ab20aea4
10-29 18:30:34.533 14175-14200/? W/bt_btif﹕ bta_dm_rm_cback:2, status:6
10-29 18:30:34.576 14175-14200/? W/bt_btif﹕ bta_dm_rm_cback:2, status:6
10-29 18:30:34.584 198-14249/? I/bt_a2dp_hw﹕ skt_disconnect: fd 25
10-29 18:30:34.584 14175-14214/? E/bt_btif﹕ warning : no command pending, ignore ack
10-29 18:30:34.584 14175-14214/? W/bt_btif﹕ pcm bytes per tick 3528
10-29 18:30:34.584 14175-14193/? I/BluetoothA2dpServiceJni﹕ bta2dp_audio_state_callback
10-29 18:30:34.585 14175-14213/? D/A2dpStateMachine﹕ Connected process message: 101
10-29 18:30:34.585 14175-14213/? D/A2dpStateMachine﹕ A2DP Playing state : device: BC:85:56:38:15:B2 State:10->11
I'm testing on a Nexus 5 running Android 6.0. Any ideas? Thanks in advance!
UPDATE: So after a bunch of tests I found out that I was erroneously doing the following if no media route was selected:
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
This was causing the bluetooth connection to be lost.
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.
After a few days of debugging, the best I can find is the following log difference:
Failure Log:
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
Successful Log:
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 -> send_audio_cal, acdb_id = 49, path = 1
D/ACDB-LOADER( 387): ACDB -> send_adm_topology
D/ACDB-LOADER( 387): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER( 387): ACDB -> send_audtable
D/ACDB-LOADER( 387): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER( 387): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER( 387): ACDB -> send_audvoltable
D/ACDB-LOADER( 387): ACDB -> 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 -> AUDIO_SET_AUDPROC_VOL_CAL
D/ACDB-LOADER( 387): ACDB -> 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
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?