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