1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_MemorySoundArchive.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: $ 16 *---------------------------------------------------------------------------*/ 17 18 /** 19 * :include nw/snd/snd_MemorySoundArchive.h 20 * 21 * @file snd_MemorySoundArchive.h 22 */ 23 24 #ifndef NW_SND_MEMORY_SOUND_ARCHIVE_H_ 25 #define NW_SND_MEMORY_SOUND_ARCHIVE_H_ 26 27 #include <nw/snd/snd_SoundArchiveFileReader.h> 28 #include <nw/io/io_FileStream.h> 29 30 namespace nw { 31 namespace snd { 32 33 //--------------------------------------------------------------------------- 34 //! @brief メモリ上にあるサウンドアーカイブを扱うクラスです。 35 //! 36 //! MemorySoundArchive クラスでは、 37 //! サウンドアーカイブから外部参照されているデータを扱うことができません。 38 //! 外部参照データの再生は必ず失敗します。 39 //! 40 //! サウンドアーカイブ内に波形データ (波形アーカイブ) が含まれている場合、 41 //! そのサウンドアーカイブはデバイスメモリ上にロードしておく必要があります。 42 //! 43 //! @date 2010/04/30 サウンドアーカイブをデバイスメモリ上にロードしておく必要がある旨、追記 44 //! @date 2010/01/15 初版 45 //--------------------------------------------------------------------------- 46 class MemorySoundArchive : public SoundArchive 47 { 48 private: 49 class MemoryFileStream; 50 51 public: 52 //---------------------------------------- 53 //! @name コンストラクタ / デストラクタ 54 //@{ 55 //! コンストラクタです。 56 MemorySoundArchive(); 57 //! デストラクタです。 58 virtual ~MemorySoundArchive(); 59 //@} 60 61 //---------------------------------------- 62 //! @name セットアップ 63 //@{ 64 65 //--------------------------------------------------------------------------- 66 //! @brief メモリ上のサウンドアーカイブデータを初期化します。 67 //! 68 //! サウンドアーカイブ内に波形データ (波形アーカイブ) が含まれている場合、 69 //! そのサウンドアーカイブはデバイスメモリ上にロードしておく必要があります。 70 //! 71 //! @param[in] soundArchiveData サウンドアーカイブデータのアドレス。 72 //! 73 //! @return 初期化に成功すれば true を、失敗すれば false を返します。 74 //! 75 //! @see Finalize 76 //! 77 //! @date 2010/11/15 返り値の記述が無かったので追記 78 //! @date 2010/04/30 サウンドアーカイブをデバイスメモリ上にロードしておく必要がある旨、追記 79 //! @date 2010/02/01 関数名変更 (Setup → Initialize) 80 //! @date 2010/01/15 初版 81 //--------------------------------------------------------------------------- 82 bool Initialize( const void* soundArchiveData ); 83 84 //--------------------------------------------------------------------------- 85 //! @brief メモリ上のサウンドアーカイブデータを破棄します。 86 //! 87 //! @see Initialize 88 //! 89 //! @date 2010/02/01 関数名変更 (Shutdown → Finalize) 90 //! @date 2010/01/15 初版 91 //--------------------------------------------------------------------------- 92 void Finalize(); 93 //@} 94 95 //! @details :private 96 virtual size_t detail_GetRequiredStreamBufferSize() const; 97 98 //! @details :private 99 virtual const void* detail_GetFileAddress( FileId fileId ) const; 100 101 protected: 102 103 //! @details :private 104 virtual io::FileStream* OpenStream( void* buffer, int size, u32 begin, u32 length ); 105 106 //! @details :private 107 virtual io::FileStream* OpenExtStream( 108 void* buffer, 109 int size, 110 const char* extFilePath, 111 // const wchar_t* extFilePath, 112 u32 begin, 113 u32 length ) const; 114 115 private: 116 const void* m_pData; 117 internal::SoundArchiveFileReader m_FileReader; 118 }; 119 120 //! @details :private 121 class MemorySoundArchive::MemoryFileStream : public io::FileStream 122 { 123 public: 124 MemoryFileStream( const void* buffer, u32 size ); 125 CanSeek()126 virtual bool CanSeek() const { return true; } CanCancel()127 virtual bool CanCancel() const { return true; } CanAsync()128 virtual bool CanAsync() const { return false; } CanRead()129 virtual bool CanRead() const { return true; } CanWrite()130 virtual bool CanWrite() const { return false; } 131 132 virtual void Close(); 133 virtual s32 Read( void* buf, u32 length ); 134 virtual void Seek( s32 offset, u32 origin ); Tell()135 virtual u32 Tell() const { return m_Position; } GetSize()136 virtual u32 GetSize() const { return m_Size; } 137 138 private: 139 const void* m_pBuffer; 140 u32 m_Size; 141 u32 m_Position; 142 }; 143 144 } // namespace nw::snd 145 } // namespace nw 146 147 148 #endif /* NW_SND_MEMORY_SOUND_ARCHIVE_H_ */ 149 150