-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds sample player #36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for adding this!
Sources/PlaydateKit/Core/Sound.swift
Outdated
@discardableResult public func setSample(path: StaticString) -> Bool { | ||
samplePointer = sample.load(path.utf8Start) | ||
guard samplePointer != nil else { return false } | ||
|
||
sampleplayer.setSample(playerPointer, samplePointer) | ||
return true | ||
} | ||
|
||
/// Assigns sample to player. | ||
@discardableResult public func setSample(path: UnsafePointer<CChar>) -> Bool { | ||
samplePointer = sample.load(path) | ||
guard samplePointer != nil else { return false } | ||
|
||
sampleplayer.setSample(playerPointer, samplePointer) | ||
return true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could probably call these methods more than once on the same SamplePlayer, resulting in the first samplePointer leaking. There should probably be a if let samplePointer { sample.freeSample(samplePointer) }
at the start of both of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct!
No description provided.