To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.
root / src / portaudio_20161030_catalina_patch / bindings / cpp / source / portaudiocpp / Device.cxx @ 162:d43aab368df9
History | View | Annotate | Download (3.34 KB)
| 1 |
#include "portaudiocpp/Device.hxx" |
|---|---|
| 2 |
|
| 3 |
#include <cstddef> |
| 4 |
|
| 5 |
#include "portaudiocpp/HostApi.hxx" |
| 6 |
#include "portaudiocpp/System.hxx" |
| 7 |
#include "portaudiocpp/Exception.hxx" |
| 8 |
|
| 9 |
namespace portaudio
|
| 10 |
{
|
| 11 |
|
| 12 |
// -------------------------------------------------------------------------------
|
| 13 |
|
| 14 |
Device::Device(PaDeviceIndex index) : index_(index) |
| 15 |
{
|
| 16 |
if (index == paNoDevice)
|
| 17 |
info_ = NULL;
|
| 18 |
else
|
| 19 |
info_ = Pa_GetDeviceInfo(index); |
| 20 |
} |
| 21 |
|
| 22 |
Device::~Device() |
| 23 |
{
|
| 24 |
} |
| 25 |
|
| 26 |
PaDeviceIndex Device::index() const
|
| 27 |
{
|
| 28 |
return index_;
|
| 29 |
} |
| 30 |
|
| 31 |
const char *Device::name() const |
| 32 |
{
|
| 33 |
if (info_ == NULL) |
| 34 |
return ""; |
| 35 |
|
| 36 |
return info_->name;
|
| 37 |
} |
| 38 |
|
| 39 |
int Device::maxInputChannels() const |
| 40 |
{
|
| 41 |
if (info_ == NULL) |
| 42 |
return 0; |
| 43 |
|
| 44 |
return info_->maxInputChannels;
|
| 45 |
} |
| 46 |
|
| 47 |
int Device::maxOutputChannels() const |
| 48 |
{
|
| 49 |
if (info_ == NULL) |
| 50 |
return 0; |
| 51 |
|
| 52 |
return info_->maxOutputChannels;
|
| 53 |
} |
| 54 |
|
| 55 |
PaTime Device::defaultLowInputLatency() const
|
| 56 |
{
|
| 57 |
if (info_ == NULL) |
| 58 |
return static_cast<PaTime>(0.0); |
| 59 |
|
| 60 |
return info_->defaultLowInputLatency;
|
| 61 |
} |
| 62 |
|
| 63 |
PaTime Device::defaultHighInputLatency() const
|
| 64 |
{
|
| 65 |
if (info_ == NULL) |
| 66 |
return static_cast<PaTime>(0.0); |
| 67 |
|
| 68 |
return info_->defaultHighInputLatency;
|
| 69 |
} |
| 70 |
|
| 71 |
PaTime Device::defaultLowOutputLatency() const
|
| 72 |
{
|
| 73 |
if (info_ == NULL) |
| 74 |
return static_cast<PaTime>(0.0); |
| 75 |
|
| 76 |
return info_->defaultLowOutputLatency;
|
| 77 |
} |
| 78 |
|
| 79 |
PaTime Device::defaultHighOutputLatency() const
|
| 80 |
{
|
| 81 |
if (info_ == NULL) |
| 82 |
return static_cast<PaTime>(0.0); |
| 83 |
|
| 84 |
return info_->defaultHighOutputLatency;
|
| 85 |
} |
| 86 |
|
| 87 |
double Device::defaultSampleRate() const |
| 88 |
{
|
| 89 |
if (info_ == NULL) |
| 90 |
return 0.0; |
| 91 |
|
| 92 |
return info_->defaultSampleRate;
|
| 93 |
} |
| 94 |
|
| 95 |
// -------------------------------------------------------------------------------
|
| 96 |
|
| 97 |
bool Device::isInputOnlyDevice() const |
| 98 |
{
|
| 99 |
return (maxOutputChannels() == 0); |
| 100 |
} |
| 101 |
|
| 102 |
bool Device::isOutputOnlyDevice() const |
| 103 |
{
|
| 104 |
return (maxInputChannels() == 0); |
| 105 |
} |
| 106 |
|
| 107 |
bool Device::isFullDuplexDevice() const |
| 108 |
{
|
| 109 |
return (maxInputChannels() > 0 && maxOutputChannels() > 0); |
| 110 |
} |
| 111 |
|
| 112 |
bool Device::isSystemDefaultInputDevice() const |
| 113 |
{
|
| 114 |
return (System::instance().defaultInputDevice() == *this); |
| 115 |
} |
| 116 |
|
| 117 |
bool Device::isSystemDefaultOutputDevice() const |
| 118 |
{
|
| 119 |
return (System::instance().defaultOutputDevice() == *this); |
| 120 |
} |
| 121 |
|
| 122 |
bool Device::isHostApiDefaultInputDevice() const |
| 123 |
{
|
| 124 |
return (hostApi().defaultInputDevice() == *this); |
| 125 |
} |
| 126 |
|
| 127 |
bool Device::isHostApiDefaultOutputDevice() const |
| 128 |
{
|
| 129 |
return (hostApi().defaultOutputDevice() == *this); |
| 130 |
} |
| 131 |
|
| 132 |
// -------------------------------------------------------------------------------
|
| 133 |
|
| 134 |
bool Device::operator==(const Device &rhs) const |
| 135 |
{
|
| 136 |
return (index_ == rhs.index_);
|
| 137 |
} |
| 138 |
|
| 139 |
bool Device::operator!=(const Device &rhs) const |
| 140 |
{
|
| 141 |
return !(*this == rhs); |
| 142 |
} |
| 143 |
|
| 144 |
// -------------------------------------------------------------------------------
|
| 145 |
|
| 146 |
HostApi &Device::hostApi() |
| 147 |
{
|
| 148 |
// NOTE: will cause an exception when called for the null device
|
| 149 |
if (info_ == NULL) |
| 150 |
throw PaException(paInternalError);
|
| 151 |
|
| 152 |
return System::instance().hostApiByIndex(info_->hostApi);
|
| 153 |
} |
| 154 |
|
| 155 |
const HostApi &Device::hostApi() const |
| 156 |
{
|
| 157 |
// NOTE; will cause an exception when called for the null device
|
| 158 |
if (info_ == NULL) |
| 159 |
throw PaException(paInternalError);
|
| 160 |
|
| 161 |
return System::instance().hostApiByIndex(info_->hostApi);
|
| 162 |
} |
| 163 |
|
| 164 |
// -------------------------------------------------------------------------------
|
| 165 |
|
| 166 |
} // namespace portaudio
|
| 167 |
|
| 168 |
|