1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_StreamSoundHandle.cpp
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 #include "precompiled.h"
19 
20 #include <nw/snd/snd_StreamSoundHandle.h>
21 
22 namespace nw {
23 namespace snd {
24 
StreamSoundHandle(SoundHandle * pHandle)25 StreamSoundHandle::StreamSoundHandle( SoundHandle* pHandle )
26 : m_pSound( NULL )
27 {
28     if ( pHandle == NULL ) return;
29 
30     // 汎用ハンドルからサウンドを取得
31     if ( !pHandle->IsAttachedSound() ) return;
32 
33     internal::StreamSound* sound =
34         ut::DynamicCast<internal::StreamSound*>( pHandle->detail_GetAttachedSound() );
35 
36     if ( sound != NULL )
37     {
38         // シーケンスサウンドなら一時ハンドルとしてAttachする
39         detail_AttachSoundAsTempHandle( sound );
40     }
41 }
42 
43 /*---------------------------------------------------------------------------*
44   Name:         detail_AttachSoundAsTempHandle
45 
46   Description:  ハンドルにサウンドを関連付ける
47 
48   Arguments:    sound - 関連付けるサウンド
49 
50   Returns:      None.
51  *---------------------------------------------------------------------------*/
detail_AttachSoundAsTempHandle(internal::StreamSound * pSound)52 void StreamSoundHandle::detail_AttachSoundAsTempHandle( internal::StreamSound* pSound )
53 {
54     NW_NULL_ASSERT( pSound );
55 
56     m_pSound = pSound;
57 
58     // 一時ハンドルとしてAttachする
59     if ( m_pSound->IsAttachedTempSpecialHandle() )
60     {
61         m_pSound->DetachTempSpecialHandle();
62     }
63     m_pSound->m_pTempSpecialHandle = this;
64 }
65 
66 /*---------------------------------------------------------------------------*
67   Name:         DetachSound
68 
69   Description:  ハンドルに結びついているサウンドの関連を外す
70 
71   Arguments:    None.
72 
73   Returns:      None.
74  *---------------------------------------------------------------------------*/
DetachSound()75 void StreamSoundHandle::DetachSound()
76 {
77     if ( IsAttachedSound() )
78     {
79         if ( m_pSound->m_pTempSpecialHandle == this ) m_pSound->m_pTempSpecialHandle = NULL;
80     }
81     if ( m_pSound != NULL ) m_pSound = NULL;
82 }
83 
84 } // namespace nw::snd
85 } // namespace nw
86 
87