many comfort features and fixed audio bug
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ void clear_audio_ibuffer() {
|
||||
|
||||
int get_buffer_offset_from_frame(long frame) {
|
||||
if (frame >= audio_ibuffer_frame) {
|
||||
return av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(sequence->audio_layout), ((frame-audio_ibuffer_frame)/sequence->frame_rate)*sequence->audio_frequency, AV_SAMPLE_FMT_S16, 1);
|
||||
return av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(sequence->audio_layout), qRound(((frame-audio_ibuffer_frame)/sequence->frame_rate)*sequence->audio_frequency), AV_SAMPLE_FMT_S16, 1);
|
||||
} else {
|
||||
qDebug() << "[WARNING] get_buffer_offset_from_frame called incorrectly";
|
||||
return 0;
|
||||
|
||||
+8
-2
@@ -36,10 +36,9 @@ void cache_audio_worker(Clip* c) {
|
||||
c->need_new_audio_frame = false;
|
||||
if (c->audio_just_reset) {
|
||||
// get precise sample offset for the elected clip_in from this audio frame
|
||||
|
||||
float target_sts = 0;
|
||||
if (c->audio_target_frame < c->timeline_in) {
|
||||
target_sts = playhead_to_seconds(c, c->clip_in);
|
||||
target_sts = clip_frame_to_seconds(c, c->clip_in);
|
||||
} else {
|
||||
target_sts = playhead_to_seconds(c, c->audio_target_frame);
|
||||
}
|
||||
@@ -82,6 +81,13 @@ void cache_audio_worker(Clip* c) {
|
||||
retrieve_next_frame_raw_data(c, frame);
|
||||
nb_bytes = av_samples_get_buffer_size(NULL, frame->channels, frame->nb_samples, static_cast<AVSampleFormat>(frame->format), 1);
|
||||
c->frame_sample_index -= nb_bytes;
|
||||
|
||||
// code DISGUSTINGLY copy/pasted from above
|
||||
int offset = audio_ibuffer_read - c->audio_buffer_write;
|
||||
if (offset > 0) {
|
||||
c->audio_buffer_write += offset;
|
||||
c->frame_sample_index += offset;
|
||||
}
|
||||
}
|
||||
while (c->frame_sample_index < nb_bytes) {
|
||||
if (c->audio_buffer_write >= audio_ibuffer_read+half_buffer || c->audio_buffer_write >= get_buffer_offset_from_frame(c->timeline_out)) {
|
||||
|
||||
@@ -175,7 +175,7 @@ void get_clip_frame(Clip* c, long playhead) {
|
||||
|
||||
float playhead_to_seconds(Clip* c, long playhead) {
|
||||
// returns time in seconds
|
||||
return (std::max((long) 0, playhead - c->timeline_in) + c->clip_in)/c->sequence->frame_rate;
|
||||
return (qMax((long) 0, playhead - c->timeline_in) + c->clip_in)/c->sequence->frame_rate;
|
||||
}
|
||||
|
||||
long seconds_to_clip_frame(Clip* c, float seconds) {
|
||||
|
||||
Reference in New Issue
Block a user