Skip to content

Commit

Permalink
Merge pull request #6 from umjammer/0.3.5
Browse files Browse the repository at this point in the history
0.3.5
  • Loading branch information
umjammer authored Mar 31, 2024
2 parents 6b7a0ce + 13214a6 commit 986a19e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ https://jitpack.io/#umjammer/vavi-sound-alac
clip.loop(Clip.LOOP_CONTINUOUSLY);
```

## References

* https://github.com/flacon/alacenc

## TODO

* play clip w/o format conversion (possible?)
Expand Down
4 changes: 3 additions & 1 deletion local.properties.sample
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
alac=/foo/bar.m4a
alac=/foo/bar.m4a

vavi.test.volume=0.02
46 changes: 42 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,50 @@

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

<name>Apple Lossless Decoder for Java</name>
<url>https://github.com/umjammer/vavi-sound-alac</url>
<description>ALAC Java sound SPI</description>

<properties>
<vavi.test.volume>0.02</vavi.test.volume>
</properties>

<profiles>
<profile>
<id>local</id>
<activation>
<file>
<exists>${basedir}/local.properties</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<id>read-properties</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/local.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand All @@ -32,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=0.02
-Dvavi.test.volume=${vavi.test.volume}
</argLine>
<trimStackTrace>false</trimStackTrace>
<reuseForks>false</reuseForks>
Expand All @@ -53,7 +91,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.1</version>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -64,7 +102,7 @@
<dependency>
<groupId>com.github.umjammer</groupId> <!-- vavi / com.github.umjammer -->
<artifactId>vavi-sound</artifactId>
<version>1.0.16</version>
<version>1.0.18</version>
</dependency>

<dependency>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/beatofthedrum/alacdecoder/Alac.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ public class Alac implements AutoCloseable {
* @param is accepts only FileInputStream or InputStream which supports mark
* if "moov" chank in the alac mp4 container is located at back of data,
* mark might not work well.
* @throws IllegalArgumentException maybe {@code is} is not alac
*/
public Alac(InputStream is) throws IOException {
context = new AlacContext();

if (!(is instanceof FileInputStream) && !is.markSupported()) {
throw new IllegalArgumentException("is must be mark supported or FileInputStream");
throw new IOException("is must be mark supported or FileInputStream");
}
if (is.markSupported()) {
int whole = is.available();
Expand Down Expand Up @@ -70,7 +71,7 @@ public Alac(InputStream is) throws IOException {
} catch (IOException e) {
logger.fine(e.getMessage());
}
throw new IOException(errorMessage);
throw new IllegalArgumentException(errorMessage);
} else if (headerRead == 3) {
// This section is used when the stream system being used doesn't
// support seeking
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/vavi/sound/sampled/alac/AlacAudioFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.net.URL;
import java.util.HashMap;
import java.util.logging.Level;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
Expand All @@ -23,7 +22,6 @@
import javax.sound.sampled.spi.AudioFileReader;

import com.beatofthedrum.alacdecoder.Alac;

import vavi.util.Debug;


Expand All @@ -40,7 +38,7 @@ public class AlacAudioFileReader extends AudioFileReader {
@Override
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
//noinspection IOStreamConstructor
try (InputStream inputStream = new FileInputStream(file)) { // must be FileInputStream
try (InputStream inputStream = new FileInputStream(file)) { // must be FileInputStream because Alac accept it to use channel in it
return getAudioFileFormat(inputStream, (int) file.length());
}
}
Expand All @@ -61,8 +59,8 @@ public AudioFileFormat getAudioFileFormat(InputStream stream) throws Unsupported
/**
* Return the AudioFileFormat from the given InputStream. Implementation.
*
* @param bitStream
* @param mediaLength
* @param bitStream input to decode
* @param mediaLength unused
* @return an AudioInputStream object based on the audio file data contained
* in the input stream.
* mark must be supported and mark size must be larger than the alac data size
Expand All @@ -75,9 +73,9 @@ protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLen
Alac alac;
try {
alac = new Alac(bitStream);
} catch (IOException e) {
Debug.println(Level.FINE, "error exit available: " + bitStream.available());
Debug.printStackTrace(Level.FINER, e);
} catch (Exception e) {
Debug.println(Level.FINER, "error exit available: " + bitStream.available());
Debug.printStackTrace(Level.FINEST, e);
throw (UnsupportedAudioFileException) new UnsupportedAudioFileException(e.getMessage()).initCause(e);
}
// TODO AudioSystem.NOT_SPECIFIED cause IllegalArgumentException at Clip#open()
Expand All @@ -90,7 +88,7 @@ protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLen
@Override
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
//noinspection IOStreamConstructor
InputStream inputStream = new FileInputStream(file); // must be FileInputStream
InputStream inputStream = new FileInputStream(file); // must be FileInputStream because Alac accept it to use channel in it
try {
return getAudioInputStream(inputStream, (int) file.length());
} catch (UnsupportedAudioFileException | IOException e) {
Expand Down Expand Up @@ -121,7 +119,7 @@ public AudioInputStream getAudioInputStream(InputStream stream) throws Unsupport
*
* @param inputStream the input stream from which the AudioInputStream
* should be constructed.
* @param mediaLength
* @param mediaLength unused
* @return an AudioInputStream object based on the audio file data contained
* in the input stream.
* @exception UnsupportedAudioFileException if the File does not point to a
Expand Down

0 comments on commit 986a19e

Please sign in to comment.