merged with master

This commit is contained in:
itsmattkc
2019-03-29 15:45:51 +11:00
19 changed files with 1115 additions and 914 deletions
+29
View File
@@ -400,3 +400,32 @@ 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_mutex.lock();
audio_wake_object = o;
audio_wake_mutex.unlock();
}
void WakeAudioWakeObject() {
QObject* audio_wake_object = GetAudioWakeObject();
if (audio_wake_object != nullptr) {
QMetaObject::invokeMethod(audio_wake_object, "play_wake", Qt::QueuedConnection);
}
}
+4
View File
@@ -64,6 +64,10 @@ extern bool recording;
extern int audio_rendering_rate;
void clear_audio_ibuffer();
QObject *GetAudioWakeObject();
void SetAudioWakeObject(QObject* o);
void WakeAudioWakeObject();
int current_audio_freq();
bool is_audio_device_set();
+2 -2
View File
@@ -460,8 +460,8 @@ 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
WakeAudioWakeObject();
}
bool Cacher::IsReversed()
+25 -2
View File
@@ -59,6 +59,7 @@ ExportThread::ExportThread(const ExportParams &params,
audio_stream(nullptr),
acodec(nullptr),
audio_frame(nullptr),
sws_frame(nullptr),
swr_frame(nullptr),
acodec_ctx(nullptr),
swr_ctx(nullptr),
@@ -215,6 +216,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));
@@ -373,12 +376,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;
}
@@ -421,6 +424,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);
}
@@ -484,6 +489,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)) {
@@ -518,6 +530,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)
@@ -672,6 +687,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();
};
+2 -3
View File
@@ -748,7 +748,6 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
// == END FINAL DRAW ON SEQUENCE BUFFER ==
}
}
} else {
if (c->media() != nullptr && c->media()->get_type() == MEDIA_TYPE_SEQUENCE) {
@@ -778,8 +777,8 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
}
}
if (audio_track_count == 0 && params.viewer != nullptr) {
params.viewer->play_wake();
if (audio_track_count == 0) {
WakeAudioWakeObject();
}
if (!params.nests.isEmpty() && !params.nests.last()->fbo.isEmpty()) {