Skip to content

Commit

Permalink
fix #555
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Sep 24, 2023
1 parent 0bd0ce8 commit 42beca1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions Sources/KSPlayer/MEPlayer/AudioEnginePlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public final class AudioEnginePlayer: AudioPlayer, FrameOutput {
addRenderNotify(audioUnit: audioUnit)
}
ceateSourceNode(audioFormat: AVAudioFormat(standardFormatWithSampleRate: 44100, channelLayout: AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Stereo)!))
engine.prepare()
}

func ceateSourceNode(audioFormat: AVAudioFormat) {
Expand All @@ -148,9 +149,6 @@ public final class AudioEnginePlayer: AudioPlayer, FrameOutput {
KSLog("[audio] outputFormat tag: \(channelLayout.layoutTag)")
KSLog("[audio] outputFormat channelDescriptions: \(channelLayout.layout.channelDescriptions)")
}
let isRunning = engine.isRunning
engine.stop()
engine.reset()
sourceNode = AVAudioSourceNode(format: audioFormat) { [weak self] _, timestamp, frameCount, audioBufferList in
if timestamp.pointee.mSampleTime == 0 {
return noErr
Expand All @@ -170,14 +168,6 @@ public final class AudioEnginePlayer: AudioPlayer, FrameOutput {
}
// 一定要传入format,这样多音轨音响才不会有问题。
engine.connect(nodes: nodes, format: audioFormat)
engine.prepare()
if isRunning {
do {
try engine.start()
} catch {
KSLog(error)
}
}
}

func play(time _: TimeInterval) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/Subtitle/KSParseProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public struct ASSStyle {
let textPosition: TextPosition
}

// swiftlint:disable cyclomatic_complexity
extension String {
func build(textPosition: inout TextPosition, attributed: [NSAttributedString.Key: Any]? = nil) -> NSAttributedString {
let lineCodes = splitStyle()
Expand Down Expand Up @@ -267,7 +268,6 @@ extension String {
}

public extension [String: String] {
// swiftlint:disable cyclomatic_complexity
func parseASSStyle() -> ASSStyle {
var attributes: [NSAttributedString.Key: Any] = [:]
if let fontName = self["Fontname"], let fontSize = self["Fontsize"].flatMap(Double.init) {
Expand Down

0 comments on commit 42beca1

Please sign in to comment.