/*---------------------------------------------------------------------------* Project: NintendoWare File: snd_WaveSound.h Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #ifndef NW_SND_WAVE_SOUND_H_ #define NW_SND_WAVE_SOUND_H_ #include #include #include #include #include #include namespace nw { namespace snd { /* ======================================================================== type declarataion ======================================================================== */ class WaveSoundHandle; /* ======================================================================== class definition ======================================================================== */ namespace internal { class WaveSound; typedef SoundInstanceManager WaveSoundInstanceManager; class WaveSound : public BasicSound { friend class WaveSoundHandle; public: NW_UT_RUNTIME_TYPEINFO; // ダウンキャスト用の実行時型情報を埋め込みます struct StartInfo { s32 index; driver::WaveSoundPlayer::StartOffsetType startOffsetType; s32 startOffset; const driver::WaveSoundPlayer::WaveSoundCallback* callback; u32 callbackData; }; struct LoadInfo { const SoundArchive* arc; const SoundDataManager* mgr; const LoadItemInfo* wsd; // const LoadItemInfo* warc; }; /* ------------------------------------------------------------------------ class member ------------------------------------------------------------------------ */ public: WaveSound( WaveSoundInstanceManager& manager ); void Prepare( const void* wsdFile, const StartInfo& info ); // プレイヤーヒープへのロードタスクを登録する // (ロード完了後、必要であれば Prepare 処理が実行される) bool RegisterDataLoadTask( const LoadInfo& loadInfo, const StartInfo& startInfo ); virtual void Initialize(); virtual void Finalize(); virtual bool IsPrepared() const { return m_PreparedFlag; } // パラメータ設定 void SetChannelPriority( int priority ); void SetReleasePriorityFix( bool fix ); // パラメータ取得 bool ReadWaveSoundDataInfo( WaveSoundDataInfo* info ) const; long GetPlaySamplePosition() const; // デバッグ関数 DebugSoundType GetSoundType() const { return DEBUG_SOUND_TYPE_WAVESOUND; } protected: virtual bool IsAttachedTempSpecialHandle(); virtual void DetachTempSpecialHandle(); virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() { return &m_WaveSoundPlayerInstance; } virtual void OnUpdatePlayerPriority(); private: typedef void (*NotifyAsyncLoadFinished)( bool result, const LoadItemInfo* wsd, void* userData ); class DataLoadTask : public Task { public: DataLoadTask(); virtual void Execute(); PlayerHeapDataManager* m_pDataManager; PlayerHeap* m_pAllocator; NotifyAsyncLoadFinished m_Callback; void* m_CallbackData; const SoundDataManager* m_pSoundDataManager; const SoundArchive* m_pSoundArchive; LoadItemInfo m_LoadInfoWsd; s32 m_Index; // .bcwsd ファイル中にいくつめのサウンドかを示す }; static void NotifyAsyncLoadFinishedFunc( bool result, const LoadItemInfo* wsd, void* userData ); driver::WaveSoundPlayer m_WaveSoundPlayerInstance; WaveSoundHandle* m_pTempSpecialHandle; WaveSoundInstanceManager& m_pManager; DataLoadTask m_DataLoadTask; PlayerHeapDataManager m_DataManager; StartInfo m_StartInfo; volatile bool m_LoadingFlag; bool m_PreparedFlag; bool m_InitializeFlag; }; } // namespace nw::snd::internal } // namespace nw::snd } // namespace nw #endif /* NW_SND_WAVE_SOUND_H_ */