devoxin / lavaplayer

A fork of Walkyst's Lavaplayer fork.
Apache License 2.0
13 stars 3 forks source link

LavaPlayer not working properly when relocating #18

Closed BaxAndrei closed 2 months ago

BaxAndrei commented 2 months ago

I am getting this error when lavaplayer try to play some mp3: Something went wrong when looking up the track and this error when it try to play ogg files:

Exception in thread "lava-daemon-pool-playback-1-thread-1" java.lang.UnsatisfiedLinkError: 'long ro.baxandrei.discordbot.lib.lavaplayer.natives.opus.OpusDecoderLibrary.create(int, int)'
        at ro.baxandrei.discordbot.lib.lavaplayer.natives.opus.OpusDecoderLibrary.create(Native Method)
        at ro.baxandrei.discordbot.lib.lavaplayer.natives.opus.OpusDecoder.<init>(OpusDecoder.java:21)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.common.OpusPacketRouter.initialiseDecoder(OpusPacketRouter.java:193)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.common.OpusPacketRouter.checkDecoderNecessity(OpusPacketRouter.java:177)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.common.OpusPacketRouter.process(OpusPacketRouter.java:93)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.ogg.opus.OggOpusTrackHandler.provideFrames(OggOpusTrackHandler.java:51)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.ogg.OggAudioTrack.processTrackLoop(OggAudioTrack.java:58)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.ogg.OggAudioTrack.lambda$process$0(OggAudioTrack.java:41)
        at ro.baxandrei.discordbot.lib.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:275)
        at ro.baxandrei.discordbot.lib.lavaplayer.container.ogg.OggAudioTrack.process(OggAudioTrack.java:39)
        at ro.baxandrei.discordbot.lib.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:25)
        at ro.baxandrei.discordbot.lib.lavaplayer.source.local.LocalAudioTrack.process(LocalAudioTrack.java:45)
        at ro.baxandrei.discordbot.lib.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:104)
        at ro.baxandrei.discordbot.lib.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:348)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)

After many hours of try/fail I reached a result: if I delete relocation for com.sedmelluq.discord.lavaplayer.natives everything works ok.

How could I relocate this package without breaking lavaplayer?

Thank you!

devoxin commented 2 months ago

I am not sure what you're asking. Are you running Lavaplayer on a supported platform/architecture?

BaxAndrei commented 2 months ago

Yes. Everything works perfectly, but if I add this line in pom.xml to relocate the package, it doesn't work anymore. (I add the line for personal reasons)

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven.shade.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                            <minimizeJar>true</minimizeJar>
                            <relocations>
                               .....
                                <relocation>
                                    <pattern>com.sedmelluq.discord.lavaplayer</pattern>
                                    <shadedPattern>ro.baxandrei.discordbot.lib.lavaplayer</shadedPattern>
                                </relocation>
                                ........
                            </relocations>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <filters>
                                ....
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
devoxin commented 2 months ago

Yes because natives work based on package path. That package path is com.sedmelluq.* so renaming it won't work. What you are trying to do is unsupported.

BaxAndrei commented 2 months ago

Yes because natives work based on package path. That package path is com.sedmelluq.* so renaming it won't work. What you are trying to do is unsupported.

Do you think you could please show me where these values ​​are hardcoded so that I can modify them manually and make my own version? Thank you.

EDIT: Also relocation is smart enough to remap all package paths but there must be something hardcoded or stored as string/text image

devoxin commented 2 months ago

It's within the compiled natives themselves. Not only would you need to modify the natives source but you would need to figure out how to compile them. This is not something I offer support for due to how arduous and temperamental the build process is.

BaxAndrei commented 2 months ago

It's within the compiled natives themselves. Not only would you need to modify the natives source but you would need to figure out how to compile them. This is not something I offer support for due to how arduous and temperamental the build process is.

I understand now, thank you very much for the answer. I will figure out a solution now that you said this. Have a nice day.