Merge remote-tracking branch 'origin/dev' into stable

Change-Id: I84b36fa41f3d5f8fea2dec2545f72ebe6a0c7908
This commit is contained in:
Oswald Buddenhagen
2014-02-19 10:04:30 +01:00
103 changed files with 955 additions and 625 deletions

View File

@@ -1,4 +1,4 @@
load(qt_build_config) load(qt_build_config)
CONFIG += qt_example_installs CONFIG += qt_example_installs
MODULE_VERSION = 5.2.2 MODULE_VERSION = 5.3.0

View File

@@ -119,12 +119,13 @@ void QGstreamerAudioInputSelector::updateAlsaDevices()
{ {
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
void **hints, **n; void **hints, **n;
if (snd_device_name_hint(-1, "pcm", &hints) < 0) { int card = -1;
qWarning()<<"no alsa devices available";
return;
}
n = hints;
while (snd_card_next(&card) == 0 && card >= 0) {
if (snd_device_name_hint(card, "pcm", &hints) < 0)
continue;
n = hints;
while (*n != NULL) { while (*n != NULL) {
char *name = snd_device_name_get_hint(*n, "NAME"); char *name = snd_device_name_get_hint(*n, "NAME");
char *descr = snd_device_name_get_hint(*n, "DESC"); char *descr = snd_device_name_get_hint(*n, "DESC");
@@ -143,9 +144,11 @@ void QGstreamerAudioInputSelector::updateAlsaDevices()
free(descr); free(descr);
if (io != NULL) if (io != NULL)
free(io); free(io);
n++; ++n;
} }
snd_device_name_free_hint(hints); snd_device_name_free_hint(hints);
}
#endif #endif
} }

View File

@@ -110,10 +110,10 @@ QDeclarativeCameraCapture::QDeclarativeCameraCapture(QCamera *camera, QObject *p
connect(m_capture, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool))); connect(m_capture, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool)));
connect(m_capture, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int))); connect(m_capture, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int)));
connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int, QImage))); connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int,QImage)));
connect(m_capture, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), this, connect(m_capture, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), this,
SLOT(_q_imageMetadataAvailable(int,QString,QVariant))); SLOT(_q_imageMetadataAvailable(int,QString,QVariant)));
connect(m_capture, SIGNAL(imageSaved(int,QString)), this, SLOT(_q_imageSaved(int, QString))); connect(m_capture, SIGNAL(imageSaved(int,QString)), this, SLOT(_q_imageSaved(int,QString)));
connect(m_capture, SIGNAL(error(int,QCameraImageCapture::Error,QString)), connect(m_capture, SIGNAL(error(int,QCameraImageCapture::Error,QString)),
this, SLOT(_q_captureFailed(int,QCameraImageCapture::Error,QString))); this, SLOT(_q_captureFailed(int,QCameraImageCapture::Error,QString)));

View File

@@ -114,7 +114,7 @@ QDeclarativeRadio::QDeclarativeRadio(QObject *parent) :
connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int))); connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int)));
connect(m_radioTuner, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int))); connect(m_radioTuner, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
connect(m_radioTuner, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); connect(m_radioTuner, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
connect(m_radioTuner, SIGNAL(stationFound(int, QString)), this, SIGNAL(stationFound(int, QString))); connect(m_radioTuner, SIGNAL(stationFound(int,QString)), this, SIGNAL(stationFound(int,QString)));
connect(m_radioTuner, SIGNAL(antennaConnectedChanged(bool)), this, SIGNAL(antennaConnectedChanged(bool))); connect(m_radioTuner, SIGNAL(antennaConnectedChanged(bool)), this, SIGNAL(antennaConnectedChanged(bool)));
connect(m_radioTuner, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)), this, SLOT(_q_availabilityChanged(QMultimedia::AvailabilityStatus))); connect(m_radioTuner, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)), this, SLOT(_q_availabilityChanged(QMultimedia::AvailabilityStatus)));

View File

@@ -39,17 +39,8 @@ SOURCES += \
audio/qaudiodecoder.cpp \ audio/qaudiodecoder.cpp \
audio/qaudiohelpers.cpp audio/qaudiohelpers.cpp
win32 {
PRIVATE_HEADERS += audio/qaudioinput_win32_p.h audio/qaudiooutput_win32_p.h audio/qaudiodeviceinfo_win32_p.h
SOURCES += audio/qaudiodeviceinfo_win32_p.cpp \
audio/qaudiooutput_win32_p.cpp \
audio/qaudioinput_win32_p.cpp
LIBS_PRIVATE += -lwinmm -lstrmiids -lole32 -loleaut32
}
unix:!mac { unix:!mac {
config_pulseaudio { config_pulseaudio {
DEFINES += QT_NO_AUDIO_BACKEND
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG_PRIVATE += libpulse PKGCONFIG_PRIVATE += libpulse
@@ -61,15 +52,6 @@ unix:!mac {
DEFINES += QT_MULTIMEDIA_QAUDIO DEFINES += QT_MULTIMEDIA_QAUDIO
PRIVATE_HEADERS += audio/qsoundeffect_qaudio_p.h PRIVATE_HEADERS += audio/qsoundeffect_qaudio_p.h
SOURCES += audio/qsoundeffect_qaudio_p.cpp SOURCES += audio/qsoundeffect_qaudio_p.cpp
config_alsa {
DEFINES += HAS_ALSA
PRIVATE_HEADERS += audio/qaudiooutput_alsa_p.h audio/qaudioinput_alsa_p.h audio/qaudiodeviceinfo_alsa_p.h
SOURCES += audio/qaudiodeviceinfo_alsa_p.cpp \
audio/qaudiooutput_alsa_p.cpp \
audio/qaudioinput_alsa_p.cpp
LIBS_PRIVATE += -lasound
}
} }
} else { } else {
DEFINES += QT_MULTIMEDIA_QAUDIO DEFINES += QT_MULTIMEDIA_QAUDIO

View File

@@ -47,18 +47,6 @@
#include "qmediapluginloader_p.h" #include "qmediapluginloader_p.h"
#include "qaudiodevicefactory_p.h" #include "qaudiodevicefactory_p.h"
#ifndef QT_NO_AUDIO_BACKEND
#if defined(Q_OS_WIN)
#include "qaudiodeviceinfo_win32_p.h"
#include "qaudiooutput_win32_p.h"
#include "qaudioinput_win32_p.h"
#elif defined(HAS_ALSA)
#include "qaudiodeviceinfo_alsa_p.h"
#include "qaudiooutput_alsa_p.h"
#include "qaudioinput_alsa_p.h"
#endif
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
@@ -132,13 +120,6 @@ public:
QList<QAudioDeviceInfo> QAudioDeviceFactory::availableDevices(QAudio::Mode mode) QList<QAudioDeviceInfo> QAudioDeviceFactory::availableDevices(QAudio::Mode mode)
{ {
QList<QAudioDeviceInfo> devices; QList<QAudioDeviceInfo> devices;
#ifndef QT_NO_AUDIO_BACKEND
#if (defined(Q_OS_WIN) || defined(HAS_ALSA))
foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode))
devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode);
#endif
#endif
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QMediaPluginLoader* l = audioLoader(); QMediaPluginLoader* l = audioLoader();
foreach (const QString& key, l->keys()) { foreach (const QString& key, l->keys()) {
@@ -165,11 +146,6 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice()
} }
#endif #endif
#ifndef QT_NO_AUDIO_BACKEND
#if (defined(Q_OS_WIN) || defined(HAS_ALSA))
return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput);
#endif
#endif
return QAudioDeviceInfo(); return QAudioDeviceInfo();
} }
@@ -185,11 +161,6 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice()
} }
#endif #endif
#ifndef QT_NO_AUDIO_BACKEND
#if (defined(Q_OS_WIN) || defined(HAS_ALSA))
return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput);
#endif
#endif
return QAudioDeviceInfo(); return QAudioDeviceInfo();
} }
@@ -197,13 +168,6 @@ QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &re
{ {
QAbstractAudioDeviceInfo *rc = 0; QAbstractAudioDeviceInfo *rc = 0;
#ifndef QT_NO_AUDIO_BACKEND
#if (defined(Q_OS_WIN) || defined(HAS_ALSA))
if (realm == QLatin1String("builtin"))
return new QAudioDeviceInfoInternal(handle, mode);
#endif
#endif
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QAudioSystemFactoryInterface* plugin = QAudioSystemFactoryInterface* plugin =
qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(realm)); qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(realm));
@@ -229,15 +193,7 @@ QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo con
{ {
if (deviceInfo.isNull()) if (deviceInfo.isNull())
return new QNullInputDevice(); return new QNullInputDevice();
#ifndef QT_NO_AUDIO_BACKEND
#if (defined(Q_OS_WIN) || defined(HAS_ALSA))
if (deviceInfo.realm() == QLatin1String("builtin")) {
QAbstractAudioInput* p = new QAudioInputPrivate(deviceInfo.handle());
if (p) p->setFormat(format);
return p;
}
#endif
#endif
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QAudioSystemFactoryInterface* plugin = QAudioSystemFactoryInterface* plugin =
qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(deviceInfo.realm())); qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(deviceInfo.realm()));
@@ -256,15 +212,6 @@ QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo c
{ {
if (deviceInfo.isNull()) if (deviceInfo.isNull())
return new QNullOutputDevice(); return new QNullOutputDevice();
#ifndef QT_NO_AUDIO_BACKEND
#if (defined(Q_OS_WIN) || defined(HAS_ALSA))
if (deviceInfo.realm() == QLatin1String("builtin")) {
QAbstractAudioOutput* p = new QAudioOutputPrivate(deviceInfo.handle());
if (p) p->setFormat(format);
return p;
}
#endif
#endif
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QAudioSystemFactoryInterface* plugin = QAudioSystemFactoryInterface* plugin =

View File

@@ -266,8 +266,8 @@ bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject)
this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); this, SIGNAL(imageMetadataAvailable(int,QString,QVariant)));
connect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)), connect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)),
this, SIGNAL(imageAvailable(int,QVideoFrame))); this, SIGNAL(imageAvailable(int,QVideoFrame)));
connect(d->control, SIGNAL(imageSaved(int, QString)), connect(d->control, SIGNAL(imageSaved(int,QString)),
this, SIGNAL(imageSaved(int, QString))); this, SIGNAL(imageSaved(int,QString)));
connect(d->control, SIGNAL(readyForCaptureChanged(bool)), connect(d->control, SIGNAL(readyForCaptureChanged(bool)),
this, SLOT(_q_readyChanged(bool))); this, SLOT(_q_readyChanged(bool)));
connect(d->control, SIGNAL(error(int,int,QString)), connect(d->control, SIGNAL(error(int,int,QString)),

View File

@@ -27,7 +27,7 @@
/*! /*!
\page blackberry.html \page blackberry.html
\title BlackBerry \title Qt Multimedia on BlackBerry
\brief Platform notes for the BlackBerry Platform \brief Platform notes for the BlackBerry Platform
Qt Multimedia supports BlackBerry devices that run the BB10 operating system. Qt Multimedia supports BlackBerry devices that run the BB10 operating system.

View File

@@ -131,7 +131,7 @@
\section2 Platform Notes \section2 Platform Notes
\list \list
\li \l{BlackBerry} \li \l{Qt Multimedia on BlackBerry}{BlackBerry}
\li \l{Qt Multimedia on Windows}{Windows} \li \l{Qt Multimedia on Windows}{Windows}
\endlist \endlist

View File

@@ -396,8 +396,8 @@ void QPlaylistFileParserPrivate::processLine(int startIndex, int length)
Q_ASSERT(m_currentParser); Q_ASSERT(m_currentParser);
connect(m_currentParser, SIGNAL(newItem(QVariant)), q, SIGNAL(newItem(QVariant))); connect(m_currentParser, SIGNAL(newItem(QVariant)), q, SIGNAL(newItem(QVariant)));
connect(m_currentParser, SIGNAL(finished()), q, SLOT(_q_handleParserFinished())); connect(m_currentParser, SIGNAL(finished()), q, SLOT(_q_handleParserFinished()));
connect(m_currentParser, SIGNAL(error(QPlaylistFileParser::ParserError, QString)), connect(m_currentParser, SIGNAL(error(QPlaylistFileParser::ParserError,QString)),
q, SLOT(_q_handleParserError(QPlaylistFileParser::ParserError, QString))); q, SLOT(_q_handleParserError(QPlaylistFileParser::ParserError,QString)));
} }
QString line; QString line;
@@ -583,8 +583,8 @@ void QPlaylistFileParser::stop()
if (d->m_currentParser) { if (d->m_currentParser) {
disconnect(d->m_currentParser, SIGNAL(newItem(QVariant)), this, SIGNAL(newItem(QVariant))); disconnect(d->m_currentParser, SIGNAL(newItem(QVariant)), this, SIGNAL(newItem(QVariant)));
disconnect(d->m_currentParser, SIGNAL(finished()), this, SLOT(_q_handleParserFinished())); disconnect(d->m_currentParser, SIGNAL(finished()), this, SLOT(_q_handleParserFinished()));
disconnect(d->m_currentParser, SIGNAL(error(QPlaylistFileParser::ParserError, QString)), disconnect(d->m_currentParser, SIGNAL(error(QPlaylistFileParser::ParserError,QString)),
this, SLOT(_q_handleParserError(QPlaylistFileParser::ParserError, QString))); this, SLOT(_q_handleParserError(QPlaylistFileParser::ParserError,QString)));
d->m_currentParser->deleteLater(); d->m_currentParser->deleteLater();
d->m_currentParser = 0; d->m_currentParser = 0;
} }

View File

@@ -113,11 +113,11 @@ QMediaNetworkPlaylistProvider::QMediaNetworkPlaylistProvider(QObject *parent)
:QMediaPlaylistProvider(*new QMediaNetworkPlaylistProviderPrivate, parent) :QMediaPlaylistProvider(*new QMediaNetworkPlaylistProviderPrivate, parent)
{ {
d_func()->q_ptr = this; d_func()->q_ptr = this;
connect(&d_func()->parser, SIGNAL(newItem(const QVariant&)), connect(&d_func()->parser, SIGNAL(newItem(QVariant)),
this, SLOT(_q_handleNewItem(const QVariant&))); this, SLOT(_q_handleNewItem(QVariant)));
connect(&d_func()->parser, SIGNAL(finished()), this, SIGNAL(loaded())); connect(&d_func()->parser, SIGNAL(finished()), this, SIGNAL(loaded()));
connect(&d_func()->parser, SIGNAL(error(QPlaylistFileParser::ParserError, const QString &)), connect(&d_func()->parser, SIGNAL(error(QPlaylistFileParser::ParserError,QString)),
this, SLOT(_q_handleParserError(QPlaylistFileParser::ParserError, const QString &))); this, SLOT(_q_handleParserError(QPlaylistFileParser::ParserError,QString)));
} }
QMediaNetworkPlaylistProvider::~QMediaNetworkPlaylistProvider() QMediaNetworkPlaylistProvider::~QMediaNetworkPlaylistProvider()

View File

@@ -0,0 +1,3 @@
{
"Keys": ["alsa"]
}

23
src/plugins/alsa/alsa.pro Normal file
View File

@@ -0,0 +1,23 @@
TARGET = qtaudio_alsa
QT += multimedia-private
PLUGIN_TYPE = audio
PLUGIN_CLASS_NAME = QAlsaPlugin
load(qt_plugin)
LIBS += -lasound
HEADERS += \
qalsaplugin.h \
qalsaaudiodeviceinfo.h \
qalsaaudioinput.h \
qalsaaudiooutput.h
SOURCES += \
qalsaplugin.cpp \
qalsaaudiodeviceinfo.cpp \
qalsaaudioinput.cpp \
qalsaaudiooutput.cpp
OTHER_FILES += \
alsa.json

View File

@@ -50,13 +50,13 @@
// INTERNAL USE ONLY: Do NOT use for any other purpose. // INTERNAL USE ONLY: Do NOT use for any other purpose.
// //
#include "qaudiodeviceinfo_alsa_p.h" #include "qalsaaudiodeviceinfo.h"
#include <alsa/version.h> #include <alsa/version.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) QAlsaAudioDeviceInfo::QAlsaAudioDeviceInfo(QByteArray dev, QAudio::Mode mode)
{ {
handle = 0; handle = 0;
@@ -66,17 +66,17 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode
checkSurround(); checkSurround();
} }
QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() QAlsaAudioDeviceInfo::~QAlsaAudioDeviceInfo()
{ {
close(); close();
} }
bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const bool QAlsaAudioDeviceInfo::isFormatSupported(const QAudioFormat& format) const
{ {
return testSettings(format); return testSettings(format);
} }
QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const QAudioFormat QAlsaAudioDeviceInfo::preferredFormat() const
{ {
QAudioFormat nearest; QAudioFormat nearest;
if(mode == QAudio::AudioOutput) { if(mode == QAudio::AudioOutput) {
@@ -101,48 +101,48 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
return nearest; return nearest;
} }
QString QAudioDeviceInfoInternal::deviceName() const QString QAlsaAudioDeviceInfo::deviceName() const
{ {
return device; return device;
} }
QStringList QAudioDeviceInfoInternal::supportedCodecs() QStringList QAlsaAudioDeviceInfo::supportedCodecs()
{ {
updateLists(); updateLists();
return codecz; return codecz;
} }
QList<int> QAudioDeviceInfoInternal::supportedSampleRates() QList<int> QAlsaAudioDeviceInfo::supportedSampleRates()
{ {
updateLists(); updateLists();
return sampleRatez; return sampleRatez;
} }
QList<int> QAudioDeviceInfoInternal::supportedChannelCounts() QList<int> QAlsaAudioDeviceInfo::supportedChannelCounts()
{ {
updateLists(); updateLists();
return channelz; return channelz;
} }
QList<int> QAudioDeviceInfoInternal::supportedSampleSizes() QList<int> QAlsaAudioDeviceInfo::supportedSampleSizes()
{ {
updateLists(); updateLists();
return sizez; return sizez;
} }
QList<QAudioFormat::Endian> QAudioDeviceInfoInternal::supportedByteOrders() QList<QAudioFormat::Endian> QAlsaAudioDeviceInfo::supportedByteOrders()
{ {
updateLists(); updateLists();
return byteOrderz; return byteOrderz;
} }
QList<QAudioFormat::SampleType> QAudioDeviceInfoInternal::supportedSampleTypes() QList<QAudioFormat::SampleType> QAlsaAudioDeviceInfo::supportedSampleTypes()
{ {
updateLists(); updateLists();
return typez; return typez;
} }
bool QAudioDeviceInfoInternal::open() bool QAlsaAudioDeviceInfo::open()
{ {
int err = 0; int err = 0;
QString dev = device; QString dev = device;
@@ -166,7 +166,7 @@ bool QAudioDeviceInfoInternal::open()
QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1);
while(snd_card_get_name(idx,&name) == 0) { while (snd_card_get_name(idx,&name) == 0) {
if(dev.contains(QLatin1String(name))) if(dev.contains(QLatin1String(name)))
break; break;
idx++; idx++;
@@ -186,14 +186,14 @@ bool QAudioDeviceInfoInternal::open()
return true; return true;
} }
void QAudioDeviceInfoInternal::close() void QAlsaAudioDeviceInfo::close()
{ {
if(handle) if(handle)
snd_pcm_close(handle); snd_pcm_close(handle);
handle = 0; handle = 0;
} }
bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const bool QAlsaAudioDeviceInfo::testSettings(const QAudioFormat& format) const
{ {
// Set nearest to closest settings that do work. // Set nearest to closest settings that do work.
// See if what is in settings will work (return value). // See if what is in settings will work (return value).
@@ -301,7 +301,7 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
return (err == 0); return (err == 0);
} }
void QAudioDeviceInfoInternal::updateLists() void QAlsaAudioDeviceInfo::updateLists()
{ {
// redo all lists based on current settings // redo all lists based on current settings
sampleRatez.clear(); sampleRatez.clear();
@@ -338,21 +338,16 @@ void QAudioDeviceInfoInternal::updateLists()
close(); close();
} }
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) QList<QByteArray> QAlsaAudioDeviceInfo::availableDevices(QAudio::Mode mode)
{ {
QList<QByteArray> devices; QList<QByteArray> devices;
QByteArray filter; QByteArray filter;
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
// Create a list of all current audio devices that support mode // Create a list of all current audio devices that support mode
void **hints, **n; void **hints;
char *name, *descr, *io; char *name, *descr, *io;
int card = -1;
if(snd_device_name_hint(-1, "pcm", &hints) < 0) {
qWarning() << "no alsa devices available";
return devices;
}
n = hints;
if(mode == QAudio::AudioInput) { if(mode == QAudio::AudioInput) {
filter = "Input"; filter = "Input";
@@ -360,6 +355,11 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
filter = "Output"; filter = "Output";
} }
while (snd_card_next(&card) == 0 && card >= 0) {
if (snd_device_name_hint(card, "pcm", &hints) < 0)
continue;
void **n = hints;
while (*n != NULL) { while (*n != NULL) {
name = snd_device_name_get_hint(*n, "NAME"); name = snd_device_name_get_hint(*n, "NAME");
if (name != 0 && qstrcmp(name, "null") != 0) { if (name != 0 && qstrcmp(name, "null") != 0) {
@@ -381,7 +381,9 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
free(name); free(name);
++n; ++n;
} }
snd_device_name_free_hint(hints); snd_device_name_free_hint(hints);
}
#else #else
int idx = 0; int idx = 0;
char* name; char* name;
@@ -398,7 +400,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
return devices; return devices;
} }
QByteArray QAudioDeviceInfoInternal::defaultInputDevice() QByteArray QAlsaAudioDeviceInfo::defaultInputDevice()
{ {
QList<QByteArray> devices = availableDevices(QAudio::AudioInput); QList<QByteArray> devices = availableDevices(QAudio::AudioInput);
if(devices.size() == 0) if(devices.size() == 0)
@@ -407,7 +409,7 @@ QByteArray QAudioDeviceInfoInternal::defaultInputDevice()
return devices.first(); return devices.first();
} }
QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() QByteArray QAlsaAudioDeviceInfo::defaultOutputDevice()
{ {
QList<QByteArray> devices = availableDevices(QAudio::AudioOutput); QList<QByteArray> devices = availableDevices(QAudio::AudioOutput);
if(devices.size() == 0) if(devices.size() == 0)
@@ -416,20 +418,21 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
return devices.first(); return devices.first();
} }
void QAudioDeviceInfoInternal::checkSurround() void QAlsaAudioDeviceInfo::checkSurround()
{ {
surround40 = false; surround40 = false;
surround51 = false; surround51 = false;
surround71 = false; surround71 = false;
void **hints, **n; void **hints;
char *name, *descr, *io; char *name, *descr, *io;
int card = -1;
if(snd_device_name_hint(-1, "pcm", &hints) < 0) while (snd_card_next(&card) == 0 && card >= 0) {
return; if (snd_device_name_hint(card, "pcm", &hints) < 0)
continue;
n = hints;
void **n = hints;
while (*n != NULL) { while (*n != NULL) {
name = snd_device_name_get_hint(*n, "NAME"); name = snd_device_name_get_hint(*n, "NAME");
descr = snd_device_name_get_hint(*n, "DESC"); descr = snd_device_name_get_hint(*n, "DESC");
@@ -453,7 +456,9 @@ void QAudioDeviceInfoInternal::checkSurround()
free(io); free(io);
++n; ++n;
} }
snd_device_name_free_hint(hints); snd_device_name_free_hint(hints);
}
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@@ -51,8 +51,8 @@
// //
#ifndef QAUDIODEVICEINFOALSA_H #ifndef QALSAAUDIODEVICEINFO_H
#define QAUDIODEVICEINFOALSA_H #define QALSAAUDIODEVICEINFO_H
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
@@ -61,9 +61,9 @@
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include "qaudio.h" #include <QtMultimedia/qaudio.h>
#include "qaudiodeviceinfo.h" #include <QtMultimedia/qaudiodeviceinfo.h>
#include "qaudiosystem.h" #include <QtMultimedia/qaudiosystem.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -72,12 +72,12 @@ const unsigned int MAX_SAMPLE_RATES = 5;
const unsigned int SAMPLE_RATES[] = const unsigned int SAMPLE_RATES[] =
{ 8000, 11025, 22050, 44100, 48000 }; { 8000, 11025, 22050, 44100, 48000 };
class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo class QAlsaAudioDeviceInfo : public QAbstractAudioDeviceInfo
{ {
Q_OBJECT Q_OBJECT
public: public:
QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); QAlsaAudioDeviceInfo(QByteArray dev,QAudio::Mode mode);
~QAudioDeviceInfoInternal(); ~QAlsaAudioDeviceInfo();
bool testSettings(const QAudioFormat& format) const; bool testSettings(const QAudioFormat& format) const;
void updateLists(); void updateLists();
@@ -119,5 +119,4 @@ private:
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif // QALSAAUDIODEVICEINFO_H

View File

@@ -51,15 +51,15 @@
// //
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include "qaudioinput_alsa_p.h" #include <QtMultimedia/private/qaudiohelpers_p.h>
#include "qaudiodeviceinfo_alsa_p.h" #include "qalsaaudioinput.h"
#include "qaudiohelpers_p.h" #include "qalsaaudiodeviceinfo.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
//#define DEBUG_AUDIO 1 //#define DEBUG_AUDIO 1
QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device) QAlsaAudioInput::QAlsaAudioInput(const QByteArray &device)
{ {
bytesAvailable = 0; bytesAvailable = 0;
handle = 0; handle = 0;
@@ -86,7 +86,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device)
connect(timer,SIGNAL(timeout()),SLOT(userFeed())); connect(timer,SIGNAL(timeout()),SLOT(userFeed()));
} }
QAudioInputPrivate::~QAudioInputPrivate() QAlsaAudioInput::~QAlsaAudioInput()
{ {
close(); close();
disconnect(timer, SIGNAL(timeout())); disconnect(timer, SIGNAL(timeout()));
@@ -94,38 +94,38 @@ QAudioInputPrivate::~QAudioInputPrivate()
delete timer; delete timer;
} }
void QAudioInputPrivate::setVolume(qreal vol) void QAlsaAudioInput::setVolume(qreal vol)
{ {
m_volume = vol; m_volume = vol;
} }
qreal QAudioInputPrivate::volume() const qreal QAlsaAudioInput::volume() const
{ {
return m_volume; return m_volume;
} }
QAudio::Error QAudioInputPrivate::error() const QAudio::Error QAlsaAudioInput::error() const
{ {
return errorState; return errorState;
} }
QAudio::State QAudioInputPrivate::state() const QAudio::State QAlsaAudioInput::state() const
{ {
return deviceState; return deviceState;
} }
void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) void QAlsaAudioInput::setFormat(const QAudioFormat& fmt)
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
settings = fmt; settings = fmt;
} }
QAudioFormat QAudioInputPrivate::format() const QAudioFormat QAlsaAudioInput::format() const
{ {
return settings; return settings;
} }
int QAudioInputPrivate::xrun_recovery(int err) int QAlsaAudioInput::xrun_recovery(int err)
{ {
int count = 0; int count = 0;
bool reset = false; bool reset = false;
@@ -166,7 +166,7 @@ int QAudioInputPrivate::xrun_recovery(int err)
return err; return err;
} }
int QAudioInputPrivate::setFormat() int QAlsaAudioInput::setFormat()
{ {
snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN; snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN;
@@ -225,7 +225,7 @@ int QAudioInputPrivate::setFormat()
: -1; : -1;
} }
void QAudioInputPrivate::start(QIODevice* device) void QAlsaAudioInput::start(QIODevice* device)
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
close(); close();
@@ -244,7 +244,7 @@ void QAudioInputPrivate::start(QIODevice* device)
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
QIODevice* QAudioInputPrivate::start() QIODevice* QAlsaAudioInput::start()
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
close(); close();
@@ -266,7 +266,7 @@ QIODevice* QAudioInputPrivate::start()
return audioSource; return audioSource;
} }
void QAudioInputPrivate::stop() void QAlsaAudioInput::stop()
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
return; return;
@@ -277,7 +277,7 @@ void QAudioInputPrivate::stop()
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
bool QAudioInputPrivate::open() bool QAlsaAudioInput::open()
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
QTime now(QTime::currentTime()); QTime now(QTime::currentTime());
@@ -310,7 +310,7 @@ bool QAudioInputPrivate::open()
QString dev = QString(QLatin1String(m_device.constData())); QString dev = QString(QLatin1String(m_device.constData()));
QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); QList<QByteArray> devices = QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioInput);
if(dev.compare(QLatin1String("default")) == 0) { if(dev.compare(QLatin1String("default")) == 0) {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
if (devices.size() > 0) if (devices.size() > 0)
@@ -472,7 +472,7 @@ bool QAudioInputPrivate::open()
return true; return true;
} }
void QAudioInputPrivate::close() void QAlsaAudioInput::close()
{ {
timer->stop(); timer->stop();
@@ -483,7 +483,7 @@ void QAudioInputPrivate::close()
} }
} }
int QAudioInputPrivate::checkBytesReady() int QAlsaAudioInput::checkBytesReady()
{ {
if(resuming) if(resuming)
bytesAvailable = period_size; bytesAvailable = period_size;
@@ -503,12 +503,12 @@ int QAudioInputPrivate::checkBytesReady()
return bytesAvailable; return bytesAvailable;
} }
int QAudioInputPrivate::bytesReady() const int QAlsaAudioInput::bytesReady() const
{ {
return qMax(bytesAvailable, 0); return qMax(bytesAvailable, 0);
} }
qint64 QAudioInputPrivate::read(char* data, qint64 len) qint64 QAlsaAudioInput::read(char* data, qint64 len)
{ {
// Read in some audio data and write it to QIODevice, pull mode // Read in some audio data and write it to QIODevice, pull mode
if ( !handle ) if ( !handle )
@@ -649,7 +649,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
return 0; return 0;
} }
void QAudioInputPrivate::resume() void QAlsaAudioInput::resume()
{ {
if(deviceState == QAudio::SuspendedState) { if(deviceState == QAudio::SuspendedState) {
int err = 0; int err = 0;
@@ -673,32 +673,32 @@ void QAudioInputPrivate::resume()
} }
} }
void QAudioInputPrivate::setBufferSize(int value) void QAlsaAudioInput::setBufferSize(int value)
{ {
buffer_size = value; buffer_size = value;
} }
int QAudioInputPrivate::bufferSize() const int QAlsaAudioInput::bufferSize() const
{ {
return buffer_size; return buffer_size;
} }
int QAudioInputPrivate::periodSize() const int QAlsaAudioInput::periodSize() const
{ {
return period_size; return period_size;
} }
void QAudioInputPrivate::setNotifyInterval(int ms) void QAlsaAudioInput::setNotifyInterval(int ms)
{ {
intervalTime = qMax(0, ms); intervalTime = qMax(0, ms);
} }
int QAudioInputPrivate::notifyInterval() const int QAlsaAudioInput::notifyInterval() const
{ {
return intervalTime; return intervalTime;
} }
qint64 QAudioInputPrivate::processedUSecs() const qint64 QAlsaAudioInput::processedUSecs() const
{ {
qint64 result = qint64(1000000) * totalTimeValue / qint64 result = qint64(1000000) * totalTimeValue /
(settings.channelCount()*(settings.sampleSize()/8)) / (settings.channelCount()*(settings.sampleSize()/8)) /
@@ -707,7 +707,7 @@ qint64 QAudioInputPrivate::processedUSecs() const
return result; return result;
} }
void QAudioInputPrivate::suspend() void QAlsaAudioInput::suspend()
{ {
if(deviceState == QAudio::ActiveState||resuming) { if(deviceState == QAudio::ActiveState||resuming) {
timer->stop(); timer->stop();
@@ -716,7 +716,7 @@ void QAudioInputPrivate::suspend()
} }
} }
void QAudioInputPrivate::userFeed() void QAlsaAudioInput::userFeed()
{ {
if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return; return;
@@ -727,7 +727,7 @@ void QAudioInputPrivate::userFeed()
deviceReady(); deviceReady();
} }
bool QAudioInputPrivate::deviceReady() bool QAlsaAudioInput::deviceReady()
{ {
if(pullMode) { if(pullMode) {
// reads some audio data and writes it to QIODevice // reads some audio data and writes it to QIODevice
@@ -764,7 +764,7 @@ bool QAudioInputPrivate::deviceReady()
return true; return true;
} }
qint64 QAudioInputPrivate::elapsedUSecs() const qint64 QAlsaAudioInput::elapsedUSecs() const
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
return 0; return 0;
@@ -772,7 +772,7 @@ qint64 QAudioInputPrivate::elapsedUSecs() const
return clockStamp.elapsed()*1000; return clockStamp.elapsed()*1000;
} }
void QAudioInputPrivate::reset() void QAlsaAudioInput::reset()
{ {
if(handle) if(handle)
snd_pcm_reset(handle); snd_pcm_reset(handle);
@@ -780,15 +780,15 @@ void QAudioInputPrivate::reset()
bytesAvailable = 0; bytesAvailable = 0;
} }
void QAudioInputPrivate::drain() void QAlsaAudioInput::drain()
{ {
if(handle) if(handle)
snd_pcm_drain(handle); snd_pcm_drain(handle);
} }
InputPrivate::InputPrivate(QAudioInputPrivate* audio) InputPrivate::InputPrivate(QAlsaAudioInput* audio)
{ {
audioDevice = qobject_cast<QAudioInputPrivate*>(audio); audioDevice = qobject_cast<QAlsaAudioInput*>(audio);
} }
InputPrivate::~InputPrivate() InputPrivate::~InputPrivate()
@@ -879,4 +879,4 @@ void RingBuffer::write(char *data, int len)
QT_END_NAMESPACE QT_END_NAMESPACE
#include "moc_qaudioinput_alsa_p.cpp" #include "moc_qalsaaudioinput.cpp"

View File

@@ -63,9 +63,9 @@
#include <QtCore/qstringlist.h> #include <QtCore/qstringlist.h>
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include "qaudio.h" #include <QtMultimedia/qaudio.h>
#include "qaudiodeviceinfo.h" #include <QtMultimedia/qaudiodeviceinfo.h>
#include "qaudiosystem.h" #include <QtMultimedia/qaudiosystem.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -95,12 +95,12 @@ private:
QByteArray m_data; QByteArray m_data;
}; };
class QAudioInputPrivate : public QAbstractAudioInput class QAlsaAudioInput : public QAbstractAudioInput
{ {
Q_OBJECT Q_OBJECT
public: public:
QAudioInputPrivate(const QByteArray &device); QAlsaAudioInput(const QByteArray &device);
~QAudioInputPrivate(); ~QAlsaAudioInput();
qint64 read(char* data, qint64 len); qint64 read(char* data, qint64 len);
@@ -171,7 +171,7 @@ class InputPrivate : public QIODevice
{ {
Q_OBJECT Q_OBJECT
public: public:
InputPrivate(QAudioInputPrivate* audio); InputPrivate(QAlsaAudioInput* audio);
~InputPrivate(); ~InputPrivate();
qint64 readData( char* data, qint64 len); qint64 readData( char* data, qint64 len);
@@ -179,7 +179,7 @@ public:
void trigger(); void trigger();
private: private:
QAudioInputPrivate *audioDevice; QAlsaAudioInput *audioDevice;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@@ -51,15 +51,15 @@
// //
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include "qaudiooutput_alsa_p.h" #include <QtMultimedia/private/qaudiohelpers_p.h>
#include "qaudiodeviceinfo_alsa_p.h" #include "qalsaaudiooutput.h"
#include "qaudiohelpers_p.h" #include "qalsaaudiodeviceinfo.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
//#define DEBUG_AUDIO 1 //#define DEBUG_AUDIO 1
QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device) QAlsaAudioOutput::QAlsaAudioOutput(const QByteArray &device)
{ {
bytesAvailable = 0; bytesAvailable = 0;
handle = 0; handle = 0;
@@ -90,7 +90,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device)
connect(timer,SIGNAL(timeout()),SLOT(userFeed())); connect(timer,SIGNAL(timeout()),SLOT(userFeed()));
} }
QAudioOutputPrivate::~QAudioOutputPrivate() QAlsaAudioOutput::~QAlsaAudioOutput()
{ {
close(); close();
disconnect(timer, SIGNAL(timeout())); disconnect(timer, SIGNAL(timeout()));
@@ -98,38 +98,38 @@ QAudioOutputPrivate::~QAudioOutputPrivate()
delete timer; delete timer;
} }
void QAudioOutputPrivate::setVolume(qreal vol) void QAlsaAudioOutput::setVolume(qreal vol)
{ {
m_volume = vol; m_volume = vol;
} }
qreal QAudioOutputPrivate::volume() const qreal QAlsaAudioOutput::volume() const
{ {
return m_volume; return m_volume;
} }
QAudio::Error QAudioOutputPrivate::error() const QAudio::Error QAlsaAudioOutput::error() const
{ {
return errorState; return errorState;
} }
QAudio::State QAudioOutputPrivate::state() const QAudio::State QAlsaAudioOutput::state() const
{ {
return deviceState; return deviceState;
} }
void QAudioOutputPrivate::async_callback(snd_async_handler_t *ahandler) void QAlsaAudioOutput::async_callback(snd_async_handler_t *ahandler)
{ {
QAudioOutputPrivate* audioOut; QAlsaAudioOutput* audioOut;
audioOut = static_cast<QAudioOutputPrivate*> audioOut = static_cast<QAlsaAudioOutput*>
(snd_async_handler_get_callback_private(ahandler)); (snd_async_handler_get_callback_private(ahandler));
if (audioOut && (audioOut->deviceState == QAudio::ActiveState || audioOut->resuming)) if (audioOut && (audioOut->deviceState == QAudio::ActiveState || audioOut->resuming))
audioOut->feedback(); audioOut->feedback();
} }
int QAudioOutputPrivate::xrun_recovery(int err) int QAlsaAudioOutput::xrun_recovery(int err)
{ {
int count = 0; int count = 0;
bool reset = false; bool reset = false;
@@ -167,7 +167,7 @@ int QAudioOutputPrivate::xrun_recovery(int err)
return err; return err;
} }
int QAudioOutputPrivate::setFormat() int QAlsaAudioOutput::setFormat()
{ {
snd_pcm_format_t pcmformat = SND_PCM_FORMAT_UNKNOWN; snd_pcm_format_t pcmformat = SND_PCM_FORMAT_UNKNOWN;
@@ -227,7 +227,7 @@ int QAudioOutputPrivate::setFormat()
: -1; : -1;
} }
void QAudioOutputPrivate::start(QIODevice* device) void QAlsaAudioOutput::start(QIODevice* device)
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
deviceState = QAudio::StoppedState; deviceState = QAudio::StoppedState;
@@ -252,7 +252,7 @@ void QAudioOutputPrivate::start(QIODevice* device)
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
QIODevice* QAudioOutputPrivate::start() QIODevice* QAlsaAudioOutput::start()
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
deviceState = QAudio::StoppedState; deviceState = QAudio::StoppedState;
@@ -280,7 +280,7 @@ QIODevice* QAudioOutputPrivate::start()
return audioSource; return audioSource;
} }
void QAudioOutputPrivate::stop() void QAlsaAudioOutput::stop()
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
return; return;
@@ -290,7 +290,7 @@ void QAudioOutputPrivate::stop()
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
bool QAudioOutputPrivate::open() bool QAlsaAudioOutput::open()
{ {
if(opened) if(opened)
return true; return true;
@@ -324,7 +324,7 @@ bool QAudioOutputPrivate::open()
} }
QString dev = QString(QLatin1String(m_device.constData())); QString dev = QString(QLatin1String(m_device.constData()));
QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); QList<QByteArray> devices = QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
if(dev.compare(QLatin1String("default")) == 0) { if(dev.compare(QLatin1String("default")) == 0) {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
if (devices.size() > 0) if (devices.size() > 0)
@@ -343,7 +343,7 @@ bool QAudioOutputPrivate::open()
QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData());
while(snd_card_get_name(idx,&name) == 0) { while (snd_card_get_name(idx,&name) == 0) {
if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0)
break; break;
idx++; idx++;
@@ -529,7 +529,7 @@ bool QAudioOutputPrivate::open()
return true; return true;
} }
void QAudioOutputPrivate::close() void QAlsaAudioOutput::close()
{ {
timer->stop(); timer->stop();
@@ -547,7 +547,7 @@ void QAudioOutputPrivate::close()
opened = false; opened = false;
} }
int QAudioOutputPrivate::bytesFree() const int QAlsaAudioOutput::bytesFree() const
{ {
if(resuming) if(resuming)
return period_size; return period_size;
@@ -573,7 +573,7 @@ int QAudioOutputPrivate::bytesFree() const
return snd_pcm_frames_to_bytes(handle, frames); return snd_pcm_frames_to_bytes(handle, frames);
} }
qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) qint64 QAlsaAudioOutput::write( const char *data, qint64 len )
{ {
// Write out some audio data // Write out some audio data
if ( !handle ) if ( !handle )
@@ -623,38 +623,38 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
return 0; return 0;
} }
int QAudioOutputPrivate::periodSize() const int QAlsaAudioOutput::periodSize() const
{ {
return period_size; return period_size;
} }
void QAudioOutputPrivate::setBufferSize(int value) void QAlsaAudioOutput::setBufferSize(int value)
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
buffer_size = value; buffer_size = value;
} }
int QAudioOutputPrivate::bufferSize() const int QAlsaAudioOutput::bufferSize() const
{ {
return buffer_size; return buffer_size;
} }
void QAudioOutputPrivate::setNotifyInterval(int ms) void QAlsaAudioOutput::setNotifyInterval(int ms)
{ {
intervalTime = qMax(0, ms); intervalTime = qMax(0, ms);
} }
int QAudioOutputPrivate::notifyInterval() const int QAlsaAudioOutput::notifyInterval() const
{ {
return intervalTime; return intervalTime;
} }
qint64 QAudioOutputPrivate::processedUSecs() const qint64 QAlsaAudioOutput::processedUSecs() const
{ {
return qint64(1000000) * totalTimeValue / settings.sampleRate(); return qint64(1000000) * totalTimeValue / settings.sampleRate();
} }
void QAudioOutputPrivate::resume() void QAlsaAudioOutput::resume()
{ {
if(deviceState == QAudio::SuspendedState) { if(deviceState == QAudio::SuspendedState) {
int err = 0; int err = 0;
@@ -680,18 +680,18 @@ void QAudioOutputPrivate::resume()
} }
} }
void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) void QAlsaAudioOutput::setFormat(const QAudioFormat& fmt)
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
settings = fmt; settings = fmt;
} }
QAudioFormat QAudioOutputPrivate::format() const QAudioFormat QAlsaAudioOutput::format() const
{ {
return settings; return settings;
} }
void QAudioOutputPrivate::suspend() void QAlsaAudioOutput::suspend()
{ {
if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) {
timer->stop(); timer->stop();
@@ -701,7 +701,7 @@ void QAudioOutputPrivate::suspend()
} }
} }
void QAudioOutputPrivate::userFeed() void QAlsaAudioOutput::userFeed()
{ {
if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return; return;
@@ -715,13 +715,13 @@ void QAudioOutputPrivate::userFeed()
deviceReady(); deviceReady();
} }
void QAudioOutputPrivate::feedback() void QAlsaAudioOutput::feedback()
{ {
updateAvailable(); updateAvailable();
} }
void QAudioOutputPrivate::updateAvailable() void QAlsaAudioOutput::updateAvailable()
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
QTime now(QTime::currentTime()); QTime now(QTime::currentTime());
@@ -730,7 +730,7 @@ void QAudioOutputPrivate::updateAvailable()
bytesAvailable = bytesFree(); bytesAvailable = bytesFree();
} }
bool QAudioOutputPrivate::deviceReady() bool QAlsaAudioOutput::deviceReady()
{ {
if(pullMode) { if(pullMode) {
int l = 0; int l = 0;
@@ -805,7 +805,7 @@ bool QAudioOutputPrivate::deviceReady()
return true; return true;
} }
qint64 QAudioOutputPrivate::elapsedUSecs() const qint64 QAlsaAudioOutput::elapsedUSecs() const
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
return 0; return 0;
@@ -813,7 +813,7 @@ qint64 QAudioOutputPrivate::elapsedUSecs() const
return clockStamp.elapsed()*1000; return clockStamp.elapsed()*1000;
} }
void QAudioOutputPrivate::reset() void QAlsaAudioOutput::reset()
{ {
if(handle) if(handle)
snd_pcm_reset(handle); snd_pcm_reset(handle);
@@ -821,9 +821,9 @@ void QAudioOutputPrivate::reset()
stop(); stop();
} }
OutputPrivate::OutputPrivate(QAudioOutputPrivate* audio) OutputPrivate::OutputPrivate(QAlsaAudioOutput* audio)
{ {
audioDevice = qobject_cast<QAudioOutputPrivate*>(audio); audioDevice = qobject_cast<QAlsaAudioOutput*>(audio);
} }
OutputPrivate::~OutputPrivate() {} OutputPrivate::~OutputPrivate() {}
@@ -857,4 +857,4 @@ qint64 OutputPrivate::writeData(const char* data, qint64 len)
QT_END_NAMESPACE QT_END_NAMESPACE
#include "moc_qaudiooutput_alsa_p.cpp" #include "moc_qalsaaudiooutput.cpp"

View File

@@ -62,22 +62,19 @@
#include <QtCore/qstringlist.h> #include <QtCore/qstringlist.h>
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include "qaudio.h" #include <QtMultimedia/qaudio.h>
#include "qaudiodeviceinfo.h" #include <QtMultimedia/qaudiodeviceinfo.h>
#include "qaudiosystem.h" #include <QtMultimedia/qaudiosystem.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAlsaAudioOutput : public QAbstractAudioOutput
class OutputPrivate;
class QAudioOutputPrivate : public QAbstractAudioOutput
{ {
friend class OutputPrivate; friend class OutputPrivate;
Q_OBJECT Q_OBJECT
public: public:
QAudioOutputPrivate(const QByteArray &device); QAlsaAudioOutput(const QByteArray &device);
~QAudioOutputPrivate(); ~QAlsaAudioOutput();
qint64 write( const char *data, qint64 len ); qint64 write( const char *data, qint64 len );
@@ -154,17 +151,17 @@ private:
class OutputPrivate : public QIODevice class OutputPrivate : public QIODevice
{ {
friend class QAudioOutputPrivate; friend class QAlsaAudioOutput;
Q_OBJECT Q_OBJECT
public: public:
OutputPrivate(QAudioOutputPrivate* audio); OutputPrivate(QAlsaAudioOutput* audio);
~OutputPrivate(); ~OutputPrivate();
qint64 readData( char* data, qint64 len); qint64 readData( char* data, qint64 len);
qint64 writeData(const char* data, qint64 len); qint64 writeData(const char* data, qint64 len);
private: private:
QAudioOutputPrivate *audioDevice; QAlsaAudioOutput *audioDevice;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@@ -0,0 +1,74 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qalsaplugin.h"
#include "qalsaaudiodeviceinfo.h"
#include "qalsaaudioinput.h"
#include "qalsaaudiooutput.h"
QT_BEGIN_NAMESPACE
QAlsaPlugin::QAlsaPlugin(QObject *parent)
: QAudioSystemPlugin(parent)
{
}
QList<QByteArray> QAlsaPlugin::availableDevices(QAudio::Mode mode) const
{
return QAlsaAudioDeviceInfo::availableDevices(mode);
}
QAbstractAudioInput *QAlsaPlugin::createInput(const QByteArray &device)
{
return new QAlsaAudioInput(device);
}
QAbstractAudioOutput *QAlsaPlugin::createOutput(const QByteArray &device)
{
return new QAlsaAudioOutput(device);
}
QAbstractAudioDeviceInfo *QAlsaPlugin::createDeviceInfo(const QByteArray &device, QAudio::Mode mode)
{
return new QAlsaAudioDeviceInfo(device, mode);
}
QT_END_NAMESPACE

View File

@@ -0,0 +1,67 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QALSAPLUGIN_H
#define QALSAPLUGIN_H
#include <QtMultimedia/qaudiosystemplugin.h>
QT_BEGIN_NAMESPACE
class QAlsaPlugin : public QAudioSystemPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.qt.audiosystemfactory/5.0" FILE "alsa.json")
public:
QAlsaPlugin(QObject *parent = 0);
~QAlsaPlugin() {}
QList<QByteArray> availableDevices(QAudio::Mode mode) const Q_DECL_OVERRIDE;
QAbstractAudioInput *createInput(const QByteArray &device) Q_DECL_OVERRIDE;
QAbstractAudioOutput *createOutput(const QByteArray &device) Q_DECL_OVERRIDE;
QAbstractAudioDeviceInfo *createDeviceInfo(const QByteArray &device, QAudio::Mode mode) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
#endif // QALSAPLUGIN_H

View File

@@ -389,7 +389,7 @@ void QAndroidCaptureSession::applySettings()
} }
// video settings // video settings
if (m_cameraSession && m_videoSettingsDirty) { if (m_cameraSession && m_cameraSession->camera() && m_videoSettingsDirty) {
if (m_videoSettings.resolution().isEmpty()) { if (m_videoSettings.resolution().isEmpty()) {
m_videoSettings.setResolution(m_defaultSettings.videoResolution); m_videoSettings.setResolution(m_defaultSettings.videoResolution);
m_resolutionDirty = true; m_resolutionDirty = true;
@@ -466,6 +466,8 @@ void QAndroidCaptureSession::onCameraOpened()
qSort(m_supportedResolutions.begin(), m_supportedResolutions.end(), qt_sizeLessThan); qSort(m_supportedResolutions.begin(), m_supportedResolutions.end(), qt_sizeLessThan);
qSort(m_supportedFramerates.begin(), m_supportedFramerates.end()); qSort(m_supportedFramerates.begin(), m_supportedFramerates.end());
applySettings();
} }
QAndroidCaptureSession::CaptureProfile QAndroidCaptureSession::getProfile(int id) QAndroidCaptureSession::CaptureProfile QAndroidCaptureSession::getProfile(int id)

View File

@@ -63,12 +63,12 @@ QAndroidMediaPlayerControl::QAndroidMediaPlayerControl(QObject *parent)
{ {
connect(mMediaPlayer, SIGNAL(bufferingUpdate(qint32)), connect(mMediaPlayer, SIGNAL(bufferingUpdate(qint32)),
this, SLOT(onBufferChanged(qint32))); this, SLOT(onBufferChanged(qint32)));
connect(mMediaPlayer, SIGNAL(info(qint32, qint32)), connect(mMediaPlayer, SIGNAL(info(qint32,qint32)),
this, SLOT(onInfo(qint32, qint32))); this, SLOT(onInfo(qint32,qint32)));
connect(mMediaPlayer, SIGNAL(error(qint32, qint32)), connect(mMediaPlayer, SIGNAL(error(qint32,qint32)),
this, SLOT(onError(qint32, qint32))); this, SLOT(onError(qint32,qint32)));
connect(mMediaPlayer, SIGNAL(mediaPlayerInfo(qint32, qint32)), connect(mMediaPlayer, SIGNAL(mediaPlayerInfo(qint32,qint32)),
this, SLOT(onMediaPlayerInfo(qint32, qint32))); this, SLOT(onMediaPlayerInfo(qint32,qint32)));
connect(mMediaPlayer, SIGNAL(videoSizeChanged(qint32,qint32)), connect(mMediaPlayer, SIGNAL(videoSizeChanged(qint32,qint32)),
this, SLOT(onVideoSizeChanged(qint32,qint32))); this, SLOT(onVideoSizeChanged(qint32,qint32)));
} }

View File

@@ -64,6 +64,7 @@ public:
void setVideoOutput(AVFVideoRendererControl *output); void setVideoOutput(AVFVideoRendererControl *output);
AVCaptureSession *captureSession() const { return m_captureSession; } AVCaptureSession *captureSession() const { return m_captureSession; }
AVCaptureDevice *videoCaptureDevice() const;
QCamera::State state() const; QCamera::State state() const;
QCamera::State requestedState() const { return m_state; } QCamera::State requestedState() const { return m_state; }

View File

@@ -155,7 +155,15 @@ void AVFCameraSession::setVideoOutput(AVFVideoRendererControl *output)
{ {
m_videoOutput = output; m_videoOutput = output;
if (output) if (output)
output->configureAVCaptureSession(m_captureSession); output->configureAVCaptureSession(this);
}
AVCaptureDevice *AVFCameraSession::videoCaptureDevice() const
{
if (m_videoInput)
return m_videoInput.device;
return 0;
} }
QCamera::State AVFCameraSession::state() const QCamera::State AVFCameraSession::state() const

View File

@@ -66,7 +66,7 @@ public:
QAbstractVideoSurface *surface() const; QAbstractVideoSurface *surface() const;
void setSurface(QAbstractVideoSurface *surface); void setSurface(QAbstractVideoSurface *surface);
void configureAVCaptureSession(AVCaptureSession *captureSession); void configureAVCaptureSession(AVFCameraSession *cameraSession);
void syncHandleViewfinderFrame(const QVideoFrame &frame); void syncHandleViewfinderFrame(const QVideoFrame &frame);
Q_SIGNALS: Q_SIGNALS:
@@ -74,13 +74,16 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void handleViewfinderFrame(); void handleViewfinderFrame();
void updateCaptureConnection();
private: private:
QAbstractVideoSurface *m_surface; QAbstractVideoSurface *m_surface;
AVFCaptureFramesDelegate *m_viewfinderFramesDelegate; AVFCaptureFramesDelegate *m_viewfinderFramesDelegate;
AVCaptureSession *m_captureSession; AVFCameraSession *m_cameraSession;
AVCaptureVideoDataOutput *m_videoDataOutput; AVCaptureVideoDataOutput *m_videoDataOutput;
bool m_needsHorizontalMirroring;
QVideoFrame m_lastViewfinderFrame; QVideoFrame m_lastViewfinderFrame;
QMutex m_vfMutex; QMutex m_vfMutex;
}; };

View File

@@ -146,13 +146,14 @@ private:
AVFVideoRendererControl::AVFVideoRendererControl(QObject *parent) AVFVideoRendererControl::AVFVideoRendererControl(QObject *parent)
: QVideoRendererControl(parent) : QVideoRendererControl(parent)
, m_surface(0) , m_surface(0)
, m_needsHorizontalMirroring(false)
{ {
m_viewfinderFramesDelegate = [[AVFCaptureFramesDelegate alloc] initWithRenderer:this]; m_viewfinderFramesDelegate = [[AVFCaptureFramesDelegate alloc] initWithRenderer:this];
} }
AVFVideoRendererControl::~AVFVideoRendererControl() AVFVideoRendererControl::~AVFVideoRendererControl()
{ {
[m_captureSession removeOutput:m_videoDataOutput]; [m_cameraSession->captureSession() removeOutput:m_videoDataOutput];
[m_viewfinderFramesDelegate release]; [m_viewfinderFramesDelegate release];
} }
@@ -169,9 +170,13 @@ void AVFVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
} }
} }
void AVFVideoRendererControl::configureAVCaptureSession(AVCaptureSession *captureSession) void AVFVideoRendererControl::configureAVCaptureSession(AVFCameraSession *cameraSession)
{ {
m_captureSession = captureSession; m_cameraSession = cameraSession;
connect(m_cameraSession, SIGNAL(readyToConfigureConnections()),
this, SLOT(updateCaptureConnection()));
m_needsHorizontalMirroring = false;
m_videoDataOutput = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; m_videoDataOutput = [[[AVCaptureVideoDataOutput alloc] init] autorelease];
@@ -188,7 +193,23 @@ void AVFVideoRendererControl::configureAVCaptureSession(AVCaptureSession *captur
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] [NSNumber numberWithInt:kCVPixelFormatType_32BGRA]
forKey:(id)kCVPixelBufferPixelFormatTypeKey]; forKey:(id)kCVPixelBufferPixelFormatTypeKey];
[m_captureSession addOutput:m_videoDataOutput]; [m_cameraSession->captureSession() addOutput:m_videoDataOutput];
}
void AVFVideoRendererControl::updateCaptureConnection()
{
AVCaptureConnection *connection = [m_videoDataOutput connectionWithMediaType:AVMediaTypeVideo];
if (connection == nil || !m_cameraSession->videoCaptureDevice())
return;
// Frames of front-facing cameras should be mirrored horizontally (it's the default when using
// AVCaptureVideoPreviewLayer but not with AVCaptureVideoDataOutput)
if (connection.isVideoMirroringSupported)
connection.videoMirrored = m_cameraSession->videoCaptureDevice().position == AVCaptureDevicePositionFront;
// If the connection does't support mirroring, we'll have to do it ourselves
m_needsHorizontalMirroring = !connection.isVideoMirrored
&& m_cameraSession->videoCaptureDevice().position == AVCaptureDevicePositionFront;
} }
//can be called from non main thread //can be called from non main thread
@@ -203,6 +224,22 @@ void AVFVideoRendererControl::syncHandleViewfinderFrame(const QVideoFrame &frame
} }
m_lastViewfinderFrame = frame; m_lastViewfinderFrame = frame;
if (m_needsHorizontalMirroring) {
m_lastViewfinderFrame.map(QAbstractVideoBuffer::ReadOnly);
// no deep copy
QImage image(m_lastViewfinderFrame.bits(),
m_lastViewfinderFrame.size().width(),
m_lastViewfinderFrame.size().height(),
m_lastViewfinderFrame.bytesPerLine(),
QImage::Format_RGB32);
QImage mirrored = image.mirrored(true, false);
m_lastViewfinderFrame.unmap();
m_lastViewfinderFrame = QVideoFrame(mirrored);
}
} }
void AVFVideoRendererControl::handleViewfinderFrame() void AVFVideoRendererControl::handleViewfinderFrame()

View File

@@ -2,7 +2,7 @@ INCLUDEPATH += $$PWD
DEFINES += QMEDIA_DIRECTSHOW_CAMERA DEFINES += QMEDIA_DIRECTSHOW_CAMERA
win32-g++: DEFINES += QT_NO_WMSDK mingw: DEFINES += QT_NO_WMSDK
win32: DEFINES += _CRT_SECURE_NO_WARNINGS win32: DEFINES += _CRT_SECURE_NO_WARNINGS

View File

@@ -49,10 +49,10 @@ DSImageCaptureControl::DSImageCaptureControl(DSCameraSession *session)
:QCameraImageCaptureControl(session), m_session(session), m_ready(false) :QCameraImageCaptureControl(session), m_session(session), m_ready(false)
{ {
connect(m_session, SIGNAL(stateChanged(QCamera::State)), SLOT(updateState())); connect(m_session, SIGNAL(stateChanged(QCamera::State)), SLOT(updateState()));
connect(m_session, SIGNAL(imageCaptured(const int, QImage)), connect(m_session, SIGNAL(imageCaptured(int,QImage)),
this, SIGNAL(imageCaptured(const int, QImage))); this, SIGNAL(imageCaptured(int,QImage)));
connect(m_session, SIGNAL(imageSaved(const int, const QString &)), connect(m_session, SIGNAL(imageSaved(int,QString)),
this, SIGNAL(imageSaved(const int, const QString &))); this, SIGNAL(imageSaved(int,QString)));
connect(m_session, SIGNAL(readyForCaptureChanged(bool)), connect(m_session, SIGNAL(readyForCaptureChanged(bool)),
this, SIGNAL(readyForCaptureChanged(bool))); this, SIGNAL(readyForCaptureChanged(bool)));
} }

View File

@@ -16,9 +16,7 @@ qtHaveModule(widgets) {
DEFINES += HAVE_WIDGETS DEFINES += HAVE_WIDGETS
} }
win32-g++ { mingw: DEFINES += NO_DSHOW_STRSAFE
DEFINES += NO_DSHOW_STRSAFE
}
!config_wmf: include(player/player.pri) !config_wmf: include(player/player.pri)
include(camera/camera.pri) include(camera/camera.pri)

View File

@@ -54,8 +54,8 @@ CameraBinLocks::CameraBinLocks(CameraBinSession *session)
m_session(session), m_session(session),
m_focus(m_session->cameraFocusControl()) m_focus(m_session->cameraFocusControl())
{ {
connect(m_focus, SIGNAL(_q_focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)), connect(m_focus, SIGNAL(_q_focusStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)),
this, SLOT(updateFocusStatus(QCamera::LockStatus, QCamera::LockChangeReason))); this, SLOT(updateFocusStatus(QCamera::LockStatus,QCamera::LockChangeReason)));
} }
CameraBinLocks::~CameraBinLocks() CameraBinLocks::~CameraBinLocks()

View File

@@ -65,7 +65,7 @@ CamerabinResourcePolicy::CamerabinResourcePolicy(QObject *parent) :
m_resource->setAlwaysReply(); m_resource->setAlwaysReply();
m_resource->initAndConnect(); m_resource->initAndConnect();
connect(m_resource, SIGNAL(resourcesGranted(const QList<ResourcePolicy::ResourceType>)), connect(m_resource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)),
SLOT(handleResourcesGranted())); SLOT(handleResourcesGranted()));
connect(m_resource, SIGNAL(resourcesDenied()), SIGNAL(resourcesDenied())); connect(m_resource, SIGNAL(resourcesDenied()), SIGNAL(resourcesDenied()));
connect(m_resource, SIGNAL(lostResources()), SLOT(handleResourcesLost())); connect(m_resource, SIGNAL(lostResources()), SLOT(handleResourcesLost()));

View File

@@ -54,7 +54,7 @@ CameraButtonListener::CameraButtonListener(QObject *parent) :
m_shutterPressed(false) m_shutterPressed(false)
{ {
m_keys = new MeeGo::QmKeys(this); m_keys = new MeeGo::QmKeys(this);
connect(m_keys, SIGNAL(keyEvent(MeeGo::QmKeys::Key, MeeGo::QmKeys::State)), connect(m_keys, SIGNAL(keyEvent(MeeGo::QmKeys::Key,MeeGo::QmKeys::State)),
this, SLOT(handleQmKeyEvent(MeeGo::QmKeys::Key,MeeGo::QmKeys::State))); this, SLOT(handleQmKeyEvent(MeeGo::QmKeys::Key,MeeGo::QmKeys::State)));
} }

View File

@@ -21,11 +21,10 @@ qnx:!blackberry {
SUBDIRS += qnx-audio SUBDIRS += qnx-audio
} }
win32 { win32:!winrt {
SUBDIRS += audiocapture SUBDIRS += audiocapture \
} windowsaudio
win32 {
config_directshow: SUBDIRS += directshow config_directshow: SUBDIRS += directshow
config_wmf: SUBDIRS += wmf config_wmf: SUBDIRS += wmf
} }
@@ -37,12 +36,14 @@ unix:!mac:!android {
SUBDIRS += audiocapture SUBDIRS += audiocapture
} }
# v4l is turned off because it is not supported in Qt 5
# !maemo*:SUBDIRS += v4l
config_pulseaudio { config_pulseaudio {
SUBDIRS += pulseaudio SUBDIRS += pulseaudio
} else:config_alsa {
SUBDIRS += alsa
} }
# v4l is turned off because it is not supported in Qt 5
# !maemo*:SUBDIRS += v4l
} }
mac:!simulator { mac:!simulator {

View File

@@ -92,10 +92,20 @@ static QString errorToString(camera_error_t error)
case CAMERA_EMICINUSE: case CAMERA_EMICINUSE:
return QLatin1String("Microphone in use already"); return QLatin1String("Microphone in use already");
#ifndef Q_OS_BLACKBERRY_TABLET #ifndef Q_OS_BLACKBERRY_TABLET
case CAMERA_ENODATA:
return QLatin1String("Data does not exist");
case CAMERA_EBUSY:
return QLatin1String("Camera busy");
case CAMERA_EDESKTOPCAMERAINUSE: case CAMERA_EDESKTOPCAMERAINUSE:
return QLatin1String("Desktop camera in use already"); return QLatin1String("Desktop camera in use already");
case CAMERA_ENOSPC: case CAMERA_ENOSPC:
return QLatin1String("Disk is full"); return QLatin1String("Disk is full");
case CAMERA_EPOWERDOWN:
return QLatin1String("Camera in power down state");
case CAMERA_3ALOCKED:
return QLatin1String("3A have been locked");
// case CAMERA_EVIEWFINDERFROZEN: // not yet available in 10.2 NDK
// return QLatin1String("Freeze flag set");
#endif #endif
default: default:
return QLatin1String("Unknown error"); return QLatin1String("Unknown error");

View File

@@ -61,7 +61,7 @@ ResourcePolicyImpl::ResourcePolicyImpl(QObject *parent)
m_resourceSet->update(); m_resourceSet->update();
connect(m_resourceSet, SIGNAL(resourcesGranted(const QList<ResourcePolicy::ResourceType>)), connect(m_resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)),
this, SLOT(handleResourcesGranted())); this, SLOT(handleResourcesGranted()));
connect(m_resourceSet, SIGNAL(resourcesDenied()), connect(m_resourceSet, SIGNAL(resourcesDenied()),
this, SLOT(handleResourcesDenied())); this, SLOT(handleResourcesDenied()));

View File

@@ -53,7 +53,7 @@
#include <QtCore/qt_windows.h> #include <QtCore/qt_windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include "qaudiodeviceinfo_win32_p.h" #include "qwindowsaudiodeviceinfo.h"
#if defined(Q_CC_MINGW) && !defined(__MINGW64_VERSION_MAJOR) #if defined(Q_CC_MINGW) && !defined(__MINGW64_VERSION_MAJOR)
struct IBaseFilter; // Needed for strmif.h from stock MinGW. struct IBaseFilter; // Needed for strmif.h from stock MinGW.
@@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE
#endif #endif
QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) QWindowsAudioDeviceInfo::QWindowsAudioDeviceInfo(QByteArray dev, QAudio::Mode mode)
{ {
QDataStream ds(&dev, QIODevice::ReadOnly); QDataStream ds(&dev, QIODevice::ReadOnly);
ds >> devId >> device; ds >> devId >> device;
@@ -136,17 +136,17 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode
updateLists(); updateLists();
} }
QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() QWindowsAudioDeviceInfo::~QWindowsAudioDeviceInfo()
{ {
close(); close();
} }
bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const bool QWindowsAudioDeviceInfo::isFormatSupported(const QAudioFormat& format) const
{ {
return testSettings(format); return testSettings(format);
} }
QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const QAudioFormat QWindowsAudioDeviceInfo::preferredFormat() const
{ {
QAudioFormat nearest; QAudioFormat nearest;
if (mode == QAudio::AudioOutput) { if (mode == QAudio::AudioOutput) {
@@ -167,58 +167,58 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
return nearest; return nearest;
} }
QString QAudioDeviceInfoInternal::deviceName() const QString QWindowsAudioDeviceInfo::deviceName() const
{ {
return device; return device;
} }
QStringList QAudioDeviceInfoInternal::supportedCodecs() QStringList QWindowsAudioDeviceInfo::supportedCodecs()
{ {
updateLists(); updateLists();
return codecz; return codecz;
} }
QList<int> QAudioDeviceInfoInternal::supportedSampleRates() QList<int> QWindowsAudioDeviceInfo::supportedSampleRates()
{ {
updateLists(); updateLists();
return sampleRatez; return sampleRatez;
} }
QList<int> QAudioDeviceInfoInternal::supportedChannelCounts() QList<int> QWindowsAudioDeviceInfo::supportedChannelCounts()
{ {
updateLists(); updateLists();
return channelz; return channelz;
} }
QList<int> QAudioDeviceInfoInternal::supportedSampleSizes() QList<int> QWindowsAudioDeviceInfo::supportedSampleSizes()
{ {
updateLists(); updateLists();
return sizez; return sizez;
} }
QList<QAudioFormat::Endian> QAudioDeviceInfoInternal::supportedByteOrders() QList<QAudioFormat::Endian> QWindowsAudioDeviceInfo::supportedByteOrders()
{ {
updateLists(); updateLists();
return byteOrderz; return byteOrderz;
} }
QList<QAudioFormat::SampleType> QAudioDeviceInfoInternal::supportedSampleTypes() QList<QAudioFormat::SampleType> QWindowsAudioDeviceInfo::supportedSampleTypes()
{ {
updateLists(); updateLists();
return typez; return typez;
} }
bool QAudioDeviceInfoInternal::open() bool QWindowsAudioDeviceInfo::open()
{ {
return true; return true;
} }
void QAudioDeviceInfoInternal::close() void QWindowsAudioDeviceInfo::close()
{ {
} }
bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const bool QWindowsAudioDeviceInfo::testSettings(const QAudioFormat& format) const
{ {
// Set nearest to closest settings that do work. // Set nearest to closest settings that do work.
// See if what is in settings will work (return value). // See if what is in settings will work (return value).
@@ -305,7 +305,7 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
return false; return false;
} }
void QAudioDeviceInfoInternal::updateLists() void QWindowsAudioDeviceInfo::updateLists()
{ {
// redo all lists based on current settings // redo all lists based on current settings
bool match = false; bool match = false;
@@ -407,7 +407,7 @@ void QAudioDeviceInfoInternal::updateLists()
sampleRatez.prepend(8000); sampleRatez.prepend(8000);
} }
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) QList<QByteArray> QWindowsAudioDeviceInfo::availableDevices(QAudio::Mode mode)
{ {
Q_UNUSED(mode) Q_UNUSED(mode)
@@ -467,7 +467,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
return devices; return devices;
} }
QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() QByteArray QWindowsAudioDeviceInfo::defaultOutputDevice()
{ {
QByteArray defaultDevice; QByteArray defaultDevice;
QDataStream ds(&defaultDevice, QIODevice::WriteOnly); QDataStream ds(&defaultDevice, QIODevice::WriteOnly);
@@ -477,7 +477,7 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
return defaultDevice; return defaultDevice;
} }
QByteArray QAudioDeviceInfoInternal::defaultInputDevice() QByteArray QWindowsAudioDeviceInfo::defaultInputDevice()
{ {
QByteArray defaultDevice; QByteArray defaultDevice;
QDataStream ds(&defaultDevice, QIODevice::WriteOnly); QDataStream ds(&defaultDevice, QIODevice::WriteOnly);

View File

@@ -51,16 +51,16 @@
// //
#ifndef QAUDIODEVICEINFOWIN_H #ifndef QWINDOWSAUDIODEVICEINFO_H
#define QAUDIODEVICEINFOWIN_H #define QWINDOWSAUDIODEVICEINFO_H
#include <QtCore/qbytearray.h> #include <QtCore/qbytearray.h>
#include <QtCore/qstringlist.h> #include <QtCore/qstringlist.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <qaudiodeviceinfo.h> #include <QtMultimedia/qaudiodeviceinfo.h>
#include <qaudiosystem.h> #include <QtMultimedia/qaudiosystem.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -69,13 +69,13 @@ QT_BEGIN_NAMESPACE
const unsigned int MAX_SAMPLE_RATES = 5; const unsigned int MAX_SAMPLE_RATES = 5;
const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 };
class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo class QWindowsAudioDeviceInfo : public QAbstractAudioDeviceInfo
{ {
Q_OBJECT Q_OBJECT
public: public:
QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); QWindowsAudioDeviceInfo(QByteArray dev,QAudio::Mode mode);
~QAudioDeviceInfoInternal(); ~QWindowsAudioDeviceInfo();
bool open(); bool open();
void close(); void close();
@@ -111,4 +111,4 @@ private:
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif // QWINDOWSAUDIODEVICEINFO_H

View File

@@ -51,13 +51,13 @@
// //
#include "qaudioinput_win32_p.h" #include "qwindowsaudioinput.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
//#define DEBUG_AUDIO 1 //#define DEBUG_AUDIO 1
QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device) QWindowsAudioInput::QWindowsAudioInput(const QByteArray &device)
{ {
bytesAvailable = 0; bytesAvailable = 0;
buffer_size = 0; buffer_size = 0;
@@ -78,21 +78,21 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device)
initMixer(); initMixer();
} }
QAudioInputPrivate::~QAudioInputPrivate() QWindowsAudioInput::~QWindowsAudioInput()
{ {
stop(); stop();
closeMixer(); closeMixer();
} }
void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, void QT_WIN_CALLBACK QWindowsAudioInput::waveInProc( HWAVEIN hWaveIn, UINT uMsg,
DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 ) DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 )
{ {
Q_UNUSED(dwParam1) Q_UNUSED(dwParam1)
Q_UNUSED(dwParam2) Q_UNUSED(dwParam2)
Q_UNUSED(hWaveIn) Q_UNUSED(hWaveIn)
QAudioInputPrivate* qAudio; QWindowsAudioInput* qAudio;
qAudio = (QAudioInputPrivate*)(dwInstance); qAudio = (QWindowsAudioInput*)(dwInstance);
if(!qAudio) if(!qAudio)
return; return;
@@ -114,7 +114,7 @@ void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg,
} }
} }
WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count) WAVEHDR* QWindowsAudioInput::allocateBlocks(int size, int count)
{ {
int i; int i;
unsigned char* buffer; unsigned char* buffer;
@@ -145,7 +145,7 @@ WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count)
return blocks; return blocks;
} }
void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) void QWindowsAudioInput::freeBlocks(WAVEHDR* blockArray)
{ {
WAVEHDR* blocks = blockArray; WAVEHDR* blocks = blockArray;
@@ -158,12 +158,12 @@ void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray)
HeapFree(GetProcessHeap(), 0, blockArray); HeapFree(GetProcessHeap(), 0, blockArray);
} }
QAudio::Error QAudioInputPrivate::error() const QAudio::Error QWindowsAudioInput::error() const
{ {
return errorState; return errorState;
} }
QAudio::State QAudioInputPrivate::state() const QAudio::State QWindowsAudioInput::state() const
{ {
return deviceState; return deviceState;
} }
@@ -181,7 +181,7 @@ QAudio::State QAudioInputPrivate::state() const
#define DRVM_MAPPER_CONSOLEVOICECOM_GET (DRVM_MAPPER+23) #define DRVM_MAPPER_CONSOLEVOICECOM_GET (DRVM_MAPPER+23)
#endif #endif
void QAudioInputPrivate::setVolume(qreal volume) void QWindowsAudioInput::setVolume(qreal volume)
{ {
for (DWORD i = 0; i < mixerLineControls.cControls; i++) { for (DWORD i = 0; i < mixerLineControls.cControls; i++) {
@@ -202,7 +202,7 @@ void QAudioInputPrivate::setVolume(qreal volume)
} }
} }
qreal QAudioInputPrivate::volume() const qreal QWindowsAudioInput::volume() const
{ {
DWORD volume = 0; DWORD volume = 0;
for (DWORD i = 0; i < mixerLineControls.cControls; i++) { for (DWORD i = 0; i < mixerLineControls.cControls; i++) {
@@ -233,18 +233,18 @@ qreal QAudioInputPrivate::volume() const
return volume / 65535.0; return volume / 65535.0;
} }
void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) void QWindowsAudioInput::setFormat(const QAudioFormat& fmt)
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
settings = fmt; settings = fmt;
} }
QAudioFormat QAudioInputPrivate::format() const QAudioFormat QWindowsAudioInput::format() const
{ {
return settings; return settings;
} }
void QAudioInputPrivate::start(QIODevice* device) void QWindowsAudioInput::start(QIODevice* device)
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
close(); close();
@@ -263,7 +263,7 @@ void QAudioInputPrivate::start(QIODevice* device)
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
QIODevice* QAudioInputPrivate::start() QIODevice* QWindowsAudioInput::start()
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
close(); close();
@@ -285,7 +285,7 @@ QIODevice* QAudioInputPrivate::start()
return audioSource; return audioSource;
} }
void QAudioInputPrivate::stop() void QWindowsAudioInput::stop()
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
return; return;
@@ -294,7 +294,7 @@ void QAudioInputPrivate::stop()
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
bool QAudioInputPrivate::open() bool QWindowsAudioInput::open()
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
QTime now(QTime::currentTime()); QTime now(QTime::currentTime());
@@ -398,7 +398,7 @@ bool QAudioInputPrivate::open()
return true; return true;
} }
void QAudioInputPrivate::close() void QWindowsAudioInput::close()
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
return; return;
@@ -421,7 +421,7 @@ void QAudioInputPrivate::close()
} }
} }
void QAudioInputPrivate::initMixer() void QWindowsAudioInput::initMixer()
{ {
QDataStream ds(&m_device, QIODevice::ReadOnly); QDataStream ds(&m_device, QIODevice::ReadOnly);
quint32 inputDevice; quint32 inputDevice;
@@ -455,13 +455,13 @@ void QAudioInputPrivate::initMixer()
} }
} }
void QAudioInputPrivate::closeMixer() void QWindowsAudioInput::closeMixer()
{ {
delete[] mixerLineControls.pamxctrl; delete[] mixerLineControls.pamxctrl;
memset(&mixerLineControls, 0, sizeof(mixerLineControls)); memset(&mixerLineControls, 0, sizeof(mixerLineControls));
} }
int QAudioInputPrivate::bytesReady() const int QWindowsAudioInput::bytesReady() const
{ {
if(period_size == 0 || buffer_size == 0) if(period_size == 0 || buffer_size == 0)
return 0; return 0;
@@ -472,7 +472,7 @@ int QAudioInputPrivate::bytesReady() const
return buf; return buf;
} }
qint64 QAudioInputPrivate::read(char* data, qint64 len) qint64 QWindowsAudioInput::read(char* data, qint64 len)
{ {
bool done = false; bool done = false;
@@ -591,7 +591,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
return written; return written;
} }
void QAudioInputPrivate::resume() void QWindowsAudioInput::resume()
{ {
if(deviceState == QAudio::SuspendedState) { if(deviceState == QAudio::SuspendedState) {
deviceState = QAudio::ActiveState; deviceState = QAudio::ActiveState;
@@ -619,32 +619,32 @@ void QAudioInputPrivate::resume()
} }
} }
void QAudioInputPrivate::setBufferSize(int value) void QWindowsAudioInput::setBufferSize(int value)
{ {
buffer_size = value; buffer_size = value;
} }
int QAudioInputPrivate::bufferSize() const int QWindowsAudioInput::bufferSize() const
{ {
return buffer_size; return buffer_size;
} }
int QAudioInputPrivate::periodSize() const int QWindowsAudioInput::periodSize() const
{ {
return period_size; return period_size;
} }
void QAudioInputPrivate::setNotifyInterval(int ms) void QWindowsAudioInput::setNotifyInterval(int ms)
{ {
intervalTime = qMax(0, ms); intervalTime = qMax(0, ms);
} }
int QAudioInputPrivate::notifyInterval() const int QWindowsAudioInput::notifyInterval() const
{ {
return intervalTime; return intervalTime;
} }
qint64 QAudioInputPrivate::processedUSecs() const qint64 QWindowsAudioInput::processedUSecs() const
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
return 0; return 0;
@@ -655,7 +655,7 @@ qint64 QAudioInputPrivate::processedUSecs() const
return result; return result;
} }
void QAudioInputPrivate::suspend() void QWindowsAudioInput::suspend()
{ {
if(deviceState == QAudio::ActiveState) { if(deviceState == QAudio::ActiveState) {
waveInReset(hWaveIn); waveInReset(hWaveIn);
@@ -664,7 +664,7 @@ void QAudioInputPrivate::suspend()
} }
} }
void QAudioInputPrivate::feedback() void QWindowsAudioInput::feedback()
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
QTime now(QTime::currentTime()); QTime now(QTime::currentTime());
@@ -674,7 +674,7 @@ void QAudioInputPrivate::feedback()
QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection);
} }
bool QAudioInputPrivate::deviceReady() bool QWindowsAudioInput::deviceReady()
{ {
bytesAvailable = bytesReady(); bytesAvailable = bytesReady();
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
@@ -701,7 +701,7 @@ bool QAudioInputPrivate::deviceReady()
return true; return true;
} }
qint64 QAudioInputPrivate::elapsedUSecs() const qint64 QWindowsAudioInput::elapsedUSecs() const
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
return 0; return 0;
@@ -709,16 +709,16 @@ qint64 QAudioInputPrivate::elapsedUSecs() const
return timeStampOpened.elapsed()*1000; return timeStampOpened.elapsed()*1000;
} }
void QAudioInputPrivate::reset() void QWindowsAudioInput::reset()
{ {
stop(); stop();
if (period_size > 0) if (period_size > 0)
waveFreeBlockCount = buffer_size / period_size; waveFreeBlockCount = buffer_size / period_size;
} }
InputPrivate::InputPrivate(QAudioInputPrivate* audio) InputPrivate::InputPrivate(QWindowsAudioInput* audio)
{ {
audioDevice = qobject_cast<QAudioInputPrivate*>(audio); audioDevice = qobject_cast<QWindowsAudioInput*>(audio);
} }
InputPrivate::~InputPrivate() {} InputPrivate::~InputPrivate() {}
@@ -749,5 +749,4 @@ void InputPrivate::trigger()
QT_END_NAMESPACE QT_END_NAMESPACE
#include "moc_qaudioinput_win32_p.cpp" #include "moc_qwindowsaudioinput.cpp"

View File

@@ -50,8 +50,8 @@
// We mean it. // We mean it.
// //
#ifndef QAUDIOINPUTWIN_H #ifndef QWINDOWSAUDIOINPUT_H
#define QAUDIOINPUTWIN_H #define QWINDOWSAUDIOINPUT_H
#include <QtCore/qt_windows.h> #include <QtCore/qt_windows.h>
#include <mmsystem.h> #include <mmsystem.h>
@@ -64,9 +64,9 @@
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include <QtCore/qmutex.h> #include <QtCore/qmutex.h>
#include <qaudio.h> #include <QtMultimedia/qaudio.h>
#include <qaudiodeviceinfo.h> #include <QtMultimedia/qaudiodeviceinfo.h>
#include <qaudiosystem.h> #include <QtMultimedia/qaudiosystem.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -81,12 +81,12 @@ QT_BEGIN_NAMESPACE
# endif # endif
#endif #endif
class QAudioInputPrivate : public QAbstractAudioInput class QWindowsAudioInput : public QAbstractAudioInput
{ {
Q_OBJECT Q_OBJECT
public: public:
QAudioInputPrivate(const QByteArray &device); QWindowsAudioInput(const QByteArray &device);
~QAudioInputPrivate(); ~QWindowsAudioInput();
qint64 read(char* data, qint64 len); qint64 read(char* data, qint64 len);
@@ -163,7 +163,7 @@ class InputPrivate : public QIODevice
{ {
Q_OBJECT Q_OBJECT
public: public:
InputPrivate(QAudioInputPrivate* audio); InputPrivate(QWindowsAudioInput* audio);
~InputPrivate(); ~InputPrivate();
qint64 readData( char* data, qint64 len); qint64 readData( char* data, qint64 len);
@@ -171,10 +171,9 @@ public:
void trigger(); void trigger();
private: private:
QAudioInputPrivate *audioDevice; QWindowsAudioInput *audioDevice;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif

View File

@@ -50,7 +50,7 @@
// INTERNAL USE ONLY: Do NOT use for any other purpose. // INTERNAL USE ONLY: Do NOT use for any other purpose.
// //
#include "qaudiooutput_win32_p.h" #include "qwindowsaudiooutput.h"
#include <QtEndian> #include <QtEndian>
#ifndef SPEAKER_FRONT_LEFT #ifndef SPEAKER_FRONT_LEFT
@@ -104,7 +104,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device) QWindowsAudioOutput::QWindowsAudioOutput(const QByteArray &device)
{ {
bytesAvailable = 0; bytesAvailable = 0;
buffer_size = 0; buffer_size = 0;
@@ -121,7 +121,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device)
volumeCache = (qreal)1.; volumeCache = (qreal)1.;
} }
QAudioOutputPrivate::~QAudioOutputPrivate() QWindowsAudioOutput::~QWindowsAudioOutput()
{ {
mutex.lock(); mutex.lock();
finished = true; finished = true;
@@ -130,15 +130,15 @@ QAudioOutputPrivate::~QAudioOutputPrivate()
close(); close();
} }
void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, void CALLBACK QWindowsAudioOutput::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg,
DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 ) DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 )
{ {
Q_UNUSED(dwParam1) Q_UNUSED(dwParam1)
Q_UNUSED(dwParam2) Q_UNUSED(dwParam2)
Q_UNUSED(hWaveOut) Q_UNUSED(hWaveOut)
QAudioOutputPrivate* qAudio; QWindowsAudioOutput* qAudio;
qAudio = (QAudioOutputPrivate*)(dwInstance); qAudio = (QWindowsAudioOutput*)(dwInstance);
if(!qAudio) if(!qAudio)
return; return;
@@ -164,7 +164,7 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg,
} }
} }
WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count) WAVEHDR* QWindowsAudioOutput::allocateBlocks(int size, int count)
{ {
int i; int i;
unsigned char* buffer; unsigned char* buffer;
@@ -186,7 +186,7 @@ WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count)
return blocks; return blocks;
} }
void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) void QWindowsAudioOutput::freeBlocks(WAVEHDR* blockArray)
{ {
WAVEHDR* blocks = blockArray; WAVEHDR* blocks = blockArray;
@@ -199,18 +199,18 @@ void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray)
HeapFree(GetProcessHeap(), 0, blockArray); HeapFree(GetProcessHeap(), 0, blockArray);
} }
QAudioFormat QAudioOutputPrivate::format() const QAudioFormat QWindowsAudioOutput::format() const
{ {
return settings; return settings;
} }
void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) void QWindowsAudioOutput::setFormat(const QAudioFormat& fmt)
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
settings = fmt; settings = fmt;
} }
void QAudioOutputPrivate::start(QIODevice* device) void QWindowsAudioOutput::start(QIODevice* device)
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
close(); close();
@@ -229,7 +229,7 @@ void QAudioOutputPrivate::start(QIODevice* device)
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
QIODevice* QAudioOutputPrivate::start() QIODevice* QWindowsAudioOutput::start()
{ {
if(deviceState != QAudio::StoppedState) if(deviceState != QAudio::StoppedState)
close(); close();
@@ -251,7 +251,7 @@ QIODevice* QAudioOutputPrivate::start()
return audioSource; return audioSource;
} }
void QAudioOutputPrivate::stop() void QWindowsAudioOutput::stop()
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
return; return;
@@ -263,7 +263,7 @@ void QAudioOutputPrivate::stop()
emit stateChanged(deviceState); emit stateChanged(deviceState);
} }
bool QAudioOutputPrivate::open() bool QWindowsAudioOutput::open()
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
QTime now(QTime::currentTime()); QTime now(QTime::currentTime());
@@ -394,7 +394,7 @@ bool QAudioOutputPrivate::open()
return true; return true;
} }
void QAudioOutputPrivate::close() void QWindowsAudioOutput::close()
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
return; return;
@@ -413,7 +413,7 @@ void QAudioOutputPrivate::close()
buffer_size = 0; buffer_size = 0;
} }
int QAudioOutputPrivate::bytesFree() const int QWindowsAudioOutput::bytesFree() const
{ {
int buf; int buf;
buf = waveFreeBlockCount*period_size; buf = waveFreeBlockCount*period_size;
@@ -421,33 +421,33 @@ int QAudioOutputPrivate::bytesFree() const
return buf; return buf;
} }
int QAudioOutputPrivate::periodSize() const int QWindowsAudioOutput::periodSize() const
{ {
return period_size; return period_size;
} }
void QAudioOutputPrivate::setBufferSize(int value) void QWindowsAudioOutput::setBufferSize(int value)
{ {
if(deviceState == QAudio::StoppedState) if(deviceState == QAudio::StoppedState)
buffer_size = value; buffer_size = value;
} }
int QAudioOutputPrivate::bufferSize() const int QWindowsAudioOutput::bufferSize() const
{ {
return buffer_size; return buffer_size;
} }
void QAudioOutputPrivate::setNotifyInterval(int ms) void QWindowsAudioOutput::setNotifyInterval(int ms)
{ {
intervalTime = qMax(0, ms); intervalTime = qMax(0, ms);
} }
int QAudioOutputPrivate::notifyInterval() const int QWindowsAudioOutput::notifyInterval() const
{ {
return intervalTime; return intervalTime;
} }
qint64 QAudioOutputPrivate::processedUSecs() const qint64 QWindowsAudioOutput::processedUSecs() const
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
return 0; return 0;
@@ -458,7 +458,7 @@ qint64 QAudioOutputPrivate::processedUSecs() const
return result; return result;
} }
qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) qint64 QWindowsAudioOutput::write( const char *data, qint64 len )
{ {
// Write out some audio data // Write out some audio data
if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
@@ -539,7 +539,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
return (len-l); return (len-l);
} }
void QAudioOutputPrivate::resume() void QWindowsAudioOutput::resume()
{ {
if(deviceState == QAudio::SuspendedState) { if(deviceState == QAudio::SuspendedState) {
deviceState = QAudio::ActiveState; deviceState = QAudio::ActiveState;
@@ -550,7 +550,7 @@ void QAudioOutputPrivate::resume()
} }
} }
void QAudioOutputPrivate::suspend() void QWindowsAudioOutput::suspend()
{ {
if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) { if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) {
int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate() int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate()
@@ -563,7 +563,7 @@ void QAudioOutputPrivate::suspend()
} }
} }
void QAudioOutputPrivate::feedback() void QWindowsAudioOutput::feedback()
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
QTime now(QTime::currentTime()); QTime now(QTime::currentTime());
@@ -577,7 +577,7 @@ void QAudioOutputPrivate::feedback()
} }
} }
bool QAudioOutputPrivate::deviceReady() bool QWindowsAudioOutput::deviceReady()
{ {
if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return false; return false;
@@ -595,14 +595,14 @@ bool QAudioOutputPrivate::deviceReady()
bool full=false; bool full=false;
mutex.lock(); mutex.lock();
if(waveFreeBlockCount==0) full = true; if (waveFreeBlockCount==0) full = true;
mutex.unlock(); mutex.unlock();
if (full){ if (full) {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
qDebug() << "Skipping data as unable to write"; qDebug() << "Skipping data as unable to write";
#endif #endif
if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime ) { if ((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
emit notify(); emit notify();
elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime;
timeStamp.restart(); timeStamp.restart();
@@ -626,7 +626,7 @@ bool QAudioOutputPrivate::deviceReady()
// Didn't write all data // Didn't write all data
audioSource->seek(audioSource->pos()-(l-out)); audioSource->seek(audioSource->pos()-(l-out));
} }
if(startup) if (startup)
waveOutRestart(hWaveOut); waveOutRestart(hWaveOut);
} else if(l == 0) { } else if(l == 0) {
bytesAvailable = bytesFree(); bytesAvailable = bytesFree();
@@ -677,7 +677,7 @@ bool QAudioOutputPrivate::deviceReady()
return true; return true;
} }
qint64 QAudioOutputPrivate::elapsedUSecs() const qint64 QWindowsAudioOutput::elapsedUSecs() const
{ {
if (deviceState == QAudio::StoppedState) if (deviceState == QAudio::StoppedState)
return 0; return 0;
@@ -685,17 +685,17 @@ qint64 QAudioOutputPrivate::elapsedUSecs() const
return timeStampOpened.elapsed()*1000; return timeStampOpened.elapsed()*1000;
} }
QAudio::Error QAudioOutputPrivate::error() const QAudio::Error QWindowsAudioOutput::error() const
{ {
return errorState; return errorState;
} }
QAudio::State QAudioOutputPrivate::state() const QAudio::State QWindowsAudioOutput::state() const
{ {
return deviceState; return deviceState;
} }
void QAudioOutputPrivate::setVolume(qreal v) void QWindowsAudioOutput::setVolume(qreal v)
{ {
const qreal normalizedVolume = qBound(qreal(0.0), v, qreal(1.0)); const qreal normalizedVolume = qBound(qreal(0.0), v, qreal(1.0));
if (deviceState != QAudio::ActiveState) { if (deviceState != QAudio::ActiveState) {
@@ -709,19 +709,19 @@ void QAudioOutputPrivate::setVolume(qreal v)
volumeCache = normalizedVolume; volumeCache = normalizedVolume;
} }
qreal QAudioOutputPrivate::volume() const qreal QWindowsAudioOutput::volume() const
{ {
return volumeCache; return volumeCache;
} }
void QAudioOutputPrivate::reset() void QWindowsAudioOutput::reset()
{ {
close(); close();
} }
OutputPrivate::OutputPrivate(QAudioOutputPrivate* audio) OutputPrivate::OutputPrivate(QWindowsAudioOutput* audio)
{ {
audioDevice = qobject_cast<QAudioOutputPrivate*>(audio); audioDevice = qobject_cast<QWindowsAudioOutput*>(audio);
} }
OutputPrivate::~OutputPrivate() {} OutputPrivate::~OutputPrivate() {}
@@ -759,4 +759,4 @@ qint64 OutputPrivate::writeData(const char* data, qint64 len)
QT_END_NAMESPACE QT_END_NAMESPACE
#include "moc_qaudiooutput_win32_p.cpp" #include "moc_qwindowsaudiooutput.cpp"

View File

@@ -50,8 +50,8 @@
// We mean it. // We mean it.
// //
#ifndef QAUDIOOUTPUTWIN_H #ifndef QWINDOWSAUDIOOUTPUT_H
#define QAUDIOOUTPUTWIN_H #define QWINDOWSAUDIOOUTPUT_H
#include <QtCore/qt_windows.h> #include <QtCore/qt_windows.h>
#include <mmsystem.h> #include <mmsystem.h>
@@ -63,9 +63,9 @@
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include <QtCore/qmutex.h> #include <QtCore/qmutex.h>
#include <qaudio.h> #include <QtMultimedia/qaudio.h>
#include <qaudiodeviceinfo.h> #include <QtMultimedia/qaudiodeviceinfo.h>
#include <qaudiosystem.h> #include <QtMultimedia/qaudiosystem.h>
// For compat with 4.6 // For compat with 4.6
#if !defined(QT_WIN_CALLBACK) #if !defined(QT_WIN_CALLBACK)
@@ -78,13 +78,12 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWindowsAudioOutput : public QAbstractAudioOutput
class QAudioOutputPrivate : public QAbstractAudioOutput
{ {
Q_OBJECT Q_OBJECT
public: public:
QAudioOutputPrivate(const QByteArray &device); QWindowsAudioOutput(const QByteArray &device);
~QAudioOutputPrivate(); ~QWindowsAudioOutput();
qint64 write( const char *data, qint64 len ); qint64 write( const char *data, qint64 len );
@@ -156,17 +155,17 @@ class OutputPrivate : public QIODevice
{ {
Q_OBJECT Q_OBJECT
public: public:
OutputPrivate(QAudioOutputPrivate* audio); OutputPrivate(QWindowsAudioOutput* audio);
~OutputPrivate(); ~OutputPrivate();
qint64 readData( char* data, qint64 len); qint64 readData( char* data, qint64 len);
qint64 writeData(const char* data, qint64 len); qint64 writeData(const char* data, qint64 len);
private: private:
QAudioOutputPrivate *audioDevice; QWindowsAudioOutput *audioDevice;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif // QWINDOWSAUDIOOUTPUT_H

View File

@@ -0,0 +1,74 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwindowsaudioplugin.h"
#include "qwindowsaudiodeviceinfo.h"
#include "qwindowsaudioinput.h"
#include "qwindowsaudiooutput.h"
QT_BEGIN_NAMESPACE
QWindowsAudioPlugin::QWindowsAudioPlugin(QObject *parent)
: QAudioSystemPlugin(parent)
{
}
QList<QByteArray> QWindowsAudioPlugin::availableDevices(QAudio::Mode mode) const
{
return QWindowsAudioDeviceInfo::availableDevices(mode);
}
QAbstractAudioInput *QWindowsAudioPlugin::createInput(const QByteArray &device)
{
return new QWindowsAudioInput(device);
}
QAbstractAudioOutput *QWindowsAudioPlugin::createOutput(const QByteArray &device)
{
return new QWindowsAudioOutput(device);
}
QAbstractAudioDeviceInfo *QWindowsAudioPlugin::createDeviceInfo(const QByteArray &device, QAudio::Mode mode)
{
return new QWindowsAudioDeviceInfo(device, mode);
}
QT_END_NAMESPACE

View File

@@ -0,0 +1,67 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSAUDIOPLUGIN_H
#define QWINDOWSAUDIOPLUGIN_H
#include <QtMultimedia/qaudiosystemplugin.h>
QT_BEGIN_NAMESPACE
class QWindowsAudioPlugin : public QAudioSystemPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.qt.audiosystemfactory/5.0" FILE "windowsaudio.json")
public:
QWindowsAudioPlugin(QObject *parent = 0);
~QWindowsAudioPlugin() {}
QList<QByteArray> availableDevices(QAudio::Mode mode) const Q_DECL_OVERRIDE;
QAbstractAudioInput *createInput(const QByteArray &device) Q_DECL_OVERRIDE;
QAbstractAudioOutput *createOutput(const QByteArray &device) Q_DECL_OVERRIDE;
QAbstractAudioDeviceInfo *createDeviceInfo(const QByteArray &device, QAudio::Mode mode) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
#endif // QWINDOWSAUDIOPLUGIN_H

View File

@@ -0,0 +1,3 @@
{
"Keys": ["default"]
}

View File

@@ -0,0 +1,23 @@
TARGET = qtaudio_windows
QT += multimedia-private
PLUGIN_TYPE = audio
PLUGIN_CLASS_NAME = QWindowsAudioPlugin
load(qt_plugin)
LIBS += -lwinmm -lstrmiids -lole32 -loleaut32
HEADERS += \
qwindowsaudioplugin.h \
qwindowsaudiodeviceinfo.h \
qwindowsaudioinput.h \
qwindowsaudiooutput.h
SOURCES += \
qwindowsaudioplugin.cpp \
qwindowsaudiodeviceinfo.cpp \
qwindowsaudioinput.cpp \
qwindowsaudiooutput.cpp
OTHER_FILES += \
windowsaudio.json

View File

@@ -58,7 +58,7 @@ MFPlayerControl::MFPlayerControl(MFPlayerSession *session)
QObject::connect(m_session, SIGNAL(audioAvailable()), this, SLOT(handleAudioAvailable())); QObject::connect(m_session, SIGNAL(audioAvailable()), this, SLOT(handleAudioAvailable()));
QObject::connect(m_session, SIGNAL(durationUpdate(qint64)), this, SLOT(handleDurationUpdate(qint64))); QObject::connect(m_session, SIGNAL(durationUpdate(qint64)), this, SLOT(handleDurationUpdate(qint64)));
QObject::connect(m_session, SIGNAL(seekableUpdate(bool)), this, SLOT(handleSeekableUpdate(bool))); QObject::connect(m_session, SIGNAL(seekableUpdate(bool)), this, SLOT(handleSeekableUpdate(bool)));
QObject::connect(m_session, SIGNAL(error(QMediaPlayer::Error, QString, bool)), this, SLOT(handleError(QMediaPlayer::Error, QString, bool))); QObject::connect(m_session, SIGNAL(error(QMediaPlayer::Error,QString,bool)), this, SLOT(handleError(QMediaPlayer::Error,QString,bool)));
QObject::connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64))); QObject::connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64)));
QObject::connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int))); QObject::connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
QObject::connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); QObject::connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));

View File

@@ -93,7 +93,7 @@ MFPlayerSession::MFPlayerSession(MFPlayerService *playerService)
, m_audioSampleGrabberNode(0) , m_audioSampleGrabberNode(0)
, m_videoProbeMFT(0) , m_videoProbeMFT(0)
{ {
QObject::connect(this, SIGNAL(sessionEvent(IMFMediaEvent *)), this, SLOT(handleSessionEvent(IMFMediaEvent *))); QObject::connect(this, SIGNAL(sessionEvent(IMFMediaEvent*)), this, SLOT(handleSessionEvent(IMFMediaEvent*)));
m_pendingState = NoPending; m_pendingState = NoPending;
ZeroMemory(&m_state, sizeof(m_state)); ZeroMemory(&m_state, sizeof(m_state));

View File

@@ -247,7 +247,10 @@ bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
if (!backendAvailable) { if (!backendAvailable) {
qWarning() << Q_FUNC_INFO << "Media service has neither renderer nor window control available."; qWarning() << Q_FUNC_INFO << "Media service has neither renderer nor window control available.";
m_backend.reset(); m_backend.reset();
} else if (!m_geometryDirty) {
m_backend->updateGeometry();
} }
return backendAvailable; return backendAvailable;
} }

View File

@@ -694,16 +694,14 @@ void tst_QDeclarativeVideoOutput::contentRect_data()
QRectF tst_QDeclarativeVideoOutput::invokeR2R(QObject *object, const char *signature, const QRectF &rect) QRectF tst_QDeclarativeVideoOutput::invokeR2R(QObject *object, const char *signature, const QRectF &rect)
{ {
QRectF r; QRectF r;
const QMetaObject *meta = object->metaObject(); QMetaObject::invokeMethod(object, signature, Q_RETURN_ARG(QRectF, r), Q_ARG(QRectF, rect));
meta->invokeMethod(object, signature, Q_RETURN_ARG(QRectF, r), Q_ARG(QRectF, rect));
return r; return r;
} }
QPointF tst_QDeclarativeVideoOutput::invokeP2P(QObject *object, const char *signature, const QPointF &point) QPointF tst_QDeclarativeVideoOutput::invokeP2P(QObject *object, const char *signature, const QPointF &point)
{ {
QPointF p; QPointF p;
const QMetaObject *meta = object->metaObject(); QMetaObject::invokeMethod(object, signature, Q_RETURN_ARG(QPointF, p), Q_ARG(QPointF, point));
meta->invokeMethod(object, signature, Q_RETURN_ARG(QPointF, p), Q_ARG(QPointF, point));
return p; return p;
} }

View File

@@ -630,8 +630,9 @@ void tst_QMediaPlayerBackend::seekPauseSeek()
QVERIFY(surface->m_frameList.isEmpty()); // frame must not appear until we call pause() or play() QVERIFY(surface->m_frameList.isEmpty()); // frame must not appear until we call pause() or play()
positionSpy.clear(); positionSpy.clear();
player.setPosition((qint64)7000); qint64 position = 7000;
QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - (qint64)7000) < (qint64)500); player.setPosition(position);
QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - position) < (qint64)500);
QCOMPARE(player.state(), QMediaPlayer::StoppedState); QCOMPARE(player.state(), QMediaPlayer::StoppedState);
QTest::qWait(250); // wait a bit to ensure the frame is not rendered QTest::qWait(250); // wait a bit to ensure the frame is not rendered
QVERIFY(surface->m_frameList.isEmpty()); // still no frame, we must call pause() or play() to see a frame QVERIFY(surface->m_frameList.isEmpty()); // still no frame, we must call pause() or play() to see a frame
@@ -642,7 +643,8 @@ void tst_QMediaPlayerBackend::seekPauseSeek()
{ {
QVideoFrame frame = surface->m_frameList.back(); QVideoFrame frame = surface->m_frameList.back();
QVERIFY(qAbs(frame.startTime() - (qint64)7000) < (qint64)500); const qint64 elapsed = frame.startTime() - position;
QVERIFY2(qAbs(elapsed) < (qint64)500, QByteArray::number(elapsed).constData());
QCOMPARE(frame.width(), 160); QCOMPARE(frame.width(), 160);
QCOMPARE(frame.height(), 120); QCOMPARE(frame.height(), 120);
@@ -657,14 +659,16 @@ void tst_QMediaPlayerBackend::seekPauseSeek()
} }
positionSpy.clear(); positionSpy.clear();
player.setPosition((qint64)12000); position = 12000;
QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - (qint64)12000) < (qint64)500); player.setPosition(position);
QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - position) < (qint64)500);
QCOMPARE(player.state(), QMediaPlayer::PausedState); QCOMPARE(player.state(), QMediaPlayer::PausedState);
QCOMPARE(surface->m_frameList.size(), 2); QCOMPARE(surface->m_frameList.size(), 2);
{ {
QVideoFrame frame = surface->m_frameList.back(); QVideoFrame frame = surface->m_frameList.back();
QVERIFY(qAbs(frame.startTime() - (qint64)12000) < (qint64)500); const qint64 elapsed = frame.startTime() - position;
QVERIFY2(qAbs(elapsed) < (qint64)500, QByteArray::number(elapsed).constData());
QCOMPARE(frame.width(), 160); QCOMPARE(frame.width(), 160);
QCOMPARE(frame.height(), 120); QCOMPARE(frame.height(), 120);

View File

@@ -78,7 +78,7 @@ tst_QAudioBuffer::tst_QAudioBuffer()
mFormat.setSampleRate(10000); mFormat.setSampleRate(10000);
mFormat.setCodec("audio/pcm"); mFormat.setCodec("audio/pcm");
QByteArray b(4000, 0x80); QByteArray b(4000, char(0x80));
mNull = new QAudioBuffer; mNull = new QAudioBuffer;
mEmpty = new QAudioBuffer(500, mFormat); // 500 stereo frames of 16 bits -> 2KB mEmpty = new QAudioBuffer(500, mFormat); // 500 stereo frames of 16 bits -> 2KB
mFromArray = new QAudioBuffer(b, mFormat); mFromArray = new QAudioBuffer(b, mFormat);

View File

@@ -504,7 +504,8 @@ void tst_QCamera::testCameraCaptureMetadata()
QCOMPARE(metadata[0].toInt(), id); QCOMPARE(metadata[0].toInt(), id);
QCOMPARE(metadata[1].toString(), QMediaMetaData::DateTimeOriginal); QCOMPARE(metadata[1].toString(), QMediaMetaData::DateTimeOriginal);
QDateTime captureTime = metadata[2].value<QVariant>().value<QDateTime>(); QDateTime captureTime = metadata[2].value<QVariant>().value<QDateTime>();
QVERIFY(qAbs(captureTime.secsTo(QDateTime::currentDateTime()) < 5)); //it should not takes more than 5 seconds for signal to arrive here const qint64 dt = captureTime.secsTo(QDateTime::currentDateTime());
QVERIFY2(qAbs(dt) < 5, QByteArray::number(dt).constData()); // it should not take more than 5 seconds for signal to arrive here
metadata = metadataSignal[2]; metadata = metadataSignal[2];
QCOMPARE(metadata[0].toInt(), id); QCOMPARE(metadata[0].toInt(), id);