ErikaRedmark / monkey-shines-java-port

Port to Java of abandoned classic Mac OS game "Monkey Shines" by Fantasoft
GNU General Public License v3.0
19 stars 1 forks source link

No audio and can't play any world #83

Open FolkertVanVerseveld opened 9 years ago

FolkertVanVerseveld commented 9 years ago

The title pretty much sums it up. Here is the error log:

methos@cokebook:~/Downloads/Monkey.Shines.v1.0.0/lib$ java -jar monkey_shines.jar 
Binary Location: /home/methos/Downloads/Monkey.Shines.v1.0.0/lib/monkey_shines.jar
WARNING: Could not open configuration file. Dropping to defaults.
Reason: /home/methos/Downloads/Monkey.Shines.v1.0.0/lib/monkey_shines.jar/logging.properties: Not a directory
File handler set up. Output is to console and 'monkeyshines.log'
Log level for system is INFO
Sep 11, 2015 4:47:24 PM org.erikaredmark.monkeyshines.logging.MonkeyShinesLog initialise
INFO: Monkey Shines Java Port Log File Initialised
Sep 11, 2015 4:47:59 PM org.erikaredmark.monkeyshines.menu.SelectAWorld loadInternalWorld
SEVERE: org.erikaredmark.monkeyshines.menu.SelectAWorld: Missing world /resources/worlds/Spooked/Spooked.world from .jar file. Possible .jar corruption.
Sep 11, 2015 4:48:00 PM org.erikaredmark.monkeyshines.menu.SelectAWorld handleWorldLoadException
WARNING: org.erikaredmark.monkeyshines.menu.SelectAWorld: null
java.lang.NegativeArraySizeException
    at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:450)
    at org.erikaredmark.monkeyshines.global.SoundUtils.clipFromOggStream(SoundUtils.java:72)
    at org.erikaredmark.monkeyshines.resource.WorldResource.loadSoundClip(WorldResource.java:547)
    at org.erikaredmark.monkeyshines.resource.WorldResource.fromPack(WorldResource.java:364)
    at org.erikaredmark.monkeyshines.menu.SelectAWorld.loadInternalWorld(SelectAWorld.java:208)
    at org.erikaredmark.monkeyshines.menu.SelectAWorld.access$000(SelectAWorld.java:39)
    at org.erikaredmark.monkeyshines.menu.SelectAWorld$1.actionPerformed(SelectAWorld.java:108)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
(...)

This happens if I click any world in the new game menu. Opening another world using other yields the same result. I didn't look in the source yet, but it probably stops because it can't play the click sound. I already tried to copy the world and data files from the original game (most remake games do this in order to prevent copyright issues), but that didn't help either. Any suggestions what is happening here? The file permissions should be correct because this is my general download folder. And starting the JVM from a parent directory does not make any difference. This will be printed if I click music and then sound in the main menu:

Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException
    at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:450)
    at org.erikaredmark.monkeyshines.global.SoundUtils.clipFromOggStream(SoundUtils.java:72)
    at org.erikaredmark.monkeyshines.menu.SoundControlDialog.<init>(SoundControlDialog.java:80)
    at org.erikaredmark.monkeyshines.menu.SoundControlDialog.launch(SoundControlDialog.java:176)
    at org.erikaredmark.monkeyshines.menu.MainMenuWindow$3.run(MainMenuWindow.java:165)
    at org.erikaredmark.monkeyshines.menu.MainMenuWindow$8.actionPerformed(MainMenuWindow.java:248)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
(...)
Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException
    at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:450)
    at org.erikaredmark.monkeyshines.global.SoundUtils.clipFromOggStream(SoundUtils.java:72)
    at org.erikaredmark.monkeyshines.menu.SoundControlDialog.<init>(SoundControlDialog.java:80)
    at org.erikaredmark.monkeyshines.menu.SoundControlDialog.launch(SoundControlDialog.java:176)
    at org.erikaredmark.monkeyshines.menu.MainMenuWindow$4.run(MainMenuWindow.java:182)
    at org.erikaredmark.monkeyshines.menu.MainMenuWindow$8.actionPerformed(MainMenuWindow.java:248)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    (...)

I have removed all the javax and java trace stuff in both pastes, because you don't need that information anyway.

Nice project btw, looks interesting :D

ErikaRedmark commented 9 years ago

That's horrible that it doesn't play at all: the biggest red flag to me is this:

SEVERE: org.erikaredmark.monkeyshines.menu.SelectAWorld: Missing world /resources/worlds/Spooked/Spooked.world from .jar file. Possible .jar corruption

When I get off of work, I'll post a quick little file-system diagram showing the expected structure of the .jar, just to confirm. Also, I don't think I ever put a click sound to the buttons (it's been a while since I last worked on this).

I am not sure what is happening with the sound, as it worked fine on my machines as well as others machines. I'll have to take a deeper look later.

Finally, only the level editor understands .plvl and .wrld data from the original level resource forks. I got support from Mark Elliott directly so copyright shouldn't be an issue in this case.

Anyway, I'll take a deeper look later, apologies that you can't even run the game... EDIT: If the jar is corrupted and can't find the worlds, it's possible it is not finding the sounds either.

ErikaRedmark commented 9 years ago

Can you confirm that, in the folder with the game and level editor executable, inside the 'lib' folder, inside monkey_shines.jar, you have a 'resources' folder, and within the following folder structure? Did you get this version from the latest 1.0.0 release?

├───fonts
├───graphics
│   ├───editor
│   │   └───hazard
│   └───mainmenu
│       ├───endgame
│       ├───help
│       ├───highscores
│       ├───keyboard
│       ├───selectworld
│       └───sound
├───sounds
│   └───mainmenu
│       └───endgame
├───standard
│   └───default
│       ├───graphics
│       ├───music
│       └───sounds
└───worlds
    ├───AboutTheHouse
    ├───In The Swing
    ├───InTheDrink
    ├───SpacedOut
    └───Spooked
FolkertVanVerseveld commented 9 years ago

Okay I ran jar tvf monkey_shines.jar | grep resources and this is the gist: https://gist.github.com/FolkertVanVerseveld/2a7e725f020db16466d8 These folders are present:

fonts/
graphics/editor/hazard
graphics/mainmenu/endgame|help|highscores|keyboard|selectworld|sound
sounds/mainmenu/endgame
standard/default/graphics|music|sounds
worlds/AboutTheHouse|In The Swing|InTheDrink|SpacedOut|Spooked
graphics/editor

I think everything is included as it is supposed to be. Maybe the program cannot properly access resources inside a jar file. I don't remember, but I think I've had some problems myself with accessing resources inside a jar file on multiple OSes. Here is more information in case you want to know:

$ uname -a
Linux cokebook 3.13.0-63-generic #103-Ubuntu SMP Fri Aug 14 21:42:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ java -version
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)

OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

ErikaRedmark commented 9 years ago

Thank you for the additional info. I will set up a virtual machine for Ubuntu with OpenJDK and test the game there, see if I get the same error. If so, I'll be able to work with it. If your .jar is fine, then the issue is definitely the system is somehow getting the wrong paths. All the issues you are having seem to stem from it's inability to find internal resources. I wonder if I am doing something that OpenJDK specifically doesn't like, because a Linux machine with a different JVM was able to run the game up to the actual playing level point (issue #78)

If you have a Windows machine handy, would you be able to use that in the interim? Mac will work as well if Java 7 is available. Also, you can try, in the interim, using Oracle's JVM and seeing if the issue persists, although I understand uprooting your JVM is something you probably wouldn't want to do.

FolkertVanVerseveld commented 9 years ago

My distro is Xubuntu 14.04 (ubuntu variants are listed just as ubuntu in uname). I tried Oracle's JVM but I got the exact same results. I tried java 7, 8 and OpenJDK 7 and 8.

jonreyna commented 9 years ago

@ErikaRedmark FYI I was able to reproduce this issue in a VM.

ErikaRedmark commented 9 years ago

I just managed to get Xubuntu running on a VM and hit the exact same issue. I'll be able to start looking into it.

@JReyLBC thank you for checking as well. Just to confirm, it worked on Kubuntu?

jonreyna commented 9 years ago

@ErikaRedmark It works in Kubuntu, and Linux Mint from what I have tested.

ErikaRedmark commented 9 years ago

It looks like the issue is indeed caused by the sound system; the .jar resources are found just fine. Specifically the issue is with icedtea.pulseaudio.PulseAudioClip. On Windows, the result of AudioSystem.getClip() is a different implementation (a direct sound line). On Xubuntu, even when using the Oracle JRE, it returns the IcedTea implementation. Not sure why it does not use the oracle implementation when using the oracle JRE... I would have expected that IcedTea class to not be available in such a context. In either case, the issue is somehow caused in that class.

I am going to see if I can find a solution that works in all systems. Barring that, I may have to just have the sound system log the issue, then fail to start without stopping the rest of the program. At least in that scenario, the game would still be playable.

I wanted to at least give an update on this since it has been a week, but I must apologise that I do not currently have any solutions still other than a different Linux distro. I'll see if there is a way to change the sound system Xubuntu uses when running the JVM.

FolkertVanVerseveld commented 9 years ago

This is really strange, because I recall that I've made a project in java that could play audio in Xubuntu. I don't know why audio in this project does not work. I think it is indeed better to ignore the sound system in case it fails to start, because now it doesn't let you play at all. You may or may not have heard of Paul's audio system (the one that is used in Minecraft). That audio system seems to work really well on all platforms. I'm not sure what license it has though. You can find it here. You may want to consider using this rather than Java's audio syste

FolkertVanVerseveld commented 9 years ago

Okay this is really weird. If I use the Oracle JVM the audio system seems to work. I tested the latest release version (january 2015). While I'm typing this message the music jitters a lot. Also, the framerate is not much because the animations don't feel as smooth as in the original mac and windows release. Maybe I'll try to compile the project from source (i.e. commit 5af4480e87f39f4e1f23428377c8342d929006d8) and try to run it in both Oracle's JVM and OpenJDK. I've found some minor things that are incorrectly implemented. I will open some issues that describe those things.

ErikaRedmark commented 9 years ago

I recently made another commit that fixed a small problem, but the latest one has the sound system fail properly without crashing the game. Tested on Xubuntu briefly, but I still need to test if completing a level doesn't mess anything up further.

Having said that, I got an answer to an old stack overflow question: http://stackoverflow.com/questions/23747940/using-ogg-vorbis-spi-for-decoding-ogg-files-fails-for-small-file-sizes which is for a different issue, but might have something to do with audio not working: the library I am using that adds the ogg decoding is messed up, and might have other bugs.

There is another bug in Phils Mac World that I need to 'hide' since I can't figure it out yet, just to make the map is playable. I'm going to look over the other issues you added and pick a few that are most important to implement and fix up, and mark them as being worked on.

I strongly encourage you to contribute where you can as well, such as with Pauls sound system if you have used it before (The license in the downloaded .zip seems to suggest it would be okay to incorporate). At the moment I am otherwise the only code contributor to this project, and as you have probably seen my activity on it has taken a nose dive that I hope to rectify. You mentioned that you had a similar project before in Java that worked in Xubuntu with sound? Did it also read .ogg files? The relevant file in the current commit for sound playing is 'JavaDefaultSoundManager.java' and you can find a few sound loading functions in 'SoundUtils.java'