3 ==============================================================================
5 This file is part of the async
6 Copyright 2005-10 by Satoshi Fujiwara.
8 async can be redistributed and/or modified under the terms of the
9 GNU General Public License, as published by the Free Software Foundation;
10 either version 2 of the License, or (at your option) any later version.
12 async is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with async; if not, visit www.gnu.org/licenses or write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
22 ==============================================================================
24 #include "singleton.h"
25 #include "exception.h"
26 #include "ring_buffer.h"
28 #include "async_reader.h"
29 #include "sf_memory.h"
30 #include "toplevel_window.h"
33 class application : public singleton<application>
37 : public sf::win32_error_exception
39 exception(uint32_t hr) : win32_error_exception(hr) {};
40 exception() : win32_error_exception() {} ;
46 int execute(HINSTANCE hInstance,
47 HINSTANCE hPrevInstance,
52 std::wstring& app_id(){return app_id_;};
53 HINSTANCE instance_handle() {return instance_handle_;};
68 void reader_thread_main();
69 void output_thread_main();
71 void change_status(uint32_t v,boost::memory_order o = boost::memory_order_seq_cst);
72 uint32_t get_status(boost::memory_order o = boost::memory_order_seq_cst);
74 void setup(const std::wstring& file_path);
80 uint64_t get_play_position() { return output_counter_;};
81 void set_play_position(uint64_t pos);
82 uint64_t get_data_size() { return reader_->total_data_bytes(); };
83 void repeat_mode(bool v) { repeat_mode_ = v ;reader_->repeat_mode(v);}
85 HINSTANCE instance_handle_;
89 boost::thread reader_thread_;
90 handle_holder event_reader_;
91 std::wstring source_file_path_;
92 std::unique_ptr<async_reader> reader_;
93 sf::buffer_t read_buffer_;
95 uint64_t read_position_;
97 handle_holder event_output_;
98 boost::thread output_thread_;
99 std::unique_ptr<sf::wasapi_shared_timer> wasapi_;
100 uint64_t output_counter_;
103 boost::atomic<uint32_t> status_;
104 uint32_t status_backup_;
105 sf::ringbuffer_t ringbuffer_;
108 sf::toplevel_window_ptr window_;
109 static std::wstring app_id_;