1*1b921108SMichael Lotz /* 2*1b921108SMichael Lotz * Copyright 2009, Haiku Inc. All Rights Reserved. 3*1b921108SMichael Lotz * Distributed under the terms of the MIT License. 4*1b921108SMichael Lotz */ 552a38012Sejakowatz 6*1b921108SMichael Lotz #ifndef _SOUND_H 752a38012Sejakowatz #define _SOUND_H 852a38012Sejakowatz 952a38012Sejakowatz #include <MediaDefs.h> 1052a38012Sejakowatz 11*1b921108SMichael Lotz class BFile; 12f2e230caSJérôme Duval class BSoundPlayer; 13f6e4cbb9SAxel Dörfler struct entry_ref; 1452a38012Sejakowatz 1552a38012Sejakowatz namespace BPrivate { 1652a38012Sejakowatz class BTrackReader; 17*1b921108SMichael Lotz }; 1852a38012Sejakowatz 1952a38012Sejakowatz class BSound { 2052a38012Sejakowatz public: 21*1b921108SMichael Lotz BSound(void *data, size_t size, 2252a38012Sejakowatz const media_raw_audio_format &format, 23*1b921108SMichael Lotz bool freeWhenDone = false); 24*1b921108SMichael Lotz BSound(const entry_ref *soundFile, 25*1b921108SMichael Lotz bool loadIntoMemory = false); 2652a38012Sejakowatz 2752a38012Sejakowatz status_t InitCheck(); 2852a38012Sejakowatz BSound * AcquireRef(); 2952a38012Sejakowatz bool ReleaseRef(); 3052a38012Sejakowatz int32 RefCount() const; // unreliable! 3152a38012Sejakowatz 3252a38012Sejakowatz virtual bigtime_t Duration() const; 3352a38012Sejakowatz virtual const media_raw_audio_format &Format() const; 34*1b921108SMichael Lotz virtual const void * Data() const; // returns NULL for files 3552a38012Sejakowatz virtual off_t Size() const; 3652a38012Sejakowatz 37*1b921108SMichael Lotz virtual bool GetDataAt(off_t offset, 38*1b921108SMichael Lotz void *intoBuffer, size_t bufferSize, 39*1b921108SMichael Lotz size_t *outUsed); 4052a38012Sejakowatz 4152a38012Sejakowatz protected: 42*1b921108SMichael Lotz BSound(const media_raw_audio_format &format); 43*1b921108SMichael Lotz virtual status_t Perform(int32 code, ...); 4452a38012Sejakowatz 4552a38012Sejakowatz private: 46*1b921108SMichael Lotz friend class DummyFriend; 4752a38012Sejakowatz virtual ~BSound(); 4852a38012Sejakowatz 4952a38012Sejakowatz public: 50*1b921108SMichael Lotz virtual status_t BindTo(BSoundPlayer *player, 5152a38012Sejakowatz const media_raw_audio_format &format); 52*1b921108SMichael Lotz virtual status_t UnbindFrom(BSoundPlayer *player); 5352a38012Sejakowatz 5452a38012Sejakowatz private: 5552a38012Sejakowatz status_t _Reserved_Sound_0(void *); // BindTo 5652a38012Sejakowatz status_t _Reserved_Sound_1(void *); // UnbindFrom 5752a38012Sejakowatz virtual status_t _Reserved_Sound_2(void *); 5852a38012Sejakowatz virtual status_t _Reserved_Sound_3(void *); 5952a38012Sejakowatz virtual status_t _Reserved_Sound_4(void *); 6052a38012Sejakowatz virtual status_t _Reserved_Sound_5(void *); 6152a38012Sejakowatz 62*1b921108SMichael Lotz void * fData; 63*1b921108SMichael Lotz size_t fDataSize; 64*1b921108SMichael Lotz BFile * fFile; 65*1b921108SMichael Lotz int32 fRefCount; 66*1b921108SMichael Lotz status_t fStatus; 67*1b921108SMichael Lotz media_raw_audio_format fFormat; 6852a38012Sejakowatz 69*1b921108SMichael Lotz bool fFreeWhenDone; 70*1b921108SMichael Lotz bool fReserved[3]; 7152a38012Sejakowatz 72*1b921108SMichael Lotz BPrivate::BTrackReader *fTrackReader; 73*1b921108SMichael Lotz uint32 fReserved2[18]; 7452a38012Sejakowatz }; 7552a38012Sejakowatz 76*1b921108SMichael Lotz #endif // _SOUND_H 77