\r
typedef std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>> audio_buffer_16;\r
\r
+class device\r
+{\r
+ ALCdevice* device_;\r
+ ALCcontext* context_;\r
+\r
+public:\r
+ device()\r
+ : device_(0)\r
+ , context_(0)\r
+ {\r
+ device_ = alcOpenDevice(nullptr);\r
+\r
+ if(!device_)\r
+ BOOST_THROW_EXCEPTION(invalid_operation());\r
+\r
+ context_ = alcCreateContext(device_, nullptr);\r
+\r
+ if(!context_)\r
+ BOOST_THROW_EXCEPTION(invalid_operation());\r
+ \r
+ if(alcMakeContextCurrent(context_) == ALC_FALSE)\r
+ BOOST_THROW_EXCEPTION(invalid_operation());\r
+ }\r
+\r
+ ~device()\r
+ {\r
+ alcMakeContextCurrent(nullptr);\r
+\r
+ if(context_)\r
+ alcDestroyContext(context_);\r
+\r
+ if(device_)\r
+ alcCloseDevice(device_);\r
+ }\r
+\r
+ ALCdevice* get()\r
+ {\r
+ return device_;\r
+ }\r
+};\r
+\r
struct oal_consumer : public core::frame_consumer\r
{\r
+ static device device_;\r
+\r
spl::shared_ptr<diagnostics::graph> graph_;\r
boost::timer perf_timer_;\r
int channel_index_;\r
\r
core::video_format_desc format_desc_;\r
\r
- ALCdevice* device_;\r
- ALCcontext* context_;\r
ALuint source_;\r
std::array<ALuint, 3> buffers_;\r
\r
public:\r
oal_consumer() \r
: channel_index_(-1)\r
- , device_(0)\r
- , context_(0)\r
, source_(0)\r
, executor_(L"oal_consumer")\r
{\r
graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));\r
graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f));\r
diagnostics::register_graph(graph_);\r
- \r
- executor_.invoke([=]\r
- { \r
- device_ = alcOpenDevice(nullptr);\r
-\r
- if(!device_)\r
- BOOST_THROW_EXCEPTION(invalid_operation());\r
-\r
- context_ = alcCreateContext(device_, nullptr);\r
-\r
- if(!context_)\r
- BOOST_THROW_EXCEPTION(invalid_operation());\r
- \r
- if(alcMakeContextCurrent(context_) == ALC_FALSE)\r
- BOOST_THROW_EXCEPTION(invalid_operation());\r
- });\r
}\r
\r
~oal_consumer()\r
if(buffer)\r
alDeleteBuffers(1, &buffer);\r
};\r
-\r
- alcMakeContextCurrent(nullptr);\r
-\r
- if(context_)\r
- alcDestroyContext(context_);\r
-\r
- if(device_)\r
- alcCloseDevice(device_);\r
});\r
}\r
\r
}\r
};\r
\r
+device oal_consumer::device_;\r
+\r
spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params)\r
{\r
if(params.size() < 1 || params[0] != L"AUDIO")\r