This commit is contained in:
itsmattkc
2019-03-29 01:59:12 +11:00
parent 814e048e8f
commit 963a20af37
9 changed files with 62 additions and 48 deletions
+20
View File
@@ -401,3 +401,23 @@ void combobox_audio_sample_rates(QComboBox *combobox) {
combobox->addItem("88200 Hz", 88200);
combobox->addItem("96000 Hz", 96000);
}
QObject* audio_wake_object = nullptr;
QMutex audio_wake_mutex;
QObject* GetAudioWakeObject()
{
audio_wake_mutex.lock();
QObject* wake_object = audio_wake_object;
audio_wake_object = nullptr;
audio_wake_mutex.unlock();
return wake_object;
}
void SetAudioWakeObject(QObject *o)
{
audio_wake_object = o;
}
+3
View File
@@ -65,6 +65,9 @@ extern bool audio_rendering;
extern int audio_rendering_rate;
void clear_audio_ibuffer();
QObject *GetAudioWakeObject();
void SetAudioWakeObject(QObject* o);
int current_audio_freq();
bool is_audio_device_set();
+5 -2
View File
@@ -460,8 +460,11 @@ void Cacher::CacheAudioWorker() {
}
}
QMetaObject::invokeMethod(panel_footage_viewer, "play_wake", Qt::QueuedConnection);
QMetaObject::invokeMethod(panel_sequence_viewer, "play_wake", Qt::QueuedConnection);
// If there's a QObject waiting for audio to be rendered, wake it now
QObject* audio_wake_object = GetAudioWakeObject();
if (audio_wake_object != nullptr) {
QMetaObject::invokeMethod(audio_wake_object, "play_wake", Qt::QueuedConnection);
}
}
bool Cacher::IsReversed()
+24 -2
View File
@@ -217,6 +217,8 @@ bool ExportThread::SetupVideo() {
}
bool ExportThread::SetupAudio() {
// if video is disabled, no setup necessary
if (!params_.audio_enabled) return true;
// Find encoder for this codec
acodec = avcodec_find_encoder(static_cast<AVCodecID>(params_.audio_codec));
@@ -375,12 +377,12 @@ void ExportThread::Export()
}
// If video is enabled, set it up in the container now
if (params_.video_enabled && !SetupVideo()) {
if (!SetupVideo()) {
return;
}
// If audio is enabled, set it up in the container now
if (params_.audio_enabled && !SetupAudio()) {
if (!SetupAudio()) {
return;
}
@@ -423,6 +425,8 @@ void ExportThread::Export()
// If we're exporting audio, run compose_audio() which will write mixed audio to the internal audio buffer
if (params_.audio_enabled) {
waiting_for_audio_ = true;
SetAudioWakeObject(this);
olive::rendering::compose_audio(nullptr, olive::ActiveSequence.get(), 1, true);
}
@@ -486,6 +490,13 @@ void ExportThread::Export()
// If we're exporting audio, copy audio from the buffer into an AVFrame for encoding
if (params_.audio_enabled) {
if (waiting_for_audio_) {
waitCond.wait(&mutex);
}
// Make sure nothing is writing while we're retrieving
audio_write_lock.lock();
// Check if the count of encoded samples exceeds the current Sequence playhead, in which case we don't need to
// encode any audio at this moment
while (!interrupt_ && file_audio_samples <= (timecode_secs*params_.audio_sampling_rate)) {
@@ -520,6 +531,9 @@ void ExportThread::Export()
// Increment by the frame's number of samples
file_audio_samples += swr_frame->nb_samples;
}
audio_write_lock.unlock();
}
// Generating encoding statistics (e.g. the time it took to encode this frame/estimated remaining time)
@@ -674,6 +688,14 @@ void ExportThread::Interrupt()
interrupt_ = true;
}
void ExportThread::play_wake()
{
mutex.lock();
waiting_for_audio_ = false;
waitCond.wakeAll();
mutex.unlock();
}
void ExportThread::wake() {
mutex.lock();
waitCond.wakeAll();
+4
View File
@@ -82,6 +82,8 @@ signals:
void ProgressChanged(int value, qint64 remaining_ms);
public slots:
void Interrupt();
void play_wake();
private:
bool Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream);
bool SetupVideo();
@@ -124,6 +126,8 @@ private:
QWaitCondition waitCond;
QString export_error;
bool waiting_for_audio_;
private slots:
void wake();
};
-27
View File
@@ -600,17 +600,6 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
// == END FINAL DRAW ON SEQUENCE BUFFER ==
}
// prepare gizmos
/*
if ((*params.gizmos) != nullptr
&& params.nests.isEmpty()
&& ((*params.gizmos) == first_gizmo_effect
|| (*params.gizmos) == selected_effect)) {
(*params.gizmos)->gizmo_draw(timecode, coords); // set correct gizmo coords
(*params.gizmos)->gizmo_world_to_screen(); // convert gizmo coords to screen coords
}
*/
glPopMatrix();
}
} else {
@@ -631,22 +620,6 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
}
}
/*
// visually update all the keyframe values
if (c->sequence == params.seq) { // only if you can currently see them
double ts = (playhead - c->timeline_in(true) + c->clip_in(true))/s->frame_rate;
for (int i=0;i<c->effects.size();i++) {
EffectPtr e = c->effects.at(i);
for (int j=0;j<e->row_count();j++) {
EffectRow* r = e->row(j);
for (int k=0;k<r->fieldCount();k++) {
r->field(k)->validate_keyframe_data(ts);
}
}
}
}
*/
}
} else {
params.texture_failed = true;