@@ -28,10 +28,7 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
2828 IMediaPlayer .OnInfoListener {
2929
3030 private val tag = MultiVideoTestActivity ::class .simpleName
31- private val threadPool1 = Executors .newSingleThreadExecutor()
32- private val threadPool2 = Executors .newSingleThreadExecutor()
33- private val threadPool3 = Executors .newSingleThreadExecutor()
34- private val threadPool4 = Executors .newSingleThreadExecutor()
31+ private val taskThread = Executors .newSingleThreadExecutor()
3532
3633 private val coroutineScope = CoroutineScope (Dispatchers .Main )
3734
@@ -251,22 +248,22 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
251248
252249 // 单个设备测试按钮
253250 btnTestDevice1.setOnClickListener {
254- threadPool1 .submit {
251+ taskThread .submit {
255252 device1Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig1) }
256253 }
257254 }
258255 btnTestDevice2.setOnClickListener {
259- threadPool2 .submit {
256+ taskThread .submit {
260257 device2Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig2) }
261258 }
262259 }
263260 btnTestDevice3.setOnClickListener {
264- threadPool3 .submit {
261+ taskThread .submit {
265262 device3Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig3) }
266263 }
267264 }
268265 btnTestDevice4.setOnClickListener {
269- threadPool4 .submit {
266+ taskThread .submit {
270267 device4Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig4) }
271268 }
272269 }
@@ -279,7 +276,12 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
279276 }
280277
281278 private fun startMultiDeviceServices () {
282-
279+ taskThread.submit {
280+ device1Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig1) }
281+ device2Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig2) }
282+ device3Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig3) }
283+ device4Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig4) }
284+ }
283285
284286// runOnUiThread {
285287// Toast.makeText(this, "开始启动4个设备连接...", Toast.LENGTH_SHORT).show()
@@ -404,30 +406,25 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
404406 }
405407
406408 private fun restartService (id : String? ) {
407- when (id) {
408- " ${device1Info?.productId} / ${device1Info?.deviceName} " -> {
409- threadPool1.submit {
409+ taskThread.submit {
410+ when (id) {
411+ " ${device1Info?.productId} / ${device1Info?.deviceName} " -> {
410412 stopDeviceService(device1Info!! , 1 )
411413 device1Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig1) }
412414 }
413- }
414415
415- " ${device2Info?.productId} /${device2Info?.deviceName} " -> {
416- threadPool2.submit {
416+ " ${device2Info?.productId} /${device2Info?.deviceName} " -> {
417417 stopDeviceService(device2Info!! , 2 )
418418 device2Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig2) }
419419 }
420- }
421420
422- " ${device3Info?.productId} /${device3Info?.deviceName} " -> {
423- threadPool3.submit {
421+ " ${device3Info?.productId} /${device3Info?.deviceName} " -> {
424422 stopDeviceService(device3Info!! , 3 )
425423 device3Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig3) }
424+
426425 }
427- }
428426
429- " ${device4Info?.productId} /${device4Info?.deviceName} " -> {
430- threadPool4.submit {
427+ " ${device4Info?.productId} /${device4Info?.deviceName} " -> {
431428 stopDeviceService(device4Info!! , 4 )
432429 device4Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig4) }
433430 }
0 commit comments