| 588 | } |
| 589 | |
| 590 | int CSound::LoadWV(const char *pFilename, int StorageType) |
| 591 | { |
| 592 | // no need to load sound when we are running with no sound |
| 593 | if(!m_SoundEnabled) |
| 594 | return -1; |
| 595 | |
| 596 | CSample *pSample = AllocSample(); |
| 597 | if(!pSample) |
| 598 | { |
| 599 | log_error("sound/wv", "Failed to allocate sample ID. Filename='%s'", pFilename); |
| 600 | return -1; |
| 601 | } |
| 602 | |
| 603 | void *pData; |
| 604 | unsigned DataSize; |
| 605 | if(!m_pStorage->ReadFile(pFilename, StorageType, &pData, &DataSize)) |
| 606 | { |
| 607 | UnloadSample(pSample->m_Index); |
| 608 | log_error("sound/wv", "Failed to open file. Filename='%s'", pFilename); |
| 609 | return -1; |
| 610 | } |
| 611 | |
| 612 | const bool DecodeSuccess = DecodeWV(*pSample, pData, DataSize, pFilename); |
| 613 | free(pData); |
| 614 | if(!DecodeSuccess) |
| 615 | { |
| 616 | UnloadSample(pSample->m_Index); |
| 617 | return -1; |
| 618 | } |
| 619 | |
| 620 | if(g_Config.m_Debug) |
| 621 | log_trace("sound/wv", "Loaded '%s' (index %d)", pFilename, pSample->m_Index); |
| 622 | |
| 623 | RateConvert(*pSample); |
| 624 | return pSample->m_Index; |
| 625 | } |
| 626 | |
| 627 | int CSound::LoadOpusFromMem(const void *pData, unsigned DataSize, bool ForceLoad, const char *pContextName) |
| 628 | { |