Skip to content

Commit cbd2729

Browse files
committed
flac: code review, seekByTime route to seek
1 parent d53389b commit cbd2729

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

engine/audio/backend/AudioDecoderFLAC.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,14 @@ namespace core {
3636
return FLAC__stream_decoder_seek_absolute(m_flac, pcm_frame);
3737
}
3838
bool AudioDecodeFLAC::seekByTime(double const sec) {
39-
if (FLAC__STREAM_DECODER_SEEK_ERROR == FLAC__stream_decoder_get_state(m_flac)) {
40-
if (!FLAC__stream_decoder_flush(m_flac)) {
41-
return false;
42-
}
43-
}
44-
FLAC__uint64 const pcm_frame = static_cast<FLAC__uint64>(sec * static_cast<double>(m_info.sample_rate));
45-
m_current_pcm_frame = static_cast<uint32_t>(pcm_frame);
46-
m_flac_frame_data.clear();
47-
return FLAC__stream_decoder_seek_absolute(m_flac, pcm_frame);
39+
auto const pcm_frame = static_cast<uint64_t>(sec * static_cast<double>(m_info.sample_rate));
40+
return seek(static_cast<uint32_t>(pcm_frame));
4841
}
49-
bool AudioDecodeFLAC::tell(uint32_t* pcm_frame) {
42+
bool AudioDecodeFLAC::tell(uint32_t* const pcm_frame) {
5043
*pcm_frame = m_current_pcm_frame;
5144
return true;
5245
}
53-
bool AudioDecodeFLAC::tellAsTime(double* sec) {
46+
bool AudioDecodeFLAC::tellAsTime(double* const sec) {
5447
*sec = static_cast<double>(m_current_pcm_frame) / static_cast<double>(m_info.sample_rate);
5548
return true;
5649
}

0 commit comments

Comments
 (0)