1/*---------------------------------------------------------------------------*
2  Project:  NintendoWare
3  File:     snd_HardwareChannelManagerAX.cppi
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:$
14 *---------------------------------------------------------------------------*/
15
16namespace nw {
17namespace snd {
18namespace internal {
19namespace driver {
20
21void HardwareChannelManager::OnInitialize()
22{
23    // なにもしない
24}
25
26HardwareChannel* HardwareChannelManager::AllocHardwareChannel(
27    u32 priority,
28    HardwareChannel::HardwareChannelCallback callback,
29    void* callbackData
30)
31{
32    HardwareChannel* pChannel = Alloc();
33    if ( pChannel == NULL ) return NULL;
34
35    AXVPB* vpb = AX_AcquireVoice(
36        priority,
37        HardwareChannel::ChannelCallback,
38        reinterpret_cast<u32>( pChannel )
39    );
40    if ( vpb == NULL )
41    {
42        Free( pChannel );
43        return NULL;
44    }
45
46    pChannel->SetParamBlock( vpb );
47    pChannel->m_Callback = callback;
48    pChannel->m_pCallbackData = callbackData;
49
50    return pChannel;
51}
52
53void HardwareChannelManager::FreeHardwareChannel( HardwareChannel* pChannel )
54{
55    NW_NULL_ASSERT( pChannel );
56
57    if ( pChannel->IsAvailable() )
58    {
59        AX_FreeVoice( pChannel->m_pVpb );
60    }
61    Free( pChannel );
62}
63
64} // namespace nw::snd::internal::driver
65} // namespace nw::snd::internal
66} // namespace nw::snd
67} // namespace nw
68