Skip to content

Commit 93fffc4

Browse files
committed
Synchronize some stuff to avoid misreading from stream
1 parent 218a5ec commit 93fffc4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/player/AbsChunkedInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private void checkAvailability(int chunk, boolean wait, boolean halted) throws I
175175
}
176176

177177
@Override
178-
public final int read(@NotNull byte[] b, int off, int len) throws IOException {
178+
public final synchronized int read(@NotNull byte[] b, int off, int len) throws IOException {
179179
if (closed) throw new IOException("Stream is closed!");
180180

181181
if (off < 0 || len < 0 || len > b.length - off) {

core/src/main/java/xyz/gianlu/librespot/player/codecs/VorbisCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void readHeader() throws IOException, CodecException {
145145
* @throws IOException if an I/O exception occurs
146146
*/
147147
@Override
148-
public int readInternal(@NotNull OutputStream out) throws IOException, CodecException {
148+
public synchronized int readInternal(@NotNull OutputStream out) throws IOException, CodecException {
149149
if (closed) return -1;
150150

151151
int written = 0;

0 commit comments

Comments
 (0)