1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: GameSoundDevice.h 23 // Author: Christopher ML Zumwalt May (zummy@users.sf.net) 24 // Description: Manages the game producer. The class may change with out 25 // notice and was only inteneded for use by the GameKit at 26 // this time. Use at your own risk. 27 //------------------------------------------------------------------------------ 28 29 #ifndef _GAMESOUNDDEVICE_H 30 #define _GAMESOUNDDEVICE_H 31 32 // Standard Includes ----------------------------------------------------------- 33 34 // System Includes ------------------------------------------------------------- 35 #include <GameSoundDefs.h> 36 37 // Project Includes ------------------------------------------------------------ 38 39 // Local Includes -------------------------------------------------------------- 40 41 // Local Defines --------------------------------------------------------------- 42 43 // Globals --------------------------------------------------------------------- 44 class BMediaNode; 45 class GameSoundBuffer; 46 struct Connection; 47 48 // BGameSoundDevice ------------------------------------------------------------ 49 class BGameSoundDevice 50 { 51 public: 52 BGameSoundDevice(); 53 virtual ~BGameSoundDevice(); 54 55 status_t InitCheck() const; 56 virtual const gs_audio_format & Format() const; 57 virtual const gs_audio_format & Format(gs_id sound) const; 58 59 virtual status_t CreateBuffer(gs_id * sound, 60 const gs_audio_format * format, 61 const void * data, 62 int64 frames); 63 virtual status_t CreateBuffer(gs_id * sound, 64 const void * object, 65 const gs_audio_format * format); 66 virtual void ReleaseBuffer(gs_id sound); 67 68 virtual status_t Buffer(gs_id sound, 69 gs_audio_format * format, 70 void * data); 71 72 virtual bool IsPlaying(gs_id sound); 73 virtual status_t StartPlaying(gs_id sound); 74 virtual status_t StopPlaying(gs_id sound); 75 76 virtual status_t GetAttributes(gs_id sound, 77 gs_attribute * attributes, 78 size_t attributeCount); 79 virtual status_t SetAttributes(gs_id sound, 80 gs_attribute * attributes, 81 size_t attributeCount); 82 83 protected: 84 void SetInitError(status_t error); 85 86 gs_audio_format fFormat; 87 private: 88 status_t Connect(); 89 int32 AllocateSound(); 90 91 status_t fInitError; 92 93 Connection * fConnection; 94 bool fIsConnected; 95 96 int32 fSoundCount; 97 GameSoundBuffer ** fSounds; 98 }; 99 100 BGameSoundDevice* GetDefaultDevice(); 101 void ReleaseDevice(); 102 103 #endif 104