aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_flac/FLACFileCallbacks.h
blob: 7bd2538c402b6fd020dcb0c87966f9476a4c490d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <FLAC/all.h>
#include "nx/nxfile.h"


FLAC__StreamDecoderReadStatus FLAC_NXFile_Read(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
FLAC__StreamDecoderSeekStatus FLAC_NXFile_Seek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
FLAC__StreamDecoderTellStatus FLAC_NXFile_Tell(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
FLAC__StreamDecoderLengthStatus FLAC_NXFile_Length(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
FLAC__bool FLAC_NXFile_EOF(const FLAC__StreamDecoder *decoder, void *client_data);


class FLACClientData
{
public:
	FLACClientData() : object(0) {}
	void SetFile(nx_file_t file) { this->file = file; }
	void SetObject(void *object) { this->object = object; }
	nx_file_t GetFile() { return file; }
	void *GetObject() { return object; }
private:
	nx_file_t file;
	void *object;
};

template <typename _t>
static _t *FLAC_GetObject(void *client_data)
{
	return (_t *)((FLACClientData *)client_data)->GetObject();
}

static nx_file_t FLAC_GetFile(void *client_data)
{
	return ((FLACClientData *)client_data)->GetFile();
}