Replace float/UInt64 durations by a more precise Time class (#388)
Improve Clock class with atomic RestartIfOver method and allows to choose required precision
This commit is contained in:
@@ -105,7 +105,7 @@ namespace Nz
|
||||
drwav_uninit(&m_decoder);
|
||||
}
|
||||
|
||||
UInt32 GetDuration() const override
|
||||
Time GetDuration() const override
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ namespace Nz
|
||||
|
||||
m_format = *formatOpt;
|
||||
|
||||
m_duration = static_cast<UInt32>(1000ULL * m_decoder.totalPCMFrameCount / m_decoder.sampleRate);
|
||||
m_duration = Time::Microseconds(1'000'000LL * m_decoder.totalPCMFrameCount / m_decoder.sampleRate);
|
||||
m_sampleCount = m_decoder.totalPCMFrameCount * m_decoder.channels;
|
||||
m_sampleRate = m_decoder.sampleRate;
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Nz
|
||||
std::vector<Int16> m_mixBuffer;
|
||||
AudioFormat m_format;
|
||||
drwav m_decoder;
|
||||
UInt32 m_duration;
|
||||
Time m_duration;
|
||||
UInt32 m_sampleRate;
|
||||
UInt64 m_readSampleCount;
|
||||
UInt64 m_sampleCount;
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 GetDuration() const override
|
||||
Time GetDuration() const override
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ namespace Nz
|
||||
m_sampleCount = frameCount * m_channelCount;
|
||||
m_sampleRate = meta->data.stream_info.sample_rate;
|
||||
|
||||
m_duration = UInt32(1000ULL * frameCount / m_sampleRate);
|
||||
m_duration = Time::Microseconds(1'000'000LL * frameCount / m_sampleRate);
|
||||
};
|
||||
|
||||
FLAC__StreamDecoderInitStatus status = FLAC__stream_decoder_init_stream(decoder, &FlacReadCallback, &FlacSeekCallback, &FlacTellCallback, &FlacLengthCallback, &FlacEofCallback, &WriteCallback, &MetadataCallback, &ErrorCallback, &m_userData);
|
||||
@@ -477,8 +477,8 @@ namespace Nz
|
||||
FLAC__StreamDecoder* m_decoder;
|
||||
AudioFormat m_format;
|
||||
FlacUserdata m_userData;
|
||||
Time m_duration;
|
||||
UInt32 m_channelCount;
|
||||
UInt32 m_duration;
|
||||
UInt32 m_sampleRate;
|
||||
UInt64 m_readSampleCount;
|
||||
UInt64 m_sampleCount;
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Nz
|
||||
ov_clear(&m_decoder);
|
||||
}
|
||||
|
||||
UInt32 GetDuration() const override
|
||||
Time GetDuration() const override
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ namespace Nz
|
||||
UInt64 frameCount = UInt64(ov_pcm_total(&m_decoder, -1));
|
||||
|
||||
m_channelCount = info->channels;
|
||||
m_duration = UInt32(1000ULL * frameCount / info->rate);
|
||||
m_duration = Time::Microseconds(1'000'000LL * frameCount / info->rate);
|
||||
m_sampleCount = UInt64(frameCount * info->channels);
|
||||
m_sampleRate = info->rate;
|
||||
|
||||
@@ -319,8 +319,8 @@ namespace Nz
|
||||
std::vector<Int16> m_mixBuffer;
|
||||
AudioFormat m_format;
|
||||
OggVorbis_File m_decoder;
|
||||
Time m_duration;
|
||||
UInt32 m_channelCount;
|
||||
UInt32 m_duration;
|
||||
UInt32 m_sampleRate;
|
||||
UInt64 m_sampleCount;
|
||||
bool m_mixToMono;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Nz
|
||||
mp3dec_ex_close(&m_decoder);
|
||||
}
|
||||
|
||||
UInt32 GetDuration() const override
|
||||
Time GetDuration() const override
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ namespace Nz
|
||||
|
||||
m_format = *formatOpt;
|
||||
|
||||
m_duration = static_cast<UInt32>(1000ULL * m_decoder.samples / (m_decoder.info.hz * m_decoder.info.channels));
|
||||
m_duration = Time::Microseconds(1'000'000LL * m_decoder.samples / (m_decoder.info.hz * m_decoder.info.channels));
|
||||
m_sampleCount = m_decoder.samples;
|
||||
m_sampleRate = m_decoder.info.hz;
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Nz
|
||||
AudioFormat m_format;
|
||||
mp3dec_ex_t m_decoder;
|
||||
mp3dec_io_t m_io;
|
||||
UInt32 m_duration;
|
||||
Time m_duration;
|
||||
UInt32 m_sampleRate;
|
||||
UInt64 m_readSampleCount;
|
||||
UInt64 m_sampleCount;
|
||||
|
||||
Reference in New Issue
Block a user