2
0
forked from Ivasoft/DSView

fix: On real-time mode, if capture is terminated in advance, the end sample is error

This commit is contained in:
dreamsourcelabTAI
2023-02-06 18:02:09 +08:00
parent 977034d976
commit a6cf5dde25
3 changed files with 33 additions and 14 deletions

View File

@@ -511,21 +511,35 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
std::vector<const uint8_t *> chunk;
std::vector<uint8_t> chunk_const;
bool bCheckEnd = false;
uint64_t end_index = decode_end;
while(i < decode_end && !_no_memory && !status->_bStop)
while(i < end_index && !_no_memory && !status->_bStop)
{
chunk.clear();
chunk_const.clear();
uint64_t chunk_end = decode_end;
// Wait the data is ready.
if (!_is_capture_end && i == _snapshot->get_ring_sample_count())
if (_is_capture_end)
{
if (!bCheckEnd){
bCheckEnd = true;
if (end_index >= _snapshot->get_ring_sample_count()){
end_index = _snapshot->get_ring_sample_count() - 1;
dsv_info("Reset the decode end sample, new:%llu, old:%llu", end_index, decode_end);
}
}
}
else if (i >= _snapshot->get_ring_sample_count())
{
// Wait the data is ready.
std::this_thread::sleep_for(std::chrono::milliseconds(100));
continue;
}
uint64_t chunk_end = end_index;
for (int j =0 ; j < logic_di->dec_num_channels; j++) {
int sig_index = logic_di->dec_channelmap[j];
@@ -544,12 +558,12 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
}
}
if (chunk_end > decode_end)
chunk_end = decode_end;
if (chunk_end > end_index)
chunk_end = end_index;
if (chunk_end - i > MaxChunkSize)
chunk_end = i + MaxChunkSize;
bEndTime = chunk_end == decode_end;
bEndTime = chunk_end == end_index;
if (srd_session_send(
session,

View File

@@ -451,7 +451,11 @@ namespace pv
dsv_err("%s", "Error!Device is running.");
return false;
}
int run_dex = 0;
clear_all_decode_task(run_dex);
// If switch the data buffer
if (_view_data != _capture_data){
_capture_data->clear();
_capture_data = _view_data;
@@ -468,7 +472,7 @@ namespace pv
_callback->trigger_message(DSV_MSG_START_COLLECT_WORK_PREV);
if (exec_capture(true))
if (exec_capture())
{
_capture_time_id++;
_is_working = true;
@@ -484,7 +488,7 @@ namespace pv
return false;
}
bool SigSession::exec_capture(bool bFirst)
bool SigSession::exec_capture()
{
if (_device_agent.is_collecting())
{
@@ -522,7 +526,7 @@ namespace pv
{
// On repeate mode, the last data can use to decode, so can't remove the current decode task.
// And on this mode, the decode task will be created when capture end.
if (is_repeat_mode() == false || bFirst){
if (is_repeat_mode() == false){
int run_dex = 0;
clear_all_decode_task(run_dex);
clear_decode_result();
@@ -1810,7 +1814,7 @@ namespace pv
if (_is_working)
{
_callback->repeat_hold(_repeat_hold_prg);
exec_capture(false);
exec_capture();
}
}
@@ -1860,7 +1864,7 @@ namespace pv
else
{
_repeat_hold_prg = 0;
exec_capture(false);
exec_capture();
}
}
}
@@ -1873,6 +1877,7 @@ namespace pv
// On repeate mode, remove the current decode task when capture ended.
if (is_repeat_mode()){
int run_dex = 0;
//Stop all old task.
clear_all_decode_task(run_dex);
clear_decode_result();

View File

@@ -393,7 +393,7 @@ private:
void set_cur_snap_samplerate(uint64_t samplerate);
void math_disable();
bool exec_capture(bool bFirst);
bool exec_capture();
void exit_capture();
inline void data_updated(){