libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/io/oss_output.hpp
Go to the documentation of this file.
00001 
00011 /*
00012  *  Copyright (C) 2011 Juan Pedro BolĂ­var Puente
00013  *
00014  *  This file is part of Psychosynth.
00015  *   
00016  *  Psychosynth is free software: you can redistribute it and/or modify
00017  *  it under the terms of the GNU General Public License as published by
00018  *  the Free Software Foundation, either version 3 of the License, or
00019  *  (at your option) any later version.
00020  *
00021  *  Psychosynth is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  You should have received a copy of the GNU General Public License
00027  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00028  *
00029  */
00030 
00031 #ifndef PSYNTH_IO_OSS_OUTPUT_H_
00032 #define PSYNTH_IO_OSS_OUTPUT_H_
00033 
00034 #include <psynth/io/oss_raw_output.hpp>
00035 #include <psynth/io/output.hpp>
00036 
00037 namespace psynth
00038 {
00039 namespace io
00040 {
00041 
00042 template <typename Range>
00043 struct oss_support;
00044 
00045 template <typename Range>
00046 struct oss_is_supported
00047 {
00048     typedef typename oss_support<Range>::is_supported type;
00049 };
00050 
00051 template <typename Range>
00052 class oss_output : public oss_raw_output,
00053                    public async_output<Range>
00054 {
00055     typedef async_output<Range> base_type;
00056     
00057 public:
00058     static_assert (oss_support<Range>::is_supported::value,
00059                    "Range output format not supported by OSS.");    
00060 
00061     typedef typename base_type::range range;
00062     typedef typename base_type::const_range const_range;
00063 
00064     oss_output (const std::string& device,
00065                 std::size_t        buffer_size,
00066                 std::size_t        rate,
00067                 callback_type      cb = callback_type ());
00068 
00069     std::size_t put (const const_range& data);
00070 
00071     std::size_t buffer_size () const
00072     { return oss_raw_output::buffer_size (); }
00073 };
00074 
00075 } /* namespace io */
00076 } /* namespace psynth */
00077 
00078 #include <psynth/io/oss_output.tpp>
00079 
00080 #endif /* PSYNTH_IO_OSS_OUTPUT_H_ */
00081