-
QuestionHi, I’m using Could you please advise if there is a way to set a timeout for Background / Tried StepsI’m using the following class SrtPlayback {
let connection = SRTConnection()
lazy var stream = SRTStream(connection: connection)
private let audioEngine = AVAudioEngine()
private lazy var audioPlayer = AudioPlayer(audioEngine: audioEngine)
private(set) var ipAddress: String
private var outputs: [StreamOutput] = []
deinit {
print("SrtPlayback deinit")
}
init(with ip: String) {
ipAddress = ip
}
func add(output: StreamOutput) async {
await stream.addOutput(output)
outputs.append(output)
}
func remove(output: StreamOutput) async {
await stream.removeOutput(output)
outputs.removeAll { $0 === output }
}
func removeAllOutput() async {
for output in outputs {
await stream.removeOutput(output)
}
}
func getReadyState() async -> StreamReadyState {
await stream.readyState
}
private func startStream() async throws {
try await self.connection.connect(
URL(string: "srt://\(self.ipAddress):9991?mode=caller&latency=100&maxbw=0&pkt_size=1316&snd_buf=4194304")
)
await stream.play()
}
}The main thread blocks at: try await self.connection.connect(
URL(string: "srt://\(self.ipAddress):9991?mode=caller&latency=100&maxbw=0&pkt_size=1316&snd_buf=4194304")
)If I comment out these lines, the main thread works fine. I also tried using Task.detached(priority: .userInitiated) {
try await connection.connect(
URL(string: "srt://\(ipAddress):9991?mode=caller&latency=100&maxbw=0&pkt_size=1316&snd_buf=4194304")
)
}
try await self.stream.play()…but then the stream cannot play after connecting. Environment
Thank you for your guidance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Task.detached(priority: .userInitiated) {
try await connection.connect(
URL(string: "srt://\(ipAddress):9991?mode=caller&latency=100&maxbw=0&pkt_size=1316&snd_buf=4194304")
)
try await stream.play()
} |
Beta Was this translation helpful? Give feedback.
-
|
Since this is in the So I’ll leave this one open. |
Beta Was this translation helpful? Give feedback.
timeoutas follows: