attotime::from_ticks: on 0hz return attotime::never instead of crashing (nw)

This commit is contained in:
hap 2018-11-11 18:01:25 +01:00
parent 46f38a9d67
commit f4f390a538
2 changed files with 12 additions and 7 deletions

View File

@ -343,6 +343,8 @@ inline u64 attotime::as_ticks(u32 frequency) const
/** Create an attotime from a tick count @ticks at the given frequency @frequency */ /** Create an attotime from a tick count @ticks at the given frequency @frequency */
inline attotime attotime::from_ticks(u64 ticks, u32 frequency) inline attotime attotime::from_ticks(u64 ticks, u32 frequency)
{
if (frequency > 0)
{ {
attoseconds_t attos_per_tick = HZ_TO_ATTOSECONDS(frequency); attoseconds_t attos_per_tick = HZ_TO_ATTOSECONDS(frequency);
@ -353,6 +355,9 @@ inline attotime attotime::from_ticks(u64 ticks, u32 frequency)
s32 secs = divu_64x32_rem(ticks, frequency, &remainder); s32 secs = divu_64x32_rem(ticks, frequency, &remainder);
return attotime(secs, u64(remainder) * attos_per_tick); return attotime(secs, u64(remainder) * attos_per_tick);
} }
else
return attotime::never;
}
/** Create an attotime from floating point count of seconds @p _time */ /** Create an attotime from floating point count of seconds @p _time */
inline attotime attotime::from_double(double _time) inline attotime attotime::from_double(double _time)

View File

@ -224,7 +224,7 @@ WRITE8_MEMBER(vis_audio_device::pcm_w)
m_samples = 0; m_samples = 0;
m_sample_byte = 0; m_sample_byte = 0;
m_isa->drq7_w(ASSERT_LINE); m_isa->drq7_w(ASSERT_LINE);
attotime rate = attotime::from_ticks((double)(1 << ((m_mode >> 5) & 3)), 44100.0); // TODO : Unknown clock attotime rate = attotime::from_ticks(1 << ((m_mode >> 5) & 3), 44100); // TODO : Unknown clock
m_pcm->adjust(rate, 0, rate); m_pcm->adjust(rate, 0, rate);
} }
else if(!(m_mode & 0x10)) else if(!(m_mode & 0x10))