[DEV] continue rework of list of device search

This commit is contained in:
Edouard DUPIN 2015-07-07 22:39:09 +02:00
parent 22dd01978a
commit a8c1a92c7a
24 changed files with 275 additions and 245 deletions

View File

@ -115,23 +115,23 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra:
bool result;
if (oChannels > 0) {
if (_oParams->deviceId == -1) {
result = probeDeviceOpenName(_oParams->deviceName,
audio::orchestra::mode_output,
oChannels,
_oParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
result = openName(_oParams->deviceName,
audio::orchestra::mode_output,
oChannels,
_oParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
} else {
result = probeDeviceOpen(_oParams->deviceId,
audio::orchestra::mode_output,
oChannels,
_oParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
result = open(_oParams->deviceId,
audio::orchestra::mode_output,
oChannels,
_oParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
}
if (result == false) {
ATA_ERROR("system ERROR");
@ -140,23 +140,23 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra:
}
if (iChannels > 0) {
if (_iParams->deviceId == -1) {
result = probeDeviceOpenName(_iParams->deviceName,
audio::orchestra::mode_input,
iChannels,
_iParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
result = openName(_iParams->deviceName,
audio::orchestra::mode_input,
iChannels,
_iParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
} else {
result = probeDeviceOpen(_iParams->deviceId,
audio::orchestra::mode_input,
iChannels,
_iParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
result = open(_iParams->deviceId,
audio::orchestra::mode_input,
iChannels,
_iParams->firstChannel,
_sampleRate,
_format,
_bufferFrames,
_options);
}
if (result == false) {
if (oChannels > 0) {
@ -188,14 +188,14 @@ enum audio::orchestra::error audio::orchestra::Api::closeStream() {
return audio::orchestra::error_none;
}
bool audio::orchestra::Api::probeDeviceOpen(uint32_t /*device*/,
audio::orchestra::mode /*mode*/,
uint32_t /*channels*/,
uint32_t /*firstChannel*/,
uint32_t /*sampleRate*/,
audio::format /*format*/,
uint32_t * /*bufferSize*/,
const audio::orchestra::StreamOptions& /*options*/) {
bool audio::orchestra::Api::open(uint32_t /*device*/,
audio::orchestra::mode /*mode*/,
uint32_t /*channels*/,
uint32_t /*firstChannel*/,
uint32_t /*sampleRate*/,
audio::format /*format*/,
uint32_t * /*bufferSize*/,
const audio::orchestra::StreamOptions& /*options*/) {
// MUST be implemented in subclasses!
return false;
}

View File

@ -66,12 +66,12 @@ namespace audio {
virtual uint32_t getDefaultInputDevice();
virtual uint32_t getDefaultOutputDevice();
enum audio::orchestra::error openStream(audio::orchestra::StreamParameters* _outputParameters,
audio::orchestra::StreamParameters* _inputParameters,
audio::format _format,
uint32_t _sampleRate,
uint32_t* _nbChunk,
audio::orchestra::AirTAudioCallback _callback,
const audio::orchestra::StreamOptions& _options);
audio::orchestra::StreamParameters* _inputParameters,
audio::format _format,
uint32_t _sampleRate,
uint32_t* _nbChunk,
audio::orchestra::AirTAudioCallback _callback,
const audio::orchestra::StreamOptions& _options);
virtual enum audio::orchestra::error closeStream();
virtual enum audio::orchestra::error startStream();
virtual enum audio::orchestra::error stopStream() = 0;
@ -119,21 +119,21 @@ namespace audio {
* "warning" message is reported and false is returned. A
* successful probe is indicated by a return value of true.
*/
virtual bool probeDeviceOpen(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
virtual bool probeDeviceOpenName(const std::string& _deviceName,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
virtual bool open(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
virtual bool openName(const std::string& _deviceName,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) { return false; }
/**
* @brief Increment the stream time.

View File

@ -308,11 +308,13 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Alsa::getDeviceInfo(uint32_t
if (nDevices == 0) {
ATA_ERROR("no devices found!");
// TODO : audio::orchestra::error_invalidUse;
info.clear();
return info;
}
if (_device >= nDevices) {
ATA_ERROR("device ID is invalid!");
// TODO : audio::orchestra::error_invalidUse;
info.clear();
return info;
}
@ -326,6 +328,7 @@ foundDevice:
if (_device >= m_devices.size()) {
ATA_ERROR("device ID was not present before stream was opened.");
// TODO : return audio::orchestra::error_warning;
info.clear();
return info;
}
return m_devices[_device];
@ -333,8 +336,10 @@ foundDevice:
bool ret = audio::orchestra::api::Alsa::getNamedDeviceInfoLocal(name, info, card, subdevice, _device, isInput);
if (ret == false) {
// TODO : ...
info.clear();
return info;
}
info.isCorrect = true;
return info;
}
@ -347,14 +352,14 @@ void audio::orchestra::api::Alsa::saveDeviceInfo() {
}
}
bool audio::orchestra::api::Alsa::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Alsa::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
// I'm not using the "plug" interface ... too much inconsistent behavior.
unsigned nDevices = 0;
int32_t result, subdevice, card;
@ -399,17 +404,17 @@ bool audio::orchestra::api::Alsa::probeDeviceOpen(uint32_t _device,
// NOTE : Find the device name : [ END ]
foundDevice:
return probeDeviceOpenName(name, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options);
return openName(name, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options);
}
bool audio::orchestra::api::Alsa::probeDeviceOpenName(const std::string& _deviceName,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Alsa::openName(const std::string& _deviceName,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
ATA_DEBUG("Probe ALSA device : ");
ATA_DEBUG(" _deviceName=" << _deviceName);
ATA_DEBUG(" _mode=" << _mode);

View File

@ -53,23 +53,23 @@ namespace audio {
std11::shared_ptr<AlsaPrivate> m_private;
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool probeDeviceOpen(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
virtual bool probeDeviceOpenName(const std::string& _deviceName,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool openName(const std::string& _deviceName,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
virtual audio::Time getStreamTime();
public:
bool isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api);

View File

@ -133,14 +133,14 @@ void audio::orchestra::api::Android::record(int16_t* _dst, int32_t _nbChunk) {
audio::orchestra::Api::tickStreamTime();
}
bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Android::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool ret = false;
ATA_INFO("Probe : device=" << _device << " channels=" << _channels << " firstChannel=" << _firstChannel << " sampleRate=" << _sampleRate);
m_mode = _mode;
@ -178,7 +178,7 @@ bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device,
uint64_t bufferBytes = m_nUserChannels[modeToIdTable(m_mode)] * m_bufferSize * audio::getFormatBytes(m_userFormat);
m_userBuffer[modeToIdTable(m_mode)].resize(bufferBytes);
if (m_userBuffer[modeToIdTable(m_mode)].size() == 0) {
ATA_ERROR("audio::orchestra::api::Android::probeDeviceOpen: error allocating user buffer memory.");
ATA_ERROR("error allocating user buffer memory.");
}
setConvertInfo(m_mode, _firstChannel);
}

View File

@ -41,14 +41,14 @@ namespace audio {
private:
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
public:
void playback(int16_t* _dst, int32_t _nbChunk);
void record(int16_t* _dst, int32_t _nbChunk);

View File

@ -244,6 +244,7 @@ class AndroidOrchestraContext {
ATA_WARNING("get device information : " << retString);
ejson::Document doc;
if (doc.parse(retString) == false) {
return info;
}
info.name = doc.getStringValue("name", "no-name");
@ -271,7 +272,7 @@ class AndroidOrchestraContext {
}
}
info.isDefault = doc.getBooleanValue("default", false);
//return retString;
info.isCorrect = true;
return info;
}
private:

View File

@ -219,14 +219,14 @@ void audio::orchestra::api::Asio::saveDeviceInfo() {
}
}
bool audio::orchestra::api::Asio::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t* _bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Asio::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t* _bufferSize,
const audio::orchestra::StreamOptions& _options) {
// For ASIO, a duplex stream MUST use the same driver.
if ( _mode == audio::orchestra::mode_input
&& m_mode == audio::orchestra::mode_output

View File

@ -38,14 +38,14 @@ namespace audio {
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool m_coInitialized;
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
};
}
}

View File

@ -433,14 +433,14 @@ static OSStatus rateListener(AudioObjectID _inDevice,
return kAudioHardwareNoError;
}
bool audio::orchestra::api::Core::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Core::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
// Get device ID
uint32_t nDevices = getDeviceCount();
if (nDevices == 0) {

View File

@ -48,14 +48,14 @@ namespace audio {
static void coreStopStream(void *_userData);
private:
std::shared_ptr<CorePrivate> m_private;
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
static const char* getErrorCode(OSStatus _code);
static OSStatus xrunListener(AudioObjectID _inDevice,
uint32_t _nAddresses,

View File

@ -36,18 +36,18 @@ namespace audio {
private:
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
public:
void callBackEvent(void* _data,
int32_t _nbChunk,
const audio::Time& _time);
const audio::Time& _time);
public:
std11::shared_ptr<CoreIosPrivate> m_private;
};

View File

@ -115,7 +115,7 @@ void audio::orchestra::api::CoreIos::callBackEvent(void* _data,
std::vector<enum audio::orchestra::status> status;
if (m_doConvertBuffer[modeToIdTable(audio::orchestra::mode_output)] == true) {
doStopStream = m_callback(nullptr,
audio::Time(),
audio::Time(),
&m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0],
_time,
_nbChunk,
@ -125,7 +125,7 @@ void audio::orchestra::api::CoreIos::callBackEvent(void* _data,
doStopStream = m_callback(_data,
_time,
nullptr,
audio::Time(),
audio::Time(),
_nbChunk,
status);
}
@ -163,14 +163,14 @@ static OSStatus playbackCallback(void *_userData,
}
bool audio::orchestra::api::CoreIos::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::CoreIos::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
ATA_INFO("Probe : device=" << _device << " channels=" << _channels << " firstChannel=" << _firstChannel << " sampleRate=" << _sampleRate);
if (_mode != audio::orchestra::mode_output) {
ATA_ERROR("Can not start a device input or duplex for CoreIos ...");

View File

@ -156,7 +156,7 @@ static BOOL CALLBACK deviceQueryCallback(LPGUID _lpguid,
if (probeInfo.isInput == true) {
DSCCAPS caps;
LPDIRECTSOUNDCAPTURE object;
hr = DirectSoundCaptureCreate(_lpguid, &object, nullptr);
hr = DirectSoundCaptureCreate(_lpguid, &object, nullptr);
if (hr != DS_OK) {
return TRUE;
}
@ -171,7 +171,7 @@ static BOOL CALLBACK deviceQueryCallback(LPGUID _lpguid,
} else {
DSCAPS caps;
LPDIRECTSOUND object;
hr = DirectSoundCreate(_lpguid, &object, nullptr);
hr = DirectSoundCreate(_lpguid, &object, nullptr);
if (hr != DS_OK) {
return TRUE;
}
@ -203,6 +203,9 @@ static BOOL CALLBACK deviceQueryCallback(LPGUID _lpguid,
}
uint32_t audio::orchestra::api::Ds::getDeviceCount() {
if (m_private->dsDevices.size()>0) {
return m_private->dsDevices.size();
}
// Query DirectSound devices.
struct DsProbeData probeInfo;
probeInfo.isInput = false;
@ -230,11 +233,13 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
}
HRESULT result;
if (m_private->dsDevices[_device].input == false) {
info.input = true;
LPDIRECTSOUND output;
DSCAPS outCaps;
result = DirectSoundCreate(m_private->dsDevices[_device].id, &output, nullptr);
if (FAILED(result)) {
ATA_ERROR(getErrorString(result) << ": opening output device (" << m_private->dsDevices[_device].name << ")!");
info.clear();
return info;
}
outCaps.dwSize = sizeof(outCaps);
@ -242,6 +247,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
if (FAILED(result)) {
output->Release();
ATA_ERROR(getErrorString(result) << ": getting capabilities!");
info.clear();
return info;
}
// Get output channel information.
@ -267,12 +273,14 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
}
output->Release();
info.name = m_private->dsDevices[_device].name;
info.isCorrect = true;
return info;
} else {
LPDIRECTSOUNDCAPTURE input;
result = DirectSoundCaptureCreate(m_private->dsDevices[_device].id, &input, nullptr);
if (FAILED(result)) {
ATA_ERROR(getErrorString(result) << ": opening input device (" << m_private->dsDevices[_device].name << ")!");
info.clear();
return info;
}
DSCCAPS inCaps;
@ -281,6 +289,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
if (FAILED(result)) {
input->Release();
ATA_ERROR(getErrorString(result) << ": getting object capabilities (" << m_private->dsDevices[_device].name << ")!");
info.clear();
return info;
}
// Get input channel information.
@ -353,6 +362,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
}
input->Release();
if (info.channels.size() == 0) {
info.clear();
return info;
}
// Copy the supported rates to the info structure but avoid duplication.
@ -372,19 +382,21 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
std::sort(info.sampleRates.begin(), info.sampleRates.end());
// Copy name and return.
info.name = m_private->dsDevices[_device].name;
info.isCorrect = true;
return info;
}
info.clear();
return info;
}
bool audio::orchestra::api::Ds::probeDeviceOpen(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Ds::open(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
if (_channels + _firstChannel > 2) {
ATA_ERROR("DirectSound does not support more than 2 channels per device.");
return false;

View File

@ -40,14 +40,14 @@ namespace audio {
bool m_coInitialized;
bool m_buffersRolling;
long m_duplexPrerollBytes;
bool probeDeviceOpen(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
enum audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
enum audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
};
}
}

View File

@ -48,14 +48,14 @@ enum audio::orchestra::error audio::orchestra::api::Dummy::abortStream() {
return audio::orchestra::error_none;
}
bool audio::orchestra::api::Dummy::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Dummy::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
return false;
}

View File

@ -29,14 +29,14 @@ namespace audio {
enum audio::orchestra::error stopStream();
enum audio::orchestra::error abortStream();
private:
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
};
}
}

View File

@ -136,6 +136,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t
if (client == nullptr) {
ATA_ERROR("Jack server not found or connection error!");
// TODO : audio::orchestra::error_warning;
info.clear();
return info;
}
const char **ports;
@ -199,6 +200,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t
jack_client_close(client);
ATA_ERROR("error determining Jack input/output channels!");
// TODO : audio::orchestra::error_warning;
info.clear();
return info;
}
// Jack always uses 32-bit floats.
@ -208,6 +210,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t
info.isDefault = true;
}
jack_client_close(client);
info.isCorrect = true;
return info;
}
@ -257,14 +260,14 @@ int32_t audio::orchestra::api::Jack::jackXrun(void* _userData) {
return 0;
}
bool audio::orchestra::api::Jack::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t* _bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Jack::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t* _bufferSize,
const audio::orchestra::StreamOptions& _options) {
// Look for jack server and try to become a client (only do once per stream).
jack_client_t *client = 0;
if ( _mode == audio::orchestra::mode_output

View File

@ -42,14 +42,14 @@ namespace audio {
static int32_t jackCallbackHandler(jack_nframes_t _nframes, void* _userData);
private:
std11::shared_ptr<JackPrivate> m_private;
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
};
}
}

View File

@ -85,6 +85,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Oss::getDeviceInfo(uint32_t
int32_t mixerfd = open("/dev/mixer", O_RDWR, 0);
if (mixerfd == -1) {
ATA_ERROR("error opening '/dev/mixer'.");
info.clear();
return info;
}
oss_sysinfo sysinfo;
@ -92,17 +93,20 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Oss::getDeviceInfo(uint32_t
if (result == -1) {
close(mixerfd);
ATA_ERROR("error getting sysinfo, OSS version >= 4.0 is required.");
info.clear();
return info;
}
unsigned nDevices = sysinfo.numaudios;
if (nDevices == 0) {
close(mixerfd);
ATA_ERROR("no devices found!");
info.clear();
return info;
}
if (_device >= nDevices) {
close(mixerfd);
ATA_ERROR("device ID is invalid!");
info.clear();
return info;
}
oss_audioinfo ainfo;
@ -112,6 +116,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Oss::getDeviceInfo(uint32_t
if (result == -1) {
ATA_ERROR("error getting device (" << ainfo.name << ") info.");
error(audio::orchestra::error_warning);
info.clear();
return info;
}
// Probe channels
@ -151,6 +156,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Oss::getDeviceInfo(uint32_t
// Check that we have at least one supported format
if (info.nativeFormats == 0) {
ATA_ERROR("device (" << ainfo.name << ") data format not supported by RtAudio.");
info.clear();
return info;
}
// Probe the supported sample rates.
@ -179,17 +185,18 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Oss::getDeviceInfo(uint32_t
info.probed = true;
info.name = ainfo.name;
}
info.isCorrect = true;
return info;
}
bool audio::orchestra::api::Oss::probeDeviceOpen(uint32_t _device,
StreamMode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
rtaudio::format _format,
uint32_t* _bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Oss::open(uint32_t _device,
StreamMode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t* _bufferSize,
const audio::orchestra::StreamOptions& _options) {
int32_t mixerfd = open("/dev/mixer", O_RDWR, 0);
if (mixerfd == -1) {
ATA_ERROR("error opening '/dev/mixer'.");

View File

@ -35,14 +35,14 @@ namespace audio {
void callbackEvent();
private:
std11::shared_ptr<OssPrivate> m_private;
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
};
}
}

View File

@ -277,14 +277,14 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::abortStream() {
return audio::orchestra::error_none;
}
bool audio::orchestra::api::Pulse::probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
bool audio::orchestra::api::Pulse::open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) {
uint64_t bufferBytes = 0;
pa_sample_spec ss;
if (_device != 0) {

View File

@ -38,14 +38,14 @@ namespace audio {
std11::shared_ptr<PulsePrivate> m_private;
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool probeDeviceOpen(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,
uint32_t _firstChannel,
uint32_t _sampleRate,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options);
};
}
}

View File

@ -213,6 +213,7 @@ static void callbackGetSinkList(pa_context* _contex, const pa_sink_info* _info,
return;
}
audio::orchestra::DeviceInfo info;
info.isCorrect = true;
info.input = false;
info.name = _info->name;
info.desc = _info->description;
@ -231,6 +232,7 @@ static void callbackGetSourceList(pa_context* _contex, const pa_source_info* _in
return;
}
audio::orchestra::DeviceInfo info;
info.isCorrect = true;
info.input = true;
info.name = _info->name;
info.desc = _info->description;