Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Popov committed Jun 11, 2020
1 parent 80125a8 commit 8f053b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
5 changes: 4 additions & 1 deletion core/src/main/java/org/gagravarr/flac/FlacNativeFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ public InputStream getInputStream() {
Vector<InputStream> streams = new Vector<>();
byte[] header = {'f', 'L', 'a', 'C'};
streams.add(new ByteArrayInputStream(header));
blocksInOrder.stream().forEach(block -> this.addStream(streams, block.getData()));
blocksInOrder.stream().forEach(block -> {
this.addStream(streams, block.getData());
});
streams.add(input);

return new SequenceInputStream(streams.elements());
Expand All @@ -154,6 +156,7 @@ public OggStreamPacketDecorator(OggStreamPacket decorated) {
}

public byte[] getData() {
decorated.write();
return decorated.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ protected OggPacket getOggPacket() {
}

public byte[] getData() {
return getDecoratedData();
}

public void setData(byte[] data) {
this.data = data;
}

private byte[] getDecoratedData() {
if (data != null) {
return data;
}
Expand All @@ -53,6 +45,10 @@ private byte[] getDecoratedData() {
return null;
}

public void setData(byte[] data) {
this.data = data;
}

/**
* Returns the approximate number of bytes overhead
* from the underlying {@link OggPacket} / {@link OggPage}
Expand All @@ -70,7 +66,7 @@ public int getOggOverheadSize() {
}

public OggPacket write() {
this.oggPacket = new OggPacket(getDecoratedData());
this.oggPacket = new OggPacket(getData());
return this.oggPacket;
}
}
16 changes: 1 addition & 15 deletions core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public abstract class VorbisStyleComments extends HighLevelOggStreamPacket imple

private String vendor;
private Map<String, List<String>> comments = new HashMap<String, List<String>>();
private boolean modified;

public VorbisStyleComments(OggPacket pkt, int dataBeginsAt) {
super(pkt);
Expand Down Expand Up @@ -202,15 +201,13 @@ public List<String> getComments(String tag) {
*/
public void removeComments(String tag) {
comments.remove(normaliseTag(tag));
this.modified = true;
}

/**
* Removes all comments across all tags
*/
public void removeAllComments() {
comments.clear();
this.modified = true;
}

/**
Expand All @@ -222,7 +219,6 @@ public void addComment(String tag, String comment) {
comments.put(nt, new ArrayList<String>());
}
comments.get(nt).add(comment);
this.modified = true;
}

/**
Expand All @@ -235,7 +231,6 @@ public void setComments(String tag, List<String> comments) {
this.comments.remove(nt);
}
this.comments.put(nt, comments);
this.modified = true;
}


Expand All @@ -258,15 +253,6 @@ protected int getInt4(byte[] d, int offset) {
return (int) IOUtils.getInt4(d, offset);
}

@Override
public byte[] getData() {
if (modified) {
// write();
modified = false;
}
return super.getData();
}

@Override
public OggPacket write() {
// Serialise the comments
Expand Down Expand Up @@ -307,7 +293,7 @@ public OggPacket write() {

// Now fill in the header
byte[] data = baos.toByteArray();
populateMetadataHeader(data, data.length);
populateMetadataHeader(data, data.length - getHeaderSize());

// Record the data
setData(data);
Expand Down

0 comments on commit 8f053b5

Please sign in to comment.