Skip to content

Commit c2622ca

Browse files
authored
Update ajm_at9.cpp
1 parent 4719d32 commit c2622ca

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/core/libraries/ajm/ajm_at9.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ std::tuple<u32, u32> AjmAt9Decoder::ProcessData(std::span<u8>& in_buf, SparseOut
5656
AjmInstanceGapless& gapless) {
5757
int ret = 0;
5858
int bytes_used = 0;
59+
Frame* frame = &static_cast<Atrac9Handle*>(m_handle)->Frame;
60+
5961
switch (m_format) {
6062
case AjmFormatEncoding::S16:
61-
ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(m_pcm_buffer.data()),
62-
&bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
63+
if (frame->Config != NULL) {
64+
ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(m_pcm_buffer.data()),
65+
&bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
66+
}
6367
break;
6468
case AjmFormatEncoding::S32:
6569
ret = Atrac9DecodeS32(m_handle, in_buf.data(), reinterpret_cast<s32*>(m_pcm_buffer.data()),
@@ -103,6 +107,14 @@ std::tuple<u32, u32> AjmAt9Decoder::ProcessData(std::span<u8>& in_buf, SparseOut
103107
UNREACHABLE();
104108
}
105109

110+
if (m_codec_info.framesInSuperframe == 0) {
111+
m_codec_info.framesInSuperframe = 1;
112+
}
113+
114+
if (m_codec_info.channels == 0) {
115+
m_codec_info.channels = 1;
116+
}
117+
106118
const auto samples_written = pcm_written / m_codec_info.channels;
107119
gapless.current.skipped_samples += m_codec_info.frameSamples - samples_written;
108120
if (gapless.init.total_samples != 0) {

0 commit comments

Comments
 (0)