Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
temporarily fix audio until i figure out why newer magma versions don…
Browse files Browse the repository at this point in the history
…'t work
  • Loading branch information
natanbc committed Jul 31, 2019
1 parent 7fdc239 commit f032b26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'com.palantir.docker' version '0.22.1'
}

def versionObj = new Version(major: 0, minor: 18, revision: 6)
def versionObj = new Version(major: 0, minor: 18, revision: 7)

sourceCompatibility = 11
targetCompatibility = 11
Expand All @@ -20,10 +20,11 @@ ext {
configVersion = '1.3.4'
jdaNasVersion = '1.1.0'
jsr305Version = '3.0.2'
koeVersion = '454cfec'
lavaplayerVersion = '1.3.19'
lavadspVersion = '0.5.2'
logbackVersion = '1.2.3'
magmaVersion = '0.10.4'
magmaVersion = '0.10.0'
nativeLoaderVersion = '0.3.0'
prometheusVersion = '0.6.0'
sentryVersion = '1.7.25'
Expand Down Expand Up @@ -51,9 +52,12 @@ dependencies {
//REST, WebSocket, etc
compile "io.vertx:vertx-web:$vertxWebVersion"

//Raw audio -> udp packet
//Audio sending
compile "club.minnced:magma:$magmaVersion"

//Audio sending
//compile "moe.kyokobot:koe:$koeVersion"

//Audio player
compile "com.sedmelluq:lavaplayer:$lavaplayerVersion"

Expand Down
28 changes: 0 additions & 28 deletions src/main/java/andesite/node/player/NonAllocatingProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,13 @@

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.util.function.Function;

class NonAllocatingProvider implements AudioProvider {
private static final Function<MutableAudioFrame, ByteBuffer> INTERNAL_BUFFER_GETTER;

private final ByteBuffer buffer = ByteBuffer.allocate(StandardAudioDataFormats.DISCORD_OPUS.maximumChunkSize());
private final MutableAudioFrame frame = new MutableAudioFrame();
private final AudioPlayer player;

static {
try {
Field f = MutableAudioFrame.class.getDeclaredField("frameBuffer");
f.setAccessible(true);
INTERNAL_BUFFER_GETTER = frame -> {
try {
return (ByteBuffer) f.get(frame);
} catch(Exception impossible) {
throw new AssertionError(impossible);
}
};
} catch(Exception e) {
throw new ExceptionInInitializerError(e);
}
}

public NonAllocatingProvider(AudioPlayer player) {
this.player = player;
frame.setBuffer(buffer);
Expand All @@ -50,14 +30,6 @@ public boolean canProvide() {
@Nonnull
@Override
public ByteBuffer provide() {
if(INTERNAL_BUFFER_GETTER.apply(frame) != buffer) {
frame.getData(buffer.array(), frame.getDataLength());
//hopefully this copy won't be needed for the next frame
//and data will be directly written to the provider's buffer.
//this call is pretty much free, and might help preventing
//more copies for future frames.
frame.setBuffer(buffer.limit(buffer.capacity()));
}
return buffer.position(0).limit(frame.getDataLength());
}

Expand Down

0 comments on commit f032b26

Please sign in to comment.