Skip to content
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

Merged
merged 3 commits into from
Apr 5, 2024
Merged

Adds sample player #36

merged 3 commits into from
Apr 5, 2024

Conversation

ricobeck
Copy link
Contributor

@ricobeck ricobeck commented Apr 4, 2024

No description provided.

Copy link
Owner

@finnvoor finnvoor left a 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!

Comment on lines 170 to 192
@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
}
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct!

@finnvoor finnvoor merged commit 9a90cd3 into finnvoor:main Apr 5, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants