void
Decoder::process_begin ()
{
- _delay_in_bytes = _fs->audio_delay() * _fs->audio_sample_rate() * _fs->audio_channels() * bytes_per_audio_sample() / 1000;
+ _delay_in_bytes = _fs->total_audio_delay() * _fs->audio_sample_rate() * _fs->audio_channels() * bytes_per_audio_sample() / 1000;
delete _delay_line;
_delay_line = new DelayLine (_delay_in_bytes);
+ _log->log (String::compose ("Decoding audio with total delay of %1", _fs->total_audio_delay()));
+
_audio_frames_processed = 0;
}
Film::examine_content_post_gui ()
{
set_length (_examine_content_job->last_video_frame ());
+ set_audio_to_discard (_examine_content_job->audio_to_discard ());
_examine_content_job.reset ();
string const tdir = dir ("thumbs");
_frames_per_second = f;
signal_changed (FRAMES_PER_SECOND);
}
+
+void
+FilmState::set_audio_to_discard (int a)
+{
+ _audio_to_discard = a;
+ signal_changed (AUDIO_TO_DISCARD);
+}
void
FilmState::signal_changed (Property p)
return _audio_streams[_audio_stream].channels ();
}
+int
+FilmState::total_audio_delay () const
+{
+ return _audio_delay - _audio_to_discard;
+}
, _audio_sample_rate (0)
, _has_subtitles (false)
, _frames_per_second (0)
+ , _audio_to_discard (0)
, _dirty (false)
{}
, _audio_streams (o._audio_streams)
, _subtitle_streams (o._subtitle_streams)
, _frames_per_second (o._frames_per_second)
+ , _audio_to_discard (o._audio_to_discard)
, _dirty (o._dirty)
{}
}
int audio_channels () const;
+ int total_audio_delay () const;
enum Property {
NONE,
AUDIO_STREAMS,
SUBTITLE_STREAMS,
FRAMES_PER_SECOND,
+ AUDIO_TO_DISCARD
};
return _frames_per_second;
}
+ int audio_to_discard () const {
+ return _audio_to_discard;
+ }
+
/* SET */
void set_audio_streams (std::vector<AudioStream>);
void set_subtitle_streams (std::vector<SubtitleStream>);
void set_frames_per_second (float);
+ void set_audio_to_discard (int);
/** Emitted when some property has changed */
mutable sigc::signal1<void, Property> Changed;
std::vector<SubtitleStream> _subtitle_streams;
/** Frames per second of the source */
float _frames_per_second;
+ /** Number of milliseconds of audio to discard at the start of this film
+ in order to sync audio with video. Can be negative.
+ */
+ int _audio_to_discard;
mutable bool _dirty;