1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_MmlSequenceTrackAllocator.cpp
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 #include "precompiled.h"
17 
18 #include <nw/snd/snd_MmlSequenceTrackAllocator.h>
19 
20 namespace nw {
21 namespace snd {
22 namespace internal {
23 namespace driver {
24 
25 /* ========================================================================
26         static member function
27    ======================================================================== */
28 
29 
30 /*---------------------------------------------------------------------------*
31   Name:         AllocTrack
32 
33   Description:  トラックを確保します
34 
35   Arguments:    None.
36 
37   Returns:      確保できたときは、トラックID
38                 確保できなかったときは、-1 を返します
39  *---------------------------------------------------------------------------*/
AllocTrack(SequenceSoundPlayer * player)40 SequenceTrack* MmlSequenceTrackAllocator::AllocTrack( SequenceSoundPlayer* player )
41 {
42     MmlSequenceTrack* track = m_TrackPool.Alloc();
43     if ( track != NULL )
44     {
45         track->SetSequenceSoundPlayer( player );
46         track->SetMmlParser( m_pParser );
47     }
48     return track;
49 }
50 
51 /*---------------------------------------------------------------------------*
52   Name:         FreeTrack
53 
54   Description:  トラックを開放します
55 
56   Arguments:    trackID - トラックID
57 
58   Returns:      None.
59  *---------------------------------------------------------------------------*/
FreeTrack(SequenceTrack * track)60 void MmlSequenceTrackAllocator::FreeTrack( SequenceTrack* track )
61 {
62     NW_NULL_ASSERT( track );
63 
64     track->SetSequenceSoundPlayer( NULL );
65 
66     m_TrackPool.Free( reinterpret_cast<MmlSequenceTrack*>( track ) ); // TODO: 気になるキャスト
67 }
68 
Create(void * buffer,unsigned long size)69 unsigned long MmlSequenceTrackAllocator::Create( void* buffer, unsigned long size )
70 {
71     return m_TrackPool.Create( buffer, size );
72 }
73 
Destroy(void * buffer,unsigned long size)74 void MmlSequenceTrackAllocator::Destroy( void* buffer, unsigned long size )
75 {
76     m_TrackPool.Destroy( buffer, size );
77 }
78 
79 } // namespace nw::snd::internal::driver
80 } // namespace nw::snd::internal
81 } // namespace nw::snd
82 } // namespace nw
83 
84