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