3 ==============================================================================
\r
5 This file is part of the async
\r
6 Copyright 2005-10 by Satoshi Fujiwara.
\r
8 async can be redistributed and/or modified under the terms of the
\r
9 GNU General Public License, as published by the Free Software Foundation;
\r
10 either version 2 of the License, or (at your option) any later version.
\r
12 async is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with async; if not, visit www.gnu.org/licenses or write to the
\r
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
\r
20 Boston, MA 02111-1307 USA
\r
22 ==============================================================================
\r
24 #include "singleton.h"
\r
25 #include "exception.h"
\r
26 #include "ring_buffer.h"
\r
28 #include "async_reader.h"
\r
29 #include "sf_memory.h"
\r
30 #include "toplevel_window.h"
\r
31 #include "reader_agent.h"
\r
32 #include "output_agent.h"
\r
33 #include "input_agent.h"
\r
34 #include "mixer_agent.h"
\r
35 #include "sequencer.h"
\r
38 class application : public singleton<application>
\r
40 static const size_t Q_SIZE = 8;
\r
43 : public sf::win32_error_exception
\r
45 exception(uint32_t hr) : win32_error_exception(hr) {};
\r
46 exception() : win32_error_exception() {} ;
\r
53 int execute(HINSTANCE hInstance,
\r
54 HINSTANCE hPrevInstance,
\r
59 std::wstring& app_id(){return app_id_;};
\r
60 HINSTANCE instance_handle() {return instance_handle_;};
\r
62 // アプリケーションのカレントディレクトリを返す
\r
63 const std::wstring& base_directory() const { return base_directory_; }
\r
66 // ----------------------------------------
\r
68 // ----------------------------------------
\r
70 //void wasapi_setup();
\r
71 HINSTANCE instance_handle_;
\r
74 //---------------------------------------
\r
76 //---------------------------------------
\r
79 void reader_setup(const std::wstring& file_path);
\r
80 void reader_read_file();
\r
81 void reader_pause();
\r
84 uint64_t reader_position() {return reader_agent_.position();}
\r
85 void reader_position(uint64_t pos){reader_agent_.position(pos);}
\r
86 uint64_t reader_data_size(){return reader_agent_.size();}
\r
87 void reader_repeat_mode(bool v){ reader_agent_.repeat_mode(v);}
\r
88 bool reader_repeat_mode(){ return reader_agent_.repeat_mode();}
\r
89 int reader_status(std::memory_order o = std::memory_order_seq_cst) {return reader_agent_.status(o);}
\r
90 ringbuffer_t& reader_ringbuffer() {return reader_agent_.ringbuffer();}
\r
92 reader_agent_t reader_agent_;
\r
94 // ----------------------------
\r
96 // ----------------------------
\r
99 void apply_output_device_config(int device_index,wasapi_device_manager::device_info::params_t& params);
\r
100 audio_base& output_device() {return output_agent_.device();}
\r
101 ringbuffer_t& output_ringbuffer() {return output_agent_.ringbuffer();}
\r
102 output_agent_t& output_thread(){return output_agent_;}
\r
104 output_agent_t output_agent_;
\r
105 // -----------------------------
\r
107 // -----------------------------
\r
109 void apply_input_device_config(int device_index,wasapi_device_manager::device_info::params_t& params)
\r
111 input_agent_.apply_config(device_index,params);
\r
113 audio_base& input_device() {return input_agent_.device();}
\r
114 ringbuffer_t& input_ringbuffer() {return input_agent_.ringbuffer();}
\r
115 input_agent_t& input_thread(){return input_agent_;}
\r
117 input_agent_t input_agent_;
\r
119 // -----------------------------
\r
121 // -----------------------------
\r
123 ringbuffer_t& mixer_ringbuffer(){return mixer_agent_.ringbuffer();}
\r
124 mixer_agent_t& mixer_thread(){return mixer_agent_;}
\r
126 mixer_agent_t mixer_agent_;
\r
128 // -----------------------------
\r
130 // -----------------------------
\r
132 std::wstring base_directory_;
\r
133 sf::toplevel_window_ptr window_;
\r
134 //--------------------------------
\r
136 //--------------------------------
\r
138 sf::sequencer & sequencer() {return seq_;}
\r
140 sf::sequencer seq_;
\r
141 static std::wstring app_id_;
\r
142 static const int WAIT_TIMEOUT_DEFAULT = 100;
\r