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

stream.cpp

Go to the documentation of this file.
00001 #include "stream.hpp"
00002 #include "context.hpp"
00003 #include "utility.hpp"
00004 
00005 
00007 
00008 Stream::Stream()
00009 {
00010   m_context       = 0;
00011   m_input_stream  = 0;
00012   m_output_stream = 0;
00013 }
00014 
00016 
00017 bool
00018 Stream::Initialize(Context* context, const char* filename)
00019 {
00020   ISampleSource* sample_source = OpenInputStream(
00021     context->m_file_system,
00022     filename);
00023   if (!sample_source) {
00024     return false;
00025   }
00026 
00027   m_input_stream = new RepeatableStream(sample_source, false);
00028 
00029   // open output stream
00030   m_output_stream = context->m_output_context->OpenStream(m_input_stream);
00031   if (!m_output_stream) {
00032     delete m_input_stream;
00033     m_input_stream = 0;
00034     return false;
00035   }
00036 
00037   m_context = context;
00038   m_context->AddRef();
00039 
00040   return true;
00041 }
00042 
00044 
00045 void
00046 Stream::Destructor()
00047 {
00048   delete m_output_stream;
00049   m_output_stream = 0;
00050 
00051   delete m_input_stream;
00052   m_input_stream = 0;
00053 
00054   if (m_context) {
00055     m_context->Release();
00056     m_context = 0;
00057   }
00058 }
00059 
00061 
00062 Stream::~Stream()
00063 {
00064   if (m_context) {
00065     AI_Lock l__(m_context);
00066     Destructor();
00067   } else {
00068     Destructor();
00069   }
00070 }
00071 
00073 
00074 void
00075 Stream::Play()
00076 {
00077   AI_Lock l__(m_context);
00078   m_output_stream->Play();
00079 }
00080 
00082 
00083 void
00084 Stream::Pause()
00085 {
00086   AI_Lock l__(m_context);
00087   m_output_stream->Stop();
00088 }
00089 
00091 
00092 void
00093 Stream::Reset()
00094 {
00095   AI_Lock l__(m_context);
00096   m_input_stream->Reset();
00097   m_output_stream->Reset();
00098 }
00099 
00101 
00102 bool
00103 Stream::IsPlaying()
00104 {
00105   AI_Lock l__(m_context);
00106   return m_output_stream->IsPlaying();
00107 }
00108 
00110 
00111 void
00112 Stream::SetRepeat(bool repeat)
00113 {
00114   AI_Lock l__(m_context);
00115   m_input_stream->SetRepeat(repeat);
00116 }
00117 
00119 
00120 bool
00121 Stream::IsRepeating()
00122 {
00123   AI_Lock l__(m_context);
00124   return m_input_stream->GetRepeat();
00125 }
00126 
00128 
00129 void
00130 Stream::SetVolume(int volume)
00131 {
00132   AI_Lock l__(m_context);
00133   m_output_stream->SetVolume(volume);
00134 }
00135 
00137 
00138 int
00139 Stream::GetVolume()
00140 {
00141   AI_Lock l__(m_context);
00142   return m_output_stream->GetVolume();
00143 }
00144 

Generated at Mon Jun 10 02:55:12 2002 for audiere by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001