going with the simpler nested audio option

This commit is contained in:
itsmattkc
2018-11-10 14:38:51 +11:00
parent bff412502f
commit 323ce263f0
8 changed files with 73 additions and 49 deletions
+3 -9
View File
@@ -86,18 +86,12 @@ void clear_audio_ibuffer() {
}
int get_buffer_offset_from_frame(Sequence* s, long frame) {
// currently debugging this function. since it has a high potential of failure and isn't actually fatal, we only assert on debug mode
/*#ifdef QT_DEBUG
Q_ASSERT(frame >= audio_ibuffer_frame);
return qFloor(av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(s->audio_layout), qRound(((frame-audio_ibuffer_frame)/s->frame_rate)*s->audio_frequency), AV_SAMPLE_FMT_S16, 1)/4)*4;
#else*/
if (frame >= audio_ibuffer_frame) {
return qFloor(av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(s->audio_layout), qRound(((frame-audio_ibuffer_frame)/s->frame_rate)*s->audio_frequency), AV_SAMPLE_FMT_S16, 1)/4)*4;
return qFloor(((double) (frame - audio_ibuffer_frame)/s->frame_rate)*s->audio_frequency)*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(s->audio_layout);
} else {
dout << "[WARNING] Invalid values passed to get_buffer_offset_from_frame";
return 0;
}
//#endif
}
AudioSenderThread::AudioSenderThread() : close(false) {
@@ -163,14 +157,14 @@ int AudioSenderThread::send_audio_to_output(int offset, int max) {
int channel_count = av_get_channel_layout_nb_channels(s->audio_layout);
long sample_cache_playhead = panel_timeline->ui->audio_monitor->sample_cache_offset + (panel_timeline->ui->audio_monitor->sample_cache.size()/channel_count);
int next_buffer_offset, buffer_offset_adjusted, i;
int buffer_offset = get_buffer_offset_from_frame(s, sample_cache_playhead);
int buffer_offset = get_buffer_offset_from_frame(s, sample_cache_playhead);
if (samples.size() != channel_count) samples.resize(channel_count);
samples.fill(0);
// TODO: I don't like this, but i'm not sure if there's a smarter way to do it
while (buffer_offset < audio_ibuffer_limit) {
sample_cache_playhead++;
next_buffer_offset = qMin(get_buffer_offset_from_frame(s, sample_cache_playhead), audio_ibuffer_limit);
next_buffer_offset = qMin(get_buffer_offset_from_frame(s, sample_cache_playhead), audio_ibuffer_limit);
while (buffer_offset < next_buffer_offset) {
for (i=0;i<samples.size();i++) {
buffer_offset_adjusted = buffer_offset%audio_ibuffer_size;