Hi Jules,
when compiling with optimization for speed (/O2) under Visual Studio 2008 (Windows 7/64), WindowsMediaAudioFormat will crash when creating a reader. The crash (access violation) happens inside line 145 of juce_WindowsMediaAudioFormat.cpp:
HRESULT hr = wmCreateSyncReader (nullptr, WMT_RIGHT_PLAYBACK, wmSyncReader.resetAndGetPointerAddress());
This can be easily reproduced by compiling the JuceDemo with /O2 and clicking on an mp3 file in the File Playback tab of the Audio demo page.
The crash doesn’t occure when I use the following code:
#pragma comment(lib, "wmvcore.lib")
//==============================================================================
class WMAudioReader : public AudioFormatReader
{
public:
WMAudioReader (InputStream* const input_)
: AudioFormatReader (input_, TRANS (wmFormatName)),
wmvCoreLib ("Wmvcore.dll"),
currentPosition (0),
bufferStart (0), bufferEnd (0)
{
typedef HRESULT (*WMCreateSyncReaderType) (IUnknown*, DWORD, IWMSyncReader**);
WMCreateSyncReaderType wmCreateSyncReader = nullptr;
wmCreateSyncReader = (WMCreateSyncReaderType) wmvCoreLib.getFunction ("WMCreateSyncReader");
if (wmCreateSyncReader != nullptr)
{
checkCoInitialiseCalled();
//HRESULT hr = wmCreateSyncReader (nullptr, WMT_RIGHT_PLAYBACK, wmSyncReader.resetAndGetPointerAddress());
HRESULT hr = WMCreateSyncReader (nullptr, WMT_RIGHT_PLAYBACK, wmSyncReader.resetAndGetPointerAddress());
Chris