| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.speech.tts; |
| 17 |
|
| 18 |
import android.os.ConditionVariable; |
| 19 |
import android.speech.tts.TextToSpeechService.UtteranceProgressDispatcher; |
| 20 |
|
| 21 |
class SilencePlaybackQueueItem extends PlaybackQueueItem { |
| 22 |
private final ConditionVariable mCondVar = new ConditionVariable(); |
| 23 |
private final long mSilenceDurationMs; |
| 24 |
|
| 25 |
SilencePlaybackQueueItem(UtteranceProgressDispatcher dispatcher, |
| 26 |
Object callerIdentity, long silenceDurationMs) { |
| 27 |
super(dispatcher, callerIdentity); |
| 28 |
mSilenceDurationMs = silenceDurationMs; |
| 29 |
} |
| 30 |
|
| 31 |
@Override |
| 32 |
public void run() { |
| 33 |
getDispatcher().dispatchOnStart(); |
| 34 |
boolean wasStopped = false; |
| 35 |
if (mSilenceDurationMs > 0) { |
| 36 |
wasStopped = mCondVar.block(mSilenceDurationMs); |
| 37 |
} |
| 38 |
if (wasStopped) { |
| 39 |
getDispatcher().dispatchOnStop(); |
| 40 |
} else { |
| 41 |
getDispatcher().dispatchOnSuccess(); |
| 42 |
} |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
@Override |
| 47 |
void stop(int errorCode) { |
| 48 |
mCondVar.open(); |
| 49 |
} |
| 50 |
} |