예제 #1
0
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;
}
예제 #2
0
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;
}
예제 #3
0
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;
}
예제 #4
0
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);
}
예제 #5
0
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);
}