Made File.Handle a non-copyable struct in the library to adopt Swift 6.4.
This commit is contained in:
@@ -8,8 +8,10 @@ extension Graphics {
|
||||
/// Wraps `LCDStreamPlayer`.
|
||||
public final class StreamPlayer {
|
||||
let pointer: OpaquePointer
|
||||
/// Retains the active source so it outlives the stream.
|
||||
/// Retains the active source so it outlives the stream. A file
|
||||
/// handle is owned outright, as it cannot be shared.
|
||||
private var retainedSource: AnyObject?
|
||||
private var retainedFile: File.Handle?
|
||||
|
||||
public init() {
|
||||
pointer = streamAPI.pointee.newPlayer.unsafelyUnwrapped().unsafelyUnwrapped
|
||||
@@ -24,22 +26,26 @@ extension Graphics {
|
||||
streamAPI.pointee.setBufferSize.unsafelyUnwrapped(pointer, Int32(video), Int32(audio))
|
||||
}
|
||||
|
||||
/// Streams from an open file.
|
||||
public func setFile(_ file: File.Handle) {
|
||||
retainedSource = file
|
||||
/// Streams from an open file. The stream takes ownership of the
|
||||
/// handle and closes it when the source changes or the stream is freed.
|
||||
public func setFile(_ file: consuming File.Handle) {
|
||||
streamAPI.pointee.setFile.unsafelyUnwrapped(pointer, file.pointer)
|
||||
retainedFile = consume file
|
||||
retainedSource = nil
|
||||
}
|
||||
|
||||
/// Streams from an HTTP connection.
|
||||
public func setHTTPConnection(_ connection: Network.HTTPConnection) {
|
||||
retainedSource = connection
|
||||
streamAPI.pointee.setHTTPConnection.unsafelyUnwrapped(pointer, connection.pointer)
|
||||
retainedSource = connection
|
||||
retainedFile = nil
|
||||
}
|
||||
|
||||
/// Streams from a TCP connection.
|
||||
public func setTCPConnection(_ connection: Network.TCPConnection) {
|
||||
retainedSource = connection
|
||||
streamAPI.pointee.setTCPConnection.unsafelyUnwrapped(pointer, connection.pointer)
|
||||
retainedSource = connection
|
||||
retainedFile = nil
|
||||
}
|
||||
|
||||
/// The player used for the stream's audio track. Owned by the stream.
|
||||
|
||||
Reference in New Issue
Block a user