00001 #ifndef CONTEXT_HPP 00002 #define CONTEXT_HPP 00003 00004 00005 #include <string> 00006 #include "audiere.h" 00007 #include "input.hpp" 00008 #include "output.hpp" 00009 #include "threads.hpp" 00010 00011 00012 struct ADR_CONTEXT_ATTRimp 00013 { 00014 std::string output_device; 00015 std::string parameters; 00016 void* opaque; 00017 ADR_FILE_OPEN open; 00018 ADR_FILE_CLOSE close; 00019 ADR_FILE_READ read; 00020 ADR_FILE_SEEK seek; 00021 ADR_FILE_TELL tell; 00022 }; 00023 00024 00025 class Stream; 00026 00027 00028 class Context : public Synchronized 00029 { 00030 public: 00031 static Context* Create( 00032 const char* output_device, 00033 const char* parameters, 00034 IFileSystem* file_system); 00035 00036 private: 00037 Context(); 00038 ~Context(); 00039 bool Initialize( 00040 const char* output_device, 00041 const char* parameters, 00042 IFileSystem* file_system); 00043 00044 public: 00045 void AddRef(); 00046 void Release(); 00047 00048 Stream* OpenStream(const char* filename); 00049 00050 private: 00051 static void ThreadRoutine(void* opaque); 00052 void ThreadRoutine(); 00053 00054 private: 00055 int m_ref_count; 00056 volatile bool m_thread_should_die; 00057 volatile bool m_thread_exists; 00058 00059 IFileSystem* m_file_system; 00060 IOutputContext* m_output_context; 00061 00062 friend class Stream; 00063 }; 00064 00065 00066 #endif