I'm trying to play some .m4a files, and I understand that JAAD only supports decoding AAC, but there are songs that I am able to get the sourceDataLine from, and then when I go to try to play them, I get behavior like this:
We read: 1024 bytes.
We read: 512 bytes.
We read: -1 bytes.
When running this:
// read from the input
bytesRead = audioInputStream.read(tempBuffer, 0, tempBuffer.length);
System.out.println("We read: " + bytesRead + " bytes.");
until bytesRead == -1
For this particular file, I'm getting the AudioFormat baseformat to be this: MPEG1L1 48000.0 Hz, unknown bits per sample, mono, unknown frame size, 125.0 frames/second.
Then the AudioFormat decodedFormat to be this: PCM_SIGNED 48000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian
I use these line of code to make the conversion:
AudioFormat baseFormat = audioInputStream.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16,
baseFormat.getChannels(),
baseFormat.getChannels() * 2,
baseFormat.getSampleRate(),
false);
Am I doing something wrong here? I don't fully understand that that second line really does, but it's been working just fine for decoding MP3 files using the MP3SPI.
I'd really appreciate any guidance here.