Fixed std::chrono::duration shenanigans

This commit is contained in:
Chris Moeller 2013-10-16 03:21:12 -07:00
parent cf3318c2c9
commit 22f9e86fd1

View file

@ -33,7 +33,7 @@ static bool is_gs_reset(const unsigned char * data, unsigned long size)
struct Cached_SoundFont struct Cached_SoundFont
{ {
unsigned long ref_count; unsigned long ref_count;
std::chrono::time_point<std::chrono::steady_clock> time_released; std::chrono::steady_clock::time_point time_released;
HSOUNDFONT handle; HSOUNDFONT handle;
Cached_SoundFont() : handle( 0 ) { } Cached_SoundFont() : handle( 0 ) { }
}; };
@ -115,7 +115,7 @@ static void cache_run()
while ( Cache_Running ) while ( Cache_Running )
{ {
std::chrono::time_point<std::chrono::steady_clock> now = std::chrono::steady_clock::now(); std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
{ {
std::lock_guard<std::mutex> lock( Cache_Lock ); std::lock_guard<std::mutex> lock( Cache_Lock );
@ -123,8 +123,8 @@ static void cache_run()
{ {
if ( it->second.ref_count == 0 ) if ( it->second.ref_count == 0 )
{ {
std::chrono::duration<double> elapsed = now - it->second.time_released; auto elapsed = std::chrono::duration_cast<std::chrono::seconds> ( now - it->second.time_released );
if ( elapsed.count() >= 10.0 ) if ( elapsed.count() >= 10 )
{ {
BASS_MIDI_FontFree( it->second.handle ); BASS_MIDI_FontFree( it->second.handle );
it = Cache_List.erase( it ); it = Cache_List.erase( it );