-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSoundEffect.cpp
More file actions
611 lines (487 loc) · 18.4 KB
/
Copy pathSoundEffect.cpp
File metadata and controls
611 lines (487 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
//--------------------------------------------------------------------------------------
// File: SoundEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
#include "pch.h"
#include "WAVFileReader.h"
#include "SoundCommon.h"
#include <list>
#if defined(_XBOX_ONE) && defined(_TITLE)
#include <apu.h>
#endif
using namespace DirectX;
//======================================================================================
// SoundEffect
//======================================================================================
// Internal object implementation class.
class SoundEffect::Impl : public IVoiceNotify
{
public:
explicit Impl( _In_ AudioEngine* engine ) :
mWaveFormat( nullptr ),
mStartAudio( nullptr ),
mAudioBytes( 0 ),
mLoopStart( 0 ),
mLoopLength( 0 ),
mEngine( engine ),
mOneShots( 0 )
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
, mSeekCount( 0 )
, mSeekTable( nullptr )
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
, mXMAMemory( nullptr )
#endif
{
assert( mEngine != 0 );
mEngine->RegisterNotify( this, false );
}
virtual ~Impl()
{
if ( !mInstances.empty() )
{
DebugTrace( "WARNING: Destroying SoundEffect with %Iu outstanding SoundEffectInstances\n", mInstances.size() );
for( auto it = mInstances.begin(); it != mInstances.end(); ++it )
{
assert( *it != 0 );
(*it)->OnDestroyParent();
}
mInstances.clear();
}
if ( mOneShots > 0 )
{
DebugTrace( "WARNING: Destroying SoundEffect with %u outstanding one shot effects\n", mOneShots );
}
if ( mEngine )
{
mEngine->UnregisterNotify( this, true, false );
mEngine = nullptr;
}
#if defined(_XBOX_ONE) && defined(_TITLE)
if ( mXMAMemory )
{
ApuFree( mXMAMemory );
mXMAMemory = nullptr;
}
#endif
}
HRESULT Initialize( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
_In_reads_opt_(seekCount) const uint32_t* seekTable, size_t seekCount,
#endif
uint32_t loopStart, uint32_t loopLength );
void Play( float volume, float pitch, float pan );
// IVoiceNotify
virtual void __cdecl OnBufferEnd() override
{
InterlockedDecrement( &mOneShots );
}
virtual void __cdecl OnCriticalError() override
{
mOneShots = 0;
}
virtual void __cdecl OnReset() override
{
// No action required
}
virtual void __cdecl OnUpdate() override
{
// We do not register for update notification
assert(false);
}
virtual void __cdecl OnDestroyEngine() override
{
mEngine = nullptr;
mOneShots = 0;
}
virtual void __cdecl OnTrim() override
{
// No action required
}
virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override
{
stats.playingOneShots += mOneShots;
stats.audioBytes += mAudioBytes;
#if defined(_XBOX_ONE) && defined(_TITLE)
if ( mXMAMemory )
stats.xmaAudioBytes += mAudioBytes;
#endif
}
const WAVEFORMATEX* mWaveFormat;
const uint8_t* mStartAudio;
uint32_t mAudioBytes;
uint32_t mLoopStart;
uint32_t mLoopLength;
AudioEngine* mEngine;
std::list<SoundEffectInstance*> mInstances;
uint32_t mOneShots;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
uint32_t mSeekCount;
const uint32_t* mSeekTable;
#endif
private:
std::unique_ptr<uint8_t[]> mWavData;
#if defined(_XBOX_ONE) && defined(_TITLE)
void* mXMAMemory;
#endif
};
_Use_decl_annotations_
HRESULT SoundEffect::Impl::Initialize( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
const uint32_t* seekTable, size_t seekCount,
#endif
uint32_t loopStart, uint32_t loopLength )
{
if ( !engine || !IsValid( wfx ) || !startAudio || !audioBytes || !wavData )
return E_INVALIDARG;
if ( audioBytes > UINT32_MAX )
return E_INVALIDARG;
switch( GetFormatTag( wfx ) )
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
case WAVE_FORMAT_ADPCM:
// Take ownership of the buffer
mWavData.reset( wavData.release() );
// WARNING: We assume the wfx and startAudio parameters are pointers into the wavData memory buffer
mWaveFormat = wfx;
mStartAudio = startAudio;
break;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
if ( !seekCount || !seekTable )
{
DebugTrace( "ERROR: SoundEffect format xWMA requires seek table\n" );
return E_FAIL;
}
if ( seekCount > UINT32_MAX )
return E_INVALIDARG;
// Take ownership of the buffer
mWavData.reset( wavData.release() );
// WARNING: We assume the wfx, startAudio, and mSeekTable parameters are pointers into the wavData memory buffer
mWaveFormat = wfx;
mStartAudio = startAudio;
mSeekCount = static_cast<uint32_t>( seekCount );
mSeekTable = seekTable;
break;
#endif // _XBOX_ONE || _WIN32_WINNT < _WIN32_WINNT_WIN8 || _WIN32_WINNT >= _WIN32_WINNT_WIN10
#if defined(_XBOX_ONE) && defined(_TITLE)
case WAVE_FORMAT_XMA2:
if ( !seekCount || !seekTable )
{
DebugTrace( "ERROR: SoundEffect format XMA2 requires seek table\n" );
return E_FAIL;
}
if ( seekCount > UINT32_MAX )
return E_INVALIDARG;
{
HRESULT hr = ApuAlloc( &mXMAMemory, nullptr,
static_cast<UINT32>( audioBytes ), SHAPE_XMA_INPUT_BUFFER_ALIGNMENT );
if ( FAILED(hr) )
{
DebugTrace( "ERROR: ApuAlloc failed. Did you allocate a large enough heap with ApuCreateHeap for all your XMA wave data?\n" );
return hr;
}
}
memcpy( mXMAMemory, startAudio, audioBytes );
mStartAudio = reinterpret_cast<const uint8_t*>( mXMAMemory );
mWavData.reset( new uint8_t[ sizeof(XMA2WAVEFORMATEX) + ( seekCount * sizeof(uint32_t) ) ] );
memcpy( mWavData.get(), wfx, sizeof(XMA2WAVEFORMATEX) );
mWaveFormat = reinterpret_cast<WAVEFORMATEX*>( mWavData.get() );
// XMA seek table is Big-Endian
{
auto dest = reinterpret_cast<uint32_t*>( mWavData.get() + sizeof(XMA2WAVEFORMATEX) );
for( size_t k = 0; k < seekCount; ++k )
{
dest[ k ] = _byteswap_ulong( seekTable[ k ]) ;
}
}
mSeekCount = static_cast<uint32_t>( seekCount );
mSeekTable = reinterpret_cast<const uint32_t*>( mWavData.get() + sizeof(XMA2WAVEFORMATEX) );
wavData.reset();
break;
#endif // _XBOX_ONE && _TITLE
default:
{
DebugTrace( "ERROR: SoundEffect encountered an unsupported format tag (%u)\n", wfx->wFormatTag );
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
}
}
mAudioBytes = static_cast<uint32_t>( audioBytes );
mLoopStart = loopStart;
mLoopLength = loopLength;
return S_OK;
}
void SoundEffect::Impl::Play( float volume, float pitch, float pan )
{
assert( volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL );
assert( pitch >= -1.f && pitch <= 1.f );
assert( pan >= -1.f && pan <= 1.f );
IXAudio2SourceVoice* voice = nullptr;
mEngine->AllocateVoice( mWaveFormat, SoundEffectInstance_Default, true, &voice );
if ( !voice )
return;
if ( volume != 1.f )
{
HRESULT hr = voice->SetVolume( volume );
ThrowIfFailed( hr );
}
if ( pitch != 0.f )
{
float fr = XAudio2SemitonesToFrequencyRatio( pitch * 12.f );
HRESULT hr = voice->SetFrequencyRatio( fr );
ThrowIfFailed( hr );
}
if ( pan != 0.f )
{
float matrix[16];
if (ComputePan(pan, mWaveFormat->nChannels, matrix))
{
HRESULT hr = voice->SetOutputMatrix(nullptr, mWaveFormat->nChannels, mEngine->GetOutputChannels(), matrix);
ThrowIfFailed( hr );
}
}
HRESULT hr = voice->Start( 0 );
ThrowIfFailed( hr );
XAUDIO2_BUFFER buffer = {};
buffer.AudioBytes = mAudioBytes;
buffer.pAudioData = mStartAudio;
buffer.Flags = XAUDIO2_END_OF_STREAM;
buffer.pContext = this;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
uint32_t tag = GetFormatTag( mWaveFormat );
if ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 )
{
XAUDIO2_BUFFER_WMA wmaBuffer = {};
wmaBuffer.PacketCount = mSeekCount;
wmaBuffer.pDecodedPacketCumulativeBytes = mSeekTable;
hr = voice->SubmitSourceBuffer( &buffer, &wmaBuffer );
}
else
#endif
{
hr = voice->SubmitSourceBuffer( &buffer, nullptr );
}
if ( FAILED(hr) )
{
DebugTrace( "ERROR: SoundEffect failed (%08X) when submitting buffer:\n", hr );
DebugTrace( "\tFormat Tag %u, %u channels, %u-bit, %u Hz, %u bytes\n", mWaveFormat->wFormatTag,
mWaveFormat->nChannels, mWaveFormat->wBitsPerSample, mWaveFormat->nSamplesPerSec, mAudioBytes );
throw std::exception( "SubmitSourceBuffer" );
}
InterlockedIncrement( &mOneShots );
}
//--------------------------------------------------------------------------------------
// SoundEffect
//--------------------------------------------------------------------------------------
// Public constructors.
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, const wchar_t* waveFileName )
: pImpl(new Impl(engine) )
{
WAVData wavInfo;
std::unique_ptr<uint8_t[]> wavData;
HRESULT hr = LoadWAVAudioFromFileEx( waveFileName, wavData, wavInfo );
if ( FAILED(hr) )
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to load from .wav file \"%ls\"\n", hr, waveFileName );
throw std::exception( "SoundEffect" );
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
hr = pImpl->Initialize( engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
wavInfo.seek, wavInfo.seekCount,
wavInfo.loopStart, wavInfo.loopLength );
#else
hr = pImpl->Initialize( engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
wavInfo.loopStart, wavInfo.loopLength );
#endif
if ( FAILED(hr) )
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize from .wav file \"%ls\"\n", hr, waveFileName );
throw std::exception( "SoundEffect" );
}
}
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes )
: pImpl(new Impl(engine) )
{
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, nullptr, 0, 0, 0 );
#else
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, 0, 0 );
#endif
if ( FAILED(hr) )
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr );
throw std::exception( "SoundEffect" );
}
}
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
uint32_t loopStart, uint32_t loopLength )
: pImpl(new Impl(engine) )
{
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, nullptr, 0, loopStart, loopLength );
#else
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, loopStart, loopLength );
#endif
if ( FAILED(hr) )
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr );
throw std::exception( "SoundEffect" );
}
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
const uint32_t* seekTable, size_t seekCount )
{
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, seekTable, seekCount, 0, 0 );
if ( FAILED(hr) )
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr );
throw std::exception( "SoundEffect" );
}
}
#endif
// Move constructor.
SoundEffect::SoundEffect(SoundEffect&& moveFrom)
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
SoundEffect& SoundEffect::operator= (SoundEffect&& moveFrom)
{
pImpl = std::move(moveFrom.pImpl);
return *this;
}
// Public destructor.
SoundEffect::~SoundEffect()
{
}
// Public methods.
void SoundEffect::Play()
{
pImpl->Play( 1.f, 0.f, 0.f );
}
void SoundEffect::Play( float volume, float pitch, float pan )
{
pImpl->Play( volume, pitch, pan );
}
std::unique_ptr<SoundEffectInstance> SoundEffect::CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS flags )
{
auto effect = new SoundEffectInstance( pImpl->mEngine, this, flags );
assert( effect != 0 );
pImpl->mInstances.emplace_back( effect );
return std::unique_ptr<SoundEffectInstance>( effect );
}
void SoundEffect::UnregisterInstance( _In_ SoundEffectInstance* instance )
{
auto it = std::find( pImpl->mInstances.begin(), pImpl->mInstances.end(), instance );
if ( it == pImpl->mInstances.end() )
return;
pImpl->mInstances.erase( it );
}
// Public accessors.
bool SoundEffect::IsInUse() const
{
return ( pImpl->mOneShots > 0 ) || !pImpl->mInstances.empty();
}
size_t SoundEffect::GetSampleSizeInBytes() const
{
return pImpl->mAudioBytes;
}
size_t SoundEffect::GetSampleDuration() const
{
if ( !pImpl->mWaveFormat || !pImpl->mWaveFormat->nChannels )
return 0;
switch( GetFormatTag( pImpl->mWaveFormat ) )
{
case WAVE_FORMAT_ADPCM:
{
auto adpcmFmt = reinterpret_cast<const ADPCMWAVEFORMAT*>( pImpl->mWaveFormat );
uint64_t duration = uint64_t( pImpl->mAudioBytes / adpcmFmt->wfx.nBlockAlign ) * adpcmFmt->wSamplesPerBlock;
int partial = pImpl->mAudioBytes % adpcmFmt->wfx.nBlockAlign;
if ( partial )
{
if ( partial >= ( 7 * adpcmFmt->wfx.nChannels ) )
duration += ( partial * 2 / adpcmFmt->wfx.nChannels - 12 );
}
return static_cast<size_t>( duration );
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
if ( pImpl->mSeekTable && pImpl->mSeekCount > 0 )
{
return pImpl->mSeekTable[ pImpl->mSeekCount - 1 ] / uint32_t( 2 * pImpl->mWaveFormat->nChannels );
}
break;
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
case WAVE_FORMAT_XMA2:
return reinterpret_cast<const XMA2WAVEFORMATEX*>( pImpl->mWaveFormat )->SamplesEncoded;
#endif
default:
if ( pImpl->mWaveFormat->wBitsPerSample > 0 )
{
return static_cast<size_t>( ( uint64_t( pImpl->mAudioBytes ) * 8 )
/ uint64_t( pImpl->mWaveFormat->wBitsPerSample * pImpl->mWaveFormat->nChannels ) );
}
}
return 0;
}
size_t SoundEffect::GetSampleDurationMS() const
{
if ( !pImpl->mWaveFormat || !pImpl->mWaveFormat->nSamplesPerSec )
return 0;
uint64_t samples = GetSampleDuration();
return static_cast<size_t>( ( samples * 1000 ) / pImpl->mWaveFormat->nSamplesPerSec );
}
const WAVEFORMATEX* SoundEffect::GetFormat() const
{
return pImpl->mWaveFormat;
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
bool SoundEffect::FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const
{
memset( &buffer, 0, sizeof(buffer) );
memset( &wmaBuffer, 0, sizeof(wmaBuffer) );
buffer.AudioBytes = pImpl->mAudioBytes;
buffer.pAudioData = pImpl->mStartAudio;
buffer.LoopBegin = pImpl->mLoopStart;
buffer.LoopLength = pImpl->mLoopLength;
uint32_t tag = GetFormatTag( pImpl->mWaveFormat );
if ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 )
{
wmaBuffer.PacketCount = pImpl->mSeekCount;
wmaBuffer.pDecodedPacketCumulativeBytes = pImpl->mSeekTable;
return true;
}
return false;
}
#else
void SoundEffect::FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const
{
memset( &buffer, 0, sizeof(buffer) );
buffer.AudioBytes = pImpl->mAudioBytes;
buffer.pAudioData = pImpl->mStartAudio;
buffer.LoopBegin = pImpl->mLoopStart;
buffer.LoopLength = pImpl->mLoopLength;
}
#endif