12

I am recording audio using AudioRecord and playing using AudioTrack. I am recording Fm analog audio stream using this classes and simultaneously passing into Bluetooth router. Its successfully working with Motorola and Samsung S5. But not working with Samsung Galaxy S6.

This is the sample code how i am recording

                            audioManager.startBluetoothSco();
                            audioManager.setBluetoothScoOn(true);
                            audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

                       //FM_SRC is the FM receiving Antenna
                        mRecorder = new AudioRecord(FM_SRC, sampleRateInHz,
                                channelConfigIn,
                                AudioFormat.ENCODING_PCM_16BIT,
                                bufferSizeInBytes);

                        mAudioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
                                sampleRateInHz, channelConfigOut,
                                AudioFormat.ENCODING_PCM_16BIT,
                                bufferSizeInBytes,
                                AudioTrack.MODE_STREAM);


                                mRecorder.startRecording();
                                mAudioTrack.play();

                            byte data[] = new byte[bufferSizeInBytes];

                            //Shuffling buffers from record to track object until A2DP routing selected
                            while (mOverA2DP) {
                                // Log.e(TAG, "mOverA2DP:" + mOverA2DP);
                                mRecorder.read(data, 0, bufferSizeInBytes);
                                mAudioTrack.write(data, 0, bufferSizeInBytes);
                            }

Please help me.

gkondati
  • 516
  • 4
  • 16
  • Anything in the logcat? – dave Jun 15 '15 at 15:37
  • In order to help others understand your issue, please post a sample of the outputs of any logs (e.g. LogCat) or something to demonstrate a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) of your problem. – Ed Holloway-George Jun 15 '15 at 15:37
  • Thank you guys for replay, Its not giving me any errors, or any specified logs, if you guys still want i can give you logs which i have generated. I thought its related to samsung phones issue, because its not even playing audio in speaker for normal Media player, when i have plugged Headphones. If i remove Headphones then its broadcasting to Bluetooth speaker. – gkondati Jun 15 '15 at 16:32

1 Answers1

0

Including the Android OS versions in your question might be helpful. I've encountered issues with Bluetooth in 4.4 which were are present in 4.1 or 5.0.

The specific problem I've seen is a bluetooth disconnect after a short period of time with Android 4.4. Commands from my headset to my app stopped working a couple of minutes after launching the app. It's not exactly your problem, but it might help you troubleshoot.

(I would have made this a comment but I don't have the reputation to comment yet).

T.D. Smith
  • 984
  • 2
  • 7
  • 22
  • Yeah thanks for replay, but my problem is different here, i am getting connected to Blue tooth, but the audio is not routing to Blue tooth speaker. – gkondati Jun 15 '15 at 15:38
  • You are right, this should be a comment and _not_ an answer. To critique or request clarification from a question's author you should leave a comment below their post. You can **always** comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Ed Holloway-George Jun 15 '15 at 15:39