Introduce the timer packet - "TI".

This timer will start the clock accounting for latency! Cool, right?
Remove useless qDebug() for music looping
This commit is contained in:
Crystalwarrior 2020-08-25 12:21:10 +03:00
parent febfbeafc1
commit 7e9c5726e0
4 changed files with 25 additions and 1 deletions

View File

@ -251,6 +251,10 @@ public:
void check_connection_received();
void start_clock(qint64 msecs);
void stop_clock();
qint64 get_ping() { return ping_timer.elapsed(); }
~Courtroom();

View File

@ -145,7 +145,6 @@ void CALLBACK loopProc(HSYNC handle, DWORD channel, DWORD data, void *user)
void AOMusicPlayer::set_looping(bool toggle, int channel)
{
qDebug() << "Setting looping for channel" << channel << "to" << toggle;
m_looping = toggle;
if (!m_looping) {
if (BASS_ChannelFlags(m_stream_list[channel], 0, 0) & BASS_SAMPLE_LOOP)

View File

@ -4715,6 +4715,16 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud,
}
}
void Courtroom::start_clock(qint64 msecs)
{
ui_clock->start(static_cast<int>(msecs));
}
void Courtroom::stop_clock()
{
ui_clock->stop();
}
Courtroom::~Courtroom()
{
delete music_player;

View File

@ -728,6 +728,17 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
f_contents.at(4) == "1",
f_contents.at(5) == "1");
}
else if (header == "TI") { // Timer packet
if (courtroom_constructed && f_contents.size() >= 1) {
qint64 resolution = f_contents.at(0).toInt();
qDebug() << "timer" << resolution << last_ping << resolution - last_ping;
resolution = resolution - last_ping;
if (resolution > 0)
w_courtroom->start_clock(resolution);
else
w_courtroom->stop_clock();
}
}
end: