'libs/ardour' - Use 'std::vector' instead of dynamically sized arrays (required to be buildable with MSVC)
This commit is contained in:
parent
fa59391f6a
commit
07d94b9b48
|
@ -22,6 +22,7 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
||||
#include <glibmm.h>
|
||||
|
||||
|
@ -37,15 +38,15 @@ namespace ARDOUR
|
|||
static void
|
||||
snprintf_bounded_null_filled (char* target, size_t target_size, char const * fmt, ...)
|
||||
{
|
||||
char buf[target_size+1];
|
||||
std::vector<char> buf(target_size+1);
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsnprintf (buf, target_size+1, fmt, ap);
|
||||
vsnprintf (&buf[0], target_size+1, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
memset (target, 0, target_size);
|
||||
memcpy (target, buf, target_size);
|
||||
memcpy (target, &buf[0], target_size);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "ardour/export_graph_builder.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <glibmm/miscutils.h>
|
||||
|
||||
#include "audiographer/process_context.h"
|
||||
|
@ -317,8 +319,8 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe
|
|||
{
|
||||
std::string tmpfile_path = parent.session.session_directory().export_path();
|
||||
tmpfile_path = Glib::build_filename(tmpfile_path, "XXXXXX");
|
||||
char tmpfile_path_buf[tmpfile_path.size() + 1];
|
||||
std::copy(tmpfile_path.begin(), tmpfile_path.end(), tmpfile_path_buf);
|
||||
std::vector<char> tmpfile_path_buf(tmpfile_path.size() + 1);
|
||||
std::copy(tmpfile_path.begin(), tmpfile_path.end(), tmpfile_path_buf.begin());
|
||||
tmpfile_path_buf[tmpfile_path.size()] = '\0';
|
||||
|
||||
config = new_config;
|
||||
|
@ -334,7 +336,7 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe
|
|||
normalizer->add_output (threader);
|
||||
|
||||
int format = ExportFormatBase::F_RAW | ExportFormatBase::SF_Float;
|
||||
tmp_file.reset (new TmpFile<float> (tmpfile_path_buf, format, channels, config.format->sample_rate()));
|
||||
tmp_file.reset (new TmpFile<float> (&tmpfile_path_buf[0], format, channels, config.format->sample_rate()));
|
||||
tmp_file->FileWritten.connect_same_thread (post_processing_connection,
|
||||
boost::bind (&Normalizer::start_post_processing, this));
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
@ -1379,20 +1380,20 @@ IO::build_legal_port_name (DataType type)
|
|||
|
||||
limit = name_size - _session.engine().client_name().length() - (suffix.length() + 5);
|
||||
|
||||
char buf1[name_size+1];
|
||||
char buf2[name_size+1];
|
||||
std::vector<char> buf1(name_size+1);
|
||||
std::vector<char> buf2(name_size+1);
|
||||
|
||||
/* colons are illegal in port names, so fix that */
|
||||
|
||||
string nom = _name.val();
|
||||
replace_all (nom, ":", ";");
|
||||
|
||||
snprintf (buf1, name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str());
|
||||
snprintf (&buf1[0], name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str());
|
||||
|
||||
int port_number = find_port_hole (buf1);
|
||||
snprintf (buf2, name_size+1, "%s %d", buf1, port_number);
|
||||
int port_number = find_port_hole (&buf1[0]);
|
||||
snprintf (&buf2[0], name_size+1, "%s %d", buf1, port_number);
|
||||
|
||||
return string (buf2);
|
||||
return string (&buf2[0]);
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
@ -1410,13 +1411,13 @@ IO::find_port_hole (const char* base)
|
|||
*/
|
||||
|
||||
for (n = 1; n < 9999; ++n) {
|
||||
char buf[jack_port_name_size()];
|
||||
std::vector<char> buf(jack_port_name_size());
|
||||
PortSet::iterator i = _ports.begin();
|
||||
|
||||
snprintf (buf, jack_port_name_size(), _("%s %u"), base, n);
|
||||
snprintf (&buf[0], jack_port_name_size(), _("%s %u"), base, n);
|
||||
|
||||
for ( ; i != _ports.end(); ++i) {
|
||||
if (i->name() == buf) {
|
||||
if (string(i->name()) == string(&buf[0])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -919,8 +919,8 @@ LadspaPlugin::do_save_preset (string name)
|
|||
|
||||
lrdf_defaults defaults;
|
||||
defaults.count = input_parameter_pids.size ();
|
||||
lrdf_portvalue portvalues[input_parameter_pids.size()];
|
||||
defaults.items = portvalues;
|
||||
std::vector<lrdf_portvalue> portvalues(input_parameter_pids.size());
|
||||
defaults.items = &portvalues[0];
|
||||
|
||||
for (vector<int>::size_type i = 0; i < input_parameter_pids.size(); ++i) {
|
||||
portvalues[i].pid = input_parameter_pids[i];
|
||||
|
|
|
@ -1119,16 +1119,16 @@ LV2Plugin::write_to(RingBuffer<uint8_t>* dest,
|
|||
uint32_t size,
|
||||
const uint8_t* body)
|
||||
{
|
||||
const uint32_t buf_size = sizeof(UIMessage) + size;
|
||||
uint8_t buf[buf_size];
|
||||
const uint32_t buf_size = sizeof(UIMessage) + size;
|
||||
vector<uint8_t> buf(buf_size);
|
||||
|
||||
UIMessage* msg = (UIMessage*)buf;
|
||||
UIMessage* msg = (UIMessage*)&buf[0];
|
||||
msg->index = index;
|
||||
msg->protocol = protocol;
|
||||
msg->size = size;
|
||||
memcpy(msg + 1, body, size);
|
||||
|
||||
return (dest->write(buf, buf_size) == buf_size);
|
||||
return (dest->write(&buf[0], buf_size) == buf_size);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1185,13 +1185,13 @@ LV2Plugin::emit_to_ui(void* controller, UIMessageSink sink)
|
|||
error << "Error reading from Plugin=>UI RingBuffer" << endmsg;
|
||||
break;
|
||||
}
|
||||
uint8_t body[msg.size];
|
||||
if (_to_ui->read(body, msg.size) != msg.size) {
|
||||
vector<uint8_t> body(msg.size);
|
||||
if (_to_ui->read(&body[0], msg.size) != msg.size) {
|
||||
error << "Error reading from Plugin=>UI RingBuffer" << endmsg;
|
||||
break;
|
||||
}
|
||||
|
||||
sink(controller, msg.index, msg.size, msg.protocol, body);
|
||||
sink(controller, msg.index, msg.size, msg.protocol, &body[0]);
|
||||
|
||||
read_space -= sizeof(msg) + msg.size;
|
||||
}
|
||||
|
@ -1671,15 +1671,15 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
error << "Error reading from UI=>Plugin RingBuffer" << endmsg;
|
||||
break;
|
||||
}
|
||||
uint8_t body[msg.size];
|
||||
if (_from_ui->read(body, msg.size) != msg.size) {
|
||||
vector<uint8_t> body(msg.size);
|
||||
if (_from_ui->read(&body[0], msg.size) != msg.size) {
|
||||
error << "Error reading from UI=>Plugin RingBuffer" << endmsg;
|
||||
break;
|
||||
}
|
||||
if (msg.protocol == urids.atom_eventTransfer) {
|
||||
LV2_Evbuf* buf = _ev_buffers[msg.index];
|
||||
LV2_Evbuf_Iterator i = lv2_evbuf_end(buf);
|
||||
const LV2_Atom* const atom = (const LV2_Atom*)body;
|
||||
const LV2_Atom* const atom = (const LV2_Atom*)&body[0];
|
||||
if (!lv2_evbuf_write(&i, nframes, 0, atom->type, atom->size,
|
||||
(const uint8_t*)(atom + 1))) {
|
||||
error << "Failed to write data to LV2 event buffer\n";
|
||||
|
|
|
@ -564,7 +564,7 @@ RegionFactory::new_region_name (string old)
|
|||
uint32_t number;
|
||||
string::size_type len = old.length() + 64;
|
||||
string remainder;
|
||||
char buf[len];
|
||||
std::vector<char> buf(len);
|
||||
|
||||
if ((last_period = old.find_last_of ('.')) == string::npos) {
|
||||
|
||||
|
@ -603,8 +603,8 @@ RegionFactory::new_region_name (string old)
|
|||
|
||||
number++;
|
||||
|
||||
snprintf (buf, len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str());
|
||||
sbuf = buf;
|
||||
snprintf (&buf[0], len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str());
|
||||
sbuf = &buf[0];
|
||||
|
||||
if (region_name_map.find (sbuf) == region_name_map.end ()) {
|
||||
break;
|
||||
|
@ -612,7 +612,7 @@ RegionFactory::new_region_name (string old)
|
|||
}
|
||||
|
||||
if (number != (UINT_MAX-1)) {
|
||||
return buf;
|
||||
return &buf[0];
|
||||
}
|
||||
|
||||
error << string_compose (_("cannot create new name for region \"%1\""), old) << endmsg;
|
||||
|
|
|
@ -766,12 +766,12 @@ SndFileSource::crossfade (Sample* data, framecnt_t cnt, int fade_in)
|
|||
|
||||
} else if (xfade < xfade_frames) {
|
||||
|
||||
gain_t in[xfade];
|
||||
gain_t out[xfade];
|
||||
std::vector<gain_t> in(xfade);
|
||||
std::vector<gain_t> out(xfade);
|
||||
|
||||
/* short xfade, compute custom curve */
|
||||
|
||||
compute_equal_power_fades (xfade, in, out);
|
||||
compute_equal_power_fades (xfade, &in[0], &out[0]);
|
||||
|
||||
for (framecnt_t n = 0; n < xfade; ++n) {
|
||||
xfade_buf[n] = (xfade_buf[n] * out[n]) + (fade_data[n] * in[n]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user