2009-03-01 23:56:19 +03:00
|
|
|
/*
|
2009-08-28 18:39:55 +04:00
|
|
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
2009-03-01 23:56:19 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _SOUND_H
|
2002-07-09 16:24:59 +04:00
|
|
|
#define _SOUND_H
|
|
|
|
|
2009-08-28 18:39:55 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <MediaDefs.h>
|
|
|
|
|
2009-03-01 23:56:19 +03:00
|
|
|
class BFile;
|
2007-10-16 02:35:52 +04:00
|
|
|
class BSoundPlayer;
|
2007-10-16 00:13:55 +04:00
|
|
|
struct entry_ref;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
class BTrackReader;
|
2009-03-01 23:56:19 +03:00
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-28 18:39:55 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BSound {
|
|
|
|
public:
|
2009-08-28 18:39:55 +04:00
|
|
|
BSound(void* data, size_t size,
|
|
|
|
const media_raw_audio_format& format,
|
2009-03-01 23:56:19 +03:00
|
|
|
bool freeWhenDone = false);
|
2009-08-28 18:39:55 +04:00
|
|
|
BSound(const entry_ref* soundFile,
|
2009-03-01 23:56:19 +03:00
|
|
|
bool loadIntoMemory = false);
|
|
|
|
|
2009-08-28 18:39:55 +04:00
|
|
|
status_t InitCheck();
|
|
|
|
BSound* AcquireRef();
|
|
|
|
bool ReleaseRef();
|
|
|
|
int32 RefCount() const; // unreliable!
|
2009-03-01 23:56:19 +03:00
|
|
|
|
2009-08-28 18:39:55 +04:00
|
|
|
virtual bigtime_t Duration() const;
|
|
|
|
virtual const media_raw_audio_format &Format() const;
|
|
|
|
virtual const void* Data() const; // returns NULL for files
|
|
|
|
virtual off_t Size() const;
|
2009-03-01 23:56:19 +03:00
|
|
|
|
2009-08-28 18:39:55 +04:00
|
|
|
virtual bool GetDataAt(off_t offset,
|
|
|
|
void* intoBuffer, size_t bufferSize,
|
|
|
|
size_t* outUsed);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
protected:
|
2009-08-28 18:39:55 +04:00
|
|
|
BSound(const media_raw_audio_format& format);
|
|
|
|
virtual status_t Perform(int32 code, ...);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2009-08-28 18:39:55 +04:00
|
|
|
friend class DummyFriend;
|
|
|
|
virtual ~BSound();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
public:
|
2009-08-28 18:39:55 +04:00
|
|
|
virtual status_t BindTo(BSoundPlayer* player,
|
|
|
|
const media_raw_audio_format& format);
|
|
|
|
virtual status_t UnbindFrom(BSoundPlayer* player);
|
|
|
|
|
|
|
|
private:
|
|
|
|
status_t _Reserved_Sound_0(void*); // BindTo
|
|
|
|
status_t _Reserved_Sound_1(void*); // UnbindFrom
|
|
|
|
virtual status_t _Reserved_Sound_2(void*);
|
|
|
|
virtual status_t _Reserved_Sound_3(void*);
|
|
|
|
virtual status_t _Reserved_Sound_4(void*);
|
|
|
|
virtual status_t _Reserved_Sound_5(void*);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2009-08-28 18:39:55 +04:00
|
|
|
void* fData;
|
|
|
|
size_t fDataSize;
|
|
|
|
BFile* fFile;
|
|
|
|
int32 fRefCount;
|
|
|
|
status_t fStatus;
|
|
|
|
media_raw_audio_format fFormat;
|
|
|
|
|
|
|
|
bool fFreeWhenDone;
|
|
|
|
bool fReserved[3];
|
|
|
|
|
|
|
|
BPrivate::BTrackReader* fTrackReader;
|
|
|
|
uint32 fReserved2[18];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2009-08-28 18:39:55 +04:00
|
|
|
#endif // _SOUND_H
|