# HG changeset patch # User Chris Cannam # Date 1460630952 -3600 # Node ID 35fa4733bc5dd88418df5bb1fe2819e1e24e76e5 # Parent 99868cd95acb92e408884c92041a0552abf90e88 Fix compiler warnings, and fix potential mangling of utf8 when downcasing (this is still a nasty and incomplete way to do it though) diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-hostsdk/Files.cpp --- a/src/vamp-hostsdk/Files.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/Files.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -75,9 +75,12 @@ vector path = Vamp::PluginHostAdapter::getPluginPath(); vector libraryFiles; - // we match case-insensitively + // we match case-insensitively, but only with ascii range + // characters (this string is expected to be utf-8) for (size_t i = 0; i < libraryName.length(); ++i) { - libraryName[i] = tolower(libraryName[i]); + if (!(libraryName[i] & 0x80)) { + libraryName[i] = char(tolower(libraryName[i])); + } } for (size_t i = 0; i < path.size(); ++i) { @@ -88,10 +91,14 @@ fi != files.end(); ++fi) { if (libraryName != "") { - // we match case-insensitively + // we match case-insensitively, but only with ascii + // range characters (this string is expected to be + // utf-8) string temp = *fi; for (size_t i = 0; i < temp.length(); ++i) { - temp[i] = tolower(temp[i]); + if (!(temp[i] & 0x80)) { + temp[i] = char(tolower(temp[i])); + } } // libraryName should be lacking an extension, as it // is supposed to have come from the plugin key @@ -182,8 +189,12 @@ li = basename.find('.'); if (li != string::npos) basename = basename.substr(0, li); + // case-insensitive, but only with ascii range characters (this + // string is expected to be utf-8) for (size_t i = 0; i < basename.length(); ++i) { - basename[i] = tolower(basename[i]); + if (!(basename[i] & 0x80)) { + basename[i] = char(tolower(basename[i])); + } } return basename; diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-hostsdk/PluginBufferingAdapter.cpp --- a/src/vamp-hostsdk/PluginBufferingAdapter.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/PluginBufferingAdapter.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -481,7 +481,7 @@ m_buffers = new float *[m_channels]; for (size_t i = 0; i < m_channels; ++i) { - m_queue.push_back(new RingBuffer(m_blockSize + m_inputBlockSize)); + m_queue.push_back(new RingBuffer(int(m_blockSize + m_inputBlockSize))); m_buffers[i] = new float[m_blockSize]; } @@ -510,19 +510,19 @@ PluginBufferingAdapter::OutputList outs = m_outputs; - for (size_t i = 0; i < outs.size(); ++i) { + for (int i = 0; i < int(outs.size()); ++i) { switch (outs[i].sampleType) { case OutputDescriptor::OneSamplePerStep: outs[i].sampleType = OutputDescriptor::FixedSampleRate; - outs[i].sampleRate = m_inputSampleRate / m_stepSize; + outs[i].sampleRate = m_inputSampleRate / float(m_stepSize); m_rewriteOutputTimes[i] = true; break; case OutputDescriptor::FixedSampleRate: if (outs[i].sampleRate == 0.f) { - outs[i].sampleRate = m_inputSampleRate / m_stepSize; + outs[i].sampleRate = m_inputSampleRate / float(m_stepSize); } // We actually only need to rewrite output times for // features that don't have timestamps already, but we @@ -595,7 +595,7 @@ // queue the new input for (size_t i = 0; i < m_channels; ++i) { - int written = m_queue[i]->write(inputBuffers[i], m_inputBlockSize); + int written = m_queue[i]->write(inputBuffers[i], int(m_inputBlockSize)); if (written < int(m_inputBlockSize) && i == 0) { std::cerr << "WARNING: PluginBufferingAdapter::Impl::process: " << "Buffer overflow: wrote " << written @@ -623,7 +623,7 @@ double rate = m_outputs[outputNo].sampleRate; if (rate == 0.0) { - rate = m_inputSampleRate / m_stepSize; + rate = m_inputSampleRate / float(m_stepSize); } if (feature.hasTimestamp) { @@ -656,7 +656,7 @@ // pad any last samples remaining and process if (m_queue[0]->getReadSpace() > 0) { for (size_t i = 0; i < m_channels; ++i) { - m_queue[i]->zero(m_blockSize - m_queue[i]->getReadSpace()); + m_queue[i]->zero(int(m_blockSize) - m_queue[i]->getReadSpace()); } processBlock(allFeatureSets); } @@ -689,7 +689,7 @@ PluginBufferingAdapter::Impl::processBlock(FeatureSet& allFeatureSets) { for (size_t i = 0; i < m_channels; ++i) { - m_queue[i]->peek(m_buffers[i], m_blockSize); + m_queue[i]->peek(m_buffers[i], int(m_blockSize)); } long frame = m_frame; @@ -749,7 +749,7 @@ // step forward for (size_t i = 0; i < m_channels; ++i) { - m_queue[i]->skip(m_stepSize); + m_queue[i]->skip(int(m_stepSize)); } // increment internal frame counter each time we step forward diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-hostsdk/PluginChannelAdapter.cpp --- a/src/vamp-hostsdk/PluginChannelAdapter.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/PluginChannelAdapter.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -248,7 +248,7 @@ } } for (size_t j = 0; j < m_blockSize; ++j) { - m_buffer[0][j] /= m_inputChannels; + m_buffer[0][j] /= float(m_inputChannels); } return m_plugin->process(m_buffer, timestamp); } else { diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-hostsdk/PluginHostAdapter.cpp --- a/src/vamp-hostsdk/PluginHostAdapter.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/PluginHostAdapter.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -126,7 +126,11 @@ size_t blockSize) { if (!m_handle) return false; - return m_descriptor->initialise(m_handle, channels, stepSize, blockSize) ? + return m_descriptor->initialise + (m_handle, + (unsigned int)channels, + (unsigned int)stepSize, + (unsigned int)blockSize) ? true : false; } diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-hostsdk/PluginInputDomainAdapter.cpp --- a/src/vamp-hostsdk/PluginInputDomainAdapter.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/PluginInputDomainAdapter.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -333,7 +333,7 @@ #ifdef HAVE_FFTW3 m_ri = (double *)fftw_malloc(blockSize * sizeof(double)); m_cbuf = (fftw_complex *)fftw_malloc((blockSize/2 + 1) * sizeof(fftw_complex)); - m_plan = fftw_plan_dft_r2c_1d(blockSize, m_ri, m_cbuf, FFTW_MEASURE); + m_plan = fftw_plan_dft_r2c_1d(int(blockSize), m_ri, m_cbuf, FFTW_MEASURE); #else m_ri = new double[m_blockSize]; m_ro = new double[m_blockSize]; @@ -507,13 +507,18 @@ PluginInputDomainAdapter::Impl::processShiftingTimestamp(const float *const *inputBuffers, RealTime timestamp) { + unsigned int roundedRate = 1; + if (m_inputSampleRate > 0.f) { + roundedRate = (unsigned int)round(m_inputSampleRate); + } + if (m_method == ShiftTimestamp) { // we may need to add one nsec if timestamp + // getTimestampAdjustment() rounds down timestamp = timestamp + getTimestampAdjustment(); RealTime nsec(0, 1); - if (RealTime::realTime2Frame(timestamp, m_inputSampleRate) < - RealTime::realTime2Frame(timestamp + nsec, m_inputSampleRate)) { + if (RealTime::realTime2Frame(timestamp, roundedRate) < + RealTime::realTime2Frame(timestamp + nsec, roundedRate)) { timestamp = timestamp + nsec; } } diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-hostsdk/PluginSummarisingAdapter.cpp --- a/src/vamp-hostsdk/PluginSummarisingAdapter.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/PluginSummarisingAdapter.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -366,8 +366,8 @@ break; case StandardDeviation: - if (continuous) result = sqrtf(summary.variance_c); - else result = sqrtf(summary.variance); + if (continuous) result = sqrt(summary.variance_c); + else result = sqrt(summary.variance); break; case Count: @@ -381,7 +381,7 @@ break; } - f.values.push_back(result); + f.values.push_back(float(result)); } fl.push_back(f); @@ -556,7 +556,7 @@ result.duration = INVALID_DURATION; if (int(f.values.size()) > m_accumulators[output].bins) { - m_accumulators[output].bins = f.values.size(); + m_accumulators[output].bins = int(f.values.size()); } for (int i = 0; i < int(f.values.size()); ++i) { @@ -574,7 +574,7 @@ int output = i->first; - int acount = m_accumulators[output].results.size(); + int acount = int(m_accumulators[output].results.size()); if (acount == 0) continue; @@ -760,7 +760,7 @@ RealTime segmentStart = j->first; OutputAccumulator &accumulator = j->second; - int sz = accumulator.results.size(); + int sz = int(accumulator.results.size()); #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER cerr << "reduce: segment starting at " << segmentStart @@ -819,9 +819,10 @@ for (int k = 0; k < sz; ++k) { float value = accumulator.results[k].values[bin]; - valvec.push_back(ValueDurationFloatPair - (value, - toSec(accumulator.results[k].duration))); + valvec.push_back + (ValueDurationFloatPair + (value, + float(toSec(accumulator.results[k].duration)))); } sort(valvec.begin(), valvec.end()); diff -r 99868cd95acb -r 35fa4733bc5d src/vamp-sdk/RealTime.cpp --- a/src/vamp-sdk/RealTime.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-sdk/RealTime.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -112,7 +112,7 @@ RealTime RealTime::fromTimeval(const struct timeval &tv) { - return RealTime(tv.tv_sec, tv.tv_usec * 1000); + return RealTime(int(tv.tv_sec), int(tv.tv_usec * 1000)); } #endif @@ -236,7 +236,7 @@ if (frame < 0) return -frame2RealTime(-frame, sampleRate); RealTime rt; - rt.sec = frame / long(sampleRate); + rt.sec = int(frame / long(sampleRate)); frame -= rt.sec * long(sampleRate); rt.nsec = (int)(((double(frame) * 1000000.0) / sampleRate) * 1000.0); return rt;