|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-03 18:33:38
|
Module: editor
Branch: master
Commit: 8564cae09e6413aebc4fd10d17c387f7bd991960
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Feb 3 19:33:27 2011 +0100
Fix EOF handling, remove useless AAC hack.
---
ffmpeg.cc | 13 +------------
ffmpeg.hh | 1 +
2 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/ffmpeg.cc b/ffmpeg.cc
index 9a06e36..c264b1d 100644
--- a/ffmpeg.cc
+++ b/ffmpeg.cc
@@ -74,18 +74,6 @@ void FFmpeg::open() {
if (audioStream == -1) throw std::runtime_error("No audio stream found");
AVCodecContext* cc = pFormatCtx->streams[audioStream]->codec;
pAudioCodec = avcodec_find_decoder(cc->codec_id);
- // Awesome HACK for AAC to work (unfortunately libavformat fails to decode this information from MPEG ADTS)
- if (pAudioCodec->name == std::string("aac") && cc->extradata_size == 0) {
- cc->extradata = static_cast<quint8*>(malloc(2));
- unsigned profile = 1; // 0 = MAIN, 1 = LC/LOW
- unsigned srate_idx = 3; // 3 = 48000 Hz
- unsigned channels = 2; // Just the number of channels
- cc->extradata[0] = ((profile + 1) << 3) | ((srate_idx & 0xE) >> 1);
- cc->extradata[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
- cc->extradata_size = 2;
- cc->sample_rate = 48000;
- cc->channels = 2;
- }
if (!pAudioCodec) throw std::runtime_error("Cannot find audio codec");
if (avcodec_open(cc, pAudioCodec) < 0) throw std::runtime_error("Cannot open audio codec");
pAudioCodecCtx = cc;
@@ -100,6 +88,7 @@ void FFmpeg::run() {
m_eof = false;
errors = 0;
} catch (eof_error&) {
+ audioQueue.setEof();
m_eof = true;
msleep(100);
} catch (std::exception& e) {
diff --git a/ffmpeg.hh b/ffmpeg.hh
index 6bfafcc..8486db1 100644
--- a/ffmpeg.hh
+++ b/ffmpeg.hh
@@ -32,6 +32,7 @@ public:
void setEof(bool eof = true) {
QMutexLocker lock(&m_mutex);
m_eof = eof;
+ m_needData.wakeOne();
}
bool output(std::vector<da::sample_t>& out) {
QMutexLocker lock(&m_mutex);
|