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