fixed audio buffer size overflow on long clips
This commit is contained in:
+4
-4
@@ -33,7 +33,7 @@ bool audio_rendering = false;
|
||||
bool recording = false;
|
||||
|
||||
qint8 audio_ibuffer[audio_ibuffer_size];
|
||||
int audio_ibuffer_read = 0;
|
||||
unsigned long audio_ibuffer_read = 0;
|
||||
long audio_ibuffer_frame = 0;
|
||||
double audio_ibuffer_timecode = 0;
|
||||
|
||||
@@ -114,9 +114,9 @@ int current_audio_freq() {
|
||||
return audio_rendering ? sequence->audio_frequency : audio_output->format().sampleRate();
|
||||
}
|
||||
|
||||
int get_buffer_offset_from_frame(double framerate, long frame) {
|
||||
unsigned long get_buffer_offset_from_frame(double framerate, long frame) {
|
||||
if (frame >= audio_ibuffer_frame) {
|
||||
return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*current_audio_freq())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO);
|
||||
return static_cast<unsigned long>(((double(frame - audio_ibuffer_frame)/framerate)*current_audio_freq())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO));
|
||||
} else {
|
||||
qWarning() << "Invalid values passed to get_buffer_offset_from_frame";
|
||||
return 0;
|
||||
@@ -168,7 +168,7 @@ int AudioSenderThread::send_audio_to_output(int offset, int max) {
|
||||
// send audio to device
|
||||
int actual_write = audio_io_device->write((const char*) audio_ibuffer+offset, max);
|
||||
|
||||
int audio_ibuffer_limit = audio_ibuffer_read + actual_write;
|
||||
unsigned long audio_ibuffer_limit = audio_ibuffer_read + actual_write;
|
||||
|
||||
// send samples to audio monitor cache
|
||||
// TODO make this work for the footage viewer - currently, enabling it causes crash due to an ASSERT
|
||||
|
||||
Reference in New Issue
Block a user