Change to Java 16 and add more exceptions to AudioPlayer setup

pull/35/head
James Ball 2021-06-02 22:45:50 +01:00
rodzic 0f912df3c9
commit 26a753464f
4 zmienionych plików z 23 dodań i 11 usunięć

Wyświetl plik

@ -80,21 +80,21 @@ To uninstall, use Windows control panel, as you would expect.
### Running using .jar
- Download the latest `osci-render-VERSION.jar` from [Releases](https://github.com/jameshball/osci-render/releases)
- Download and install [Java 15 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
- Download and install [Java 16 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
- Donwload and unpack [JavaFX 16 or later](https://gluonhq.com/products/javafx/)
- Make sure you scroll down to `Latest Release`
- Download the SDK for your platform
- Unpack the `.zip` at your root directory (e.g. `C:\javafx-sdk-16` for me on Windows)
- The `lib` subfolder should be located at `/javafx-sdk-16/lib`
- Run the following command from your terminal to run the `.jar`, substituting the correct paths
- `java --enable-preview --module-path /javafx-sdk-16/lib --add-modules=javafx.controls,javafx.fxml -jar "path/to/osci-render-VERSION.jar"`
- `java --module-path /javafx-sdk-16/lib --add-modules=javafx.controls,javafx.fxml -jar "PATH/TO/osci-render-VERSION.jar"`
- Start rendering!
## Building
I am using Maven for dependency management and to package the program. Doing the following will setup the project. I highly recommend using IntelliJ.
- Download and install [Java 15 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
- Download and install [Java 16 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
- Run `git clone git@github.com:jameshball/osci-render.git`
- `cd` into the `osci-render` directory
- Run `mvn package`

Wyświetl plik

@ -6,13 +6,13 @@
<groupId>sh.ball</groupId>
<artifactId>osci-render</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
<name>osci-render</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>15</maven.compiler.release>
<maven.compiler.release>16</maven.compiler.release>
<javafx.version>16</javafx.version>
<project.modulePath>${project.build.directory}\modules</project.modulePath>
<appModule>oscirender</appModule>
@ -99,7 +99,6 @@
<source>${maven.compiler.release}</source>
<target>${maven.compiler.release}</target>
<compilerArgs>
<compilerArg>--enable-preview</compilerArg>
<compilerArg>--module-path</compilerArg>
<compilerArg>${project.modulePath}</compilerArg>
</compilerArgs>
@ -118,7 +117,6 @@
<modulePath>${project.build.directory}/modules;${project.build.directory}/classes</modulePath>
<destination>${project.build.directory}</destination>
<javaOptions>
<option>--enable-preview</option>
<option>-Dfile.encoding=UTF-8</option>
</javaOptions>
</configuration>

Wyświetl plik

@ -167,19 +167,25 @@ public class AudioPlayer implements Renderer<List<Shape>, AudioInputStream> {
if (service == null) {
service = platform.getService(platform.setupToSystem(XtSetup.CONSUMER_AUDIO));
}
if (service == null) return;
if (service == null) {
throw new RuntimeException("Failed to connect to any audio service");
}
if (service.getCapabilities().contains(Enums.XtServiceCaps.NONE)) {
throw new RuntimeException("Audio service has no capabilities");
}
String output = service.getDefaultDeviceId(true);
if (output == null) {
output = service.openDeviceList(EnumSet.of(Enums.XtEnumFlags.OUTPUT)).getId(0);
output = getFirstDevice(service);
}
try (XtDevice device = service.openDevice(output)) {
if (device.supportsFormat(format)) {
XtBufferSize size = device.getBufferSize(format);
XtStreamParams streamParams = new XtStreamParams(true, this::render, null, null);
XtDeviceStreamParams deviceParams = new XtDeviceStreamParams(streamParams, format, size.current);
try (XtStream stream = device.openStream(deviceParams, null);
XtSafeBuffer safe = XtSafeBuffer.register(stream, true)) {
stream.start();
@ -188,11 +194,17 @@ public class AudioPlayer implements Renderer<List<Shape>, AudioInputStream> {
}
stream.stop();
}
} else {
throw new RuntimeException("Audio device does not support audio format");
}
}
}
}
private String getFirstDevice(XtService service) {
return service.openDeviceList(EnumSet.of(Enums.XtEnumFlags.OUTPUT)).getId(0);
}
@Override
public void stop() {
stopped = true;

Wyświetl plik

@ -236,7 +236,9 @@ public class Controller implements Initializable, FrequencyListener, Listener {
renderer.addEffect(EffectType.TRANSLATE, translateEffect);
executor.submit(producer);
new Thread(renderer).start();
Thread renderThread = new Thread(renderer);
renderThread.setUncaughtExceptionHandler((thread, throwable) -> throwable.printStackTrace());
renderThread.start();
FrequencyAnalyser<List<Shape>, AudioInputStream> analyser = new FrequencyAnalyser<>(renderer, 2, SAMPLE_RATE);
analyser.addListener(this);
analyser.addListener(wobbleEffect);