fixed: crash from invalid buffer positioning, error from shutting thread
down before instantiation; removed old code;
This commit is contained in:
@@ -110,9 +110,9 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
|
||||
private boolean synchronizeBufferWithPlayback() {
|
||||
int bufferPos = calcBufferPosition();
|
||||
if (bufferPos <= playingBuffer.limit()) {
|
||||
if (bufferPos < playingBuffer.limit() || bufferPos >= 0) {
|
||||
synchronized (this) {
|
||||
playingBuffer.position(calcBufferPosition());
|
||||
playingBuffer.position(bufferPos);
|
||||
windowsRead = (int) ((mc.getCurrentPosition() * sampleRate) / windowSize);
|
||||
return true;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
@@ -121,6 +122,12 @@ public class MainPage extends Page implements Observer {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||
getStage().setScrollFocus(null);
|
||||
super.setCameraPositionToPage(cameraPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (o == mc) {
|
||||
|
@@ -49,7 +49,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
|
||||
private Batch screenBatch;
|
||||
|
||||
private float targetDelta;
|
||||
public MainScreen(RhythmBullet core) {
|
||||
this.rhythmBullet = core;
|
||||
stage = new Stage(new ScreenViewport());
|
||||
@@ -63,7 +62,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
|
||||
listeners = new Listeners();
|
||||
screenBatch = new SpriteBatch();
|
||||
targetDelta = 1f/core.getScreenConfiguration().getTargetFramesPerSecond();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +78,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
}
|
||||
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, targetDelta*lerpAlpha);
|
||||
stage.getCamera().position.lerp(cameraPosition, 0.15f);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
|
||||
@@ -144,7 +142,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
@Override
|
||||
public void show() {
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
calcLerpAlpha(Gdx.graphics.getWidth());
|
||||
super.show();
|
||||
}
|
||||
|
||||
@@ -167,7 +164,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
stage.getViewport().update(width, height, false);
|
||||
cameraPosition.x = width/2;
|
||||
cameraPosition.y = height/2;
|
||||
calcLerpAlpha(width);
|
||||
super.resize(width, height);
|
||||
}
|
||||
|
||||
@@ -180,14 +176,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private void calcLerpAlpha(int width) {
|
||||
if (width <= 3835) {
|
||||
lerpAlpha = 5.0f;
|
||||
} else {
|
||||
lerpAlpha = 5.5f;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisplayedPage(Page page) {
|
||||
page.setCameraPositionToPage(cameraPosition);
|
||||
}
|
||||
|
@@ -62,6 +62,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
|
||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||
private float musicSelectDelay;
|
||||
|
||||
public MusicSelectionPage(AssetManager assetManager, Skin skin, MusicController musicController, AudioMetadataController musicMetadataController, ChangeListener backButtonListener, ChangeListener beginButtonListener) {
|
||||
super(1, 0);
|
||||
this.assets = assetManager;
|
||||
@@ -289,7 +290,9 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
|
||||
public void stop() {
|
||||
clear();
|
||||
thread.interrupt();
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
}
|
||||
work = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user