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

playback_stream.h

Go to the documentation of this file.
00001 /*
00002         $Id: playback_stream.h,v 1.1 2001/03/06 15:09:25 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 
00014         File purpose:
00015                 Sound card impl. that uses the ClanSound library.
00016 
00017 */
00018 
00019 #ifndef header_playback_stream
00020 #define header_playback_stream
00021 
00022 #ifdef USE_CLANSOUND
00023 
00024 #include "API/Sound/stream_soundprovider.h"
00025 #include "API/Core/System/keep_alive.h"
00026 #include "soundcard_clan.h"
00027 #include "cardplayback_clan.h"
00028 #include "Core/System/Unix/init_linux.h"
00029 #include "../Generic/soundbuffer_generic.h"
00030 
00031 class CL_Playback_Stream
00032 : public CL_CardPlayback_ClanSound, CL_KeepAlive
00033 {
00034 public:
00035         CL_Playback_Stream(
00036                 CL_SoundCard_ClanSound *card,
00037                 CL_StreamSoundProvider *provider,
00038                 CL_SoundBuffer_Generic *owner);
00039         virtual ~CL_Playback_Stream();
00040 
00041         virtual void keep_alive();
00042 
00043         // Functions inherited from Generic:
00044         // ---------------------------------
00045         virtual int get_position();
00046         virtual float get_position_relative();
00047 
00048         virtual bool set_position(int new_pos);
00049         virtual bool set_position_relative(float new_pos);
00050 
00051         virtual int get_length(); // -1 if unknown
00052 
00053         virtual int get_frequency();
00054         virtual bool set_frequency(int new_freq);
00055 
00056         virtual float get_volume();
00057         virtual bool set_volume(float new_volume);
00058 
00059         virtual float get_pan();
00060         virtual bool set_pan(float new_pan);
00061 
00062         virtual void set_looping(bool looping);
00063         virtual bool get_looping();
00064 
00065         virtual void play();
00066         virtual void stop();
00067 
00068         virtual bool is_playing();
00069         
00070         virtual CL_SoundBuffer_Generic *get_owner()
00071         {
00072                 return owner;
00073         }
00074 
00075         // Mixer interface (from cardplayback_clansound):
00076         // ----------------------------------------------
00077         
00078         virtual void get_playback_data(int *data, int num_samples);
00079         virtual void mix_to(int *data, int num_samples);
00080 
00081 private:
00082         int ask_update();
00083         int update(void *data, int data_size);
00084         void update_format(int pos, int num_samples, void *data);
00085         void flush();
00086         int get_samples_available();
00087 
00088 private:
00089         CL_StreamSoundProvider *provider;
00090         CL_StreamSoundProvider_Session *provider_session;
00091         CL_SoundBuffer_Generic *owner;
00092 
00093         int format;
00094         float volume;
00095         float pan;
00096         int frequency;
00097         volatile double pos;
00098 
00099         bool playing;
00100         volatile int filled_pos;
00101         bool first_time;
00102         
00103         short *ring_buffer;
00104         int buffer_size;
00105         bool stream_eof;
00106 };
00107 
00108 #endif /* USE_CLANSOUND */
00109 
00110 #endif

Generated at Wed Apr 4 19:54:02 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001