remove error part of sseek()

This commit is contained in:
Luna 2019-07-15 10:58:45 -03:00
parent d12268f028
commit c5a2e317c4

View file

@ -54,12 +54,10 @@ fn swrite(file: *c.SNDFILE, buf: [*]f32, frames: i64) !void {
}
}
fn sseek(file: *c.SNDFILE, offset: usize) !void {
fn sseek(file: *c.SNDFILE, offset: usize) void {
const frames = c.sf_seek(file, @intCast(i64, offset), c.SEEK_SET);
if (frames != @intCast(i64, offset)) {
std.debug.warn("failed to seek to {}\n", offset);
return error.SeekFail;
}
}
@ -187,8 +185,8 @@ pub const Image = struct {
// we do sf_seek() calls to make sure we are actually on the start
// and actually end at the end position for the file.
try sseek(self.sndfile, start);
try sseek(out_file, start);
sseek(self.sndfile, start);
sseek(out_file, start);
while (i <= end) : (i += buf.len) {
std.debug.warn("i={}, buf.len={}, end={}\n", i, buf.len, end);
@ -212,8 +210,8 @@ pub const Image = struct {
try swrite(out_file, view.ptr, @intCast(i64, view.len));
}
try sseek(self.sndfile, end);
try sseek(out_file, end);
sseek(self.sndfile, end);
sseek(out_file, end);
}
fn getSeekPos(self: *Image, position: plugins.Position) plugins.SeekPos {
@ -304,7 +302,7 @@ pub const Image = struct {
seek_pos.start,
);
try sseek(self.sndfile, seek_pos.start);
sseek(self.sndfile, seek_pos.start);
var i: usize = seek_pos.start;
std.debug.warn("\tseek pos start: {} end: {}\n", seek_pos.start, seek_pos.end);
@ -323,7 +321,7 @@ pub const Image = struct {
try swrite(out_file, outbuf.ptr, 1);
}
try sseek(self.sndfile, seek_pos.end);
sseek(self.sndfile, seek_pos.end);
// post-plugin copy
try self.copyBytes(
@ -368,7 +366,7 @@ pub const Image = struct {
const seek_pos = self.getSeekPos(position);
// make sure we start from 0
try sseek(self.sndfile, 0);
sseek(self.sndfile, 0);
// there are four main stages:
// - the bmp header copy
@ -383,7 +381,7 @@ pub const Image = struct {
seek_pos.start,
);
try sseek(self.sndfile, seek_pos.start);
sseek(self.sndfile, seek_pos.start);
var i: usize = seek_pos.start;
std.debug.warn("\tseek pos start: {} end: {}\n", seek_pos.start, seek_pos.end);
@ -402,7 +400,7 @@ pub const Image = struct {
try swrite(out_file, bufs.out.ptr, 1);
}
try sseek(self.sndfile, seek_pos.end);
sseek(self.sndfile, seek_pos.end);
// post-plugin copy
try self.copyBytes(