1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_WaveSound.h 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 #ifndef NW_SND_WAVE_SOUND_H_ 19 #define NW_SND_WAVE_SOUND_H_ 20 21 #include <nw/snd/snd_BasicSound.h> 22 #include <nw/snd/snd_WaveSoundPlayer.h> 23 #include <nw/snd/snd_SoundInstanceManager.h> 24 #include <nw/snd/snd_Debug.h> 25 #include <nw/snd/snd_Task.h> 26 #include <nw/snd/snd_PlayerHeapDataManager.h> 27 28 namespace nw { 29 namespace snd { 30 31 /* ======================================================================== 32 type declarataion 33 ======================================================================== */ 34 35 class WaveSoundHandle; 36 37 /* ======================================================================== 38 class definition 39 ======================================================================== */ 40 41 namespace internal { 42 43 class WaveSound; 44 45 typedef SoundInstanceManager<WaveSound, driver::WaveSoundPlayer> WaveSoundInstanceManager; 46 47 class WaveSound : public BasicSound 48 { 49 friend class WaveSoundHandle; 50 51 public: 52 NW_UT_RUNTIME_TYPEINFO; // ダウンキャスト用の実行時型情報を埋め込みます 53 54 struct StartInfo 55 { 56 s32 index; 57 driver::WaveSoundPlayer::StartOffsetType startOffsetType; 58 s32 startOffset; 59 const driver::WaveSoundPlayer::WaveSoundCallback* callback; 60 u32 callbackData; 61 }; 62 63 struct LoadInfo 64 { 65 const SoundArchive* arc; 66 const SoundDataManager* mgr; 67 const LoadItemInfo* wsd; 68 // const LoadItemInfo* warc; 69 }; 70 71 /* ------------------------------------------------------------------------ 72 class member 73 ------------------------------------------------------------------------ */ 74 public: 75 WaveSound( WaveSoundInstanceManager& manager ); 76 77 void Prepare( const void* wsdFile, const StartInfo& info ); 78 79 // プレイヤーヒープへのロードタスクを登録する 80 // (ロード完了後、必要であれば Prepare 処理が実行される) 81 bool RegisterDataLoadTask( const LoadInfo& loadInfo, const StartInfo& startInfo ); 82 83 virtual void Initialize(); 84 virtual void Finalize(); IsPrepared()85 virtual bool IsPrepared() const { return m_PreparedFlag; } 86 87 // パラメータ設定 88 void SetChannelPriority( int priority ); 89 void SetReleasePriorityFix( bool fix ); 90 91 // パラメータ取得 92 bool ReadWaveSoundDataInfo( WaveSoundDataInfo* info ) const; 93 long GetPlaySamplePosition() const; 94 95 // デバッグ関数 GetSoundType()96 DebugSoundType GetSoundType() const { return DEBUG_SOUND_TYPE_WAVESOUND; } 97 98 protected: 99 virtual bool IsAttachedTempSpecialHandle(); 100 virtual void DetachTempSpecialHandle(); 101 GetBasicSoundPlayerHandle()102 virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() { return &m_WaveSoundPlayerInstance; } 103 104 virtual void OnUpdatePlayerPriority(); 105 106 private: 107 typedef void (*NotifyAsyncLoadFinished)( 108 bool result, 109 const LoadItemInfo* wsd, 110 void* userData 111 ); 112 113 class DataLoadTask : public Task 114 { 115 public: 116 DataLoadTask(); 117 virtual void Execute(); 118 119 PlayerHeapDataManager* m_pDataManager; 120 PlayerHeap* m_pAllocator; 121 NotifyAsyncLoadFinished m_Callback; 122 void* m_CallbackData; 123 124 const SoundDataManager* m_pSoundDataManager; 125 const SoundArchive* m_pSoundArchive; 126 LoadItemInfo m_LoadInfoWsd; 127 128 s32 m_Index; // .bcwsd ファイル中にいくつめのサウンドかを示す 129 }; 130 131 static void NotifyAsyncLoadFinishedFunc( 132 bool result, 133 const LoadItemInfo* wsd, 134 void* userData 135 ); 136 137 138 driver::WaveSoundPlayer m_WaveSoundPlayerInstance; 139 WaveSoundHandle* m_pTempSpecialHandle; 140 WaveSoundInstanceManager& m_pManager; 141 142 DataLoadTask m_DataLoadTask; 143 PlayerHeapDataManager m_DataManager; 144 StartInfo m_StartInfo; 145 146 volatile bool m_LoadingFlag; 147 bool m_PreparedFlag; 148 bool m_InitializeFlag; 149 }; 150 151 } // namespace nw::snd::internal 152 } // namespace nw::snd 153 } // namespace nw 154 155 156 #endif /* NW_SND_WAVE_SOUND_H_ */ 157 158