OSDN Git Service

最初のコミット
[winaudioj/wasapi2.git] / wasapi2 / ring_buffer.h
1 #pragma once\r
2 /*\r
3   ==============================================================================\r
4 \r
5    This file is part of the async\r
6    Copyright 2005-10 by Satoshi Fujiwara.\r
7 \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
11 \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
16 \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
21 \r
22   ==============================================================================\r
23 */\r
24 #include <malloc.h>\r
25 #include <atomic>\r
26 #include <boost/lockfree/ringbuffer.hpp>\r
27 namespace sf {\r
28 \r
29 \r
30   // アラインされたメモリの解放\r
31   struct buffer_deleter{\r
32     void operator()(uint8_t *mem)\r
33     {\r
34       _aligned_free(mem);\r
35     };\r
36   };\r
37 \r
38   // バッファメモリのスマートポインタ\r
39   // アラインされたメモリを想定\r
40   typedef std::unique_ptr<uint8_t,buffer_deleter> memory_block_t;\r
41 \r
42   // メモリブロックの配列\r
43   // ストレージからのデータはここに一時的に格納する\r
44   // この配列値のunique_ptrをget()してリングバッファに渡す\r
45   typedef boost::array<memory_block_t,16> buffer_t;\r
46 \r
47   // リングバッファ マルチスレッド対応\r
48   typedef boost::lockfree::ringbuffer<uint8_t* ,8> ringbuffer_t;\r
49 \r
50 }\r
51 \r