Skip to content
Snippets Groups Projects
Commit 7dd67518 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix for not enough audio buffer space

parent 9559174b
No related branches found
No related tags found
No related merge requests found
Pipeline #27111 passed
......@@ -91,16 +91,20 @@ bool SoftwareEncoder::_encodeOpus(const std::vector<short> &in, ftl::codecs::Pac
int channels = (cur_stereo_) ? 2 : 1;
pkt.data.resize(MAX_PACKET_SIZE);
int frame_est = (in.size() / (channels*FRAME_SIZE))+1;
pkt.data.resize(MAX_PACKET_SIZE*frame_est);
int count = 0;
int frames = 0;
unsigned char *outptr = pkt.data.data();
//LOG(INFO) << "Encode " << (in.size() / (channels*FRAME_SIZE)) << " audio frames";
for (unsigned int i=0; i<in.size(); i+=channels*FRAME_SIZE) {
short *len = (short*)outptr;
outptr += 2;
int nbBytes = opus_multistream_encode(opus_encoder_, &in.data()[i], FRAME_SIZE, outptr, MAX_PACKET_SIZE);
//LOG(INFO) << "Opus encode: " << nbBytes << ", " << (in.size()-i);
if (nbBytes <= 0) return false;
//if (nbBytes > 32000) LOG(WARNING) << "Packet exceeds size limit";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment