fix capture thread stop bug

This commit is contained in:
dreamsourcelabTAI 2021-11-25 15:41:00 +08:00
parent 5740946c7c
commit f6ca1f6ed8
8 changed files with 161 additions and 71 deletions

View File

@ -64,11 +64,6 @@ void Snapshot::free_data()
_ch_index.clear();
}
bool Snapshot::memory_failed()
{
return _memory_failed;
}
bool Snapshot::empty()
{
if (get_sample_count() == 0)
@ -77,16 +72,6 @@ bool Snapshot::empty()
return false;
}
bool Snapshot::last_ended()
{
return _last_ended;
}
void Snapshot::set_last_ended(bool ended)
{
_last_ended = ended;
}
uint64_t Snapshot::get_sample_count()
{
std::lock_guard<std::mutex> lock(_mutex);
@ -104,12 +89,7 @@ uint64_t Snapshot::get_ring_end()
std::lock_guard<std::mutex> lock(_mutex);
return ring_end();
}
uint64_t Snapshot::sample_count()
{
return _sample_count;
}
uint64_t Snapshot::ring_start()
{
if (_sample_count < _total_sample_count)
@ -128,26 +108,6 @@ uint64_t Snapshot::ring_end()
return _ring_sample_count - 1;
}
const void* Snapshot::get_data()
{
return _data;
}
int Snapshot::unit_size()
{
return _unit_size;
}
uint8_t Snapshot::get_unit_bytes()
{
return _unit_bytes;
}
unsigned int Snapshot::get_channel_num()
{
return _channel_num;
}
void Snapshot::capture_ended()
{
set_last_ended(true);

View File

@ -43,18 +43,35 @@ public:
uint64_t get_ring_start();
uint64_t get_ring_end();
const void * get_data();
inline const void* get_data(){
return _data;
}
int unit_size();
uint8_t get_unit_bytes();
inline int unit_size(){
return _unit_size;
}
inline uint8_t get_unit_bytes(){
return _unit_bytes;
}
inline bool memory_failed(){
return _memory_failed;
}
bool memory_failed();
bool empty();
bool last_ended();
void set_last_ended(bool ended);
inline bool last_ended(){
return _last_ended;
}
unsigned int get_channel_num();
inline void set_last_ended(bool ended){
_last_ended = ended;
}
inline unsigned int get_channel_num(){
return _channel_num;
}
virtual void capture_ended();
virtual bool has_data(int index) = 0;
@ -64,10 +81,11 @@ public:
protected:
virtual void free_data();
uint64_t sample_count();
inline uint64_t sample_count(){
return _sample_count;
}
uint64_t ring_start();
uint64_t ring_end();
protected:

View File

@ -200,7 +200,12 @@ void DevInst::start()
void DevInst::run()
{
sr_session_run();
qDebug()<<"session run loop start";
int ret = sr_session_run();
if (ret != SR_OK){
qDebug()<<"start session error!";
}
qDebug()<<"session run loop end";
}
void DevInst::stop()

View File

@ -40,6 +40,7 @@
#include <QApplication>
#include <QStandardPaths>
#include <QScreen>
#include <QTimer>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QGuiApplication>
@ -236,10 +237,7 @@ void MainWindow::setup_ui()
// UI initial
_measure_widget->add_dist_measure();
// update device
update_device_list();
_session->start_hotplug_work();
retranslateUi();
@ -302,6 +300,9 @@ void MainWindow::setup_ui()
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view, SLOT(set_trig_pos(int)));
_logo_bar->set_mainform_callback(this);
//delay to update device list
QTimer::singleShot(200, this, SLOT(update_device_list()));
}
@ -457,8 +458,6 @@ void MainWindow::on_load_file(QString file_name)
} catch(QString e) {
show_error(tr("Failed to load ") + file_name);
_session->set_default_device();
update_device_list();
return;
}
update_device_list();

View File

@ -91,8 +91,7 @@ private:
void setup_ui();
void retranslateUi();
bool eventFilter(QObject *object, QEvent *event);
bool load_session_json(QJsonDocument json, bool file_dev,bool bDecoder=true);
void update_device_list();
bool load_session_json(QJsonDocument json, bool file_dev,bool bDecoder=true);
public slots:
void switchTheme(QString style);
@ -102,6 +101,7 @@ private slots:
void on_load_file(QString file_name);
void on_open_doc();
void on_device_updated_reload();
void update_device_list();
void on_run_stop();
void on_instant_stop();

View File

@ -28,7 +28,7 @@
#endif
// firmware binary file directory, endswith letter '/'
extern char DS_RES_PATH[256];
extern char DS_RES_PATH[500];
/**
* @file

View File

@ -34,12 +34,10 @@
#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
char DS_RES_PATH[256] = {0};
char DS_RES_PATH[500] = {0};
int bExportOriginalData = 0; //able export all data
int session_loop_stop_flag = 0;
/**
* @file
*
@ -407,14 +405,12 @@ SR_API int sr_session_run(void)
session->running = TRUE;
session_loop_stop_flag = 0;
sr_info("Running...");
/* Do we have real sources? */
if (session->num_sources == 1 && session->pollfds[0].fd == -1) {
/* Dummy source, freewheel over it. */
while (session->num_sources && !session_loop_stop_flag) {
while (session->num_sources) {
if (session->abort_session) {
session->sources[0].cb(-1, -1, session->sources[0].cb_data);
break;
@ -424,7 +420,7 @@ SR_API int sr_session_run(void)
}
} else {
/* Real sources, use g_poll() main loop. */
while (session->num_sources && !session_loop_stop_flag){
while (session->num_sources){
sr_session_iteration(TRUE);
}
}
@ -491,8 +487,6 @@ SR_API int sr_session_stop(void)
return SR_ERR_BUG;
}
session_loop_stop_flag = 1; //set flag, the run loop will exit
g_mutex_lock(&session->stop_mutex);
if (session->running)
session->abort_session = TRUE;
@ -841,8 +835,8 @@ void sr_set_firmware_resource_dir(const char *dir)
int len = strlen(DS_RES_PATH);
if (DS_RES_PATH[len-1] != '/'){
DS_RES_PATH[len] = '/';
DS_RES_PATH[len+1] = 0;
DS_RES_PATH[len] = '/';
DS_RES_PATH[len + 1] = 0;
}
}
}

View File

@ -0,0 +1,114 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* The canonical host libsigrokdecode will run on. */
#define CONF_HOST "x86_64-pc-linux-gnu"
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "support@dreamsourcelab.com"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libsigrokdecode4DSL"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libsigrokdecode4DSL 0.6.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libsigrokdecode4DSL"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://www.dreamsourcelab.com"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.6.0"
/* Binary age of libsigrokdecode4DSL. */
#define SRD_LIB_VERSION_AGE 0
/* Binary version of libsigrokdecode4DSL. */
#define SRD_LIB_VERSION_CURRENT 4
/* Binary revision of libsigrokdecode4DSL. */
#define SRD_LIB_VERSION_REVISION 0
/* Binary version triple of libsigrokdecode4DSL. */
#define SRD_LIB_VERSION_STRING "4:0:0"
/* Major version number of libsigrokdecode4DSL. */
#define SRD_PACKAGE_VERSION_MAJOR 0
/* Micro version number of libsigrokdecode4DSL. */
#define SRD_PACKAGE_VERSION_MICRO 0
/* Minor version number of libsigrokdecode4DSL. */
#define SRD_PACKAGE_VERSION_MINOR 6
/* Version of libsigrokdecode4DSL. */
#define SRD_PACKAGE_VERSION_STRING "0.6.0-git-c708a00"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* The targeted POSIX standard. */
#ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200112L
#endif