11b921108SMichael Lotz /* 2*cb3f273dSStephan Aßmus * Copyright 2009, Haiku, Inc. All rights reserved. 31b921108SMichael Lotz * Distributed under the terms of the MIT License. 41b921108SMichael Lotz */ 51b921108SMichael Lotz #ifndef _SOUND_H 652a38012Sejakowatz #define _SOUND_H 752a38012Sejakowatz 8*cb3f273dSStephan Aßmus 952a38012Sejakowatz #include <MediaDefs.h> 1052a38012Sejakowatz 111b921108SMichael Lotz class BFile; 12f2e230caSJérôme Duval class BSoundPlayer; 13f6e4cbb9SAxel Dörfler struct entry_ref; 1452a38012Sejakowatz 1552a38012Sejakowatz namespace BPrivate { 1652a38012Sejakowatz class BTrackReader; 171b921108SMichael Lotz }; 1852a38012Sejakowatz 19*cb3f273dSStephan Aßmus 2052a38012Sejakowatz class BSound { 2152a38012Sejakowatz public: 221b921108SMichael Lotz BSound(void* data, size_t size, 2352a38012Sejakowatz const media_raw_audio_format& format, 241b921108SMichael Lotz bool freeWhenDone = false); 251b921108SMichael Lotz BSound(const entry_ref* soundFile, 261b921108SMichael Lotz bool loadIntoMemory = false); 2752a38012Sejakowatz 2852a38012Sejakowatz status_t InitCheck(); 2952a38012Sejakowatz BSound* AcquireRef(); 3052a38012Sejakowatz bool ReleaseRef(); 3152a38012Sejakowatz int32 RefCount() const; // unreliable! 3252a38012Sejakowatz 3352a38012Sejakowatz virtual bigtime_t Duration() const; 3452a38012Sejakowatz virtual const media_raw_audio_format &Format() const; 351b921108SMichael Lotz virtual const void* Data() const; // returns NULL for files 3652a38012Sejakowatz virtual off_t Size() const; 3752a38012Sejakowatz 381b921108SMichael Lotz virtual bool GetDataAt(off_t offset, 391b921108SMichael Lotz void* intoBuffer, size_t bufferSize, 401b921108SMichael Lotz size_t* outUsed); 4152a38012Sejakowatz 4252a38012Sejakowatz protected: 431b921108SMichael Lotz BSound(const media_raw_audio_format& format); 441b921108SMichael Lotz virtual status_t Perform(int32 code, ...); 4552a38012Sejakowatz 4652a38012Sejakowatz private: 471b921108SMichael Lotz friend class DummyFriend; 4852a38012Sejakowatz virtual ~BSound(); 4952a38012Sejakowatz 5052a38012Sejakowatz public: 511b921108SMichael Lotz virtual status_t BindTo(BSoundPlayer* player, 5252a38012Sejakowatz const media_raw_audio_format& format); 531b921108SMichael Lotz virtual status_t UnbindFrom(BSoundPlayer* player); 5452a38012Sejakowatz 5552a38012Sejakowatz private: 5652a38012Sejakowatz status_t _Reserved_Sound_0(void*); // BindTo 5752a38012Sejakowatz status_t _Reserved_Sound_1(void*); // UnbindFrom 5852a38012Sejakowatz virtual status_t _Reserved_Sound_2(void*); 5952a38012Sejakowatz virtual status_t _Reserved_Sound_3(void*); 6052a38012Sejakowatz virtual status_t _Reserved_Sound_4(void*); 6152a38012Sejakowatz virtual status_t _Reserved_Sound_5(void*); 6252a38012Sejakowatz 63*cb3f273dSStephan Aßmus private: 641b921108SMichael Lotz void* fData; 651b921108SMichael Lotz size_t fDataSize; 661b921108SMichael Lotz BFile* fFile; 671b921108SMichael Lotz int32 fRefCount; 681b921108SMichael Lotz status_t fStatus; 691b921108SMichael Lotz media_raw_audio_format fFormat; 7052a38012Sejakowatz 711b921108SMichael Lotz bool fFreeWhenDone; 721b921108SMichael Lotz bool fReserved[3]; 7352a38012Sejakowatz 741b921108SMichael Lotz BPrivate::BTrackReader* fTrackReader; 751b921108SMichael Lotz uint32 fReserved2[18]; 7652a38012Sejakowatz }; 7752a38012Sejakowatz 781b921108SMichael Lotz #endif // _SOUND_H 79