9#include <private/qwindowsaudioutils_p.h>
24 m_sourceResolver->Release();
29 if (!m_device && m_source ==
fileName)
32 m_sourceResolver->
cancel();
39 m_sourceResolver->
load(m_source, 0);
40 m_loadingSource =
true;
49 m_sourceResolver->
cancel();
57 m_sourceResolver->
load(
QUrl(), m_device);
58 m_loadingSource =
true;
63void MFAudioDecoderControl::handleMediaSourceReady()
65 m_loadingSource =
false;
66 if (m_deferredStart) {
67 m_deferredStart =
false;
68 startReadingSource(m_sourceResolver->
mediaSource());
72void MFAudioDecoderControl::handleMediaSourceError(
long hr)
74 m_loadingSource =
false;
75 m_deferredStart =
false;
76 if (hr == MF_E_UNSUPPORTED_BYTESTREAM_TYPE) {
78 }
else if (hr == ERROR_FILE_NOT_FOUND) {
86void MFAudioDecoderControl::startReadingSource(IMFMediaSource *
source)
90 m_decoderSourceReader = makeComObject<MFDecoderSourceReader>();
91 if (!m_decoderSourceReader) {
96 auto mediaType = m_decoderSourceReader->setSource(
source, m_outputFormat.
sampleFormat());
100 m_decoderSourceReader.Reset();
104 ComPtr<IMFPresentationDescriptor> pd;
105 if (SUCCEEDED(
source->CreatePresentationDescriptor(pd.GetAddressOf()))) {
107 pd->GetUINT64(MF_PD_DURATION, &
duration);
113 if (!m_resampler.
setup(mediaFormat, m_outputFormat.
isValid() ? m_outputFormat : mediaFormat)) {
114 qWarning() <<
"Failed to set up resampler";
123 m_decoderSourceReader->readNextSample();
131 if (m_loadingSource) {
132 m_deferredStart =
true;
144 startReadingSource(
source);
151 m_deferredStart =
false;
156 m_decoderSourceReader->clearSource();
157 m_decoderSourceReader.Reset();
166 if (m_position != -1) {
170 if (m_duration != -1) {
176void MFAudioDecoderControl::handleNewSample(ComPtr<IMFSample> sample)
194void MFAudioDecoderControl::handleSourceFinished()
202 if (m_outputFormat ==
format)
213 buffer.swap(m_audioBuffer);
214 m_position =
buffer.startTime() / 1000;
217 m_decoderSourceReader->readNextSample();
225#include "moc_mfaudiodecodercontrol_p.cpp"
IOBluetoothDevice * device
qint64 duration() const override
void setAudioFormat(const QAudioFormat &format) override
bool bufferAvailable() const override
MFAudioDecoderControl(QAudioDecoder *parent)
void setSourceDevice(QIODevice *device) override
QAudioBuffer read() override
void setSource(const QUrl &fileName) override
~MFAudioDecoderControl() override
void newSample(ComPtr< IMFSample >)
void swap(QAudioBuffer &other) noexcept
Swaps the audio buffer with other.
The QAudioDecoder class implements decoding audio.
\inmodule QtCore \reentrant
bool isOpen() const
Returns true if the device is open; otherwise returns false.
bool isReadable() const
Returns true if data can be read from the device; otherwise returns false.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static QString fromStdString(const std::string &s)
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
void clear()
Resets the content of the QUrl.
bool setup(const QAudioFormat &in, const QAudioFormat &out)
QByteArray resample(const QByteArrayView &in)
quint64 totalOutputBytes() const
QAudioFormat outputFormat() const
IMFMediaSource * mediaSource() const
void load(const QUrl &url, QIODevice *stream)
Combined button and popup list for selecting options.
Q_MULTIMEDIA_EXPORT QAudioFormat mediaTypeToFormat(IMFMediaType *mediaType)
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
QTextStream out(stdout)
[7]
myObject disconnect()
[26]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent