PDA

View Full Version : QAudioOutput Play Audio Buffer chat voice ?



Thành Viên Mới
2nd May 2011, 16:09
i dont understand source code Play audio of Qt sample output:


qint64 Generator::readData(char *data, qint64 len)
{
qint64 total = 0;
while (len - total) {
const qint64 chunk = qMin((m_buffer.size() - m_pos), len - total);
memcpy(data, m_buffer.constData() + m_pos, chunk);
m_pos = (m_pos + chunk) % m_buffer.size();
total += chunk;
}
return total;
}

in source code: http://doc.qt.nokia.com/latest/multimedia-audiooutput-audiooutput-cpp.html

can you explain for me ?

high_flyer
3rd May 2011, 13:08
It would help if you explain what exactly it is you don't understand... one can only guess otherwise.
The code reads (copies) 'len' bytes from the buffer to user given buffer 'data', and moves the current position on the buffer respectively.

Thành Viên Mới
9th May 2011, 17:31
i want play quicky buffer, but qint64 len allway is: 16384 byte, so it allway slower than 1 second , can you help me change qint64 len = 256 byte ?

high_flyer
10th May 2011, 09:12
'len' is an input parameter, the callers sets it.

Thành Viên Mới
11th May 2011, 17:38
i dont know set it, beacase i is not call qint64 Generator::readData(char *data, qint64 len) , QAudioOutput automatic call it :(

high_flyer
11th May 2011, 19:35
but 'Generator' is not a phonon class, its your class.
You are giving too little information to help you, and by revealing one more detail in each post is not helping.