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