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