/*---------------------------------------------------------------------------* Project: NintendoWare File: snd_StreamSoundFile.cpp Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. 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. $Revision: 13145 $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include namespace nw { namespace snd { namespace internal { // // StreamSoundFile::FileHeader // const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy( u16 typeId ) const { for ( int i = 0; i < BLOCK_SIZE; i++ ) { if ( toBlocks[ i ].typeId == typeId ) { return &toBlocks[ i ]; } } return NULL; } u32 StreamSoundFile::FileHeader::GetInfoBlockSize() const { return GetReferenceBy( ElementType_StreamSoundFile_InfoBlock )->size; } u32 StreamSoundFile::FileHeader::GetSeekBlockSize() const { return GetReferenceBy( ElementType_StreamSoundFile_SeekBlock )->size; } u32 StreamSoundFile::FileHeader::GetDataBlockSize() const { return GetReferenceBy( ElementType_StreamSoundFile_DataBlock )->size; } u32 StreamSoundFile::FileHeader::GetInfoBlockOffset() const { return GetReferenceBy( ElementType_StreamSoundFile_InfoBlock )->offset; } u32 StreamSoundFile::FileHeader::GetSeekBlockOffset() const { return GetReferenceBy( ElementType_StreamSoundFile_SeekBlock )->offset; } u32 StreamSoundFile::FileHeader::GetDataBlockOffset() const { return GetReferenceBy( ElementType_StreamSoundFile_DataBlock )->offset; } // // StreamSoundFile::InfoBlockBody // const StreamSoundFile::StreamSoundInfo* StreamSoundFile::InfoBlockBody::GetStreamSoundInfo() const { if ( toStreamSoundInfo.typeId != ElementType_StreamSoundFile_StreamSoundInfo ) { return NULL; } return static_cast( ut::AddOffsetToPtr( this, toStreamSoundInfo.offset ) ); } const StreamSoundFile::TrackInfoTable* StreamSoundFile::InfoBlockBody::GetTrackInfoTable() const { if ( toTrackInfoTable.typeId != ElementType_Table_ReferenceTable ) { return NULL; } return static_cast( ut::AddOffsetToPtr( this, toTrackInfoTable.offset ) ); } const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChannelInfoTable() const { if ( toChannelInfoTable.typeId != ElementType_Table_ReferenceTable ) { return NULL; } return static_cast( ut::AddOffsetToPtr( this, toChannelInfoTable.offset ) ); } // // StreamSoundFile::TrackInfoTable // const StreamSoundFile::TrackInfo* StreamSoundFile::TrackInfoTable::GetTrackInfo( u32 index ) const { return static_cast( table.GetReferedItem( index, ElementType_StreamSoundFile_TrackInfo ) ); } // // StreamSoundFile::ChannelInfoTable // const StreamSoundFile::ChannelInfo* StreamSoundFile::ChannelInfoTable::GetChannelInfo( u32 index ) const { NW_ASSERT( index < table.count ); return static_cast( table.GetReferedItem( index, ElementType_StreamSoundFile_ChannelInfo ) ); } // // StreamSoundFile::ChannlInfo // const StreamSoundFile::DspAdpcmChannelInfo* StreamSoundFile::ChannelInfo::GetDspAdpcmChannelInfo() const { if ( ! toDetailChannelInfo.IsValidTypeId( ElementType_Codec_DspAdpcmInfo ) ) { return NULL; } return reinterpret_cast( ut::AddOffsetToPtr( this, toDetailChannelInfo.offset ) ); } } // namespace nw::snd::internal } // namespace nw::snd } // namespace nw