Hello,

I want to play a sample file to test the bluetooth sco connection on
Android 2.2. The device is an earpiece (Nokia BH-701).
The problem is that I can hear and see that the SCO connection is Ok
but I can not hear the sample audio (mono,8kHz, 16 bits).
The connection seems to be established twice and AudioFlinger shows a
blocking write msg.
Did I miss something ?
--
extract of logs:
12-26 16:45:35.821: I/ActivityManager(1964): Starting activity: Intent
{ act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10000000
cmp=com.rider/.RiderBlueToothActivity }
12-26 16:45:36.261: D/ScoSocket(2038): connect()
android.bluetooth.ScoSocket@43ef8eb0
12-26 16:45:36.261: I/bluetooth_ScoSocket.cpp(2038): getScoType Nokia
BH-701 - 0x0
12-26 16:45:36.266: I/bluetooth_ScoSocket.cpp(2038): Connecting to
socket
12-26 16:45:36.311: D/brd(12018): Audio SCO state: 1
12-26 16:45:36.311: I/brd(12018): SCO_AUDIO_STATE_CONNECTED
12-26 16:45:36.321: I/StagefrightPlayer(1895): setDataSource('/mnt/
sdcard/Sounds/tmpAmr/lathe.mp3')
12-26 16:45:36.336: D/AudioHardware(1895): AudioStreamOutALSA::write:
AudioHardware pcm playback is exiting standby.
12-26 16:45:36.336: D/AudioHardware(1895): openPcmOut_l() mPcmOpenCnt:
0
12-26 16:45:36.421: W/AudioFlinger(1895): write blocked for 86 msecs,
32 delayed writes, thread 0xc820
12-26 16:45:36.486: I/bluetooth_ScoSocket.cpp(2038): SCO socket
connected (outgoing)
12-26 16:45:36.586: D/brd(12018): Audio SCO state: 1
12-26 16:45:36.591: I/brd(12018): SCO_AUDIO_STATE_CONNECTED
12-26 16:45:36.596: I/StagefrightPlayer(1895): setDataSource('/mnt/
sdcard/Sounds/tmpAmr/lathe.mp3')
12-26 16:45:41.986: D/dalvikvm(2296): GC_EXPLICIT freed 1469 objects /
70512 bytes in 355ms
12-26 16:45:43.841: D/AudioHardware(1895): AudioHardware pcm playback
is going to standby.
12-26 16:45:43.881: D/AudioHardware(1895): closePcmOut_l()
mPcmOpenCnt: 1
12-26 16:45:49.051: D/dalvikvm(12018): Calling exit(1)
--
The sample code is:
in an Activity:
IntentFilter l_intentFilter = new
IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED);
rbmBroadcastReceiver=new MyBroadcastReceiver();
this.getApplicationContext().registerReceiver(rbmBroadcastReceiver,l_intentFilter,null,null);
rbmAudioManager = (AudioManager)
getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
rbmAudioManager.startBluetoothSco();

and in MyBroadcastReceiver:
public void onReceive(Context arg0, Intent arg1)
        {
                if
(action.equalsIgnoreCase(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED))
                {
                int l_state = 
arg1.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE,
-1);
                if (AudioManager.SCO_AUDIO_STATE_CONNECTED == l_state)
{

                Log.i("brd", "SCO_AUDIO_STATE_CONNECTED");
File l_tstFile = new File("/mnt/sdcard/Sounds/tmpAmr/lathe.mp3");
            Uri myUri = Uri.fromFile(l_tstFile); // initialize Uri
here
            MediaPlayer mediaPlayer = new MediaPlayer();
 
mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
            try
                {
                        mediaPlayer.setDataSource(arg0, myUri);
                mediaPlayer.prepare();
                mediaPlayer.start();

                } catch (IllegalArgumentException e)
                {
                        // TODO Auto-generated catch block
                        Log.i("brd", "IllegalArgumentException");
                        e.printStackTrace();
                } catch (SecurityException e)
                {
                        // TODO Auto-generated catch block
                        Log.i("brd", "SecurityException");
                        e.printStackTrace();
                } catch (IllegalStateException e)
                {
                        // TODO Auto-generated catch block
                        Log.i("brd", "IllegalStateException");
                        e.printStackTrace();
                } catch (Exception e)
                        {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
        }
                }
        }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to