Skip to content

Commit e4367a0

Browse files
committed
decoder/DsdLib: dsdlib_skip*() may throw
Prepare for getting detailed seek errors.
1 parent dfd5334 commit e4367a0

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/decoder/plugins/DsdLib.cxx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ dsdlib_skip_to(DecoderClient *client, InputStream &is,
3434
offset_type offset)
3535
{
3636
if (is.IsSeekable()) {
37-
try {
38-
is.LockSeek(offset);
39-
return true;
40-
} catch (...) {
41-
return false;
42-
}
37+
is.LockSeek(offset);
38+
return true;
4339
}
4440

4541
if (is.GetOffset() > offset)
@@ -56,12 +52,8 @@ dsdlib_skip(DecoderClient *client, InputStream &is,
5652
return true;
5753

5854
if (is.IsSeekable()) {
59-
try {
60-
is.LockSeek(is.GetOffset() + delta);
61-
return true;
62-
} catch (...) {
63-
return false;
64-
}
55+
is.LockSeek(is.GetOffset() + delta);
56+
return true;
6557
}
6658

6759
if (delta > 1024 * 1024)

src/decoder/plugins/DsdLib.hxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct DsdId {
2222

2323
/**
2424
* Skip the #InputStream to the specified offset.
25+
*
26+
* On error, either throws exception or returns false.
2527
*/
2628
[[nodiscard]]
2729
bool
@@ -30,6 +32,8 @@ dsdlib_skip_to(DecoderClient *client, InputStream &is,
3032

3133
/**
3234
* Skip some bytes from the #InputStream.
35+
*
36+
* On error, either throws exception or returns false.
3337
*/
3438
[[nodiscard]]
3539
bool

src/decoder/plugins/DsdiffDecoderPlugin.cxx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,16 @@ dsdiff_decode_chunk(DecoderClient &client, InputStream &is,
377377
break;
378378
}
379379

380-
if (dsdlib_skip_to(&client, is,
381-
start_offset + offset)) {
382-
client.CommandFinished();
383-
remaining_bytes = total_bytes - offset;
384-
} else
380+
try {
381+
if (dsdlib_skip_to(&client, is,
382+
start_offset + offset)) {
383+
client.CommandFinished();
384+
remaining_bytes = total_bytes - offset;
385+
} else
386+
client.SeekError();
387+
} catch (...) {
385388
client.SeekError();
389+
}
386390
}
387391

388392
/* see how much aligned data from the remaining chunk

src/decoder/plugins/DsfDecoderPlugin.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,16 @@ dsf_decode_chunk(DecoderClient &client, InputStream &is,
257257

258258
offset_type offset =
259259
start_offset + block * block_size;
260-
if (dsdlib_skip_to(&client, is, offset)) {
261-
client.CommandFinished();
262-
i = block;
263-
} else
260+
261+
try {
262+
if (dsdlib_skip_to(&client, is, offset)) {
263+
client.CommandFinished();
264+
i = block;
265+
} else
266+
client.SeekError();
267+
} catch (...) {
264268
client.SeekError();
269+
}
265270
}
266271

267272
/* worst-case buffer size */

0 commit comments

Comments
 (0)