Menu

Crash at end of mp3 playing

chris
2012-06-22
2012-07-04
  • chris

    chris - 2012-06-22

    When an mp3 was finished playing for me, it would crash with an ArrayIndexOutOfBoundsException.

    to combat this I caught the exception and cast endOfStream. I don't know if this is the best way to handle it, but its working great for me now. Thanks for this codec.

    Also, I tried posting on your forum post on paulscode, but it seems the web server died. Here is a diff patch for the changes I made:

    ~~~~~~~~~~~~~~~~~~~~
    Index: src/de/cuina/fireandfuel/CodecJLayerMP3.java
    ===================================================================
    --- src/de/cuina/fireandfuel/CodecJLayerMP3.java (revision 11)
    +++ src/de/cuina/fireandfuel/CodecJLayerMP3.java (working copy)
    @@ -28,7 +28,6 @@
    import javazoom.jl.decoder.Header;
    import javazoom.jl.decoder.Obuffer;
    import javazoom.mp3spi.DecodedMpegAudioInputStream;
    -
    import paulscode.sound.ICodec;
    import paulscode.sound.SoundBuffer;
    import paulscode.sound.SoundSystemConfig;
    @@ -218,8 +217,7 @@
    // keep track of how many bytes were read:
    bytesRead += cnt;
    }

    • } catch (IOException ioe)
    • {
    • } catch (IOException ioe) {
      /*
      * errorMessage( "Exception thrown while reading from the " +
      * "AudioInputStream (location #3)." ); printStackTrace( e ); return
      @@ -228,6 +226,11 @@
      // OGG files!
      endOfStream(SET, true);
      return null;
    • } catch (ArrayIndexOutOfBoundsException e) {
    • //this exception is thrown at the end of the mp3's
    • e.printStackTrace();
    • endOfStream(SET, true);
    • return null;
      }
      // Return null if no data was read:
      

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     
    • fireandfuel

      fireandfuel - 2012-06-22

      Interesting, I don't have that ArrayIndexOutOfBoundsException when a mp3 finished playing.
      Your patch adds only a simple catch clause, but I integrated it into the repository and released a new download package (r2, included the optimizations from Lioncash).

      Thank you for testing and reporting.
      PS: Please add a patch as an attachment, makes it easier for me to apply and test it.

       

      Last edit: fireandfuel 2012-06-22
  • chris

    chris - 2012-07-04

    will do. I didnt see the the attachment feature, actually until just now actually. Don't use sourceforge much.

     

Log in to post a comment.

MongoDB Logo MongoDB