4#include <QtCore/qcoreapplication.h>
5#include <QtCore/qdebug.h>
6#include <QtCore/qmath.h>
7#include <private/qaudiohelpers_p.h>
28 return maybeAppSrc.error();
45 gstPipeline(
"pipeline"),
46 gstVolume(
std::move(volume)),
53 gstAppSrc = m_appSrc->
element();
58 gstVolume.
set(
"volume", m_volume);
64 gstOutput = gst_device_create_element(audioInfo->gstDevice,
nullptr);
66 gstPipeline.
add(gstAppSrc,
queue, audioconvert, gstVolume, gstOutput);
67 gstAppSrc.
link(
queue, audioconvert, gstVolume, gstOutput);
82 if (m_errorState ==
error)
96 if (m_deviceState ==
state)
99 m_deviceState =
state;
105 return m_deviceState;
124 m_audioSource =
nullptr;
154 return m_audioSource;
158static void padAdded(GstElement *element, GstPad *pad, gpointer
data)
160 GstElement *
other =
static_cast<GstElement *
>(
data);
162 gchar *
name = gst_pad_get_name(pad);
163 qDebug(
"A new pad %s was created for %s\n",
name, gst_element_get_name(element));
166 qDebug(
"element %s will be linked to %s\n",
167 gst_element_get_name(element),
168 gst_element_get_name(
other));
169 gst_element_link(element,
other);
175 auto *msg =
message.rawMessage();
176 switch (GST_MESSAGE_TYPE (msg)) {
177 case GST_MESSAGE_EOS:
180 case GST_MESSAGE_ERROR: {
185 gst_message_parse_error (msg, &
error, &
debug);
189 g_error_free (
error);
200bool QGStreamerAudioSink::open()
212 m_appSrc->
setup(m_audioSource, m_audioSource ? m_audioSource->
pos() : 0);
216 gstPipeline.
setState(GST_STATE_PLAYING);
221 m_bytesProcessed = 0;
226void QGStreamerAudioSink::close()
232 qWarning() <<
"failed to close the audio output stream";
234 if (!m_pullMode && m_audioSource)
235 delete m_audioSource;
236 m_audioSource =
nullptr;
272 m_bufferSize =
value;
274 gst_app_src_set_max_bytes(GST_APP_SRC(gstAppSrc.
element()),
value);
295 gstPipeline.
setState(GST_STATE_PLAYING);
297 setState(m_suspendedInState);
315 m_suspendedInState = m_deviceState;
319 gstPipeline.
setState(GST_STATE_PAUSED);
332 m_audioDevice = audio;
347 return m_audioDevice->write(
data,
len);
357 gstVolume.
set(
"volume", vol);
365void QGStreamerAudioSink::bytesProcessedByAppSrc(
int bytes)
367 m_bytesProcessed += bytes;
372void QGStreamerAudioSink::needData()
382#include "moc_qgstreameraudiosink_p.cpp"
IOBluetoothDevice * device
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
GStreamerOutputPrivate(QGStreamerAudioSink *audio)
qint64 readData(char *data, qint64 len) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
The QAudioDevice class provides an information about audio devices and their functionality.
qint64 restart() noexcept
Restarts the timer and returns the number of milliseconds elapsed since the previous start.
static QMaybe< QPlatformAudioSink * > create(const QAudioDevice &device, QObject *parent)
void setFormat(const QAudioFormat &format) override
friend class GStreamerOutputPrivate
QIODevice * start() override
QAudioFormat format() const override
void setVolume(qreal volume) override
QAudio::State state() const override
bool processBusMessage(const QGstreamerMessage &message) override
qsizetype bufferSize() const override
qsizetype bytesFree() const override
qint64 processedUSecs() const override
qreal volume() const override
void setBufferSize(qsizetype value) override
QAudio::Error error() const override
void setAudioFormat(const QAudioFormat &f)
void bytesProcessed(int bytes)
bool setup(QIODevice *stream=nullptr, qint64 offset=0)
static QMaybe< QGstAppSrc * > create(QObject *parent=nullptr)
void write(const char *data, qsizetype size)
void add(const QGstElement &element)
GstElement * element() const
bool setStateSync(GstState state)
bool link(const QGstElement &next)
void set(const char *property, const char *str)
GstStateChangeReturn setState(GstState state)
void installMessageFilter(QGstreamerSyncMessageFilter *filter)
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QAudio namespace contains enums used by the audio classes.
State
\value ActiveState Audio data is being processed, this state is set after start() is called and while...
Error
\value NoError No errors have occurred \value OpenError An error occurred opening the audio device \v...
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QString errorMessageCannotFindElement(std::string_view element)
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent