Committed by
GitHub
Fix crash in Android tts engine demo. (#2029)
正在显示
1 个修改的文件
包含
4 行增加
和
3 行删除
| @@ -177,8 +177,6 @@ class MainActivity : ComponentActivity() { | @@ -177,8 +177,6 @@ class MainActivity : ComponentActivity() { | ||
| 177 | rtfText = "" | 177 | rtfText = "" |
| 178 | Log.i(TAG, "Started with text $testText") | 178 | Log.i(TAG, "Started with text $testText") |
| 179 | 179 | ||
| 180 | - samplesChannel = Channel<FloatArray>() | ||
| 181 | - | ||
| 182 | CoroutineScope(Dispatchers.IO).launch { | 180 | CoroutineScope(Dispatchers.IO).launch { |
| 183 | for (samples in samplesChannel) { | 181 | for (samples in samplesChannel) { |
| 184 | track.write( | 182 | track.write( |
| @@ -191,6 +189,10 @@ class MainActivity : ComponentActivity() { | @@ -191,6 +189,10 @@ class MainActivity : ComponentActivity() { | ||
| 191 | break | 189 | break |
| 192 | } | 190 | } |
| 193 | } | 191 | } |
| 192 | + | ||
| 193 | + for (s in samplesChannel) { | ||
| 194 | + // drain the channel | ||
| 195 | + } | ||
| 194 | } | 196 | } |
| 195 | 197 | ||
| 196 | CoroutineScope(Dispatchers.Default).launch { | 198 | CoroutineScope(Dispatchers.Default).launch { |
| @@ -219,7 +221,6 @@ class MainActivity : ComponentActivity() { | @@ -219,7 +221,6 @@ class MainActivity : ComponentActivity() { | ||
| 219 | audioDuration, | 221 | audioDuration, |
| 220 | elapsed / audioDuration | 222 | elapsed / audioDuration |
| 221 | ) | 223 | ) |
| 222 | - samplesChannel.close() | ||
| 223 | 224 | ||
| 224 | val filename = | 225 | val filename = |
| 225 | application.filesDir.absolutePath + "/generated.wav" | 226 | application.filesDir.absolutePath + "/generated.wav" |
-
请 注册 或 登录 后发表评论