cout << "Pass " << *earliest << "\n";
#endif
earliest->decoder->pass ();
+
+ if (earliest->decoder->done()) {
+ shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (earliest->content);
+ assert (ac);
+ shared_ptr<Resampler> re = resampler (ac, false);
+ if (re) {
+ shared_ptr<const AudioBuffers> b = re->flush ();
+ if (b->frames ()) {
+ process_audio (earliest, b, ac->audio_length ());
+ }
+ }
+ }
}
break;
}
/* Resample */
if (content->content_audio_frame_rate() != content->output_audio_frame_rate()) {
- shared_ptr<Resampler> r = resampler (content);
+ shared_ptr<Resampler> r = resampler (content, true);
audio = r->run (audio);
}
}
shared_ptr<Resampler>
-Player::resampler (shared_ptr<AudioContent> c)
+Player::resampler (shared_ptr<AudioContent> c, bool create)
{
map<shared_ptr<AudioContent>, shared_ptr<Resampler> >::iterator i = _resamplers.find (c);
if (i != _resamplers.end ()) {
return i->second;
}
+
+ if (!create) {
+ return shared_ptr<Resampler> ();
+ }
shared_ptr<Resampler> r (new Resampler (c->content_audio_frame_rate(), c->output_audio_frame_rate(), c->audio_channels()));
_resamplers[c] = r;
void flush ();
void emit_black ();
void emit_silence (OutputAudioFrame);
- boost::shared_ptr<Resampler> resampler (boost::shared_ptr<AudioContent>);
+ boost::shared_ptr<Resampler> resampler (boost::shared_ptr<AudioContent>, bool);
void film_changed (Film::Property);
void update_subtitle ();
input and output layouts are the same.
*/
+ cout << "resamp for " << _channels << " " << _in_rate << " " << _out_rate << "\n";
+
_swr_context = swr_alloc_set_opts (
0,
av_get_default_channel_layout (_channels),
return resampled;
}
-/* XXX: no-one calls this */
shared_ptr<const AudioBuffers>
Resampler::flush ()
{