Browse Source

WindowsMediaAudioFormat fix for some file types.

tags/2021-05-28
jules 13 years ago
parent
commit
48569794c5
2 changed files with 32 additions and 17 deletions
  1. +23
    -4
      modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp
  2. +9
    -13
      modules/juce_audio_formats/format/juce_AudioFormatManager.cpp

+ 23
- 4
modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp View File

@@ -177,18 +177,24 @@ public:
bufferStart = bufferEnd = 0;
}
const int stride = numChannels * sizeof (int16);
bool firstLoop = true;
while (numSamples > 0)
{
if (bufferEnd <= bufferStart)
{
INSSBuffer* sampleBuffer = nullptr;
ComSmartPtr<INSSBuffer> sampleBuffer;
QWORD sampleTime, duration;
DWORD flags, outputNum;
WORD streamNum;
int64 readBufferStart;
HRESULT hr = wmSyncReader->GetNextSample (0, &sampleBuffer, &sampleTime,
HRESULT hr = wmSyncReader->GetNextSample (1, sampleBuffer.resetAndGetPointerAddress(), &sampleTime,
&duration, &flags, &outputNum, &streamNum);
readBufferStart = (int64)floor((sampleTime * sampleRate) * 0.0000001);
if (sampleBuffer != nullptr)
{
BYTE* rawData = nullptr;
@@ -206,7 +212,15 @@ public:
buffer.ensureSize (bufferEnd);
memcpy (buffer.getData(), rawData, bufferEnd);
sampleBuffer->Release();
if (firstLoop && readBufferStart < startSampleInFile)
{
bufferStart += (startSampleInFile - readBufferStart) * stride;
if (bufferStart > bufferEnd)
bufferStart = bufferEnd;
}
}
else
{
@@ -215,9 +229,11 @@ public:
buffer.ensureSize (bufferEnd);
buffer.fillWith (0);
}
firstLoop = false;
}
const int stride = numChannels * sizeof (int16);
const int16* const rawData = static_cast <const int16*> (addBytesToPointer (buffer.getData(), bufferStart));
const int numToDo = jmin (numSamples, (bufferEnd - bufferStart) / stride);
@@ -237,6 +253,9 @@ public:
}
bufferStart += numToDo * stride;
if (bufferEnd - bufferStart < stride)
bufferStart = bufferEnd;
startOffsetInDestBuffer += numToDo;
numSamples -= numToDo;
currentPosition += numToDo;


+ 9
- 13
modules/juce_audio_formats/format/juce_AudioFormatManager.cpp View File

@@ -23,14 +23,8 @@
==============================================================================
*/
AudioFormatManager::AudioFormatManager()
: defaultFormatIndex (0)
{
}
AudioFormatManager::~AudioFormatManager()
{
}
AudioFormatManager::AudioFormatManager() : defaultFormatIndex (0) {}
AudioFormatManager::~AudioFormatManager() {}
//==============================================================================
void AudioFormatManager::registerFormat (AudioFormat* newFormat, const bool makeThisTheDefaultFormat)
@@ -71,13 +65,15 @@ void AudioFormatManager::registerBasicFormats()
#if JUCE_MAC || JUCE_IOS
registerFormat (new CoreAudioFormat(), false);
#elif JUCE_USE_WINDOWS_MEDIA_FORMAT
registerFormat (new WindowsMediaAudioFormat(), false);
#elif JUCE_USE_MP3AUDIOFORMAT
// The software MP3 decoder is only used as a default format if
// there isn't an OS-provided alternative.
#endif
#if JUCE_USE_MP3AUDIOFORMAT
registerFormat (new MP3AudioFormat(), false);
#endif
#if JUCE_USE_WINDOWS_MEDIA_FORMAT
registerFormat (new WindowsMediaAudioFormat(), false);
#endif
}
void AudioFormatManager::clearFormats()


Loading…
Cancel
Save