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

0.3.6 #7

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>vavi</groupId>
<artifactId>vavi-sound-alac</artifactId>
<version>0.3.5</version>
<version>0.3.6</version>

<name>Apple Lossless Decoder for Java</name>
<url>https://github.com/umjammer/vavi-sound-alac</url>
Expand All @@ -31,7 +31,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.1.0</version>
<version>1.2.1</version>
<executions>
<execution>
<id>read-properties</id>
Expand Down Expand Up @@ -70,7 +70,7 @@
<argLine>
--add-opens java.base/java.io=ALL-UNNAMED
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
-Dvavi.test.volume=${vavi.test.volume}
-Dvavi.test.volume=@{vavi.test.volume}
</argLine>
<trimStackTrace>false</trimStackTrace>
<reuseForks>false</reuseForks>
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/com/beatofthedrum/alacdecoder/Alac.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioFormat;

import static java.lang.System.getLogger;


/**
* Alac. (wrapped AlacContext and utilities for working independently)
Expand All @@ -21,9 +24,9 @@
*/
public class Alac implements AutoCloseable {

private static final Logger logger = Logger.getLogger(Alac.class.getName());
private static final Logger logger = getLogger(Alac.class.getName());

private AlacContext context;
private final AlacContext context;

/**
* Creates ALAC decoder.
Expand All @@ -50,7 +53,7 @@ public Alac(InputStream is) throws IOException {
QTMovieT qtMovie = new QTMovieT(context.inputStream);
DemuxResT demuxRes = new DemuxResT();
int headerRead = qtMovie.read(demuxRes);
logger.fine("headerRead: " + headerRead);
logger.log(Level.DEBUG, "headerRead: " + headerRead);

if (headerRead == 0) {
String errorMessage;
Expand All @@ -63,13 +66,13 @@ public Alac(InputStream is) throws IOException {
try {
if (is.markSupported()) {
is.reset();
logger.fine("reset: " + is.available());
logger.log(Level.DEBUG, "reset: " + is.available());
} else if (is instanceof FileInputStream) {
((FileInputStream) is).getChannel().position(0);
logger.fine("seek: 0");
logger.log(Level.DEBUG, "seek: 0");
}
} catch (IOException e) {
logger.fine(e.getMessage());
logger.log(Level.DEBUG, e.getMessage());
}
throw new IllegalArgumentException(errorMessage);
} else if (headerRead == 3) {
Expand All @@ -81,10 +84,10 @@ public Alac(InputStream is) throws IOException {

if (is.markSupported()) {
is.reset();
logger.fine("reset: " + is.available());
logger.log(Level.DEBUG, "reset: " + is.available());
} else if (is instanceof FileInputStream) {
((FileInputStream) is).getChannel().position(0);
logger.fine("seek: 0");
logger.log(Level.DEBUG, "seek: 0");
}

qtMovie.qtStream.currentPos = 0;
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/beatofthedrum/alacdecoder/AlacContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@

package com.beatofthedrum.alacdecoder;


import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.nio.channels.FileChannel;
import java.util.logging.Logger;

import static java.lang.System.getLogger;


/**
* AlacContext.
*/
public class AlacContext {

private static final Logger logger = Logger.getLogger(AlacContext.class.getName());
private static final Logger logger = getLogger(AlacContext.class.getName());

/**
* @author Denis Tulskiy
Expand All @@ -42,18 +44,18 @@ private static class AlacInputStream extends DataInputStream {
public AlacInputStream(InputStream in) throws IOException {
super(in);
total = in.available();
logger.fine("total: " + total);
logger.log(Level.DEBUG, "total: " + total);
}

public void seek(long pos) throws IOException {
if (in instanceof FileInputStream) {
FileChannel fc = ((FileInputStream) in).getChannel();
fc.position(pos);
logger.fine("position: " + fc.position());
logger.log(Level.DEBUG, "position: " + fc.position());
} else if (in.markSupported()) {
in.reset();
in.mark(total);
logger.fine("reset: " + in.available());
logger.log(Level.DEBUG, "reset: " + in.available());
if (pos != 0)
skipBytes((int) pos);
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/beatofthedrum/alacdecoder/AlacFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@

package com.beatofthedrum.alacdecoder;

import java.lang.System.Logger;
import java.lang.System.Logger.Level;

import java.util.logging.Logger;
import static java.lang.System.getLogger;


/**
* AlacFile.
*/
class AlacFile {

private static final Logger logger = Logger.getLogger(AlacFile.class.getName());
private static final Logger logger = getLogger(AlacFile.class.getName());

static int RICE_THRESHOLD = 8;
byte[] inputBuffer;
Expand Down Expand Up @@ -451,7 +453,7 @@ public int decodeFrame(byte[] inBuffer, int[] outBuffer, int outputSize) {
if (predictionType == 0) { // adaptive fir
this.outputSamplesBufferA = predictorDecompressFirAdapt(this.predicterrorBufferA, outputSamples, readSampleSize, predictorCoefTable, predictorCoefNum, predictionQuantitization);
} else {
logger.warning("FIXME: unhandled predicition type: " + predictionType);
logger.log(Level.WARNING, "FIXME: unhandled predicition type: " + predictionType);

// i think the only other prediction type (or perhaps this is just a
// boolean?) runs adaptive fir twice.. like:
Expand Down Expand Up @@ -533,7 +535,7 @@ public int decodeFrame(byte[] inBuffer, int[] outBuffer, int outputSize) {
}
case 20:
case 32:
logger.warning("FIXME: unimplemented sample size " + this.setInfo_sampleSize);
logger.log(Level.WARNING, "FIXME: unimplemented sample size " + this.setInfo_sampleSize);
default:
}
} else if (channels == 1) { // 2 channels
Expand Down Expand Up @@ -639,7 +641,7 @@ public int decodeFrame(byte[] inBuffer, int[] outBuffer, int outputSize) {
this.outputSamplesBufferA = predictorDecompressFirAdapt(this.predicterrorBufferA, outputSamples, readSampleSize, predictorCoefTableA, predictorCoefNumA, predictionQuantitizationA);

} else { // see mono case
logger.warning("FIXME: unhandled predicition type: " + predictionTypeA);
logger.log(Level.WARNING, "FIXME: unhandled predicition type: " + predictionTypeA);
}

// channel 2
Expand All @@ -648,7 +650,7 @@ public int decodeFrame(byte[] inBuffer, int[] outBuffer, int outputSize) {
if (predictionTypeB == 0) { // adaptive fir
this.outputsamplesBufferB = predictorDecompressFirAdapt(this.predicterrorBufferB, outputSamples, readSampleSize, predictorCoefTableB, predictorCoefNumB, predictionQuantitizationB);
} else {
logger.warning("FIXME: unhandled predicition type: " + predictionTypeB);
logger.log(Level.WARNING, "FIXME: unhandled predicition type: " + predictionTypeB);
}
} else { // not compressed, easy case
if (this.setInfo_sampleSize <= 16) {
Expand Down Expand Up @@ -710,7 +712,7 @@ public int decodeFrame(byte[] inBuffer, int[] outBuffer, int outputSize) {
case 20:
case 32:
default:
logger.warning("FIXME: unimplemented sample size " + this.setInfo_sampleSize);
logger.log(Level.WARNING, "FIXME: unimplemented sample size " + this.setInfo_sampleSize);
}
}
return outputSize;
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/com/beatofthedrum/alacdecoder/MyStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@

import java.io.DataInputStream;
import java.io.IOException;
import java.util.logging.Logger;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;

import static java.lang.System.getLogger;


class MyStream {

private static final Logger logger = Logger.getLogger(MyStream.class.getName());
private static final Logger logger = getLogger(MyStream.class.getName());

DataInputStream stream;

int currentPos = 0;

private byte[] readBuf = new byte[8];
private final byte[] readBuf = new byte[8];

MyStream(DataInputStream stream) {
this.stream = stream;
Expand All @@ -37,10 +40,8 @@ int position() {
return this.currentPos;
}

/** */
/** TODO */
int isEof() {
// TODO

return 0;
}

Expand All @@ -53,7 +54,7 @@ void skip(int skip) throws IOException {
throw new IllegalArgumentException("skip: request to seek backwards in stream - not supported, sorry");
}

logger.finer("skip: " + toskip);
logger.log(Level.TRACE, "skip: " + toskip);
bytesRead = this.stream.skipBytes(toskip);
this.currentPos = this.currentPos + bytesRead;
}
Expand Down
Loading