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; }
40 bool initialize_pa ();
42 void host_api_list (std::vector<std::string>&);
43 void set_host_api (const std::string& host_api_name);
44 PaHostApiIndex get_host_api_index_from_name (const std::string& name);
46 PaDeviceIndex get_default_input_device ();
47 PaDeviceIndex get_default_output_device ();
50 void input_device_list (std::map<int, std::string> &devices) const;
51 void output_device_list (std::map<int, std::string> &devices) const;
53 int available_sample_rates (int device_id, std::vector<float>& sampleRates);
54 int available_buffer_sizes (int device_id, std::vector<uint32_t>& sampleRates);
64 uint32_t samples_per_period
67 uint32_t n_playback_channels (void) const { return _playback_channels; }
68 uint32_t n_capture_channels (void) const { return _capture_channels; }
70 double sample_rate (void) const { return _cur_sample_rate; }
71 uint32_t capture_latency (void) const { return _cur_input_latency; }
72 uint32_t playback_latency (void) const { return _cur_output_latency; }
73 double stream_time(void) const { if (_stream) return Pa_GetStreamTime (_stream); return 0; }
75 int next_cycle(uint32_t n_samples);
76 int get_capture_channel (uint32_t chn, float *input, uint32_t n_samples);
77 int set_playback_channel (uint32_t chn, const float *input, uint32_t n_samples);
81 void clear_device_lists ();
82 void add_default_devices ();
89 uint32_t _capture_channels;
90 uint32_t _playback_channels;
95 float *_output_buffer;
97 double _cur_sample_rate;
98 uint32_t _cur_input_latency;
99 uint32_t _cur_output_latency;
106 paDevice (std::string n, uint32_t i, uint32_t o)
113 std::map<int, paDevice *> _input_devices;
114 std::map<int, paDevice *> _output_devices;
116 PaHostApiIndex _host_api_index;
122 #endif /* __libbackend_portaudio_pcmio_h__ */