1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_ChannelManager.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_CHANNEL_MANAGER_H_
17 #define NW_SND_CHANNEL_MANAGER_H_
18 
19 #include <nw/snd/snd_Channel.h>
20 #include <nw/snd/snd_InstancePool.h>
21 #include <nw/ut/ut_LinkList.h>
22 
23 namespace nw {
24 namespace snd {
25 namespace internal {
26 namespace driver {
27 
28 class ChannelManager
29 {
30   public:
31     static ChannelManager& GetInstance();
32 
33     size_t GetRequiredMemSize( int channelCount );
34     void Initialize( void* mem, unsigned long memSize );
35     void Finalize();
36     Channel* Alloc();
37     void Free( Channel* channel );
38 
39     void UpdateAllChannel();
40 
41   private:
42     typedef InstancePool<Channel> ChannelPool;
43     typedef ut::LinkList< Channel, offsetof(Channel,m_Link)> ChannelList;
44 
45     ChannelManager();
46 
47     ChannelPool m_Pool;
48     ChannelList m_ChannelList;
49     bool m_IsInitialized;
50     unsigned long m_ChannelCount;
51     void* m_pMem;
52     unsigned long m_MemSize;
53 };
54 
55 } // namespace nw::snd::driver
56 } // namespace nw::snd::internal
57 } // namespace nw::snd
58 } // namespace nw
59 
60 
61 #endif /* NW_SND_CHANNEL_MANAGER_H_ */
62 
63