@@ -57,13 +57,13 @@ void CSoundRender_Source::decompress(void* dest, u32 byte_offset, u32 size)
57
57
std::lock_guard guard{ read_lock };
58
58
59
59
// seek
60
- const auto sample_offset = ogg_int64_t (byte_offset / m_wformat. nBlockAlign );
60
+ const auto sample_offset = ogg_int64_t (byte_offset / m_info. blockAlign );
61
61
const u32 cur_pos = u32 (ov_pcm_tell (&ovf));
62
62
if (cur_pos != sample_offset)
63
63
ov_pcm_seek (&ovf, sample_offset);
64
64
65
65
// decompress
66
- if (m_wformat. wFormatTag == WAVE_FORMAT_IEEE_FLOAT )
66
+ if (m_info. format == SoundFormat:: Float32 )
67
67
i_decompress (static_cast <float *>(dest), size);
68
68
else
69
69
i_decompress (static_cast <char *>(dest), size);
@@ -85,7 +85,7 @@ void CSoundRender_Source::i_decompress(char* _dest, u32 size)
85
85
86
86
void CSoundRender_Source::i_decompress (float * _dest, u32 size)
87
87
{
88
- s32 left = s32 (size / m_wformat. nBlockAlign );
88
+ s32 left = s32 (size / m_info. blockAlign );
89
89
while (left)
90
90
{
91
91
float ** pcm;
@@ -98,7 +98,7 @@ void CSoundRender_Source::i_decompress(float* _dest, u32 size)
98
98
samples = left;
99
99
100
100
for (long j = 0 ; j < samples; j++)
101
- for (long i = 0 ; i < m_wformat. nChannels ; i++)
101
+ for (long i = 0 ; i < m_info. channels ; i++)
102
102
*_dest++ = pcm[i][j];
103
103
104
104
left -= samples;
@@ -184,28 +184,29 @@ bool CSoundRender_Source::LoadWave(pcstr pName, bool crashOnError)
184
184
return false ;
185
185
});
186
186
187
- ZeroMemory (&m_wformat, sizeof (WAVEFORMATEX)) ;
187
+ m_info = {} ;
188
188
189
- m_wformat. nSamplesPerSec = ovi->rate ;
190
- m_wformat. nChannels = u16 (ovi->channels );
189
+ m_info. samplesPerSec = ovi->rate ;
190
+ m_info. channels = u16 (ovi->channels );
191
191
192
192
if (SoundRender->supports_float_pcm )
193
193
{
194
- m_wformat. wFormatTag = WAVE_FORMAT_IEEE_FLOAT ;
195
- m_wformat. wBitsPerSample = 32 ;
194
+ m_info. format = SoundFormat:: Float32 ;
195
+ m_info. bitsPerSample = 32 ;
196
196
}
197
197
else
198
198
{
199
- m_wformat. wFormatTag = WAVE_FORMAT_PCM ;
200
- m_wformat. wBitsPerSample = 16 ;
199
+ m_info. format = SoundFormat::PCM ;
200
+ m_info. bitsPerSample = 16 ;
201
201
}
202
202
203
- m_wformat.nBlockAlign = m_wformat.wBitsPerSample / 8 * m_wformat.nChannels ;
204
- m_wformat.nAvgBytesPerSec = m_wformat.nSamplesPerSec * m_wformat.nBlockAlign ;
203
+ m_info.blockAlign = m_info.bitsPerSample / 8 * m_info.channels ;
204
+ m_info.avgBytesPerSec = m_info.samplesPerSec * m_info.blockAlign ;
205
+ m_info.bytesPerBuffer = sdef_target_block * m_info.avgBytesPerSec / 1000 ;
205
206
206
207
const s64 pcm_total = ov_pcm_total (&ovf, -1 );
207
- dwBytesTotal = u32 (pcm_total * m_wformat. nBlockAlign );
208
- fTimeTotal = dwBytesTotal / float (m_wformat. nAvgBytesPerSec );
208
+ dwBytesTotal = u32 (pcm_total * m_info. blockAlign );
209
+ fTimeTotal = dwBytesTotal / float (m_info. avgBytesPerSec );
209
210
210
211
const vorbis_comment* ovm = ov_comment (&ovf, -1 );
211
212
if (ovm->comments )
0 commit comments