xref: /haiku/src/kits/game/GameSoundDevice.h (revision e7d2f0f0e8ba899556c14b1d9885b36d3cf7286a)
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:		GameSoundDevice.h
234703fb5dSbeveloper //	Author:			Christopher ML Zumwalt May (zummy@users.sf.net)
244703fb5dSbeveloper //	Description:	Manages the game producer. The class may change with out
254703fb5dSbeveloper //					notice and was only inteneded for use by the GameKit at
264703fb5dSbeveloper //					this time. Use at your own risk.
274703fb5dSbeveloper //------------------------------------------------------------------------------
284703fb5dSbeveloper 
294703fb5dSbeveloper #ifndef _GAMESOUNDDEVICE_H
304703fb5dSbeveloper #define _GAMESOUNDDEVICE_H
314703fb5dSbeveloper 
324703fb5dSbeveloper #include <GameSoundDefs.h>
334703fb5dSbeveloper 
344703fb5dSbeveloper 
354703fb5dSbeveloper class BMediaNode;
364703fb5dSbeveloper class GameSoundBuffer;
374703fb5dSbeveloper struct Connection;
384703fb5dSbeveloper 
39*e7d2f0f0SStefano Ceccherini class BGameSoundDevice {
404703fb5dSbeveloper public:
414703fb5dSbeveloper 								BGameSoundDevice();
424703fb5dSbeveloper 	virtual							~BGameSoundDevice();
434703fb5dSbeveloper 
444703fb5dSbeveloper 			status_t				InitCheck() const;
454703fb5dSbeveloper 	virtual const gs_audio_format &	Format() const;
464703fb5dSbeveloper 	virtual const gs_audio_format &	Format(gs_id sound) const;
474703fb5dSbeveloper 
484703fb5dSbeveloper 	virtual	status_t				CreateBuffer(gs_id * sound,
494703fb5dSbeveloper 												 const gs_audio_format * format,
504703fb5dSbeveloper 												 const void * data,
514703fb5dSbeveloper 												 int64 frames);
524703fb5dSbeveloper 	virtual status_t				CreateBuffer(gs_id * sound,
534703fb5dSbeveloper 												 const void * object,
544703fb5dSbeveloper 												 const gs_audio_format * format);
554703fb5dSbeveloper 	virtual void					ReleaseBuffer(gs_id sound);
564703fb5dSbeveloper 
574703fb5dSbeveloper 	virtual status_t				Buffer(gs_id sound,
584703fb5dSbeveloper 											gs_audio_format * format,
59*e7d2f0f0SStefano Ceccherini 											void *& data);
604703fb5dSbeveloper 
614703fb5dSbeveloper 	virtual	bool					IsPlaying(gs_id sound);
624703fb5dSbeveloper 	virtual	status_t				StartPlaying(gs_id sound);
634703fb5dSbeveloper 	virtual status_t				StopPlaying(gs_id sound);
644703fb5dSbeveloper 
654703fb5dSbeveloper 	virtual	status_t				GetAttributes(gs_id sound,
664703fb5dSbeveloper 												gs_attribute * attributes,
674703fb5dSbeveloper 												size_t attributeCount);
684703fb5dSbeveloper 	virtual status_t				SetAttributes(gs_id sound,
694703fb5dSbeveloper 											  	gs_attribute * attributes,
704703fb5dSbeveloper 											  	size_t attributeCount);
714703fb5dSbeveloper 
724703fb5dSbeveloper protected:
734703fb5dSbeveloper 			void					SetInitError(status_t error);
744703fb5dSbeveloper 
754703fb5dSbeveloper 			gs_audio_format			fFormat;
764703fb5dSbeveloper private:
774703fb5dSbeveloper 			status_t				Connect();
784703fb5dSbeveloper 			int32					AllocateSound();
794703fb5dSbeveloper 
804703fb5dSbeveloper 			status_t				fInitError;
814703fb5dSbeveloper 
824703fb5dSbeveloper 			Connection *			fConnection;
834703fb5dSbeveloper 			bool					fIsConnected;
844703fb5dSbeveloper 
854703fb5dSbeveloper 			int32					fSoundCount;
864703fb5dSbeveloper 			GameSoundBuffer **		fSounds;
874703fb5dSbeveloper };
884703fb5dSbeveloper 
894703fb5dSbeveloper BGameSoundDevice* 	GetDefaultDevice();
904703fb5dSbeveloper void				ReleaseDevice();
914703fb5dSbeveloper 
924703fb5dSbeveloper #endif
93