1 /* 2 * Copyright 2009, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _SOUND_H 7 #define _SOUND_H 8 9 #include <MediaDefs.h> 10 11 class BFile; 12 class BSoundPlayer; 13 struct entry_ref; 14 15 namespace BPrivate { 16 class BTrackReader; 17 }; 18 19 class BSound { 20 public: 21 BSound(void *data, size_t size, 22 const media_raw_audio_format &format, 23 bool freeWhenDone = false); 24 BSound(const entry_ref *soundFile, 25 bool loadIntoMemory = false); 26 27 status_t InitCheck(); 28 BSound * AcquireRef(); 29 bool ReleaseRef(); 30 int32 RefCount() const; // unreliable! 31 32 virtual bigtime_t Duration() const; 33 virtual const media_raw_audio_format &Format() const; 34 virtual const void * Data() const; // returns NULL for files 35 virtual off_t Size() const; 36 37 virtual bool GetDataAt(off_t offset, 38 void *intoBuffer, size_t bufferSize, 39 size_t *outUsed); 40 41 protected: 42 BSound(const media_raw_audio_format &format); 43 virtual status_t Perform(int32 code, ...); 44 45 private: 46 friend class DummyFriend; 47 virtual ~BSound(); 48 49 public: 50 virtual status_t BindTo(BSoundPlayer *player, 51 const media_raw_audio_format &format); 52 virtual status_t UnbindFrom(BSoundPlayer *player); 53 54 private: 55 status_t _Reserved_Sound_0(void *); // BindTo 56 status_t _Reserved_Sound_1(void *); // UnbindFrom 57 virtual status_t _Reserved_Sound_2(void *); 58 virtual status_t _Reserved_Sound_3(void *); 59 virtual status_t _Reserved_Sound_4(void *); 60 virtual status_t _Reserved_Sound_5(void *); 61 62 void * fData; 63 size_t fDataSize; 64 BFile * fFile; 65 int32 fRefCount; 66 status_t fStatus; 67 media_raw_audio_format fFormat; 68 69 bool fFreeWhenDone; 70 bool fReserved[3]; 71 72 BPrivate::BTrackReader *fTrackReader; 73 uint32 fReserved2[18]; 74 }; 75 76 #endif // _SOUND_H 77