Skip to content

Commit c9afe67

Browse files
committed
Fix WMF
1 parent 315774d commit c9afe67

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

modules/yup_audio_formats/formats/yup_AppleCoreAudioFormat.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,13 +1039,12 @@ const char* const AppleCoreAudioFormat::timeSig = "time signature";
10391039
const char* const AppleCoreAudioFormat::keySig = "key signature";
10401040

10411041
AppleCoreAudioFormat::AppleCoreAudioFormat()
1042-
: formatName ("CoreAudio file")
1043-
, streamKind (StreamKind::kNone)
1042+
: AppleCoreAudioFormat (StreamKind::kNone)
10441043
{
10451044
}
10461045

10471046
AppleCoreAudioFormat::AppleCoreAudioFormat (StreamKind kind)
1048-
: formatName ("CoreAudio file")
1047+
: formatName ("CoreAudio")
10491048
, streamKind (kind)
10501049
{
10511050
}

modules/yup_audio_formats/formats/yup_WindowsMediaAudioFormat.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ class MediaFoundationAsyncState : public IUnknown
6868
}
6969

7070
STDMETHODIMP_ (ULONG)
71+
7172
AddRef() override
7273
{
7374
return (ULONG) InterlockedIncrement (&refCount);
7475
}
7576

7677
STDMETHODIMP_ (ULONG)
78+
7779
Release() override
7880
{
7981
const auto count = (ULONG) InterlockedDecrement (&refCount);
@@ -85,7 +87,7 @@ class MediaFoundationAsyncState : public IUnknown
8587
ULONG bytesProcessed = 0;
8688

8789
private:
88-
~MediaFoundationAsyncState() override = default;
90+
~MediaFoundationAsyncState() = default;
8991

9092
LONG refCount = 1;
9193
};
@@ -128,12 +130,14 @@ class MediaFoundationInputByteStream final : public IMFByteStream
128130
}
129131

130132
STDMETHODIMP_ (ULONG)
133+
131134
AddRef() override
132135
{
133136
return (ULONG) InterlockedIncrement (&refCount);
134137
}
135138

136139
STDMETHODIMP_ (ULONG)
140+
137141
Release() override
138142
{
139143
const auto count = (ULONG) InterlockedDecrement (&refCount);
@@ -189,7 +193,7 @@ class MediaFoundationInputByteStream final : public IMFByteStream
189193
if (stream == nullptr)
190194
return E_FAIL;
191195

192-
return stream->setPosition ((int64) qwPosition) ? S_OK : E_FAIL;
196+
return stream->setPosition ((int64) qwPosition) ? S_OK : E_NOTIMPL;
193197
}
194198

195199
STDMETHODIMP IsEndOfStream (BOOL* pfEndOfStream) override
@@ -219,7 +223,7 @@ class MediaFoundationInputByteStream final : public IMFByteStream
219223
if (pcbRead != nullptr)
220224
*pcbRead = (ULONG) bytesRead;
221225

222-
return S_OK;
226+
return bytesRead == (int) cb ? S_OK : S_FALSE;
223227
}
224228

225229
STDMETHODIMP BeginRead (BYTE* pb,
@@ -330,7 +334,7 @@ class MediaFoundationInputByteStream final : public IMFByteStream
330334
}
331335

332336
private:
333-
~MediaFoundationInputByteStream() override = default;
337+
~MediaFoundationInputByteStream() = default;
334338

335339
LONG refCount = 1;
336340
InputStream* stream = nullptr;
@@ -371,12 +375,14 @@ class MediaFoundationOutputByteStream final : public IMFByteStream
371375
}
372376

373377
STDMETHODIMP_ (ULONG)
378+
374379
AddRef() override
375380
{
376381
return (ULONG) InterlockedIncrement (&refCount);
377382
}
378383

379384
STDMETHODIMP_ (ULONG)
385+
380386
Release() override
381387
{
382388
const auto count = (ULONG) InterlockedDecrement (&refCount);
@@ -591,7 +597,7 @@ class MediaFoundationOutputByteStream final : public IMFByteStream
591597
}
592598

593599
private:
594-
~MediaFoundationOutputByteStream() override = default;
600+
~MediaFoundationOutputByteStream() = default;
595601

596602
LONG refCount = 1;
597603
OutputStream* stream = nullptr;
@@ -835,7 +841,7 @@ bool WindowsMediaAudioFormatReader::copyInterleavedToDest (const void* source,
835841
using SourceFormat = AudioData::Format<AudioData::Int16, AudioData::LittleEndian>;
836842
using DestFormat = AudioData::Format<AudioData::Float32, AudioData::NativeEndian>;
837843

838-
AudioData::deinterleaveSamples (AudioData::InterleavedSource<SourceFormat> { static_cast<const int16*> (source), numChannels },
844+
AudioData::deinterleaveSamples (AudioData::InterleavedSource<SourceFormat> { reinterpret_cast<const uint16*> (source), numChannels },
839845
AudioData::NonInterleavedDest<DestFormat> { offsetDestChannels.getData(), numDestChannels },
840846
numFrames);
841847
return true;
@@ -1110,7 +1116,7 @@ bool WindowsMediaAudioFormatWriter::openWriter (OutputStream* stream,
11101116
const auto containerType = resolveContainerType (stream);
11111117
attributes->SetGUID (MF_TRANSCODE_CONTAINERTYPE, containerType);
11121118

1113-
hr = MFCreateSinkWriterFromByteStream (byteStream, attributes, &sinkWriter);
1119+
hr = MFCreateSinkWriterFromURL (nullptr, byteStream, attributes, &sinkWriter);
11141120
safeRelease (&attributes);
11151121

11161122
if (FAILED (hr) || sinkWriter == nullptr)
@@ -1246,7 +1252,7 @@ bool WindowsMediaAudioFormatWriter::flush()
12461252
//==============================================================================
12471253
// WindowsMediaAudioFormat implementation
12481254
WindowsMediaAudioFormat::WindowsMediaAudioFormat()
1249-
: formatName ("Windows Media Foundation")
1255+
: formatName ("Windows Media")
12501256
{
12511257
}
12521258

@@ -1259,7 +1265,7 @@ const String& WindowsMediaAudioFormat::getFormatName() const
12591265

12601266
Array<String> WindowsMediaAudioFormat::getFileExtensions() const
12611267
{
1262-
return { ".m4a", ".mp4", ".aac", ".wma", ".aiff" };
1268+
return { ".m4a", ".mp4", ".aac", ".wma", ".wm", ".wmv", ".asf", ".mp3" };
12631269
}
12641270

12651271
std::unique_ptr<AudioFormatReader> WindowsMediaAudioFormat::createReaderFor (InputStream* sourceStream)

modules/yup_audio_formats/yup_audio_formats.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
#if YUP_WINDOWS
5555
#include <windows.h>
56+
#include <mfobjects.h>
5657
#include <mfapi.h>
5758
#include <mfidl.h>
5859
#include <mfreadwrite.h>

0 commit comments

Comments
 (0)