1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_StreamBufferPool.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 19566 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_STREAM_BUFFER_POOL_H_ 17 #define NW_SND_STREAM_BUFFER_POOL_H_ 18 19 namespace nw { 20 namespace snd { 21 namespace internal { 22 namespace driver { 23 24 class StreamBufferPool 25 { 26 public: 27 void Initialize( void* pBuffer, size_t size, int blockCount ); 28 void Finalize(); 29 30 void* Alloc(); 31 void Free( void* pPtr ); 32 GetBlockSize()33 size_t GetBlockSize() const { return m_BlockSize; } 34 35 private: 36 static const int BLOCK_MAX = 32; // 8の倍数 37 static const int BIT_PER_BYTE = 8; 38 39 void* m_pBuffer; //< バッファのアドレス 40 size_t m_BufferSize; //< バッファの全体サイズ 41 size_t m_BlockSize; //< 1 ブロックあたりのバイト数 42 // (バッファは m_BlockCount 個のブロックに分けて管理される) 43 int m_BlockCount; //< ブロック数 (最大ストリームチャンネル数と同じ数になる) 44 int m_AllocCount; //< ブロックの確保数 45 u8 m_AllocFlags[ BLOCK_MAX / BIT_PER_BYTE ]; 46 }; 47 48 } // namespace nw::snd::internal::driver 49 } // namespace nw::snd::internal 50 } // namespace nw::snd 51 } // namespace nw 52 53 54 #endif /* NW_SND_STREAM_BUFFER_POOL_H_ */ 55 56