@@ -464,10 +464,17 @@ public void onServiceDisconnected(ComponentName name) {
464464
465465 Intent intent = new Intent ("android.intent.action.START_TTS_SERVICE" );
466466 intent .addCategory ("android.intent.category.TTS" );
467- mContext .bindService (intent , mServiceConnection ,
468- Context .BIND_AUTO_CREATE );
469- // TODO handle case where the binding works (should always work) but
470- // the plugin fails
467+ boolean bound = mContext .bindService (intent , mServiceConnection , Context .BIND_AUTO_CREATE );
468+ if (!bound ) {
469+ Log .e ("TextToSpeech.java" , "initTts() failed to bind to service" );
470+ if (mInitListener != null ) {
471+ mInitListener .onInit (ERROR );
472+ }
473+ } else {
474+ // initialization listener will be called inside ServiceConnection
475+ Log .i ("TextToSpeech.java" , "initTts() successfully bound to service" );
476+ }
477+ // TODO handle plugin failures
471478 }
472479
473480
@@ -717,8 +724,9 @@ public int speak(String text, int queueMode, HashMap<String,String> params)
717724 {
718725 synchronized (mStartLock ) {
719726 int result = ERROR ;
720- Log .i ("TTS received: " , text );
727+ Log .i ("TextToSpeech.java - speak " , "speak text of length " + text . length () );
721728 if (!mStarted ) {
729+ Log .e ("TextToSpeech.java - speak" , "service isn't started" );
722730 return result ;
723731 }
724732 try {
@@ -1226,7 +1234,10 @@ public int synthesizeToFile(String text, HashMap<String,String> params,
12261234 String filename ) {
12271235 synchronized (mStartLock ) {
12281236 int result = ERROR ;
1237+ Log .i ("TextToSpeech.java - synthesizeToFile" , "synthesizeToFile text of length "
1238+ + text .length ());
12291239 if (!mStarted ) {
1240+ Log .e ("TextToSpeech.java - synthesizeToFile" , "service isn't started" );
12301241 return result ;
12311242 }
12321243 try {
0 commit comments