Skip to content

Commit

Permalink
fix AudioFrame.clone wang-bin#681
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jul 17, 2016
1 parent 3dbd444 commit ae9677e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/AudioFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ AudioFrame AudioFrame::clone() const
if (d->samples_per_ch <= 0 || bytesPerLine(0) <= 0)
return AudioFrame(format());
QByteArray buf(bytesPerLine()*planeCount(), 0);
AudioFrame f(d->format, buf);
f.setSamplesPerChannel(samplesPerChannel());
char *dst = buf.data(); //must before buf is shared, otherwise data will be detached.
for (int i = 0; i < f.planeCount(); ++i) {
const int plane_size = f.bytesPerLine(i);
memcpy(dst, f.constBits(i), plane_size);
for (int i = 0; i < planeCount(); ++i) {
const int plane_size = bytesPerLine(i);
memcpy(dst, constBits(i), plane_size);
dst += plane_size;
}
AudioFrame f(d->format, buf);
f.setSamplesPerChannel(samplesPerChannel());
f.setTimestamp(timestamp());
// meta data?
return f;
Expand Down

0 comments on commit ae9677e

Please sign in to comment.