/////////////////////////////////////////////////////////////////////////// ResMusic ///////////////////////////////////////////////////////////////////////////
| 337 | /// ResMusic |
| 338 | //////////////////////////////////////////////////////////////////////////////// |
| 339 | fResult ResMusic::BGMWrapper::Read(fData pBuffer, fuInt SizeToRead, fuInt* pSizeRead) |
| 340 | { |
| 341 | fResult tFR; |
| 342 | |
| 343 | // ��õ���������С |
| 344 | fuInt tBlockAlign = GetBlockAlign(); |
| 345 | |
| 346 | // ������Ҫ��ȡ�IJ������� |
| 347 | fuInt tSampleToRead = SizeToRead / tBlockAlign; |
| 348 | |
| 349 | // �����Ƶ���� |
| 350 | while (tSampleToRead) |
| 351 | { |
| 352 | // ��õ�ǰ������λ��(����) |
| 353 | fuInt tCurSample = (fuInt)GetPosition() / tBlockAlign; |
| 354 | |
| 355 | // ����ȡλ���Ƿ�ѭ���� |
| 356 | if (tCurSample + tSampleToRead > m_pLoopEndSample) |
| 357 | { |
| 358 | // ����������� |
| 359 | if (tCurSample < m_pLoopEndSample) |
| 360 | { |
| 361 | fuInt tVaildSample = m_pLoopEndSample - tCurSample; |
| 362 | fuInt tVaildSize = tVaildSample * tBlockAlign; |
| 363 | |
| 364 | if (FAILED(tFR = m_pDecoder->Read(pBuffer, tVaildSize, pSizeRead))) |
| 365 | return tFR; |
| 366 | |
| 367 | // ָ����� |
| 368 | pBuffer += tVaildSize; |
| 369 | |
| 370 | // ���ٲ��� |
| 371 | tSampleToRead -= tVaildSample; |
| 372 | } |
| 373 | |
| 374 | // ����ѭ��ͷ |
| 375 | SetPosition(FCYSEEKORIGIN_BEG, m_pLoopStartSample * tBlockAlign); |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | // ֱ��������� |
| 380 | if (FAILED(tFR = m_pDecoder->Read(pBuffer, tSampleToRead * tBlockAlign, pSizeRead))) |
| 381 | return tFR; |
| 382 | |
| 383 | break; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | if (pSizeRead) |
| 388 | *pSizeRead = SizeToRead; |
| 389 | |
| 390 | return FCYERR_OK; |
| 391 | } |
| 392 | |
| 393 | ResMusic::BGMWrapper::BGMWrapper(fcyRefPointer<f2dSoundDecoder> pOrg, fDouble LoopStart, fDouble LoopEnd) |
| 394 | : m_pDecoder(pOrg) |
nothing calls this directly
no outgoing calls
no test coverage detected