Skip to content

Commit

Permalink
Merge pull request #14 from umjammer/1.19.5
Browse files Browse the repository at this point in the history
1.19.5
  • Loading branch information
umjammer authored Feb 17, 2024
2 parents f53ea3d + 1dfeaa4 commit 90d6317
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 244 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/maven-publish.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Release](https://jitpack.io/v/umjammer/mp3spi.svg)](https://jitpack.io/#umjammer/mp3spi)
[![Maven Package](https://github.com/umjammer/mp3spi/actions/workflows/maven-publish.yml/badge.svg)](https://github.com/umjammer?tab=packages&repo_name=mp3spi)
[![Java CI](https://github.com/umjammer/mp3spi/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/mp3spi/actions/workflows/maven.yml)
[![CodeQL](https://github.com/umjammer/mp3spi/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/mp3spi/actions/workflows/codeql-analysis.yml)
Expand All @@ -17,7 +18,7 @@ Both are in pure Java.

## Install

* [maven](https://github.com/umjammer?tab=packages&repo_name=mp3spi)
* [maven](https://jitpack.io/#umjammer/mp3spi)

## Usage

Expand All @@ -29,7 +30,7 @@ Both are in pure Java.
## TODO

* ~~encoder using https://github.com/nwaldispuehl/java-lame~~
* rename project as vavi-sound-mp3
* rename project as vavi-sound-mp3-javazoom

----

Expand Down
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
23 changes: 6 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@

<groupId>net.javazoom</groupId>
<artifactId>mp3spi</artifactId>
<version>1.9.14</version>
<version>1.9.15</version>

<properties>
<tritonus.version>0.3.12</tritonus.version>
<tritonus.groupId>com.github.umjammer.tritonus</tritonus.groupId> <!-- org.tritonus / com.github.umjammer.tritonus -->
<tritonus.version>0.3.13</tritonus.version>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/umjammer/mp3spi</url>
</repository>
</distributionManagement>

<build>
<plugins>
<plugin>
Expand All @@ -39,7 +33,6 @@
<argLine>
--add-opens java.desktop/com.sun.media.sound=ALL-UNNAMED
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
-Dvavi.util.logging.VaviFormatter.extraClassMethod=org\\.tritonus\\.share\\.TDebug#out
-Dvavi.test.volume=0.02
</argLine>
<trimStackTrace>false</trimStackTrace>
Expand All @@ -53,10 +46,6 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/umjammer/*</url>
</repository>
</repositories>

<dependencyManagement>
Expand All @@ -79,12 +68,12 @@
</dependency>

<dependency>
<groupId>org.tritonus</groupId>
<groupId>${tritonus.groupId}</groupId>
<artifactId>tritonus-share</artifactId>
<version>${tritonus.version}</version>
</dependency>
<dependency>
<groupId>org.tritonus</groupId>
<groupId>${tritonus.groupId}</groupId>
<artifactId>tritonus-remaining</artifactId>
<version>${tritonus.version}</version>
</dependency>
Expand Down Expand Up @@ -123,7 +112,7 @@
</dependency>

<dependency>
<groupId>com.github.umjammer</groupId>
<groupId>com.github.umjammer</groupId> <!-- vavi / com.github.umjammer -->
<artifactId>vavi-sound</artifactId>
<version>1.0.16</version>
<scope>test</scope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import java.io.IOException;
import java.io.InputStream;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.HashMap;
import java.util.Map;
import javax.sound.sampled.AudioFormat;
Expand All @@ -41,15 +43,18 @@
import javazoom.spi.mpeg.sampled.file.IcyListener;
import javazoom.spi.mpeg.sampled.file.tag.TagParseEvent;
import javazoom.spi.mpeg.sampled.file.tag.TagParseListener;
import org.tritonus.share.TDebug;
import org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream;

import static java.lang.System.getLogger;


/**
* Main decoder.
*/
public class DecodedMpegAudioInputStream extends TAsynchronousFilteredAudioInputStream implements PropertiesContainer, TagParseListener {

private static final Logger logger = getLogger("org.tritonus.TraceAudioConverter");

private InputStream m_encodedStream;

private Bitstream m_bitstream;
Expand Down Expand Up @@ -88,14 +93,12 @@ public class DecodedMpegAudioInputStream extends TAsynchronousFilteredAudioInput

public DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream) {
super(outputFormat, -1);
if (TDebug.TraceAudioConverter) {
TDebug.out(">DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream)");
}
logger.log(Level.TRACE, ">DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream)");
try {
// Try to find out inputstream length to allow skip.
byteslength = inputStream.available();
} catch (IOException e) {
TDebug.out("DecodedMpegAudioInputStream : Cannot run inputStream.available() : " + e.getMessage());
logger.log(Level.TRACE, "DecodedMpegAudioInputStream : Cannot run inputStream.available() : " + e.getMessage());
byteslength = -1;
}
m_encodedStream = inputStream;
Expand All @@ -116,7 +119,7 @@ public DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream in
if ((m_header != null) && (frameslength == -1) && (byteslength > 0))
frameslength = m_header.maxNumberOfFrames((int) byteslength);
} catch (BitstreamException e) {
TDebug.out("DecodedMpegAudioInputStream : Cannot read first frame : " + e.getMessage());
logger.log(Level.TRACE, "DecodedMpegAudioInputStream : Cannot read first frame : " + e.getMessage());
byteslength = -1;
}
properties = new HashMap<>();
Expand Down Expand Up @@ -164,21 +167,17 @@ public Map<String, Object> properties() {

@Override
public void execute() {
if (TDebug.TraceAudioConverter)
TDebug.out("execute() : begin");
logger.log(Level.TRACE, "execute() : begin");
try {
// Following line hangs when FrameSize is available in AudioFormat.
Header header = null;
if (m_header == null)
header = m_bitstream.readFrame();
else
header = m_header;
if (TDebug.TraceAudioConverter)
TDebug.out("execute() : header = " + header);
logger.log(Level.TRACE, "execute() : header = " + header);
if (header == null) {
if (TDebug.TraceAudioConverter) {
TDebug.out("header is null (end of mpeg stream)");
}
logger.log(Level.TRACE, "header is null (end of mpeg stream)");
getCircularBuffer().close();
return;
}
Expand All @@ -198,12 +197,9 @@ public void execute() {
if (m_header != null)
m_header = null;
} catch (BitstreamException | DecoderException e) {
if (TDebug.TraceAudioConverter) {
TDebug.out(e);
}
logger.log(Level.ERROR, e.getMessage(), e);
}
if (TDebug.TraceAudioConverter)
TDebug.out("execute() : end");
logger.log(Level.TRACE, "execute() : end");
}

@Override
Expand All @@ -226,8 +222,7 @@ public long skip(long bytes) {
* @return bytes length skipped matching to frames skipped.
*/
public long skipFrames(long frames) {
if (TDebug.TraceAudioConverter)
TDebug.out("skip(long frames) : begin");
logger.log(Level.TRACE, "skip(long frames) : begin");
int framesRead = 0;
int bytesReads = 0;
try {
Expand All @@ -241,11 +236,9 @@ public long skipFrames(long frames) {
framesRead++;
}
} catch (BitstreamException e) {
if (TDebug.TraceAudioConverter)
TDebug.out(e);
logger.log(Level.ERROR, e.getMessage(), e);
}
if (TDebug.TraceAudioConverter)
TDebug.out("skip(long frames) : end");
logger.log(Level.TRACE, "skip(long frames) : end");
currentFrame = currentFrame + framesRead;
return bytesReads;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@

package javazoom.spi.mpeg.sampled.convert;

import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.Arrays;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;

import javazoom.spi.mpeg.sampled.file.MpegEncoding;
import org.tritonus.share.TDebug;
import org.tritonus.share.sampled.Encodings;
import org.tritonus.share.sampled.convert.TEncodingFormatConversionProvider;

import static java.lang.System.getLogger;
import static javax.sound.sampled.AudioSystem.NOT_SPECIFIED;


Expand All @@ -41,6 +43,8 @@
*/
public class MpegFormatConversionProvider extends TEncodingFormatConversionProvider {

private static final Logger logger = getLogger("org.tritonus.TraceAudioConverter");

private static final AudioFormat.Encoding MP3 = Encodings.getEncoding("MP3");
private static final AudioFormat.Encoding PCM_SIGNED = Encodings.getEncoding("PCM_SIGNED");

Expand All @@ -67,16 +71,12 @@ public class MpegFormatConversionProvider extends TEncodingFormatConversionProvi
*/
public MpegFormatConversionProvider() {
super(Arrays.asList(INPUT_FORMATS), Arrays.asList(OUTPUT_FORMATS));
if (TDebug.TraceAudioConverter) {
TDebug.out(">MpegFormatConversionProvider()");
}
logger.log(Level.TRACE, ">MpegFormatConversionProvider()");
}

@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream) {
if (TDebug.TraceAudioConverter) {
TDebug.out(">MpegFormatConversionProvider.getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream):");
}
logger.log(Level.TRACE, ">MpegFormatConversionProvider.getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream):");
return new DecodedMpegAudioInputStream(targetFormat, audioInputStream);
}

Expand All @@ -89,12 +89,10 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput
*/
@Override
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) {
if (TDebug.TraceAudioConverter) {
TDebug.out(">MpegFormatConversionProvider.isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat):");
TDebug.out("checking if conversion possible");
TDebug.out("from: " + sourceFormat);
TDebug.out("to: " + targetFormat);
}
logger.log(Level.TRACE, ">MpegFormatConversionProvider.isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat):");
logger.log(Level.TRACE, "checking if conversion possible");
logger.log(Level.TRACE, "from: " + sourceFormat);
logger.log(Level.TRACE, "to: " + targetFormat);

boolean conversion = super.isConversionSupported(targetFormat, sourceFormat);
if (!conversion) {
Expand Down
Loading

0 comments on commit 90d6317

Please sign in to comment.