Commit c2db6fe1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix timeline audio record broken after pause/play

parent bac847b6
Pipeline #206893 passed with stage
in 7 minutes and 20 seconds
......@@ -145,6 +145,7 @@ MediaCapture::MediaCapture(QObject *parent)
, m_audioDevice("default:")
, m_path(QUrl())
, m_recordState(0)
, m_recOffset(0)
, m_tid(-1)
, m_readyForRecord(false)
{
......@@ -226,6 +227,11 @@ void MediaCapture::switchMonitorState(bool run)
}
}
int MediaCapture::recDuration() const
{
return m_recOffset + m_lastPos;
}
const QVector<double> MediaCapture::recLevels() const
{
return m_recLevels;
......@@ -264,6 +270,7 @@ void MediaCapture::recordAudio(int tid, bool record)
m_resetTimer.start();
m_recLevels.clear();
m_lastPos = -1;
m_recOffset = 0;
emit audioLevels(QVector<qreal>());
// m_readyForRecord is true if we were only displaying the countdown but real recording didn't start yet
if (!m_readyForRecord) {
......@@ -309,6 +316,7 @@ void MediaCapture::recordAudio(int tid, bool record)
int MediaCapture::startCapture()
{
m_lastPos = -1;
m_recOffset = 0;
m_recTimer.start();
m_audioRecorder->record();
m_readyForRecord = false;
......@@ -452,6 +460,7 @@ void MediaCapture::pauseRecording()
void MediaCapture::resumeRecording()
{
if (m_audioRecorder->state() == QMediaRecorder::PausedState) {
m_recOffset += m_lastPos;
m_lastPos = -1;
m_recTimer.start();
m_audioRecorder->record();
......
......@@ -47,7 +47,7 @@ class MediaCapture : public QObject
Q_OBJECT
Q_PROPERTY(QVector<qreal> levels READ levels NOTIFY levelsChanged)
Q_PROPERTY(int recordState READ recordState NOTIFY recordStateChanged)
Q_PROPERTY(int recDuration MEMBER m_lastPos NOTIFY recDurationChanged)
Q_PROPERTY(int recDuration READ recDuration NOTIFY recDurationChanged)
public:
MediaCapture(QObject *parent);
......@@ -69,6 +69,7 @@ public:
int currentState;
Q_INVOKABLE QVector<qreal> levels() const;
Q_INVOKABLE int recordState() const;
Q_INVOKABLE int recDuration() const;
void switchMonitorState(bool run);
/** @brief Returns true is audio monitoring is currently in progress **/
bool isMonitoring() const;
......@@ -97,8 +98,10 @@ private:
QVector<qreal> m_levels;
QVector<double> m_recLevels;
int m_recordState;
/** @brief Duration of the recording */
/** @brief Last recorded frame */
int m_lastPos;
/** @brief Duration of pre-pause recording */
int m_recOffset;
int m_tid;
/** @brief true if we started the record countdown */
bool m_readyForRecord;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment