Panda3D

milesAudioStream.h

00001 // Filename: milesAudioStream.h
00002 // Created by:  drose (26Jul07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef MILESAUDIOSTREAM_H
00016 #define MILESAUDIOSTREAM_H
00017 
00018 #include "pandabase.h"
00019 #ifdef HAVE_RAD_MSS //[
00020 
00021 #include "milesAudioSound.h"
00022 #include "milesAudioManager.h"
00023 #include "mss.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : MilesAudioStream
00027 // Description : This represents a sound file played by the Miles
00028 //               Sound System, similar to MilesAudioSample, except
00029 //               that it is streamed from disk instead of preloaded
00030 //               into memory.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_MILES_AUDIO MilesAudioStream : public MilesAudioSound {
00033 private:
00034   MilesAudioStream(MilesAudioManager *manager, const string &file_name,
00035                    const Filename &path);
00036 
00037 public:
00038   virtual ~MilesAudioStream();
00039   
00040   virtual void play();
00041   virtual void stop();
00042   
00043   virtual PN_stdfloat get_time() const;
00044   
00045   virtual void set_volume(PN_stdfloat volume=1.0f);
00046   virtual void set_balance(PN_stdfloat balance_right=0.0f);
00047   virtual void set_play_rate(PN_stdfloat play_rate=1.0f);
00048   
00049   virtual PN_stdfloat length() const;
00050 
00051   virtual AudioSound::SoundStatus status() const;
00052 
00053   virtual void cleanup();
00054 
00055 private:
00056   static void AILCALLBACK finish_callback(HSTREAM stream);
00057   void do_set_time(PN_stdfloat time);
00058 
00059   Filename _path;
00060   HSTREAM _stream;
00061   S32 _original_playback_rate;
00062   mutable PN_stdfloat _length;
00063   mutable bool _got_length;
00064 
00065 public:
00066   static TypeHandle get_class_type() {
00067     return _type_handle;
00068   }
00069   static void init_type() {
00070     MilesAudioSound::init_type();
00071     register_type(_type_handle, "MilesAudioStream",
00072                   MilesAudioSound::get_class_type());
00073   }
00074   virtual TypeHandle get_type() const {
00075     return get_class_type();
00076   }
00077   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00078 
00079 private:
00080   static TypeHandle _type_handle;
00081 
00082   friend class MilesAudioManager;
00083 };
00084 
00085 #include "milesAudioStream.I"
00086 
00087 #endif //]
00088 
00089 #endif
 All Classes Functions Variables Enumerations