Skip to content

Commit

Permalink
#209 Fix concurrency error in DSD parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed May 11, 2019
1 parent 50d7d01 commit 5a9c50f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/ParserFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ export class ParserFactory {

case 'musepack':
return 'musepack';

case 'dsf':
return 'dsf';
}
break;

Expand Down
4 changes: 2 additions & 2 deletions src/dsf/DsfParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class DsfParser extends AbstractID3Parser {

const p0 = this.tokenizer.position; // mark start position, normally 0
const chunkHeader = await this.tokenizer.readToken<IChunkHeader>(ChunkHeader);
assert.strictEqual(chunkHeader.id, 'DSD ');
assert.strictEqual(chunkHeader.id, 'DSD ', 'Invalid chunk signature');
this.metadata.setFormat('dataformat', 'DSF');
this.metadata.setFormat('lossless', true);
const dsdChunk = await this.tokenizer.readToken<IDsdChunk>(DsdChunk);
Expand All @@ -29,7 +29,7 @@ export class DsfParser extends AbstractID3Parser {
debug(`expect ID3v2 at offset=${dsdChunk.metadataPointer}`);
await this.parseChunks(dsdChunk.fileSize - chunkHeader.size);
// Jump to ID3 header
this.tokenizer.ignore(dsdChunk.metadataPointer - this.tokenizer.position - p0);
await this.tokenizer.ignore(dsdChunk.metadataPointer - this.tokenizer.position - p0);
return new ID3v2Parser().parse(this.metadata, this.tokenizer, this.options);
}
}
Expand Down

0 comments on commit 5a9c50f

Please sign in to comment.