Skip to content

Commit 7b745bc

Browse files
committed
fixed a bug where audio capture would not resume.
1 parent 90bec5f commit 7b745bc

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

app/src/main/java/com/haishinkit/app/Preference.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data class Preference(
1414
companion object {
1515
var shared =
1616
Preference(
17-
"rtmp://192.168.1.16/live",
17+
"rtmp://192.168.1.7/live",
1818
"live",
1919
)
2020
}

haishinkit/src/main/java/com/haishinkit/media/MediaMixer.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class MediaMixer(
175175
return
176176
}
177177
orientationEventListener.enable()
178-
startAudioCapturing()
179178
launch {
180179
videoSources.forEach {
181180
val track = it.key
@@ -184,7 +183,10 @@ class MediaMixer(
184183
screen.attachVideo(track, source)
185184
}
186185
}
186+
audioSources.values.forEach { it.open(this@MediaMixer) }
187187
}
188+
keepAlive = true
189+
startAudioCapturing()
188190
isRunning.set(true)
189191
}
190192

@@ -201,6 +203,7 @@ class MediaMixer(
201203
source.close()
202204
screen.attachVideo(track, null)
203205
}
206+
audioSources.values.forEach { it.close() }
204207
}
205208
isRunning.set(false)
206209
}
@@ -211,14 +214,8 @@ class MediaMixer(
211214
fun dispose() {
212215
stopRunning()
213216
screen.dispose()
214-
launch {
215-
for (key in audioSources.keys) {
216-
attachAudio(key, null)
217-
}
218-
for (key in videoSources.keys) {
219-
attachVideo(key, null)
220-
}
221-
}
217+
audioSources.clear()
218+
videoSources.clear()
222219
}
223220

224221
private fun startAudioCapturing() =

0 commit comments

Comments
 (0)