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

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

View File

@ -224,7 +224,7 @@ WRITE8_MEMBER(vis_audio_device::pcm_w)
m_samples = 0;
m_sample_byte = 0;
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);
}
else if(!(m_mode & 0x10))