Changeset View
Changeset View
Standalone View
Standalone View
gstreamer/pipeline.cpp
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Line(s) | 242 | { | |||
---|---|---|---|---|---|
247 | if (state == GST_STATE_READY && m_reader) { | 247 | if (state == GST_STATE_READY && m_reader) { | ||
248 | debug() << "forcing stop as we are in ready state and have a reader..."; | 248 | debug() << "forcing stop as we are in ready state and have a reader..."; | ||
249 | m_reader->stop(); | 249 | m_reader->stop(); | ||
250 | } | 250 | } | ||
251 | 251 | | |||
252 | return gst_element_set_state(GST_ELEMENT(m_pipeline), state); | 252 | return gst_element_set_state(GST_ELEMENT(m_pipeline), state); | ||
253 | } | 253 | } | ||
254 | 254 | | |||
255 | void Pipeline::writeToDot(MediaObject *media, const QString &type) | 255 | void Pipeline::writeToDot(MediaObject *media, const QString &type) | ||
dvratil: Docs say that `GstClockTime` is measured in nanoseconds. I would propose a timeout of at least… | |||||
256 | { | 256 | { | ||
257 | GstBin *bin = GST_BIN(m_pipeline); | 257 | GstBin *bin = GST_BIN(m_pipeline); | ||
258 | if (media) { | 258 | if (media) { | ||
259 | debug() << media << "Dumping" << QString("%0.dot").arg(type); | 259 | debug() << media << "Dumping" << QString("%0.dot").arg(type); | ||
260 | } else { | 260 | } else { | ||
261 | debug() << type; | 261 | debug() << type; | ||
262 | } | 262 | } | ||
263 | GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(bin, GST_DEBUG_GRAPH_SHOW_ALL, QString("phonon-%0").arg(type).toUtf8().constData()); | 263 | GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(bin, GST_DEBUG_GRAPH_SHOW_ALL, QString("phonon-%0").arg(type).toUtf8().constData()); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
320 | gboolean Pipeline::cb_buffering(GstBus *bus, GstMessage *gstMessage, gpointer data) | 320 | gboolean Pipeline::cb_buffering(GstBus *bus, GstMessage *gstMessage, gpointer data) | ||
321 | { | 321 | { | ||
322 | DEBUG_BLOCK; | 322 | DEBUG_BLOCK; | ||
323 | Q_UNUSED(bus) | 323 | Q_UNUSED(bus) | ||
324 | Pipeline *that = static_cast<Pipeline*>(data); | 324 | Pipeline *that = static_cast<Pipeline*>(data); | ||
325 | gint percent = 0; | 325 | gint percent = 0; | ||
326 | gst_message_parse_buffering(gstMessage, &percent); | 326 | gst_message_parse_buffering(gstMessage, &percent); | ||
327 | 327 | | |||
328 | // we should not trigger paused state or gstreamer will starts buffering again | ||||
329 | if (percent == 0) { | ||||
sitter: I think our code style is
`if (percent == 0) {` | |||||
anthonyfieroni: Yes, but it's related to other code style in the file. | |||||
330 | return true; | ||||
331 | } | ||||
332 | | ||||
328 | debug() << Q_FUNC_INFO << "Buffering :" << percent; | 333 | debug() << Q_FUNC_INFO << "Buffering :" << percent; | ||
329 | 334 | | |||
330 | // Instead of playing when the pipeline is still streaming, we pause | 335 | // Instead of playing when the pipeline is still streaming, we pause | ||
331 | // and let gst finish streaming. | 336 | // and let gst finish streaming. | ||
332 | if ( percent < 100 && gstMessage->type == GST_MESSAGE_BUFFERING) { | 337 | if ( percent < 100 && gstMessage->type == GST_MESSAGE_BUFFERING) { | ||
333 | QMetaObject::invokeMethod(that, "setState", Qt::QueuedConnection, Q_ARG(GstState, GST_STATE_PAUSED)); | 338 | QMetaObject::invokeMethod(that, "setState", Qt::QueuedConnection, Q_ARG(GstState, GST_STATE_PAUSED)); | ||
334 | 339 | | |||
335 | } else { | 340 | } else { | ||
▲ Show 20 Lines • Show All 612 Lines • Show Last 20 Lines |
Docs say that GstClockTime is measured in nanoseconds. I would propose a timeout of at least 10ms here since the operation is asynchronous and I doubt much is accomplished in 1 µs.