1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_SoundHandle.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: 23643 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include "precompiled.h" 17 18 #include <nw/snd/snd_SoundHandle.h> 19 20 namespace nw { 21 namespace snd { 22 23 /*---------------------------------------------------------------------------* 24 Name: DuplicateHandle 25 26 Description: 変換コンストラクタ 27 28 Arguments: sound - 関連付けるサウンド 29 30 Returns: None. 31 *---------------------------------------------------------------------------*/ detail_DuplicateHandle(SoundHandle * handle)32void SoundHandle::detail_DuplicateHandle( SoundHandle* handle ) 33 { 34 DetachSound(); 35 36 if ( handle == NULL ) 37 { 38 return; 39 } 40 41 // サウンドを取得 42 if ( handle->IsAttachedSound() == false ) 43 { 44 return; 45 } 46 47 internal::BasicSound* sound = handle->detail_GetAttachedSound(); 48 49 if ( sound != NULL ) 50 { 51 // 一時ハンドルとしてAttachする 52 detail_AttachSoundAsTempHandle( sound ); 53 } 54 } 55 56 /*---------------------------------------------------------------------------* 57 Name: detail_AttachSoundTemp 58 59 Description: ハンドルにサウンドを関連付ける 60 61 Arguments: sound - 関連付けるサウンド 62 63 Returns: None. 64 *---------------------------------------------------------------------------*/ detail_AttachSoundAsTempHandle(internal::BasicSound * sound)65void SoundHandle::detail_AttachSoundAsTempHandle( internal::BasicSound* sound ) 66 { 67 NW_NULL_ASSERT( sound ); 68 69 m_pSound = sound; 70 71 if ( m_pSound->IsAttachedTempGeneralHandle() ) 72 { 73 m_pSound->DetachTempGeneralHandle(); 74 } 75 m_pSound->m_pTempGeneralHandle = this; 76 } 77 78 /*---------------------------------------------------------------------------* 79 Name: detail_AttachSound 80 81 Description: ハンドルにサウンドを関連付ける 82 83 Arguments: sound - 関連付けるサウンド 84 85 Returns: None. 86 *---------------------------------------------------------------------------*/ detail_AttachSound(internal::BasicSound * sound)87void SoundHandle::detail_AttachSound( internal::BasicSound* sound ) 88 { 89 NW_NULL_ASSERT( sound ); 90 91 m_pSound = sound; 92 93 if ( m_pSound->IsAttachedGeneralHandle() ) 94 { 95 m_pSound->DetachGeneralHandle(); 96 } 97 m_pSound->m_pGeneralHandle = this; 98 } 99 100 /*---------------------------------------------------------------------------* 101 Name: DetachSound 102 103 Description: ハンドルに結びついているサウンドの関連を外す 104 105 Arguments: None. 106 107 Returns: None. 108 *---------------------------------------------------------------------------*/ DetachSound()109void SoundHandle::DetachSound() 110 { 111 if ( IsAttachedSound() ) 112 { 113 if ( m_pSound->m_pGeneralHandle == this ) 114 { 115 m_pSound->m_pGeneralHandle = NULL; 116 } 117 if ( m_pSound->m_pTempGeneralHandle == this ) 118 { 119 m_pSound->m_pTempGeneralHandle = NULL; 120 } 121 } 122 if ( m_pSound != NULL ) 123 { 124 m_pSound = NULL; 125 } 126 } 127 128 } // namespace nw::snd 129 } // namespace nw 130 131