libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/io/oss_raw_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_RAW_OUTPUT_H_
00032 #define PSYNTH_IO_OSS_RAW_OUTPUT_H_
00033 
00034 #include <psynth/io/exception.hpp>
00035 #include <psynth/io/thread_async.hpp>
00036 
00037 namespace psynth
00038 {
00039 namespace io
00040 {
00041 
00042 PSYNTH_DECLARE_ERROR (error, oss_error);
00043 PSYNTH_DECLARE_ERROR (oss_error, oss_open_error);
00044 PSYNTH_DECLARE_ERROR (oss_error, oss_param_error);
00045 
00046 class oss_raw_output : public thread_async,
00047                        private boost::noncopyable
00048 {
00049 public:
00050     typedef thread_async::callback_type callback_type;
00051     
00055     oss_raw_output (const char* device,
00056                     int         format,
00057                     int         sample_size,
00058                     int         buffer_size,
00059                     bool        interleaved,
00060                     int         rate,
00061                     int         channels,
00062                     callback_type cb = callback_type ());
00063     
00064     ~oss_raw_output ();
00065 
00066     std::size_t put_i (const void*        data, std::size_t frames);
00067     std::size_t put_n (const void* const* data, std::size_t frames);
00068 
00069     std::size_t buffer_size () const
00070     { return _buffer_size; }
00071     
00072 private:
00073     void iterate ();
00074 
00075     int         _handle;
00076     std::size_t _frame_size;
00077     std::size_t _buffer_size;
00078 };
00079 
00080 } /* namespace io */
00081 } /* namespace psynth */
00082 
00083 #endif /* PSYNTH_IO_OSS_RAW_OUTPUT_H_ */
00084