Skip to content

Commit

Permalink
Merge pull request #845 from MediaArea/crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dericed authored Dec 17, 2024
2 parents 987faf1 + 8095ade commit e2832ad
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 45 deletions.
63 changes: 22 additions & 41 deletions .github/workflows/qctools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Install dependencies
run: |
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Install dependencies
run: |
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Install dependencies
run: |
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
- name: Build FFmpeg
run: |
git clone --depth 1 --branch n5.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
git clone --depth 1 --branch n6.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
cd ../ffmpeg
./configure --enable-gpl \
--enable-static \
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Install dependencies
run: |
Expand All @@ -256,7 +256,7 @@ jobs:
- name: Build FFmpeg
run: |
git clone --depth 1 --branch n5.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
git clone --depth 1 --branch n6.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
cd ../ffmpeg
./configure --enable-gpl \
--enable-static \
Expand Down Expand Up @@ -287,7 +287,7 @@ jobs:
compiler: ['gcc-9']
include:
- compiler: gcc-9
packages: gcc-9 g++-9
packages: gcc-9 g++-9 libbz2-dev
env: { 'CC': 'gcc-9', 'CXX': 'g++-9' }
- qt_version: "5.15.*"
qt_packages: "libxkbcommon-dev libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0"
Expand All @@ -308,28 +308,18 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Install Python 3.7 version
- name: Install Python 3.x version
uses: actions/setup-python@v1
with:
python-version: '3.7'
python-version: '3'
architecture: 'x64'

- name: Install compiler and FFmpeg dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y ${{ matrix.packages }} \
libunwind-dev \
libavcodec-dev \
libavformat-dev \
libavdevice-dev \
libegl1-mesa-dev \
libglew-dev \
libxv-dev \
libraw1394-dev \
libavc1394-dev \
libiec61883-dev
sudo apt-get install -y ${{ matrix.packages }}
- name: Install Qt 5.15
uses: jurplel/install-qt-action@v3
Expand All @@ -350,7 +340,7 @@ jobs:
- name: Build FFmpeg
run: |
git clone --depth 1 --branch n5.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
git clone --depth 1 --branch n6.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
cd ../ffmpeg
./configure --enable-gpl \
--enable-shared \
Expand Down Expand Up @@ -379,7 +369,7 @@ jobs:
compiler: ['gcc-9']
include:
- compiler: gcc-9
packages: gcc-9 g++-9
packages: gcc-9 g++-9 libbz2-dev
env: { 'CC': 'gcc-9', 'CXX': 'g++-9' }
- qt_version: "6.5.*"
qt_modules: "qtmultimedia qt5compat"
Expand All @@ -401,27 +391,18 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Install Python 3.7 version
- name: Install Python 3.x version
uses: actions/setup-python@v1
with:
python-version: '3.7'
python-version: '3'
architecture: 'x64'

- name: Install compiler and FFmpeg dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y ${{ matrix.packages }} \
libunwind-dev \
libgstreamer-plugins-base1.0-dev \
libavcodec-dev \
libavformat-dev \
libavdevice-dev \
libegl1-mesa-dev \
libglew-dev \
libxkbcommon-dev \
libxv-dev
sudo apt-get install -y ${{ matrix.packages }}
- name: Install Qt 6
uses: jurplel/install-qt-action@v3
Expand All @@ -443,7 +424,7 @@ jobs:
- name: Build FFmpeg
run: |
git clone --depth 1 --branch n5.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
git clone --depth 1 --branch n6.1 https://github.com/FFmpeg/FFmpeg ../ffmpeg
cd ../ffmpeg
./configure --enable-gpl \
--enable-shared \
Expand Down Expand Up @@ -486,7 +467,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Build and install zlib
shell: cmd
Expand Down Expand Up @@ -567,7 +548,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Build and install zlib
shell: cmd
Expand Down Expand Up @@ -647,7 +628,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Init vs environment
uses: egor-tensin/vs-shell@v2
Expand Down Expand Up @@ -732,7 +713,7 @@ jobs:
git submodule sync --recursive
git -c "http.extraheader=$AUTH_HEADER" \
-c protocol.version=2 \
submodule update --init --force --recursive --depth=1
submodule update --init --force --recursive --remote --depth=1
- name: Init vs environment
uses: egor-tensin/vs-shell@v2
Expand Down
26 changes: 24 additions & 2 deletions Source/Core/CommonStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C"

#include "Core/Core.h"
#include "tinyxml2.h"
#include <QMutexLocker>
#include <sstream>
#include <iomanip>
#include <cstdlib>
Expand Down Expand Up @@ -126,6 +127,9 @@ CommonStats::CommonStats (const struct per_item* PerItem_, int Type_, size_t Cou
//---------------------------------------------------------------------------
CommonStats::~CommonStats()
{
//Lock data
QMutexLocker Lock(&Mutex);

// Data - Counts
delete[] Stats_Totals;
delete[] Stats_Counts;
Expand Down Expand Up @@ -154,9 +158,9 @@ CommonStats::~CommonStats()
delete[] pict_type_char;

for (size_t j = 0; j < Data_Reserved; ++j)
delete [] comments[j];
free(comments[j]);

delete [] comments;
delete[] comments;

auto numberOfIntValues = lastStatsIndexByValueType[StatsValueInfo::Int];

Expand Down Expand Up @@ -189,6 +193,9 @@ void CommonStats::processAdditionalStats(const char* key, const char* value, boo
if (strcmp(key, "qctools.comment") == 0)
return;

// Lock data
QMutexLocker Lock(&Mutex);

if(!statsMapInitialized) {
auto type = StatsValueInfo::typeFromKey(key, value);
auto stats = StatsValueInfo {
Expand Down Expand Up @@ -223,6 +230,9 @@ void CommonStats::processAdditionalStats(const char* key, const char* value, boo

void CommonStats::writeAdditionalStats(std::stringstream &stream, size_t index)
{
// Lock data
QMutexLocker Lock(&Mutex);

if(additionalIntStats) {
for(size_t i = 0; i < statsKeysByIndexByValueType[StatsValueInfo::Int].size(); ++i) {
auto key = statsKeysByIndexByValueType[StatsValueInfo::Int][i];
Expand Down Expand Up @@ -253,6 +263,9 @@ void CommonStats::writeAdditionalStats(std::stringstream &stream, size_t index)

void CommonStats::updateAdditionalStats(StatsValueInfo::Type type, size_t oldSize, size_t size)
{
// Lock data
QMutexLocker Lock(&Mutex);

if (type==StatsValueInfo::Int)
{
auto additionalIntStats_Old = additionalIntStats;
Expand Down Expand Up @@ -305,6 +318,9 @@ void CommonStats::updateAdditionalStats(StatsValueInfo::Type type, size_t oldSiz

void CommonStats::initializeAdditionalStats()
{
// Lock data
QMutexLocker Lock(&Mutex);

auto numberOfIntValues = lastStatsIndexByValueType[StatsValueInfo::Int];
if(numberOfIntValues != 0) {
additionalIntStats = new int*[numberOfIntValues];
Expand Down Expand Up @@ -367,6 +383,9 @@ double CommonStats::State_Get()
//---------------------------------------------------------------------------
void CommonStats::StatsFinish ()
{
// Lock data
QMutexLocker Lock(&Mutex);

// Adaptation
if (x_Current==1)
{
Expand Down Expand Up @@ -517,6 +536,9 @@ void CommonStats::statsFromExternalData(const char *Data, size_t Size, const std
//---------------------------------------------------------------------------
void CommonStats::Data_Reserve(size_t NewValue)
{
// Lock data
QMutexLocker Lock(&Mutex);

// Saving old data
size_t Data_Reserved_Old = Data_Reserved;
double** x_Old = x;
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/CommonStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cctype>
#include <functional>
#include <Core/Core.h>
#include <QMutex>
#include <QtAVPlayer/qavplayer.h>

struct AVFrame;
Expand Down Expand Up @@ -198,6 +199,9 @@ class CommonStats
int** additionalIntStats;
double** additionalDoubleStats;
char*** additionalStringStats;

// Thread synchronisation
QMutex Mutex;
};

#endif // Stats_H
4 changes: 2 additions & 2 deletions Source/Core/FileInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ FileInformation::FileInformation (SignalServer* signalServer, const QString &Fil
QObject::connect(m_mediaParser, &QAVPlayer::audioFrame, m_mediaParser, [this](const QAVAudioFrame &frame) {
qDebug() << "audio frame came from: " << frame.filterName() << frame.stream() << frame.stream().index();

if (frame.filterName() == astats) {
if (frame.filterName() == astats && frame.stream().index() < Stats.size()) {
auto stat = Stats[frame.stream().index()];

stat->TimeStampFromFrame(frame, stat->x_Current);
Expand All @@ -1074,7 +1074,7 @@ FileInformation::FileInformation (SignalServer* signalServer, const QString &Fil
QObject::connect(m_mediaParser, &QAVPlayer::videoFrame, m_mediaParser, [this](const QAVVideoFrame &frame) {
qDebug() << "video frame came from: " << frame.filterName() << frame.stream() << frame.stream().index();

if(frame.filterName() == stats) {
if(frame.filterName() == stats && frame.stream().index() < Stats.size()) {
auto stat = Stats[frame.stream().index()];

stat->TimeStampFromFrame(frame, stat->x_Current);
Expand Down

0 comments on commit e2832ad

Please sign in to comment.