1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_StreamSound.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_STREAM_SOUND_H_
19 #define NW_SND_STREAM_SOUND_H_
20 
21 #include <nw/snd/snd_SoundInstanceManager.h>
22 #include <nw/snd/snd_BasicSound.h>
23 #include <nw/snd/snd_StreamSoundPlayer.h>
24 #include <nw/snd/snd_StreamBufferPool.h>
25 #include <nw/snd/snd_Debug.h>
26 
27 namespace nw {
28 namespace snd {
29 
30 class StreamSoundHandle;
31 
32 namespace internal {
33 
34 class StreamSound;
35 
36 typedef SoundInstanceManager<StreamSound, driver::StreamSoundPlayer> StreamSoundInstanceManager;
37 
38 class StreamSound : public BasicSound
39 {
40     friend class StreamSoundHandle;
41 
42 public:
43     NW_UT_RUNTIME_TYPEINFO;      // ダウンキャスト用の実行時型情報を埋め込みます
44 
45     static const int FILE_STREAM_BUFFER_SIZE = 512;
46 
47     /* ------------------------------------------------------------------------
48             class member
49        ------------------------------------------------------------------------ */
50 public:
51     StreamSound( StreamSoundInstanceManager& manager );
52 
53     void Setup(
54         driver::StreamBufferPool* pBufferPool,
55         int allocChannelCount,
56         u16 allocTrackFlag
57     );
58     void Prepare(
59         driver::StreamSoundPlayer::StartOffsetType startOffsetType,
60         s32 offset,
61         io::FileStream* pFileStream
62     );
63     virtual void Initialize();
64     virtual void Finalize();
65     virtual bool IsPrepared() const;
66     bool IsSuspendByLoadingDelay() const;
67 
GetFileStreamBuffer()68     void* GetFileStreamBuffer() { return m_FileStreamBuffer; }
GetFileStreamBufferSize()69     long GetFileStreamBufferSize() { return FILE_STREAM_BUFFER_SIZE; }
70 
71     // トラックパラメータ
72     void SetTrackVolume( unsigned long trackBitFlag, float volume, int frames = 0 );
73     void SetTrackPan( unsigned long trackBitFlag, float pan );
74     void SetTrackSurroundPan( unsigned long trackBitFlag, float span );
75 
76     // 情報取得
77     bool ReadStreamDataInfo( StreamDataInfo* info ) const;
78     long GetPlayLoopCount() const;
79     long GetPlaySamplePosition() const;
80     float GetFilledBufferPercentage() const;
81 
detail_GetStreamSoundPlayer()82     const driver::StreamSoundPlayer& detail_GetStreamSoundPlayer() const
83     {
84         return m_StreamSoundPlayerInstance;
85     }
detail_GetStreamSoundPlayer()86     driver::StreamSoundPlayer& detail_GetStreamSoundPlayer()
87     {
88         return m_StreamSoundPlayerInstance;
89     }
90 
91     // デバッグ関数
GetSoundType()92     DebugSoundType GetSoundType() const { return DEBUG_SOUND_TYPE_STRMSOUND; }
93 
94 protected:
95     virtual bool IsAttachedTempSpecialHandle();
96     virtual void DetachTempSpecialHandle();
97     virtual void UpdateMoveValue();
98     virtual void UpdateParam();
99 
GetBasicSoundPlayerHandle()100     virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() { return &m_StreamSoundPlayerInstance; }
101 
102     virtual void OnUpdatePlayerPriority();
103 
104 private:
105     driver::StreamSoundPlayer m_StreamSoundPlayerInstance;
106     StreamSoundHandle* m_pTempSpecialHandle;
107     StreamSoundInstanceManager& m_Manager;
108 
109     MoveValue<float, int> m_TrackVolume[ driver::StreamSoundPlayer::STRM_TRACK_NUM ];
110 
111     io::FileStream* m_pFileStream;
112     int m_FileStreamBuffer[ FILE_STREAM_BUFFER_SIZE/sizeof(int) ];
113     u16 m_AllocTrackFlag;
114     bool m_InitializeFlag;
115 };
116 
117 } // namespace nw::snd::internal
118 } // namespace nw::snd
119 } // namespace nw
120 
121 
122 #endif /* NW_SND_STREAM_SOUND_H_ */
123 
124