2 * Copyright (C) 2015 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __libbackend_portaudio_pcmio_h__
20 #define __libbackend_portaudio_pcmio_h__
25 #include <boost/shared_ptr.hpp>
29 #include <portaudio.h>
38 int state (void) const { return _state; }
41 void device_list (std::map<int, std::string> &devices) const;
43 int available_sample_rates (int device_id, std::vector<float>& sampleRates);
44 int available_buffer_sizes (int device_id, std::vector<uint32_t>& sampleRates);
54 uint32_t samples_per_period
57 uint32_t n_playback_channels (void) const { return _playback_channels; }
58 uint32_t n_capture_channels (void) const { return _capture_channels; }
60 double sample_rate (void) const { return _cur_sample_rate; }
61 uint32_t capture_latency (void) const { return _cur_input_latency; }
62 uint32_t playback_latency (void) const { return _cur_output_latency; }
63 double stream_time(void) const { if (_stream) return Pa_GetStreamTime (_stream); return 0; }
65 int next_cycle(uint32_t n_samples);
66 int get_capture_channel (uint32_t chn, float *input, uint32_t n_samples);
67 int set_playback_channel (uint32_t chn, const float *input, uint32_t n_samples);
73 uint32_t _capture_channels;
74 uint32_t _playback_channels;
79 float *_output_buffer;
81 double _cur_sample_rate;
82 uint32_t _cur_input_latency;
83 uint32_t _cur_output_latency;
91 paDevice (std::string n, uint32_t i, uint32_t o)
98 std::map<int, paDevice *> _devices;
103 #endif /* __libbackend_portaudio_pcmio_h__ */