diff --git a/common/netjack.c b/common/netjack.c index 9f99f5ae..56e7baa0 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -97,7 +97,21 @@ int netjack_wait( netjack_driver_state_t *netj ) // Increment expected frame here. - netj->expected_framecnt += 1; + if( netj->expected_framecnt_valid ) { + netj->expected_framecnt += 1; + } else { + // starting up.... lets look into the packetcache, and fetch the highest packet. + packet_cache_drain_socket( global_packcache, netj->sockfd ); + if( packet_cache_get_highest_available_framecnt( global_packcache, &next_frame_avail ) ) { + netj->expected_framecnt = next_frame_avail; + netj->expected_framecnt_valid = 1; + } else { + // no packets there... start normally. + netj->expected_framecnt = 0; + netj->expected_framecnt_valid = 1; + } + + } //jack_log( "expect %d", netj->expected_framecnt ); // Now check if required packet is already in the cache.