xref: /haiku/headers/os/game/PushGameSound.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  *  Copyright 2020, Haiku, Inc. All Rights Reserved.
3  *  Distributed under the terms of the MIT License.
4  */
5 #ifndef _PUSHGAMESOUND_H
6 #define _PUSHGAMESOUND_H
7 
8 
9 #include <StreamingGameSound.h>
10 
11 
12 class BList;
13 
14 class BPushGameSound : public BStreamingGameSound {
15 public:
16 						BPushGameSound(size_t inBufferFrameCount,
17 							const gs_audio_format* format,
18 							size_t inBufferCount = 2,
19 							BGameSoundDevice* device = NULL);
20 	virtual				~BPushGameSound();
21 
22 	enum lock_status {
23 		lock_failed = -1,
24 		lock_ok = 0,
25 		lock_ok_frames_dropped
26 	};
27 
28 	virtual	lock_status	LockNextPage(void** _pagePtr, size_t* _pageSize);
29 	virtual	status_t	UnlockPage(void* pagePtr);
30 
31 	virtual	lock_status	LockForCyclic(void** _basePtr, size_t* _size);
32 	virtual	status_t	UnlockCyclic();
33 	virtual	size_t		CurrentPosition();
34 
35 	virtual	BGameSound*	Clone() const;
36 
37 	virtual	status_t	Perform(int32 selector, void* data);
38 
39 protected:
40 						BPushGameSound(BGameSoundDevice* device);
41 
42 	virtual	status_t	SetParameters(size_t bufferFrameCount,
43 							const gs_audio_format* format, size_t bufferCount);
44 
45 	virtual	status_t	SetStreamHook(void (*hook)(void* inCookie,
46 								void* buffer, size_t byteCount,
47 								BStreamingGameSound* me),
48 							void* cookie);
49 
50 	virtual	void		FillBuffer(void* buffer, size_t byteCount);
51 
52 private:
53 						BPushGameSound();
54 						BPushGameSound(const BPushGameSound& other);
55 	BPushGameSound&		operator=(const BPushGameSound& other);
56 
57 			bool		BytesReady(size_t* bytes);
58 
59 	virtual	status_t	_Reserved_BPushGameSound_0(int32 arg, ...);
60 	virtual	status_t	_Reserved_BPushGameSound_1(int32 arg, ...);
61 	virtual	status_t	_Reserved_BPushGameSound_2(int32 arg, ...);
62 	virtual	status_t	_Reserved_BPushGameSound_3(int32 arg, ...);
63 	virtual	status_t	_Reserved_BPushGameSound_4(int32 arg, ...);
64 	virtual	status_t	_Reserved_BPushGameSound_5(int32 arg, ...);
65 	virtual	status_t	_Reserved_BPushGameSound_6(int32 arg, ...);
66 	virtual	status_t	_Reserved_BPushGameSound_7(int32 arg, ...);
67 	virtual	status_t	_Reserved_BPushGameSound_8(int32 arg, ...);
68 	virtual	status_t	_Reserved_BPushGameSound_9(int32 arg, ...);
69 	virtual	status_t	_Reserved_BPushGameSound_10(int32 arg, ...);
70 	virtual	status_t	_Reserved_BPushGameSound_11(int32 arg, ...);
71 	virtual	status_t	_Reserved_BPushGameSound_12(int32 arg, ...);
72 	virtual	status_t	_Reserved_BPushGameSound_13(int32 arg, ...);
73 	virtual	status_t	_Reserved_BPushGameSound_14(int32 arg, ...);
74 	virtual	status_t	_Reserved_BPushGameSound_15(int32 arg, ...);
75 	virtual	status_t	_Reserved_BPushGameSound_16(int32 arg, ...);
76 	virtual	status_t	_Reserved_BPushGameSound_17(int32 arg, ...);
77 	virtual	status_t	_Reserved_BPushGameSound_18(int32 arg, ...);
78 	virtual	status_t	_Reserved_BPushGameSound_19(int32 arg, ...);
79 	virtual	status_t	_Reserved_BPushGameSound_20(int32 arg, ...);
80 	virtual	status_t	_Reserved_BPushGameSound_21(int32 arg, ...);
81 	virtual	status_t	_Reserved_BPushGameSound_22(int32 arg, ...);
82 	virtual	status_t	_Reserved_BPushGameSound_23(int32 arg, ...);
83 
84 private:
85 			sem_id		fLock;
86 			BList*		fPageLocked;
87 			size_t		fLockPos;
88 
89 			size_t		fPlayPos;
90 			char*		fBuffer;
91 
92 			size_t		fPageSize;
93 			int32		fPageCount;
94 			size_t		fBufferSize;
95 
96 			uint32		_reserved[12];
97 };
98 
99 #endif