xref: /haiku/headers/os/game/FileGameSound.h (revision f6e4cbb95290a74b33d012600438b84742b0e572)
14703fb5dSbeveloper //------------------------------------------------------------------------------
24703fb5dSbeveloper //	Copyright (c) 2001-2002, OpenBeOS
34703fb5dSbeveloper //
44703fb5dSbeveloper //	Permission is hereby granted, free of charge, to any person obtaining a
54703fb5dSbeveloper //	copy of this software and associated documentation files (the "Software"),
64703fb5dSbeveloper //	to deal in the Software without restriction, including without limitation
74703fb5dSbeveloper //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
84703fb5dSbeveloper //	and/or sell copies of the Software, and to permit persons to whom the
94703fb5dSbeveloper //	Software is furnished to do so, subject to the following conditions:
104703fb5dSbeveloper //
114703fb5dSbeveloper //	The above copyright notice and this permission notice shall be included in
124703fb5dSbeveloper //	all copies or substantial portions of the Software.
134703fb5dSbeveloper //
144703fb5dSbeveloper //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154703fb5dSbeveloper //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164703fb5dSbeveloper //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
174703fb5dSbeveloper //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
184703fb5dSbeveloper //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
194703fb5dSbeveloper //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
204703fb5dSbeveloper //	DEALINGS IN THE SOFTWARE.
214703fb5dSbeveloper //
224703fb5dSbeveloper //	File Name:		FileGameSound.h
234703fb5dSbeveloper //	Author:			Christopher ML Zumwalt May (zummy@users.sf.net)
244703fb5dSbeveloper //	Description:	BFileGameSound is a class that streams data out of a file.
254703fb5dSbeveloper //------------------------------------------------------------------------------
264703fb5dSbeveloper #ifndef _FILEGAMESOUND_H
274703fb5dSbeveloper #define _FILEGAMESOUND_H
284c2bc7e8Sbeveloper 
294703fb5dSbeveloper 
304c2bc7e8Sbeveloper #include <StreamingGameSound.h>
314c2bc7e8Sbeveloper 
32*f6e4cbb9SAxel Dörfler struct entry_ref;
334703fb5dSbeveloper struct _gs_media_tracker;
344703fb5dSbeveloper struct _gs_ramp;
354703fb5dSbeveloper 
36*f6e4cbb9SAxel Dörfler 
37*f6e4cbb9SAxel Dörfler class BFileGameSound : public BStreamingGameSound {
384c2bc7e8Sbeveloper public:
394703fb5dSbeveloper 							BFileGameSound(const entry_ref * file,
404c2bc7e8Sbeveloper 											bool looping = true,
414c2bc7e8Sbeveloper 											BGameSoundDevice * device = NULL);
424703fb5dSbeveloper 							BFileGameSound(const char * file,
434c2bc7e8Sbeveloper 											bool looping = true,
444c2bc7e8Sbeveloper 											BGameSoundDevice * device = NULL);
454c2bc7e8Sbeveloper 
464c2bc7e8Sbeveloper 	virtual					~BFileGameSound();
474c2bc7e8Sbeveloper 
484c2bc7e8Sbeveloper 	virtual	BGameSound *	Clone() const;
494c2bc7e8Sbeveloper 
504c2bc7e8Sbeveloper 	virtual	status_t		StartPlaying();
514c2bc7e8Sbeveloper 	virtual	status_t		StopPlaying();
524c2bc7e8Sbeveloper 			status_t		Preload();		//	if you have stopped and want to start quickly again
534c2bc7e8Sbeveloper 
544703fb5dSbeveloper 	virtual	void			FillBuffer(void * inBuffer,
554c2bc7e8Sbeveloper 										size_t inByteCount);
564c2bc7e8Sbeveloper 	virtual	status_t 		Perform(int32 selector, void * data);
574703fb5dSbeveloper 	virtual	status_t		SetPaused(bool isPaused,
584c2bc7e8Sbeveloper 										bigtime_t rampTime);
594c2bc7e8Sbeveloper 			enum {
604c2bc7e8Sbeveloper 				B_NOT_PAUSED,
614c2bc7e8Sbeveloper 				B_PAUSE_IN_PROGRESS,
624c2bc7e8Sbeveloper 				B_PAUSED
634c2bc7e8Sbeveloper 			};
644c2bc7e8Sbeveloper 			int32			IsPaused();
654c2bc7e8Sbeveloper 
664c2bc7e8Sbeveloper private:
674703fb5dSbeveloper 			_gs_media_tracker *	fAudioStream;
684c2bc7e8Sbeveloper 
694703fb5dSbeveloper 			bool				fStopping;
704703fb5dSbeveloper 			bool				fLooping;
714703fb5dSbeveloper 			char				fReserved;
724703fb5dSbeveloper 			char *				fBuffer;
734c2bc7e8Sbeveloper 
744703fb5dSbeveloper 			size_t				fFrameSize;
754703fb5dSbeveloper 			size_t				fBufferSize;
764703fb5dSbeveloper 			size_t				fPlayPosition;
774703fb5dSbeveloper 
784703fb5dSbeveloper 			thread_id			fReadThread;
794703fb5dSbeveloper 			port_id				fPort;
804703fb5dSbeveloper 
814703fb5dSbeveloper 			_gs_ramp *			fPausing;
824703fb5dSbeveloper 			bool				fPaused;
834703fb5dSbeveloper 			float				fPauseGain;
844703fb5dSbeveloper 
854703fb5dSbeveloper 			status_t			Init(const entry_ref* file);
864703fb5dSbeveloper 
874703fb5dSbeveloper 			bool				Load();
884703fb5dSbeveloper 			bool				Read(void * buffer, size_t bytes);
894c2bc7e8Sbeveloper 
904c2bc7e8Sbeveloper 	/* leave these declarations private unless you plan on actually implementing and using them. */
914c2bc7e8Sbeveloper 	BFileGameSound();
924c2bc7e8Sbeveloper 	BFileGameSound(const BFileGameSound&);
934c2bc7e8Sbeveloper 	BFileGameSound& operator=(const BFileGameSound&);
944c2bc7e8Sbeveloper 
954c2bc7e8Sbeveloper 	/* fbc data and virtuals */
964c2bc7e8Sbeveloper 
974703fb5dSbeveloper 	uint32 _reserved_BFileGameSound_[9];
984c2bc7e8Sbeveloper 
994c2bc7e8Sbeveloper 		status_t _Reserved_BFileGameSound_0(int32 arg, ...);	/* SetPaused(bool paused, bigtime_t ramp); */
1004c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_1(int32 arg, ...);
1014c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_2(int32 arg, ...);
1024c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_3(int32 arg, ...);
1034c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_4(int32 arg, ...);
1044c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_5(int32 arg, ...);
1054c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_6(int32 arg, ...);
1064c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_7(int32 arg, ...);
1074c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_8(int32 arg, ...);
1084c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_9(int32 arg, ...);
1094c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_10(int32 arg, ...);
1104c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_11(int32 arg, ...);
1114c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_12(int32 arg, ...);
1124c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_13(int32 arg, ...);
1134c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_14(int32 arg, ...);
1144c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_15(int32 arg, ...);
1154c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_16(int32 arg, ...);
1164c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_17(int32 arg, ...);
1174c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_18(int32 arg, ...);
1184c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_19(int32 arg, ...);
1194c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_20(int32 arg, ...);
1204c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_21(int32 arg, ...);
1214c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_22(int32 arg, ...);
1224c2bc7e8Sbeveloper virtual	status_t _Reserved_BFileGameSound_23(int32 arg, ...);
1234c2bc7e8Sbeveloper };
1244c2bc7e8Sbeveloper 
125*f6e4cbb9SAxel Dörfler #endif	// _FILEGAMESOUND_H
126