6#include <QtCore/qcoreapplication.h>
8#include <private/qmediastoragelocation_p.h>
10#include <mm/renderer.h>
22 if (
settings.audioChannelCount() > 0)
42void QQnxAudioRecorder::openConnection()
44 static int idCounter = 0;
46 m_connection = ConnectionUniquePtr { mmr_connect(
nullptr) };
49 qWarning(
"QQnxAudioRecorder: Unable to connect to the multimedia renderer");
55 char contextName[256];
57 std::snprintf(contextName,
sizeof contextName,
"QQnxAudioRecorder_%d_%llu",
60 m_context = ContextUniquePtr { mmr_context_create(m_connection.get(),
61 contextName, 0, S_IRWXU|S_IRWXG|S_IRWXO) };
66 qWarning(
"QQnxAudioRecorder: Unable to create context");
71void QQnxAudioRecorder::closeConnection()
79void QQnxAudioRecorder::attach()
90 if (m_audioId == -1) {
91 qWarning(
"QQnxAudioRecorder: mmr_output_attach() for file failed");
95 configureOutputBitRate();
99 if (mmr_input_attach(m_context.get(), devicePath.
constData(),
"track") != 0) {
100 qWarning(
"QQnxAudioRecorder: mmr_input_attach() failed");
107void QQnxAudioRecorder::detach()
112 mmr_input_detach(m_context.get());
113 mmr_output_detach(m_context.get(), m_audioId);
118void QQnxAudioRecorder::configureOutputBitRate()
122 if (!isAttached() || bitRate <= 0)
126 std::snprintf(
buf,
sizeof buf,
"%d", bitRate);
129 dict = strm_dict_set(dict,
"audio_bitrate",
buf);
131 if (mmr_output_parameters(m_context.get(), m_audioId, dict) != 0)
132 qWarning(
"mmr_output_parameters: setting bitrate failed");
135bool QQnxAudioRecorder::isAttached()
const
137 return m_context && m_audioId != -1;
142 m_inputDeviceId =
id;
164 if (mmr_play(m_context.get()) != 0)
165 qWarning(
"QQnxAudioRecorder: mmr_play() failed");
173 mmr_stop(m_context.get());
178void QQnxAudioRecorder::startMonitoring()
180 m_eventThread = std::make_unique<QQnxMediaEventThread>(m_context.get());
183 this, &QQnxAudioRecorder::readEvents);
186 m_eventThread->start();
189void QQnxAudioRecorder::stopMonitoring()
192 m_eventThread.reset();
195void QQnxAudioRecorder::readEvents()
201 switch (
event->type) {
203 handleMmEventStatus(
event);
206 handleMmEventState(
event);
209 handleMmEventError(
event);
226 m_eventThread->signalRead();
240 const qint64 duration = valueBa.toLongLong(&
ok);
243 qCritical(
"Could not parse duration from '%s'", valueBa.constData());
253 switch (
event->state) {
275 if (
event->details.error.info.error_code == MMR_ERROR_NONE) {
284#include "moc_qqnxaudiorecorder_p.cpp"
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
static qint64 applicationPid() Q_DECL_CONST_FUNCTION
QString preferredSuffix
the preferred suffix for the MIME type
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setInputDeviceId(const QByteArray &id)
void durationChanged(qint64 durationMs)
void setOutputUrl(const QUrl &url)
void stateChanged(QMediaRecorder::RecorderState state)
QQnxAudioRecorder(QObject *parent=nullptr)
void setMediaEncoderSettings(const QMediaEncoderSettings &settings)
void actualLocationChanged(const QUrl &location)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
const mmr_event_t * mmr_event_get(mmr_context_t *ctxt)
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
GLenum GLuint GLenum GLsizei const GLchar * buf
static QByteArray buildDevicePath(const QByteArray &deviceId, const QMediaEncoderSettings &settings)
#define qPrintable(string)
#define QStringLiteral(str)
QSettings settings("MySoft", "Star Runner")
[0]
QUrl url("example.com")
[constructor-url-reference]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent