1/*
2 * Copyright 2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _SOUND_H
6#define _SOUND_H
7
8
9#include <MediaDefs.h>
10
11class BFile;
12class BSoundPlayer;
13struct entry_ref;
14
15namespace BPrivate {
16	class BTrackReader;
17};
18
19
20class BSound {
21public:
22								BSound(void* data, size_t size,
23									const media_raw_audio_format& format,
24									bool freeWhenDone = false);
25								BSound(const entry_ref* soundFile,
26									bool loadIntoMemory = false);
27
28			status_t			InitCheck();
29			BSound* 			AcquireRef();
30			bool				ReleaseRef();
31			int32				RefCount() const; // unreliable!
32
33	virtual	bigtime_t			Duration() const;
34	virtual	const media_raw_audio_format &Format() const;
35	virtual	const void*			Data() const; // returns NULL for files
36	virtual	off_t				Size() const;
37
38	virtual	bool				GetDataAt(off_t offset,
39									void* intoBuffer, size_t bufferSize,
40									size_t* outUsed);
41
42protected:
43								BSound(const media_raw_audio_format& format);
44	virtual	status_t			Perform(int32 code, ...);
45
46private:
47			friend	class DummyFriend;
48	virtual						~BSound();
49
50public:
51	virtual	status_t			BindTo(BSoundPlayer* player,
52									const media_raw_audio_format& format);
53	virtual	status_t			UnbindFrom(BSoundPlayer* player);
54
55private:
56			status_t			_Reserved_Sound_0(void*);	// BindTo
57			status_t			_Reserved_Sound_1(void*);	// UnbindFrom
58	virtual	status_t			_Reserved_Sound_2(void*);
59	virtual	status_t			_Reserved_Sound_3(void*);
60	virtual	status_t			_Reserved_Sound_4(void*);
61	virtual	status_t			_Reserved_Sound_5(void*);
62
63private:
64			void*				fData;
65			size_t				fDataSize;
66			BFile*				fFile;
67			int32				fRefCount;
68			status_t			fStatus;
69			media_raw_audio_format fFormat;
70
71			bool				fFreeWhenDone;
72			bool				fReserved[3];
73
74			BPrivate::BTrackReader* fTrackReader;
75			uint32				fReserved2[18];
76};
77
78#endif // _SOUND_H
79