I'm using Qt to make some audio output. There is an example audioouput, where pure virtual function qint64 QIODevice::readData ( char * data, qint64 maxSize ) is reimplemented like this(this is not actual code from example).
qint64 Generator::readData(char *data, qint64 len)
{
memcpy(data, m_buffer.data(), len);
return len;
}
So, we get pointer to data, copy memory from our buffer to this data. I'm wondering whether I can just assign pointer data to new location, like this:
qint64 Generator::readData(char *data, qint64 len)
{
data = m_buffer.data();
return len;
}
Because, memcpy is slow and C. So can I? Thank you!
OK, just not to receive comments "what is slow": first - memcpy slower than pointer assignment second - yes, I have latency in sound playing, I want to make program optimal at every point.
P.S. I'm trying to do it, and I have no sound, so maybe answer is no. Then why?
std::copy_n
. – Casey