Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

StreamPlayer.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * ストリームプレーヤヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef STREAM_PLAYER_H_
00026 #define STREAM_PLAYER_H_
00027 
00028 #include <Core/Thread/Thread.h>
00029 
00030 namespace Lamp{
00031 
00032 class SoundBuffer;
00033 class SoundReader;
00034 
00035 //------------------------------------------------------------------------------
00036 /**
00037  * ストリームプレーヤ
00038  */
00039 class StreamPlayer : public Thread{
00040 friend class StreamSound;
00041 friend class StreamSound3D;
00042 protected:
00043     /**
00044      * コンストラクタ
00045      */
00046     StreamPlayer();
00047 
00048     /**
00049      * デストラクタ
00050      */
00051     virtual ~StreamPlayer();
00052 
00053     /**
00054      * 初期化
00055      * @param soundBuffer サウンドバッファ
00056      * @param soundReader サウンドリーダ
00057      */
00058     virtual bool initialize(SoundBuffer* soundBuffer, SoundReader* soundReader);
00059 
00060     /**
00061      * リセット
00062      */
00063     virtual void reset();
00064 
00065     //--------------------------------------------------------------------------
00066     /**
00067      * 実行
00068      * @param thread 実行しているスレッド
00069      *
00070      * isStopRequested()がtrueを返す場合は速やかに処理を終了させる
00071      */
00072     virtual void run(Thread* thread);
00073 
00074     /**
00075      * ストリーム書き込み
00076      * @param offset 0ならバッファ前半、1なら後半に書き込む
00077      * @return 成功すればtrue
00078      */
00079     virtual bool writeStream(int offset);
00080 
00081     //--------------------------------------------------------------------------
00082     // 再生位置
00083     //--------------------------------------------------------------------------
00084     /**
00085      * 再生位置設定
00086      * @param cursor 再生位置のバイト数
00087      */
00088     virtual void setCursor(u_int cursor);
00089 
00090     /**
00091      * 再生位置取得
00092      * @return 再生位置のバイト数
00093      */
00094     virtual u_int getCursor() const{ return cursor_; }
00095 
00096     //--------------------------------------------------------------------------
00097     // ループ
00098     //--------------------------------------------------------------------------
00099     /**
00100      * ループ位置の設定
00101      * @param loopCursor ループ位置をバイト数で指定
00102      */
00103     virtual void setLoopCursor(u_int loopCursor);
00104 
00105     /**
00106      * ループ位置の取得
00107      * @return ループ位置のバイト数
00108      */
00109     virtual u_int getLoopCursor() const{ return loopCursor_; }
00110 
00111 private:
00112     //--------------------------------------------------------------------------
00113     // コピーコンストラクタの隠蔽
00114     StreamPlayer(const StreamPlayer& copy);
00115 
00116     // 代入コピーの隠蔽
00117     void operator =(const StreamPlayer& copy);
00118 
00119     // DirectSoundNotify
00120     DirectSoundNotify* directSoundNotify_;
00121     // サウンドバッファ
00122     SoundBuffer* soundBuffer_;
00123     // サウンドリーダ
00124     SoundReader* soundReader_;
00125     // イベント数
00126     static const int eventCount_ = 3;
00127     // イベントハンドル
00128     HANDLE event_[eventCount_];
00129     // 再生位置
00130     u_int cursor_;
00131     // ループ位置
00132     u_int loopCursor_;
00133     // 初期化フラグ
00134     volatile bool initialized_;
00135 };
00136 
00137 //------------------------------------------------------------------------------
00138 } // End of namespace Lamp
00139 #endif // End of STREAM_PLAYER_H_
00140 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:36 2005 for Lamp by doxygen 1.3.2