1//------------------------------------------------------------------------------ 2// Copyright (c) 2001-2002, Haiku 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#include <GameSoundDefs.h> 33 34 35class BMediaNode; 36class GameSoundBuffer; 37struct Connection; 38 39class BGameSoundDevice { 40public: 41 BGameSoundDevice(); 42 virtual ~BGameSoundDevice(); 43 44 status_t InitCheck() const; 45 virtual const gs_audio_format & Format() const; 46 virtual const gs_audio_format & Format(gs_id sound) const; 47 48 virtual status_t CreateBuffer(gs_id * sound, 49 const gs_audio_format * format, 50 const void * data, 51 int64 frames); 52 virtual status_t CreateBuffer(gs_id * sound, 53 const void * object, 54 const gs_audio_format * format, 55 size_t inBufferFrameCount = 0, 56 size_t inBufferCount = 0); 57 virtual void ReleaseBuffer(gs_id sound); 58 59 virtual status_t Buffer(gs_id sound, 60 gs_audio_format * format, 61 void *& data); 62 63 virtual bool IsPlaying(gs_id sound); 64 virtual status_t StartPlaying(gs_id sound); 65 virtual status_t StopPlaying(gs_id sound); 66 67 virtual status_t GetAttributes(gs_id sound, 68 gs_attribute * attributes, 69 size_t attributeCount); 70 virtual status_t SetAttributes(gs_id sound, 71 gs_attribute * attributes, 72 size_t attributeCount); 73 74protected: 75 void SetInitError(status_t error); 76 77 gs_audio_format fFormat; 78 79private: 80 int32 AllocateSound(); 81 82 status_t fInitError; 83 84 bool fIsConnected; 85 86 int32 fSoundCount; 87 GameSoundBuffer ** fSounds; 88}; 89 90BGameSoundDevice* GetDefaultDevice(); 91void ReleaseDevice(); 92 93#endif 94