FIX: error log reduce
Change-Id: I836ba41eefb3a8c12a57a22d208ee7d60140e345
This commit is contained in:
parent
f343b4d1db
commit
c58baa6b16
|
@ -208,6 +208,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
if (machine == m_machine)
|
||||
return;
|
||||
m_machine = machine;
|
||||
m_last_errors.clear();
|
||||
auto fs = m_image_grid->GetFileSystem();
|
||||
if (fs) {
|
||||
m_image_grid->SetFileSystem(nullptr);
|
||||
|
@ -265,7 +266,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
if (e.GetInt() == PrinterFileSystem::Initializing)
|
||||
fetchUrl(boost::weak_ptr(fs));
|
||||
|
||||
if (status == PrinterFileSystem::Failed
|
||||
if ((status == PrinterFileSystem::Failed && m_last_errors.find(fs->GetLastError()) == m_last_errors.end())
|
||||
|| status == PrinterFileSystem::ListReady) {
|
||||
json j;
|
||||
j["code"] = fs->GetLastError();
|
||||
|
@ -281,6 +282,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
if (agent)
|
||||
agent->track_event("download_video_conn", j.dump());
|
||||
}
|
||||
m_last_errors.insert(fs->GetLastError());
|
||||
}
|
||||
});
|
||||
fs->Bind(EVT_DOWNLOAD, [this, wfs = boost::weak_ptr(fs)](auto& e) {
|
||||
|
|
|
@ -85,6 +85,7 @@ private:
|
|||
|
||||
int m_last_mode = 0;
|
||||
int m_last_type = 0;
|
||||
std::set<int> m_last_errors;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
|||
m_machine = machine;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl switch machine: " << m_machine;
|
||||
m_failed_retry = 0;
|
||||
m_last_failed_codes.clear();
|
||||
std::string stream_url;
|
||||
if (get_stream_url(&stream_url)) {
|
||||
m_streaming = boost::algorithm::contains(stream_url, "device=" + m_machine);
|
||||
|
@ -215,7 +216,7 @@ void MediaPlayCtrl::Play()
|
|||
|
||||
void MediaPlayCtrl::Stop(wxString const &msg)
|
||||
{
|
||||
bool init_failed = m_last_state != wxMEDIASTATE_PLAYING;
|
||||
int last_state = m_last_state;
|
||||
|
||||
if (m_last_state != MEDIASTATE_IDLE) {
|
||||
m_media_ctrl->InvalidateBestSize();
|
||||
|
@ -238,19 +239,22 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
|||
m_failed_code = 0;
|
||||
}
|
||||
|
||||
if (init_failed && m_failed_code != 0 && m_last_failed_code != m_failed_code) {
|
||||
if (last_state != wxMEDIASTATE_PLAYING && m_failed_code != 0
|
||||
&& m_last_failed_codes.find(m_failed_code) == m_last_failed_codes.end()
|
||||
&& (m_user_triggered || m_failed_retry > 3)) {
|
||||
json j;
|
||||
j["stage"] = std::to_string(m_last_state);
|
||||
j["stage"] = last_state;
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
j["result"] = "failed";
|
||||
j["user_triggered"] = m_user_triggered;
|
||||
j["code"] = m_failed_code;
|
||||
j["msg"] = into_u8(msg);
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_event("start_liveview", j.dump());
|
||||
m_last_failed_codes.insert(m_failed_code);
|
||||
}
|
||||
m_last_failed_code = m_failed_code;
|
||||
|
||||
++m_failed_retry;
|
||||
if (m_failed_code != 0 && !m_tutk_support && (m_failed_retry > 1 || m_user_triggered)) {
|
||||
|
@ -258,7 +262,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
|||
if (wxGetApp().show_modal_ip_address_enter_dialog(_L("LAN Connection Failed (Failed to start liveview)"))) {
|
||||
m_failed_retry = 0;
|
||||
m_user_triggered = true;
|
||||
m_last_failed_code = 0;
|
||||
m_last_failed_codes.clear();
|
||||
m_next_retry = wxDateTime::Now();
|
||||
return;
|
||||
}
|
||||
|
@ -276,7 +280,7 @@ void MediaPlayCtrl::TogglePlay()
|
|||
} else {
|
||||
m_failed_retry = 0;
|
||||
m_user_triggered = true;
|
||||
m_last_failed_code = 0;
|
||||
m_last_failed_codes.clear();
|
||||
m_next_retry = wxDateTime::Now();
|
||||
Play();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <boost/thread/condition_variable.hpp>
|
||||
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
class Button;
|
||||
class Label;
|
||||
|
@ -86,7 +87,7 @@ private:
|
|||
bool m_user_triggered = false;
|
||||
int m_failed_retry = 0;
|
||||
int m_failed_code = 0;
|
||||
int m_last_failed_code = 0;
|
||||
std::set<int> m_last_failed_codes;
|
||||
wxDateTime m_next_retry;
|
||||
|
||||
::Button *m_button_play;
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef __cplusplus
|
||||
typedef wchar_t tchar;
|
||||
#else
|
||||
typedef unsigned short tchar;
|
||||
#endif
|
||||
#else
|
||||
typedef char tchar;
|
||||
#endif
|
||||
|
@ -117,7 +117,7 @@ BAMBU_EXPORT void BAMBU_FUNC(Bambu_SetLogger)(Bambu_Tunnel tunnel, Logger logger
|
|||
|
||||
BAMBU_EXPORT int BAMBU_FUNC(Bambu_Open)(Bambu_Tunnel tunnel);
|
||||
|
||||
BAMBU_EXPORT int BAMBU_FUNC(Bambu_StartStream)(Bambu_Tunnel tunnel, bool video);
|
||||
BAMBU_EXPORT int BAMBU_FUNC(Bambu_StartStream)(Bambu_Tunnel tunnel, int video);
|
||||
|
||||
BAMBU_EXPORT int BAMBU_FUNC(Bambu_GetStreamCount)(Bambu_Tunnel tunnel);
|
||||
|
||||
|
|
|
@ -1074,9 +1074,14 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
|
|||
if (ret == 0)
|
||||
ret = Bambu_StartStream(tunnel, false);
|
||||
l.lock();
|
||||
m_session.tunnel = tunnel;
|
||||
if (ret == 0)
|
||||
if (ret == 0) {
|
||||
m_session.tunnel = tunnel;
|
||||
break;
|
||||
}
|
||||
if (tunnel) {
|
||||
Bambu_Close(tunnel);
|
||||
Bambu_Destroy(tunnel);
|
||||
}
|
||||
m_last_error = ret;
|
||||
}
|
||||
m_status = Status::Failed;
|
||||
|
|
|
@ -89,8 +89,8 @@ void wxMediaCtrl2::Load(wxURI url)
|
|||
BambuPlayer * player = (BambuPlayer *) m_player;
|
||||
if (player) {
|
||||
[player close];
|
||||
[player open: url.BuildURI().ToUTF8()];
|
||||
m_error = 0;
|
||||
[player open: url.BuildURI().ToUTF8()];
|
||||
}
|
||||
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
|
||||
event.SetId(GetId());
|
||||
|
|
Loading…
Reference in New Issue