예제 #1
0
static int
set_pos_rel_callback(void *id, int32_t delta, int mode)
{
	assert(nullptr != id);
	
	WavPackDecoder *decoder = static_cast<WavPackDecoder *>(id);
	InputSource *inputSource = decoder->GetInputSource();

	if(!inputSource->SupportsSeeking())
		return -1;
	
	// Adjust offset as required
	SInt64 offset = delta;
	switch(mode) {
		case SEEK_SET:
			// offset remains unchanged
			break;
		case SEEK_CUR:
			offset += inputSource->GetOffset();
			break;
		case SEEK_END:
			offset += inputSource->GetLength();
			break;
	}
	
	return (!inputSource->SeekToOffset(offset));
}
예제 #2
0
// FIXME: How does one emulate ungetc when the data is non-seekable?
static int
push_back_byte_callback(void *id, int c)
{
	assert(nullptr != id);
	
	WavPackDecoder *decoder = static_cast<WavPackDecoder *>(id);
	InputSource *inputSource = decoder->GetInputSource();
	
	if(!inputSource->SupportsSeeking())
		return EOF;
	
	if(!inputSource->SeekToOffset(inputSource->GetOffset() - 1))
		return EOF;
	
	return c;
}