void DecoderHandler::stop(void) { VERBOSE(VB_PLAYBACK, QString("DecoderHandler: Stopping decoder")); if (m_decoder && m_decoder->isRunning()) { m_decoder->lock(); m_decoder->stop(); m_decoder->unlock(); } if (m_decoder) { m_decoder->lock(); m_decoder->cond()->wakeAll(); m_decoder->unlock(); } if (m_decoder) { m_decoder->wait(); delete m_decoder->input(); delete m_decoder; m_decoder = NULL; } deleteIOFactory(); doOperationStop(); m_state = STOPPED; }
void DecoderHandler::stop(void) { LOG(VB_PLAYBACK, LOG_INFO, QString("DecoderHandler: Stopping decoder")); if (m_decoder && m_decoder->isRunning()) { m_decoder->lock(); m_decoder->stop(); m_decoder->unlock(); } if (m_decoder) { m_decoder->lock(); m_decoder->cond()->wakeAll(); m_decoder->unlock(); } if (m_decoder) { m_decoder->wait(); //delete m_decoder->input(); // TODO: need to sort out who is responsible for the input delete m_decoder; m_decoder = NULL; } deleteIOFactory(); doOperationStop(); m_state = STOPPED; }
bool DecoderHandler::next(void) { if (done()) return false; if (m_meta.Format() == "cast") { m_playlist_pos = random() % m_playlist.size(); } else { m_playlist_pos++; } PlayListFileEntry *entry = m_playlist.get(m_playlist_pos); if (QFileInfo(entry->File()).isAbsolute()) m_url = QUrl::fromLocalFile(entry->File()); else m_url.setUrl(entry->File()); LOG(VB_PLAYBACK, LOG_INFO, QString("Now playing '%1'").arg(m_url.toString())); deleteIOFactory(); createIOFactory(m_url); if (! haveIOFactory()) return false; getIOFactory()->addListener(this); getIOFactory()->start(); m_state = ACTIVE; return true; }
void DecoderHandler::createIOFactory(const QUrl &url) { if (haveIOFactory()) deleteIOFactory(); if (url.scheme() == "file" || QFileInfo(url.toString()).isAbsolute() || url.toString().endsWith(".cda")) m_io_factory = new DecoderIOFactoryFile(this); else if (m_meta && m_meta->Format() == "cast") m_io_factory = new DecoderIOFactoryShoutCast(this); else m_io_factory = new DecoderIOFactoryUrl(this); }
void DecoderHandler::createIOFactory(const QUrl &url) { if (haveIOFactory()) deleteIOFactory(); if (url.scheme() == "myth") m_io_factory = new DecoderIOFactorySG(this); else if (m_meta && m_meta->Format() == "cast") m_io_factory = new DecoderIOFactoryShoutCast(this); else if (url.scheme() == "http") m_io_factory = new DecoderIOFactoryUrl(this); else m_io_factory = new DecoderIOFactoryFile(this); }