xref: /haiku/src/kits/game/GameSoundDevice.h (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
14703fb5dSbeveloper //------------------------------------------------------------------------------
2*2ca13760SColdfirex //	Copyright (c) 2001-2002, Haiku
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 
39e7d2f0f0SStefano 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,
540cc21580SAdrien Destugues 										const gs_audio_format * format,
550cc21580SAdrien Destugues 										size_t inBufferFrameCount = 0,
560cc21580SAdrien Destugues 										size_t inBufferCount = 0);
574703fb5dSbeveloper 	virtual void					ReleaseBuffer(gs_id sound);
584703fb5dSbeveloper 
594703fb5dSbeveloper 	virtual status_t				Buffer(gs_id sound,
604703fb5dSbeveloper 										gs_audio_format * format,
61e7d2f0f0SStefano Ceccherini 										void *& data);
624703fb5dSbeveloper 
634703fb5dSbeveloper 	virtual	bool					IsPlaying(gs_id sound);
644703fb5dSbeveloper 	virtual	status_t				StartPlaying(gs_id sound);
654703fb5dSbeveloper 	virtual status_t				StopPlaying(gs_id sound);
664703fb5dSbeveloper 
674703fb5dSbeveloper 	virtual	status_t				GetAttributes(gs_id sound,
684703fb5dSbeveloper 										gs_attribute * attributes,
694703fb5dSbeveloper 										size_t attributeCount);
704703fb5dSbeveloper 	virtual status_t				SetAttributes(gs_id sound,
714703fb5dSbeveloper 										gs_attribute * attributes,
724703fb5dSbeveloper 										size_t attributeCount);
734703fb5dSbeveloper 
744703fb5dSbeveloper protected:
754703fb5dSbeveloper 			void					SetInitError(status_t error);
764703fb5dSbeveloper 
774703fb5dSbeveloper 			gs_audio_format			fFormat;
780cc21580SAdrien Destugues 
794703fb5dSbeveloper private:
804703fb5dSbeveloper 			int32					AllocateSound();
814703fb5dSbeveloper 
824703fb5dSbeveloper 			status_t				fInitError;
834703fb5dSbeveloper 
844703fb5dSbeveloper 			bool					fIsConnected;
854703fb5dSbeveloper 
864703fb5dSbeveloper 			int32					fSoundCount;
874703fb5dSbeveloper 			GameSoundBuffer **		fSounds;
884703fb5dSbeveloper };
894703fb5dSbeveloper 
904703fb5dSbeveloper BGameSoundDevice* 	GetDefaultDevice();
914703fb5dSbeveloper void				ReleaseDevice();
924703fb5dSbeveloper 
934703fb5dSbeveloper #endif
94