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