/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <iostream>
#include <sndfile.h>
+#include "audio_content.h"
#include "sndfile_content.h"
#include "sndfile_decoder.h"
#include "exceptions.h"
using std::cout;
using boost::shared_ptr;
-SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c, bool fast)
+SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c, bool fast, shared_ptr<Log> log)
: Sndfile (c)
- , AudioDecoder (c, fast)
, _done (0)
, _remaining (_info.frames)
, _deinterleave_buffer (0)
{
-
+ audio.reset (new AudioDecoder (this, c->audio, fast, log));
}
SndfileDecoder::~SndfileDecoder ()
/* Do things in half second blocks as I think there may be limits
to what FFmpeg (and in particular the resampler) can cope with.
*/
- sf_count_t const block = _sndfile_content->audio_stream()->frame_rate() / 2;
+ sf_count_t const block = _sndfile_content->audio->stream()->frame_rate() / 2;
sf_count_t const this_time = min (block, _remaining);
- int const channels = _sndfile_content->audio_stream()->channels ();
+ int const channels = _sndfile_content->audio->stream()->channels ();
shared_ptr<AudioBuffers> data (new AudioBuffers (channels, this_time));
- if (_sndfile_content->audio_stream()->channels() == 1) {
+ if (_sndfile_content->audio->stream()->channels() == 1) {
/* No de-interleaving required */
sf_read_float (_sndfile, data->data(0), this_time);
} else {
}
data->set_frames (this_time);
- audio (_sndfile_content->audio_stream (), data, ContentTime::from_frames (_done, _info.samplerate));
+ audio->audio (_sndfile_content->audio->stream (), data, ContentTime::from_frames (_done, _info.samplerate));
_done += this_time;
_remaining -= this_time;
void
SndfileDecoder::seek (ContentTime t, bool accurate)
{
- AudioDecoder::seek (t, accurate);
+ audio->seek (t, accurate);
_done = t.frames_round (_info.samplerate);
_remaining = _info.frames - _done;