ALSA backend: code cleanup and scoping and indent
This is combination of clang-format and manual edits. The latter mainly to add braces and reduce scope of variables.
This commit is contained in:
parent
6801c2cac2
commit
14961e6bc7
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014-2015 Tim Mayberry <mojofunk@gmail.com>
|
* Copyright (C) 2014-2015 Tim Mayberry <mojofunk@gmail.com>
|
||||||
* Copyright (C) 2014-2018 Paul Davis <paul@linuxaudiosystems.com>
|
* Copyright (C) 2014-2018 Paul Davis <paul@linuxaudiosystems.com>
|
||||||
* Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
|
* Copyright (C) 2014-2021 Robin Gareus <robin@gareus.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -43,6 +43,7 @@
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
||||||
static std::string s_instance_name;
|
static std::string s_instance_name;
|
||||||
|
|
||||||
size_t AlsaAudioBackend::_max_buffer_size = 8192;
|
size_t AlsaAudioBackend::_max_buffer_size = 8192;
|
||||||
std::vector<std::string> AlsaAudioBackend::_midi_options;
|
std::vector<std::string> AlsaAudioBackend::_midi_options;
|
||||||
std::vector<AudioBackend::DeviceStatus> AlsaAudioBackend::_input_audio_device_status;
|
std::vector<AudioBackend::DeviceStatus> AlsaAudioBackend::_input_audio_device_status;
|
||||||
|
@ -113,8 +114,12 @@ AlsaAudioBackend::enumerate_devices () const
|
||||||
std::map<std::string, std::string> devices;
|
std::map<std::string, std::string> devices;
|
||||||
get_alsa_audio_device_names (devices);
|
get_alsa_audio_device_names (devices);
|
||||||
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
||||||
if (_input_audio_device == "") _input_audio_device = i->first;
|
if (_input_audio_device == "") {
|
||||||
if (_output_audio_device == "") _output_audio_device = i->first;
|
_input_audio_device = i->first;
|
||||||
|
}
|
||||||
|
if (_output_audio_device == "") {
|
||||||
|
_output_audio_device = i->first;
|
||||||
|
}
|
||||||
_duplex_audio_device_status.push_back (DeviceStatus (i->first, true));
|
_duplex_audio_device_status.push_back (DeviceStatus (i->first, true));
|
||||||
}
|
}
|
||||||
return _duplex_audio_device_status;
|
return _duplex_audio_device_status;
|
||||||
|
@ -128,7 +133,9 @@ AlsaAudioBackend::enumerate_input_devices () const
|
||||||
get_alsa_audio_device_names (devices, HalfDuplexIn);
|
get_alsa_audio_device_names (devices, HalfDuplexIn);
|
||||||
_input_audio_device_status.push_back (DeviceStatus (get_standard_device_name (DeviceNone), true));
|
_input_audio_device_status.push_back (DeviceStatus (get_standard_device_name (DeviceNone), true));
|
||||||
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
||||||
if (_input_audio_device == "") _input_audio_device = i->first;
|
if (_input_audio_device == "") {
|
||||||
|
_input_audio_device = i->first;
|
||||||
|
}
|
||||||
_input_audio_device_status.push_back (DeviceStatus (i->first, true));
|
_input_audio_device_status.push_back (DeviceStatus (i->first, true));
|
||||||
}
|
}
|
||||||
return _input_audio_device_status;
|
return _input_audio_device_status;
|
||||||
|
@ -142,7 +149,9 @@ AlsaAudioBackend::enumerate_output_devices () const
|
||||||
get_alsa_audio_device_names (devices, HalfDuplexOut);
|
get_alsa_audio_device_names (devices, HalfDuplexOut);
|
||||||
_output_audio_device_status.push_back (DeviceStatus (get_standard_device_name (DeviceNone), true));
|
_output_audio_device_status.push_back (DeviceStatus (get_standard_device_name (DeviceNone), true));
|
||||||
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
||||||
if (_output_audio_device == "") _output_audio_device = i->first;
|
if (_output_audio_device == "") {
|
||||||
|
_output_audio_device = i->first;
|
||||||
|
}
|
||||||
_output_audio_device_status.push_back (DeviceStatus (i->first, true));
|
_output_audio_device_status.push_back (DeviceStatus (i->first, true));
|
||||||
}
|
}
|
||||||
return _output_audio_device_status;
|
return _output_audio_device_status;
|
||||||
|
@ -154,11 +163,9 @@ AlsaAudioBackend::available_sample_rates2 (const std::string& input_device, cons
|
||||||
std::vector<float> sr;
|
std::vector<float> sr;
|
||||||
if (input_device == get_standard_device_name (DeviceNone) && output_device == get_standard_device_name (DeviceNone)) {
|
if (input_device == get_standard_device_name (DeviceNone) && output_device == get_standard_device_name (DeviceNone)) {
|
||||||
return sr;
|
return sr;
|
||||||
}
|
} else if (input_device == get_standard_device_name (DeviceNone)) {
|
||||||
else if (input_device == get_standard_device_name(DeviceNone)) {
|
|
||||||
sr = available_sample_rates (output_device);
|
sr = available_sample_rates (output_device);
|
||||||
}
|
} else if (output_device == get_standard_device_name (DeviceNone)) {
|
||||||
else if (output_device == get_standard_device_name(DeviceNone)) {
|
|
||||||
sr = available_sample_rates (input_device);
|
sr = available_sample_rates (input_device);
|
||||||
} else {
|
} else {
|
||||||
std::vector<float> sr_in = available_sample_rates (input_device);
|
std::vector<float> sr_in = available_sample_rates (input_device);
|
||||||
|
@ -178,8 +185,7 @@ AlsaAudioBackend::available_sample_rates (const std::string& device) const
|
||||||
}
|
}
|
||||||
if (device == _input_audio_device && _input_audio_device_info.valid) {
|
if (device == _input_audio_device && _input_audio_device_info.valid) {
|
||||||
nfo = &_input_audio_device_info;
|
nfo = &_input_audio_device_info;
|
||||||
}
|
} else if (device == _output_audio_device && _output_audio_device_info.valid) {
|
||||||
else if (device == _output_audio_device && _output_audio_device_info.valid) {
|
|
||||||
nfo = &_output_audio_device_info;
|
nfo = &_output_audio_device_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +206,9 @@ AlsaAudioBackend::available_buffer_sizes2 (const std::string& input_device, cons
|
||||||
std::vector<uint32_t> bs;
|
std::vector<uint32_t> bs;
|
||||||
if (input_device == get_standard_device_name (DeviceNone) && output_device == get_standard_device_name (DeviceNone)) {
|
if (input_device == get_standard_device_name (DeviceNone) && output_device == get_standard_device_name (DeviceNone)) {
|
||||||
return bs;
|
return bs;
|
||||||
}
|
} else if (input_device == get_standard_device_name (DeviceNone)) {
|
||||||
else if (input_device == get_standard_device_name(DeviceNone)) {
|
|
||||||
bs = available_buffer_sizes (output_device);
|
bs = available_buffer_sizes (output_device);
|
||||||
}
|
} else if (output_device == get_standard_device_name (DeviceNone)) {
|
||||||
else if (output_device == get_standard_device_name(DeviceNone)) {
|
|
||||||
bs = available_buffer_sizes (input_device);
|
bs = available_buffer_sizes (input_device);
|
||||||
} else {
|
} else {
|
||||||
std::vector<uint32_t> bs_in = available_buffer_sizes (input_device);
|
std::vector<uint32_t> bs_in = available_buffer_sizes (input_device);
|
||||||
|
@ -224,8 +228,7 @@ AlsaAudioBackend::available_buffer_sizes (const std::string& device) const
|
||||||
}
|
}
|
||||||
if (device == _input_audio_device && _input_audio_device_info.valid) {
|
if (device == _input_audio_device && _input_audio_device_info.valid) {
|
||||||
nfo = &_input_audio_device_info;
|
nfo = &_input_audio_device_info;
|
||||||
}
|
} else if (device == _output_audio_device && _output_audio_device_info.valid) {
|
||||||
else if (device == _output_audio_device && _output_audio_device_info.valid) {
|
|
||||||
nfo = &_output_audio_device_info;
|
nfo = &_output_audio_device_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +399,9 @@ AlsaAudioBackend::can_measure_systemic_latency () const
|
||||||
int
|
int
|
||||||
AlsaAudioBackend::set_sample_rate (float sr)
|
AlsaAudioBackend::set_sample_rate (float sr)
|
||||||
{
|
{
|
||||||
if (sr <= 0) { return -1; }
|
if (sr <= 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
_samplerate = sr;
|
_samplerate = sr;
|
||||||
engine.sample_rate_change (sr);
|
engine.sample_rate_change (sr);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -432,7 +437,9 @@ AlsaAudioBackend::set_buffer_size (uint32_t bs)
|
||||||
int
|
int
|
||||||
AlsaAudioBackend::set_interleaved (bool yn)
|
AlsaAudioBackend::set_interleaved (bool yn)
|
||||||
{
|
{
|
||||||
if (!yn) { return 0; }
|
if (!yn) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +487,9 @@ int
|
||||||
AlsaAudioBackend::set_systemic_midi_input_latency (std::string const device, uint32_t sl)
|
AlsaAudioBackend::set_systemic_midi_input_latency (std::string const device, uint32_t sl)
|
||||||
{
|
{
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
||||||
if (!nfo) return -1;
|
if (!nfo) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
nfo->systemic_input_latency = sl;
|
nfo->systemic_input_latency = sl;
|
||||||
if (_run && nfo->enabled) {
|
if (_run && nfo->enabled) {
|
||||||
update_systemic_midi_latencies ();
|
update_systemic_midi_latencies ();
|
||||||
|
@ -492,7 +501,9 @@ int
|
||||||
AlsaAudioBackend::set_systemic_midi_output_latency (std::string const device, uint32_t sl)
|
AlsaAudioBackend::set_systemic_midi_output_latency (std::string const device, uint32_t sl)
|
||||||
{
|
{
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
||||||
if (!nfo) return -1;
|
if (!nfo) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
nfo->systemic_output_latency = sl;
|
nfo->systemic_output_latency = sl;
|
||||||
if (_run && nfo->enabled) {
|
if (_run && nfo->enabled) {
|
||||||
update_systemic_midi_latencies ();
|
update_systemic_midi_latencies ();
|
||||||
|
@ -624,7 +635,9 @@ uint32_t
|
||||||
AlsaAudioBackend::systemic_midi_input_latency (std::string const device) const
|
AlsaAudioBackend::systemic_midi_input_latency (std::string const device) const
|
||||||
{
|
{
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
||||||
if (!nfo) return 0;
|
if (!nfo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return nfo->systemic_input_latency;
|
return nfo->systemic_input_latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,13 +645,16 @@ uint32_t
|
||||||
AlsaAudioBackend::systemic_midi_output_latency (std::string const device) const
|
AlsaAudioBackend::systemic_midi_output_latency (std::string const device) const
|
||||||
{
|
{
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
||||||
if (!nfo) return 0;
|
if (!nfo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return nfo->systemic_output_latency;
|
return nfo->systemic_output_latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MIDI */
|
/* MIDI */
|
||||||
struct AlsaAudioBackend::AlsaMidiDeviceInfo*
|
struct AlsaAudioBackend::AlsaMidiDeviceInfo*
|
||||||
AlsaAudioBackend::midi_device_info(std::string const name) const {
|
AlsaAudioBackend::midi_device_info (std::string const name) const
|
||||||
|
{
|
||||||
for (std::map<std::string, struct AlsaMidiDeviceInfo*>::const_iterator i = _midi_devices.begin (); i != _midi_devices.end (); ++i) {
|
for (std::map<std::string, struct AlsaMidiDeviceInfo*>::const_iterator i = _midi_devices.begin (); i != _midi_devices.end (); ++i) {
|
||||||
if (i->first == name) {
|
if (i->first == name) {
|
||||||
return (i->second);
|
return (i->second);
|
||||||
|
@ -682,8 +698,7 @@ AlsaAudioBackend::enumerate_midi_devices () const
|
||||||
|
|
||||||
if (_midi_driver_option == _("ALSA raw devices")) {
|
if (_midi_driver_option == _("ALSA raw devices")) {
|
||||||
get_alsa_rawmidi_device_names (devices);
|
get_alsa_rawmidi_device_names (devices);
|
||||||
}
|
} else if (_midi_driver_option == _("ALSA sequencer")) {
|
||||||
else if (_midi_driver_option == _("ALSA sequencer")) {
|
|
||||||
get_alsa_sequencer_names (devices);
|
get_alsa_sequencer_names (devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,7 +731,9 @@ int
|
||||||
AlsaAudioBackend::set_midi_device_enabled (std::string const device, bool enable)
|
AlsaAudioBackend::set_midi_device_enabled (std::string const device, bool enable)
|
||||||
{
|
{
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
||||||
if (!nfo) return -1;
|
if (!nfo) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
const bool prev_enabled = nfo->enabled;
|
const bool prev_enabled = nfo->enabled;
|
||||||
nfo->enabled = enable;
|
nfo->enabled = enable;
|
||||||
|
|
||||||
|
@ -731,7 +748,11 @@ AlsaAudioBackend::set_midi_device_enabled (std::string const device, bool enable
|
||||||
for (std::vector<BackendPortPtr>::iterator it = _system_midi_out.begin (); it != _system_midi_out.end ();) {
|
for (std::vector<BackendPortPtr>::iterator it = _system_midi_out.begin (); it != _system_midi_out.end ();) {
|
||||||
assert (_rmidi_out.size () > i);
|
assert (_rmidi_out.size () > i);
|
||||||
AlsaMidiOut* rm = _rmidi_out.at (i);
|
AlsaMidiOut* rm = _rmidi_out.at (i);
|
||||||
if (rm->name () != device) { ++it; ++i; continue; }
|
if (rm->name () != device) {
|
||||||
|
++it;
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
unregister_port (*it);
|
unregister_port (*it);
|
||||||
it = _system_midi_out.erase (it);
|
it = _system_midi_out.erase (it);
|
||||||
rm->stop ();
|
rm->stop ();
|
||||||
|
@ -744,7 +765,11 @@ AlsaAudioBackend::set_midi_device_enabled (std::string const device, bool enable
|
||||||
for (std::vector<BackendPortPtr>::iterator it = _system_midi_in.begin (); it != _system_midi_in.end ();) {
|
for (std::vector<BackendPortPtr>::iterator it = _system_midi_in.begin (); it != _system_midi_in.end ();) {
|
||||||
assert (_rmidi_in.size () > i);
|
assert (_rmidi_in.size () > i);
|
||||||
AlsaMidiIn* rm = _rmidi_in.at (i);
|
AlsaMidiIn* rm = _rmidi_in.at (i);
|
||||||
if (rm->name () != device) { ++it; ++i; continue; }
|
if (rm->name () != device) {
|
||||||
|
++it;
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
unregister_port (*it);
|
unregister_port (*it);
|
||||||
it = _system_midi_in.erase (it);
|
it = _system_midi_in.erase (it);
|
||||||
rm->stop ();
|
rm->stop ();
|
||||||
|
@ -763,13 +788,16 @@ bool
|
||||||
AlsaAudioBackend::midi_device_enabled (std::string const device) const
|
AlsaAudioBackend::midi_device_enabled (std::string const device) const
|
||||||
{
|
{
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (device);
|
||||||
if (!nfo) return false;
|
if (!nfo) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return nfo->enabled;
|
return nfo->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* State Control */
|
/* State Control */
|
||||||
|
|
||||||
static void * pthread_process (void *arg)
|
static void*
|
||||||
|
pthread_process (void* arg)
|
||||||
{
|
{
|
||||||
AlsaAudioBackend* d = static_cast<AlsaAudioBackend*> (arg);
|
AlsaAudioBackend* d = static_cast<AlsaAudioBackend*> (arg);
|
||||||
d->main_process_thread ();
|
d->main_process_thread ();
|
||||||
|
@ -816,6 +844,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
int duplex = 0;
|
int duplex = 0;
|
||||||
std::string audio_device;
|
std::string audio_device;
|
||||||
std::string alsa_device;
|
std::string alsa_device;
|
||||||
|
|
||||||
std::map<std::string, std::string> devices;
|
std::map<std::string, std::string> devices;
|
||||||
|
|
||||||
if (_input_audio_device == get_standard_device_name (DeviceNone) && _output_audio_device == get_standard_device_name (DeviceNone)) {
|
if (_input_audio_device == get_standard_device_name (DeviceNone) && _output_audio_device == get_standard_device_name (DeviceNone)) {
|
||||||
|
@ -916,7 +945,8 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pcmi->state ()) {
|
if (_pcmi->state ()) {
|
||||||
delete _pcmi; _pcmi = 0;
|
delete _pcmi;
|
||||||
|
_pcmi = 0;
|
||||||
_device_reservation.release_device ();
|
_device_reservation.release_device ();
|
||||||
return error_code;
|
return error_code;
|
||||||
}
|
}
|
||||||
|
@ -967,7 +997,8 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
|
|
||||||
if (register_system_audio_ports ()) {
|
if (register_system_audio_ports ()) {
|
||||||
PBD::error << _("AlsaAudioBackend: failed to register system ports.") << endmsg;
|
PBD::error << _("AlsaAudioBackend: failed to register system ports.") << endmsg;
|
||||||
delete _pcmi; _pcmi = 0;
|
delete _pcmi;
|
||||||
|
_pcmi = 0;
|
||||||
_device_reservation.release_device ();
|
_device_reservation.release_device ();
|
||||||
return PortRegistrationError;
|
return PortRegistrationError;
|
||||||
}
|
}
|
||||||
|
@ -977,7 +1008,8 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
|
|
||||||
if (engine.reestablish_ports ()) {
|
if (engine.reestablish_ports ()) {
|
||||||
PBD::error << _("AlsaAudioBackend: Could not re-establish ports.") << endmsg;
|
PBD::error << _("AlsaAudioBackend: Could not re-establish ports.") << endmsg;
|
||||||
delete _pcmi; _pcmi = 0;
|
delete _pcmi;
|
||||||
|
_pcmi = 0;
|
||||||
_device_reservation.release_device ();
|
_device_reservation.release_device ();
|
||||||
return PortReconnectError;
|
return PortReconnectError;
|
||||||
}
|
}
|
||||||
|
@ -986,11 +1018,11 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
g_atomic_int_set (&_port_change_flag, 0);
|
g_atomic_int_set (&_port_change_flag, 0);
|
||||||
|
|
||||||
if (pbd_realtime_pthread_create (PBD_SCHED_FIFO, PBD_RT_PRI_MAIN, PBD_RT_STACKSIZE_PROC,
|
if (pbd_realtime_pthread_create (PBD_SCHED_FIFO, PBD_RT_PRI_MAIN, PBD_RT_STACKSIZE_PROC,
|
||||||
&_main_thread, pthread_process, this))
|
&_main_thread, pthread_process, this)) {
|
||||||
{
|
|
||||||
if (pbd_pthread_create (PBD_RT_STACKSIZE_PROC, &_main_thread, pthread_process, this)) {
|
if (pbd_pthread_create (PBD_RT_STACKSIZE_PROC, &_main_thread, pthread_process, this)) {
|
||||||
PBD::error << _("AlsaAudioBackend: failed to create process thread.") << endmsg;
|
PBD::error << _("AlsaAudioBackend: failed to create process thread.") << endmsg;
|
||||||
delete _pcmi; _pcmi = 0;
|
delete _pcmi;
|
||||||
|
_pcmi = 0;
|
||||||
_device_reservation.release_device ();
|
_device_reservation.release_device ();
|
||||||
_run = false;
|
_run = false;
|
||||||
return ProcessThreadStartError;
|
return ProcessThreadStartError;
|
||||||
|
@ -1000,11 +1032,14 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeout = 5000;
|
int timeout = 5000;
|
||||||
while (!_active && --timeout > 0) { Glib::usleep (1000); }
|
while (!_active && --timeout > 0) {
|
||||||
|
Glib::usleep (1000);
|
||||||
|
}
|
||||||
|
|
||||||
if (timeout == 0 || !_active) {
|
if (timeout == 0 || !_active) {
|
||||||
PBD::error << _("AlsaAudioBackend: failed to start process thread.") << endmsg;
|
PBD::error << _("AlsaAudioBackend: failed to start process thread.") << endmsg;
|
||||||
delete _pcmi; _pcmi = 0;
|
delete _pcmi;
|
||||||
|
_pcmi = 0;
|
||||||
_device_reservation.release_device ();
|
_device_reservation.release_device ();
|
||||||
_run = false;
|
_run = false;
|
||||||
return ProcessThreadStartError;
|
return ProcessThreadStartError;
|
||||||
|
@ -1028,7 +1063,9 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
if (NULL != getenv ("ARDOUR_ALSA_EXT")) {
|
if (NULL != getenv ("ARDOUR_ALSA_EXT")) {
|
||||||
boost::char_separator<char> sep (";");
|
boost::char_separator<char> sep (";");
|
||||||
std::string ext (getenv ("ARDOUR_ALSA_EXT"));
|
std::string ext (getenv ("ARDOUR_ALSA_EXT"));
|
||||||
|
|
||||||
boost::tokenizer<boost::char_separator<char> > devs (ext, sep);
|
boost::tokenizer<boost::char_separator<char> > devs (ext, sep);
|
||||||
|
|
||||||
BOOST_FOREACH (const std::string& tmp, devs) {
|
BOOST_FOREACH (const std::string& tmp, devs) {
|
||||||
std::string dev (tmp);
|
std::string dev (tmp);
|
||||||
unsigned int sr = _samplerate;
|
unsigned int sr = _samplerate;
|
||||||
|
@ -1036,14 +1073,17 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
||||||
unsigned int ppc = _periods_per_cycle;
|
unsigned int ppc = _periods_per_cycle;
|
||||||
AudioSlave::DuplexMode duplex = AudioSlave::FullDuplex;
|
AudioSlave::DuplexMode duplex = AudioSlave::FullDuplex;
|
||||||
std::string::size_type n = dev.find ('@');
|
std::string::size_type n = dev.find ('@');
|
||||||
|
|
||||||
if (n != std::string::npos) {
|
if (n != std::string::npos) {
|
||||||
std::string const opt (dev.substr (n + 1));
|
std::string const opt (dev.substr (n + 1));
|
||||||
sr = PBD::atoi (opt);
|
sr = PBD::atoi (opt);
|
||||||
dev = dev.substr (0, n);
|
dev = dev.substr (0, n);
|
||||||
|
|
||||||
std::string::size_type n = opt.find ('/');
|
std::string::size_type n = opt.find ('/');
|
||||||
if (n != std::string::npos) {
|
if (n != std::string::npos) {
|
||||||
std::string const opt2 (opt.substr (n + 1));
|
std::string const opt2 (opt.substr (n + 1));
|
||||||
spp = PBD::atoi (opt2);
|
spp = PBD::atoi (opt2);
|
||||||
|
|
||||||
std::string::size_type n = opt2.find ('*');
|
std::string::size_type n = opt2.find ('*');
|
||||||
if (n != std::string::npos) {
|
if (n != std::string::npos) {
|
||||||
ppc = PBD::atoi (opt2.substr (n + 1));
|
ppc = PBD::atoi (opt2.substr (n + 1));
|
||||||
|
@ -1100,7 +1140,8 @@ AlsaAudioBackend::stop ()
|
||||||
}
|
}
|
||||||
|
|
||||||
unregister_ports ();
|
unregister_ports ();
|
||||||
delete _pcmi; _pcmi = 0;
|
delete _pcmi;
|
||||||
|
_pcmi = 0;
|
||||||
_device_reservation.release_device ();
|
_device_reservation.release_device ();
|
||||||
_measure_latency = false;
|
_measure_latency = false;
|
||||||
|
|
||||||
|
@ -1159,7 +1200,6 @@ AlsaAudioBackend::samples_since_cycle_start ()
|
||||||
return std::max ((pframes_t)0, (pframes_t)rint (1e-6 * elapsed_time_us * _samplerate));
|
return std::max ((pframes_t)0, (pframes_t)rint (1e-6 * elapsed_time_us * _samplerate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
AlsaAudioBackend::alsa_process_thread (void* arg)
|
AlsaAudioBackend::alsa_process_thread (void* arg)
|
||||||
{
|
{
|
||||||
|
@ -1192,8 +1232,7 @@ AlsaAudioBackend::join_process_threads ()
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
for (std::vector<pthread_t>::const_iterator i = _threads.begin (); i != _threads.end (); ++i)
|
for (std::vector<pthread_t>::const_iterator i = _threads.begin (); i != _threads.end (); ++i) {
|
||||||
{
|
|
||||||
void* status;
|
void* status;
|
||||||
if (pthread_join (*i, &status)) {
|
if (pthread_join (*i, &status)) {
|
||||||
PBD::error << _("AudioEngine: cannot terminate process thread.") << endmsg;
|
PBD::error << _("AudioEngine: cannot terminate process thread.") << endmsg;
|
||||||
|
@ -1211,8 +1250,7 @@ AlsaAudioBackend::in_process_thread ()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<pthread_t>::const_iterator i = _threads.begin (); i != _threads.end (); ++i)
|
for (std::vector<pthread_t>::const_iterator i = _threads.begin (); i != _threads.end (); ++i) {
|
||||||
{
|
|
||||||
if (pthread_equal (*i, pthread_self ()) != 0) {
|
if (pthread_equal (*i, pthread_self ()) != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1263,7 +1301,8 @@ AlsaAudioBackend::register_system_audio_ports()
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
snprintf (tmp, sizeof (tmp), "system:capture_%d", i);
|
snprintf (tmp, sizeof (tmp), "system:capture_%d", i);
|
||||||
PortHandle p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsOutput | IsPhysical | IsTerminal));
|
PortHandle p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsOutput | IsPhysical | IsTerminal));
|
||||||
if (!p) return -1;
|
if (!p)
|
||||||
|
return -1;
|
||||||
set_latency_range (p, false, lr);
|
set_latency_range (p, false, lr);
|
||||||
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
||||||
ap->set_hw_port_name (string_compose (_("Main In %1"), i));
|
ap->set_hw_port_name (string_compose (_("Main In %1"), i));
|
||||||
|
@ -1275,7 +1314,8 @@ AlsaAudioBackend::register_system_audio_ports()
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
snprintf (tmp, sizeof (tmp), "system:playback_%d", i);
|
snprintf (tmp, sizeof (tmp), "system:playback_%d", i);
|
||||||
PortHandle p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsInput | IsPhysical | IsTerminal));
|
PortHandle p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsInput | IsPhysical | IsTerminal));
|
||||||
if (!p) return -1;
|
if (!p)
|
||||||
|
return -1;
|
||||||
set_latency_range (p, true, lr);
|
set_latency_range (p, true, lr);
|
||||||
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
||||||
if (a_out == 2) {
|
if (a_out == 2) {
|
||||||
|
@ -1437,7 +1477,6 @@ AlsaAudioBackend::update_system_port_latencies ()
|
||||||
pthread_mutex_unlock (&_device_port_mutex);
|
pthread_mutex_unlock (&_device_port_mutex);
|
||||||
|
|
||||||
for (AudioSlaves::iterator s = _slaves.begin (); s != _slaves.end (); ++s) {
|
for (AudioSlaves::iterator s = _slaves.begin (); s != _slaves.end (); ++s) {
|
||||||
|
|
||||||
if ((*s)->dead) {
|
if ((*s)->dead) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1456,7 +1495,8 @@ AlsaAudioBackend::update_system_port_latencies ()
|
||||||
* " (IO)", " (I)", or " (O)"
|
* " (IO)", " (I)", or " (O)"
|
||||||
* depending of the device is full-duples or half-duplex
|
* depending of the device is full-duples or half-duplex
|
||||||
*/
|
*/
|
||||||
static std::string replace_name_io (std::string const& name, bool in)
|
static std::string
|
||||||
|
replace_name_io (std::string const& name, bool in)
|
||||||
{
|
{
|
||||||
if (name.empty ()) {
|
if (name.empty ()) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -1503,8 +1543,12 @@ AlsaAudioBackend::register_system_midi_ports(const std::string device)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
struct AlsaMidiDeviceInfo* nfo = midi_device_info (i->first);
|
struct AlsaMidiDeviceInfo* nfo = midi_device_info (i->first);
|
||||||
if (!nfo) continue;
|
if (!nfo) {
|
||||||
if (!nfo->enabled) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (!nfo->enabled) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
AlsaMidiOut* mout;
|
AlsaMidiOut* mout;
|
||||||
if (_midi_driver_option == _("ALSA raw devices")) {
|
if (_midi_driver_option == _("ALSA raw devices")) {
|
||||||
|
@ -1514,17 +1558,13 @@ AlsaAudioBackend::register_system_midi_ports(const std::string device)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mout->state ()) {
|
if (mout->state ()) {
|
||||||
PBD::warning << string_compose (
|
PBD::warning << string_compose (_("AlsaMidiOut: failed to open midi device '%1'."), i->second) << endmsg;
|
||||||
_("AlsaMidiOut: failed to open midi device '%1'."), i->second)
|
|
||||||
<< endmsg;
|
|
||||||
delete mout;
|
delete mout;
|
||||||
} else {
|
} else {
|
||||||
mout->setup_timing (_samples_per_period, _samplerate);
|
mout->setup_timing (_samples_per_period, _samplerate);
|
||||||
mout->sync_time (g_get_monotonic_time ());
|
mout->sync_time (g_get_monotonic_time ());
|
||||||
if (mout->start ()) {
|
if (mout->start ()) {
|
||||||
PBD::warning << string_compose (
|
PBD::warning << string_compose (_("AlsaMidiOut: failed to start midi device '%1'."), i->second) << endmsg;
|
||||||
_("AlsaMidiOut: failed to start midi device '%1'."), i->second)
|
|
||||||
<< endmsg;
|
|
||||||
delete mout;
|
delete mout;
|
||||||
} else {
|
} else {
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
|
@ -1561,17 +1601,13 @@ AlsaAudioBackend::register_system_midi_ports(const std::string device)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (midin->state ()) {
|
if (midin->state ()) {
|
||||||
PBD::warning << string_compose (
|
PBD::warning << string_compose (_("AlsaMidiIn: failed to open midi device '%1'."), i->second) << endmsg;
|
||||||
_("AlsaMidiIn: failed to open midi device '%1'."), i->second)
|
|
||||||
<< endmsg;
|
|
||||||
delete midin;
|
delete midin;
|
||||||
} else {
|
} else {
|
||||||
midin->setup_timing (_samples_per_period, _samplerate);
|
midin->setup_timing (_samples_per_period, _samplerate);
|
||||||
midin->sync_time (g_get_monotonic_time ());
|
midin->sync_time (g_get_monotonic_time ());
|
||||||
if (midin->start ()) {
|
if (midin->start ()) {
|
||||||
PBD::warning << string_compose (
|
PBD::warning << string_compose (_("AlsaMidiIn: failed to start midi device '%1'."), i->second) << endmsg;
|
||||||
_("AlsaMidiIn: failed to start midi device '%1'."), i->second)
|
|
||||||
<< endmsg;
|
|
||||||
delete midin;
|
delete midin;
|
||||||
} else {
|
} else {
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
|
@ -1762,9 +1798,9 @@ void *
|
||||||
AlsaAudioBackend::main_process_thread ()
|
AlsaAudioBackend::main_process_thread ()
|
||||||
{
|
{
|
||||||
AudioEngine::thread_init_callback (this);
|
AudioEngine::thread_init_callback (this);
|
||||||
_active = true;
|
|
||||||
bool reset_dll = true;
|
bool reset_dll = true;
|
||||||
int last_n_periods = 0;
|
int last_n_periods = 0;
|
||||||
|
_active = true;
|
||||||
_processed_samples = 0;
|
_processed_samples = 0;
|
||||||
|
|
||||||
double dll_dt = (double)_samples_per_period / (double)_samplerate;
|
double dll_dt = (double)_samples_per_period / (double)_samplerate;
|
||||||
|
@ -1869,10 +1905,7 @@ AlsaAudioBackend::main_process_thread ()
|
||||||
}
|
}
|
||||||
if (no_proc_errors > bailout) {
|
if (no_proc_errors > bailout) {
|
||||||
PBD::error
|
PBD::error
|
||||||
<< string_compose (
|
<< string_compose (_("AlsaAudioBackend: Audio Process Terminated after %1 consecutive xruns."), no_proc_errors) << endmsg;
|
||||||
_("AlsaAudioBackend: Audio Process Terminated after %1 consecutive xruns."),
|
|
||||||
no_proc_errors)
|
|
||||||
<< endmsg;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2065,7 +2098,6 @@ AlsaAudioBackend::main_process_thread ()
|
||||||
engine.latency_callback (false);
|
engine.latency_callback (false);
|
||||||
engine.latency_callback (true);
|
engine.latency_callback (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
_pcmi->pcm_stop ();
|
_pcmi->pcm_stop ();
|
||||||
_active = false;
|
_active = false;
|
||||||
|
@ -2105,7 +2137,9 @@ AlsaAudioBackend::add_slave (const char* device,
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
PortPtr p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsOutput | IsPhysical | IsTerminal));
|
PortPtr p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsOutput | IsPhysical | IsTerminal));
|
||||||
if (!p) goto errout;
|
if (!p) {
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
||||||
ap->set_hw_port_name (string_compose (_("Aux In %1"), n));
|
ap->set_hw_port_name (string_compose (_("Aux In %1"), n));
|
||||||
s->inputs.push_back (ap);
|
s->inputs.push_back (ap);
|
||||||
|
@ -2122,7 +2156,9 @@ AlsaAudioBackend::add_slave (const char* device,
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
PortPtr p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsInput | IsPhysical | IsTerminal));
|
PortPtr p = add_port (std::string (tmp), DataType::AUDIO, static_cast<PortFlags> (IsInput | IsPhysical | IsTerminal));
|
||||||
if (!p) goto errout;
|
if (!p) {
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
BackendPortPtr ap = boost::dynamic_pointer_cast<BackendPort> (p);
|
||||||
ap->set_hw_port_name (string_compose (_("Aux Out %1"), n));
|
ap->set_hw_port_name (string_compose (_("Aux Out %1"), n));
|
||||||
s->outputs.push_back (ap);
|
s->outputs.push_back (ap);
|
||||||
|
@ -2253,7 +2289,6 @@ extern "C" ARDOURBACKEND_API ARDOUR::AudioBackendInfo* descriptor ()
|
||||||
return &_descriptor;
|
return &_descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -2294,7 +2329,6 @@ AlsaAudioPort::get_buffer (pframes_t n_samples)
|
||||||
return _buffer;
|
return _buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AlsaMidiPort::AlsaMidiPort (AlsaAudioBackend& b, const std::string& name, PortFlags flags)
|
AlsaMidiPort::AlsaMidiPort (AlsaAudioBackend& b, const std::string& name, PortFlags flags)
|
||||||
: BackendPort (b, name, flags)
|
: BackendPort (b, name, flags)
|
||||||
, _n_periods (1)
|
, _n_periods (1)
|
||||||
|
@ -2314,7 +2348,8 @@ AlsaMidiPort::~AlsaMidiPort ()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MidiEventSorter {
|
struct MidiEventSorter {
|
||||||
bool operator() (AlsaMidiEvent const& a, AlsaMidiEvent const& b) {
|
bool operator() (AlsaMidiEvent const& a, AlsaMidiEvent const& b)
|
||||||
|
{
|
||||||
return a < b;
|
return a < b;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2360,7 +2395,8 @@ AlsaMidiEvent::AlsaMidiEvent (const AlsaMidiEvent& other)
|
||||||
|
|
||||||
AlsaDeviceReservation::AlsaDeviceReservation ()
|
AlsaDeviceReservation::AlsaDeviceReservation ()
|
||||||
: _device_reservation (0)
|
: _device_reservation (0)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
AlsaDeviceReservation::AlsaDeviceReservation (const char* device_name)
|
AlsaDeviceReservation::AlsaDeviceReservation (const char* device_name)
|
||||||
: _device_reservation (0)
|
: _device_reservation (0)
|
||||||
|
@ -2377,17 +2413,17 @@ bool
|
||||||
AlsaDeviceReservation::acquire_device (const char* device_name)
|
AlsaDeviceReservation::acquire_device (const char* device_name)
|
||||||
{
|
{
|
||||||
int device_number = card_to_num (device_name);
|
int device_number = card_to_num (device_name);
|
||||||
if (device_number < 0) return false;
|
if (device_number < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
assert (_device_reservation == 0);
|
assert (_device_reservation == 0);
|
||||||
_reservation_succeeded = false;
|
_reservation_succeeded = false;
|
||||||
|
|
||||||
std::string request_device_exe;
|
std::string request_device_exe;
|
||||||
if (!PBD::find_file (
|
if (!PBD::find_file (
|
||||||
PBD::Searchpath(Glib::build_filename(ARDOUR::ardour_dll_directory(), "ardouralsautil")
|
PBD::Searchpath (Glib::build_filename (ARDOUR::ardour_dll_directory (), "ardouralsautil") + G_SEARCHPATH_SEPARATOR_S + ARDOUR::ardour_dll_directory ()),
|
||||||
+ G_SEARCHPATH_SEPARATOR_S + ARDOUR::ardour_dll_directory()),
|
"ardour-request-device", request_device_exe)) {
|
||||||
"ardour-request-device", request_device_exe))
|
|
||||||
{
|
|
||||||
PBD::warning << "ardour-request-device binary was not found..'" << endmsg;
|
PBD::warning << "ardour-request-device binary was not found..'" << endmsg;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2443,4 +2479,3 @@ AlsaDeviceReservation::reservation_stdout (std::string d, size_t /* s */)
|
||||||
_reservation_succeeded = true;
|
_reservation_succeeded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
#ifndef __libbackend_alsa_audiobackend_h__
|
#ifndef __libbackend_alsa_audiobackend_h__
|
||||||
#define __libbackend_alsa_audiobackend_h__
|
#define __libbackend_alsa_audiobackend_h__
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
@ -41,10 +41,10 @@
|
||||||
|
|
||||||
#include "ardouralsautil/deviceinfo.h"
|
#include "ardouralsautil/deviceinfo.h"
|
||||||
|
|
||||||
#include "zita-alsa-pcmi.h"
|
|
||||||
#include "alsa_rawmidi.h"
|
#include "alsa_rawmidi.h"
|
||||||
#include "alsa_sequencer.h"
|
#include "alsa_sequencer.h"
|
||||||
#include "alsa_slave.h"
|
#include "alsa_slave.h"
|
||||||
|
#include "zita-alsa-pcmi.h"
|
||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,23 +1,20 @@
|
||||||
// ----------------------------------------------------------------------------
|
/*
|
||||||
//
|
* Copyright (C) 2006-2012 Fons Adriaensen <fons@linuxaudio.org>
|
||||||
// Copyright (C) 2006-2012 Fons Adriaensen <fons@linuxaudio.org>
|
* Copyright (C) 2014-2021 Robin Gareus <robin@gareus.org>
|
||||||
// Copyright (C) 2014-2021 Robin Gareus <robin@gareus.org>
|
*
|
||||||
//
|
* This program is free software; you can redistribute it and/or modify
|
||||||
// This program is free software; you can redistribute it and/or modify
|
* it under the terms of the GNU General Public License as published by
|
||||||
// it under the terms of the GNU General Public License as published by
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
// the Free Software Foundation; either version 3 of the License, or
|
* (at your option) any later version.
|
||||||
// (at your option) any later version.
|
*
|
||||||
//
|
* This program is distributed in the hope that it will be useful,
|
||||||
// This program is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details.
|
||||||
// GNU General Public License for more details.
|
*
|
||||||
//
|
* You should have received a copy of the GNU General Public License
|
||||||
// You should have received a copy of the GNU General Public License
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
*/
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _ZITA_ALSA_PCMI_H_
|
#ifndef _ZITA_ALSA_PCMI_H_
|
||||||
#define _ZITA_ALSA_PCMI_H_
|
#define _ZITA_ALSA_PCMI_H_
|
||||||
|
@ -31,7 +28,6 @@
|
||||||
class Alsa_pcmi
|
class Alsa_pcmi
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Alsa_pcmi (
|
Alsa_pcmi (
|
||||||
const char* play_name,
|
const char* play_name,
|
||||||
const char* capt_name,
|
const char* capt_name,
|
||||||
|
@ -44,8 +40,7 @@ public:
|
||||||
|
|
||||||
~Alsa_pcmi (void);
|
~Alsa_pcmi (void);
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
DEBUG_INIT = 0x001,
|
DEBUG_INIT = 0x001,
|
||||||
DEBUG_STAT = 0x002,
|
DEBUG_STAT = 0x002,
|
||||||
DEBUG_WAIT = 0x004,
|
DEBUG_WAIT = 0x004,
|
||||||
|
@ -60,9 +55,10 @@ public:
|
||||||
|
|
||||||
int pcm_start (void);
|
int pcm_start (void);
|
||||||
int pcm_stop (void);
|
int pcm_stop (void);
|
||||||
snd_pcm_sframes_t pcm_wait (void);
|
|
||||||
int pcm_idle (int len);
|
int pcm_idle (int len);
|
||||||
|
|
||||||
|
snd_pcm_sframes_t pcm_wait (void);
|
||||||
|
|
||||||
int play_init (snd_pcm_uframes_t len);
|
int play_init (snd_pcm_uframes_t len);
|
||||||
void clear_chan (int chan, int len);
|
void clear_chan (int chan, int len);
|
||||||
void play_chan (int chan, const float* src, int len, int step = 1);
|
void play_chan (int chan, const float* src, int len, int step = 1);
|
||||||
|
@ -102,21 +98,23 @@ public:
|
||||||
int state (void) const { return _state; }
|
int state (void) const { return _state; }
|
||||||
size_t fsize (void) const { return _fsize; }
|
size_t fsize (void) const { return _fsize; }
|
||||||
uint32_t fsamp (void) const { return _fsamp; }
|
uint32_t fsamp (void) const { return _fsamp; }
|
||||||
|
|
||||||
uint32_t play_nfrag (void) const { return _play_nfrag; }
|
uint32_t play_nfrag (void) const { return _play_nfrag; }
|
||||||
uint32_t capt_nfrag (void) const { return _capt_nfrag; }
|
uint32_t capt_nfrag (void) const { return _capt_nfrag; }
|
||||||
|
|
||||||
uint32_t nplay (void) const { return _play_nchan; }
|
uint32_t nplay (void) const { return _play_nchan; }
|
||||||
uint32_t ncapt (void) const { return _capt_nchan; }
|
uint32_t ncapt (void) const { return _capt_nchan; }
|
||||||
|
|
||||||
snd_pcm_t* play_handle (void) const { return _play_handle; }
|
snd_pcm_t* play_handle (void) const { return _play_handle; }
|
||||||
snd_pcm_t* capt_handle (void) const { return _capt_handle; }
|
snd_pcm_t* capt_handle (void) const { return _capt_handle; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef char* (Alsa_pcmi::*clear_function) (char*, int);
|
typedef char* (Alsa_pcmi::*clear_function) (char*, int);
|
||||||
typedef char* (Alsa_pcmi::*play_function) (const float*, char*, int, int);
|
typedef char* (Alsa_pcmi::*play_function) (const float*, char*, int, int);
|
||||||
typedef const char* (Alsa_pcmi::*capt_function) (const char*, float*, int, int);
|
typedef const char* (Alsa_pcmi::*capt_function) (const char*, float*, int, int);
|
||||||
|
|
||||||
enum { MAXPFD = 16, MAXCHAN = 128 };
|
enum { MAXPFD = 16,
|
||||||
|
MAXCHAN = 128 };
|
||||||
|
|
||||||
void initialise (const char* play_name, const char* capt_name, const char* ctrl_name);
|
void initialise (const char* play_name, const char* capt_name, const char* ctrl_name);
|
||||||
int set_hwpar (snd_pcm_t* handle, snd_pcm_hw_params_t* hwpar, const char* sname, unsigned int nfrag, unsigned int* nchan);
|
int set_hwpar (snd_pcm_t* handle, snd_pcm_hw_params_t* hwpar, const char* sname, unsigned int nfrag, unsigned int* nchan);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user