+ // Encode and add all audio frames up to and including the pts of this video frame.
+ // (They can never be queued to us after the video frame they belong to, only before.)
+ for ( ;; ) {
+ int64_t audio_pts;
+ std::vector<float> audio;
+ {
+ unique_lock<mutex> lock(frame_queue_mutex);
+ if (pending_audio_frames.empty()) break;
+ auto it = pending_audio_frames.begin();
+ if (it->first > int(pts)) break;
+ audio_pts = it->first;
+ audio = move(it->second);
+ pending_audio_frames.erase(it);
+ }