|
|
|
@ -201,7 +201,7 @@ class SimpleAudioReceiver(private val context: Context) { |
|
|
|
fun startAudioRecord(audioSourceType: AudioSourceType, callback: AudioDataCallback?) { |
|
|
|
try { |
|
|
|
this.audioSourceType = audioSourceType |
|
|
|
this.audioDataCallback = callback |
|
|
|
this.audioDataCallback = callback |
|
|
|
|
|
|
|
isWriting.set(true) |
|
|
|
|
|
|
|
@ -209,10 +209,6 @@ fun startAudioRecord(audioSourceType: AudioSourceType, callback: AudioDataCallba |
|
|
|
Log.d("tag", "存下来的数据: ${writeQueue?.size}") |
|
|
|
} |
|
|
|
|
|
|
|
// 启动前台服务 |
|
|
|
AudioRecordingForegroundService.startService(context) |
|
|
|
Log.d(TAG, "前台服务已启动,开始音频录制") |
|
|
|
|
|
|
|
when (audioSourceType) { |
|
|
|
AudioSourceType.MICROPHONE -> runMicrophoneCapture() |
|
|
|
AudioSourceType.EXTERNAL -> runExternalCapture() |
|
|
|
@ -287,6 +283,9 @@ fun startAudioRecord(audioSourceType: AudioSourceType, callback: AudioDataCallba |
|
|
|
*/ |
|
|
|
private fun runMicrophoneCapture() { |
|
|
|
try { |
|
|
|
// 启动前台服务 |
|
|
|
AudioRecordingForegroundService.startService(context) |
|
|
|
Log.d(TAG, "前台服务已启动,开始音频录制") |
|
|
|
// 根据手机品牌决定是否设置通话音频模式 |
|
|
|
if (isHonorDevice()) { |
|
|
|
Log.d(TAG, "检测到荣耀设备,启用通话音频模式") |
|
|
|
|