use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class PlayingTrackManager method handleTrackDataRequest.
@MessageHandler
private void handleTrackDataRequest(TrackFrameRequestMessage message, MessageOutput output) {
List<AudioFrame> frames = new ArrayList<>();
PlayingTrack track = tracks.get(message.executorId);
boolean finished = false;
if (track != null) {
submitPendingMessages(track, output);
track.lastFrameRequestTime = System.currentTimeMillis();
track.volume.set(message.volume);
if (message.seekPosition >= 0) {
track.audioTrack.setPosition(message.seekPosition);
}
if (message.maximumFrames > 0) {
track.lastNonZeroFrameRequestTime = track.lastFrameRequestTime;
}
finished = consumeFramesFromTrack(frames, track.audioTrack, message.maximumFrames);
if (finished) {
log.info("Clearing ended track {} (context {})", track.audioTrack.getIdentifier(), message.executorId);
tracks.remove(message.executorId);
}
}
output.send(new TrackFrameDataMessage(message.executorId, frames, finished, message.seekPosition));
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class RemoteAudioTrackExecutor method provide.
@Override
public AudioFrame provide(long timeout, TimeUnit unit) throws TimeoutException, InterruptedException {
AudioFrame frame = frameBuffer.provide(timeout, unit);
processProvidedFrame(frame);
return frame;
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class RemoteNodeProcessor method handleTrackFrameData.
private void handleTrackFrameData(TrackFrameDataMessage message) throws Exception {
RemoteAudioTrackExecutor executor = playingTracks.get(message.executorId);
if (executor != null) {
if (message.seekedPosition >= 0) {
executor.clearSeek(message.seekedPosition);
}
AudioFrameBuffer buffer = executor.getAudioBuffer();
executor.receivedData();
AudioDataFormat format = executor.getConfiguration().getOutputFormat();
for (AudioFrame frame : message.frames) {
buffer.consume(new AudioFrame(frame.timecode, frame.data, frame.volume, format));
}
if (message.finished) {
buffer.setTerminateOnEmpty();
trackEnded(executor, false);
}
}
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class AudioPlayer method provideShadowFrame.
private AudioFrame provideShadowFrame() {
InternalAudioTrack shadow = shadowTrack;
AudioFrame frame = null;
if (shadow != null) {
frame = shadow.provide();
if (frame != null && frame.isTerminator()) {
shadowTrack = null;
frame = null;
}
}
return frame;
}
Aggregations