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

Sound Fixes for Linux/OpenJDK #252

Merged
merged 6 commits into from
Feb 26, 2017

Conversation

chanceVermilion
Copy link

The PR of mine prior to this fixed the loading of audio clips on Linux, but they would only play once. After lots of digging into the internals of the icedtea-sound library, I've finally gotten all hit sounds and sound effects to play consistently using the OpenJDK and pulseaudio on Linux. I've documented most things that aren't obvious, but let me know if you want more details or clarification.

Steffan Byrne added 5 commits February 1, 2017 00:14
DataLine.Info info = new DataLine.Info(Clip.class, format);
c = (Clip) AudioSystem.getLine(info);
if (format != null)
c.open(format, audioData, 0, audioData.length);
// This is a little hacky, but we can't do an instanceof check and
// there's no reason to add the listener unless the system is using
// PulseAudioClip et al.
Copy link
Owner

Choose a reason for hiding this comment

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

What is the "et al." referring to here?

Copy link
Author

Choose a reason for hiding this comment

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

I meant the other classes related to to the pulse audio backend, but all that really matters is the PulseAudioClip check so I'll remove that bit in the comment.

// there's no reason to add the listener unless the system is using
// PulseAudioClip et al.
if (c.getClass().getSimpleName().equals("PulseAudioClip")) {
c.addLineListener(new PulseAudioFixerListener(c));
Copy link
Owner

Choose a reason for hiding this comment

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

I'd prefer if you inline the listener instead of defining a new class for it.

Also, it'd be helpful to comment on any specific version numbers (at least for your system) where this is applicable.

Copy link
Author

Choose a reason for hiding this comment

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

When I first wrote the listener, I had it inlined, but it resulted in a proliferation of threads. I moved the listener to a defined class and switch to a static cached thread pool which works really well at keeping extraneous threads low. I also like keeping the ugliness tied to a particular Clip implementation separate.

That being said, I can move the static cached thread pool to the Multiclip class and inline the listener or I can do something like keep the class declaration and just move it to the MutlipClip file. What do you think?

@@ -186,10 +195,17 @@ private Clip getClip() throws LineUnavailableException {
} else {
// create a new clip
// NOTE: AudioSystem.getClip() doesn't work on some Linux setups.
Log.debug("creating a new clip");
Copy link
Owner

Choose a reason for hiding this comment

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

Could you get rid of these? :P

@itdelatrisu itdelatrisu added the bug label Feb 6, 2017
@itdelatrisu
Copy link
Owner

Looks good, thank you for doing this! :) Left a few comments in the diff.

@Lourens-Rich
Copy link

@itdelatrisu will you merge this PR? Thank you!

@itdelatrisu itdelatrisu merged commit c74e854 into itdelatrisu:master Feb 26, 2017
itdelatrisu added a commit that referenced this pull request Feb 26, 2017
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants