blob: 2db3fa1dd4d07cdb30e157d3c2617470af0b68de (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#pragma once
#include "foundation/dispatch.h"
#include "nx/nxuri.h"
#include "metadata/ifc_metadata.h"
/* this is the class you actually use */
class ifc_audio_decoder_callback : public Wasabi2::Dispatchable
{
protected:
ifc_audio_decoder_callback() : Dispatchable(DISPATCHABLE_VERSION) {}
~ifc_audio_decoder_callback() {}
public:
/* you must implement this class to use the decoder */
class callback : public Wasabi2::Dispatchable
{
protected:
callback() : Dispatchable(DISPATCHABLE_VERSION) {}
~callback() {}
public:
/* frames is defined as all channels, e.g. 16bit stereo is 4 bytes per frame (2 bytes per sample)
return NErr_Success to continue receiving callbacks
*/
int OnAudio(const void *buffer, size_t buffer_frames) { return AudioDecoderCallback_OnAudio(buffer, buffer_frames); }
enum
{
DISPATCHABLE_VERSION=0,
};
private:
virtual int WASABICALL AudioDecoderCallback_OnAudio(const void *buffer, size_t buffer_frames)=0;
};
/* if possible, returns an upper bound on the number of frames used internally. this would be the maximum buffer_frames value you receive in a callback */
int GetFrameSize(size_t *frame_size) { return AudioDecoderCallback_GetFrameSize(frame_size); }
int GetMetadata(ifc_metadata **metadata) { return AudioDecoderCallback_GetMetadata(metadata); }
/* returns
* NErr_Success on a successfully completed decode
* NErr_Interrupted if the callback function aborted decoding
* anything else indicates a decoding error
*/
int Decode(ifc_audio_decoder_callback::callback *callback) { return AudioDecoderCallback_Decode(callback); }
/* Like decode, but only processes one frame.
returns NErr_EndOfFile on the last frame */
int DecodeStep(ifc_audio_decoder_callback::callback *callback) { return AudioDecoderCallback_DecodeStep(callback); }
enum
{
DISPATCHABLE_VERSION=0,
};
private:
virtual int WASABICALL AudioDecoderCallback_Decode(ifc_audio_decoder_callback::callback *callback)=0;
virtual int WASABICALL AudioDecoderCallback_DecodeStep(ifc_audio_decoder_callback::callback *callback)=0;
virtual int WASABICALL AudioDecoderCallback_GetFrameSize(size_t *frame_size)=0;
virtual int WASABICALL AudioDecoderCallback_GetMetadata(ifc_metadata **metadata)=0;
};
|