示例#1
0
void AudioPlayer::play(PModel playlistModel, const QModelIndex& index)
{
    if (!index.isValid())
        return;
    PTrack currentlyPlayingTrack = playingTrack_;
    setPlaying(playlistModel, index);
    setBuffering(PModel(), QModelIndex());
    if (!playingTrack_)
        return;

    if (currentlyPlayingTrack && audioOutput_->state() == AudioState::Playing && currentlyPlayingTrack->isCueTrack() && playingTrack_->isCueTrack()
        && currentlyPlayingTrack->location == playingTrack_->location) {
        // Playing in the same cue file
        audioOutput_->seek(playingTrack_->cueOffset());
        emit trackPlaying(playingTrack_);
        emit trackPositionChanged(0, true);
    } else {
        audioOutput_->clearQueue();
        audioOutput_->setCurrentSource(playingTrack_->location);
        setVolume(volume_);
        if (playingTrack_->isCueTrack()) {
            audioOutput_->play(playingTrack_->cueOffset());
        }
        else
            audioOutput_->play();
    }
}
示例#2
0
void AudioPlayer::deletePlaylist(PModel model)
{
    queue_.removePlaylistModel(model);
    playlists_.erase(model);
    if (playingModel_ == model)
        setPlaying(PModel(), QModelIndex());
    if (bufferingTrackPlaylist_ == model)
        setBuffering(PModel(), QModelIndex());
}
示例#3
0
/**
 * Opens a file.  This opens the file for both lowlevel I/O
 * and also for higher level I/O.
 *
 * @param name       Name of the stream.
 * @param openFlags  The open flags.  This are the same flags used on the open()
 *                   function.
 *
 * @return true if the file was opened successfully, false otherwise.
 *
 * @remarks  TTY devices should not be buffered.  Stdin, stdout, etc. are set
 *           correctly in their setStdIn() setStdOut(), etc., functions.  But
 *           here we need to check for TTY devices and not buffer them.
 *           /dev/pts/n for example.
 */
bool SysFile::open(const char *name, int openFlags, int openMode, int shareMode)
{
    flags = openFlags;           // save the initial flag values

    // we must open this with the NOINHERIT flag added
    fileHandle = ::open(name, openFlags, (mode_t)openMode); //TODO open
    if ( fileHandle == -1 )
    {
        errInfo = errno;
        return false;
    }

    // mark that we opened this handle
    openedHandle = true;

    // save a copy of the name
    filename = strdup(name);
    ungetchar = -1;              // 0xFF indicates no char

    // is this append mode?
    if ((flags & RX_O_APPEND) != 0)
    {
        // mark this true, and position at the end
        append = true;
        lseek64(fileHandle, 0, SEEK_END);
    }

    // set eof flag
    fileeof = false;

    getStreamTypeInfo();

    // set the default buffer size (and allocate the buffer)
    if ( isTTY )
    {
        setBuffering(false, 0);
    }
    else
    {
        setBuffering(true, 0);
    }

    return true;
}
示例#4
0
/**
 * Open a stream using a provided handle value.
 *
 * @param handle     The source stream handle.
 * @param fdopenMode The fdopen() mode flags for the stream.
 *
 * @return true if the file opened ok, false otherwise.
 *
 * @remarks  TTY devices should not be buffered.  Stdin, stdout, etc. are set
 *           correctly in their setStdIn() setStdOut(), etc., functions.  But
 *           here we need to check for TTY devices and not buffer them.
 *           /dev/pts/n for example.
 */
bool SysFile::open(int handle)
{
    // we didn't open this.
    openedHandle = false;
    fileHandle = handle;
    ungetchar = -1;              // 0xFF indicates no char
    getStreamTypeInfo();

    // set the default buffer size (and allocate the buffer)
    if ( isTTY )
    {
        setBuffering(false, 0);
    }
    else
    {
        setBuffering(true, 0);
    }

    return true;
}
示例#5
0
void AudioPlayer::bufferTrack(PModel playlistModel, QModelIndex index)
{
    setBuffering(playlistModel, index);
    if (!bufferingTrack_)
        return;
    if (!bufferingTrack_->isCueTrack()) {
        audioOutput_->clearQueue();
        audioOutput_->enqueue(bufferingTrack_->location);
        qDebug() << "Enqueue " << bufferingTrack_->location;
    }
}
示例#6
0
/**
 * Set a SysFile object to the stderr stream.
 */
void SysFile::setStdErr()
{
    // set the file handle
    fileHandle = stderrHandle;
    // we didn't open this.
    openedHandle = false;
    ungetchar = -1;              // -1 indicates no char
    getStreamTypeInfo();
    setBuffering(false, 0);
    writeable = true;             // force this to writeable

    // STDERR is not buffered by default so no need to do anything
}
示例#7
0
/**
 * Set a SysFile object to be the standard output stream.
 */
void SysFile::setStdIn()
{
    // set the file handle
    fileHandle = stdinHandle;
    // we didn't open this.
    openedHandle = false;
    ungetchar = -1;              // -1 indicates no char
    getStreamTypeInfo();
    setBuffering(false, 0);
    readable = true;             // force this to readable
    // STDIN is buffered by default so make it unbuffered
    setbuf(stdin, NULL);
}
示例#8
0
void ExtWorkerConfig::config(const XmlNode *pNode)
{
    const char *pValue;
    int iMaxConns = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                    "maxConns", 1, 2000, 1);
    int iRetryTimeout = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                        "retryTimeout", 0, LONG_MAX, 10);
    int iInitTimeout = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                       "initTimeout", 1, LONG_MAX, 3);
    int iBuffer = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                  "respBuffer", 0, 2, 1);
    int iKeepAlive = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                     "persistConn", 0, 1, 1);
    int iKeepAliveTimeout = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                            "pcKeepAliveTimeout", -1, INT_MAX, INT_MAX);

    if (iKeepAliveTimeout == -1)
        iKeepAliveTimeout = INT_MAX;

    if (iBuffer == 1)
        iBuffer = 0;
    else if (iBuffer == 0)
        iBuffer = HEC_RESP_NOBUFFER;
    else if (iBuffer == 2)
        iBuffer = HEC_RESP_NPH;

    setPersistConn(iKeepAlive);
    setKeepAliveTimeout(iKeepAliveTimeout);
    setMaxConns(iMaxConns);
    setTimeout(iInitTimeout);
    setRetryTimeout(iRetryTimeout);
    setBuffering(iBuffer);
    clearEnv();
    const XmlNodeList *pList = pNode->getChildren("env");

    if (pList)
    {
        XmlNodeList::const_iterator iter;

        for (iter = pList->begin(); iter != pList->end(); ++iter)
        {
            pValue = (*iter)->getValue();

            if (pValue)
                addEnv((*iter)->getValue());
        }
    }

}
示例#9
0
void AudioPlayer::currentSourceChanged()
{
//     qDebug() << "currentSourceChanged() " << audioOutput_->currentTime() << " " << audioOutput_->totalTime();
    if (queue_.peeked()) {
        auto p = queue_.peekTrack();
        if (p.first == bufferingTrackPlaylist_ && p.second == bufferingIndex_)
            queue_.popPeekedTrack();
    }
    if (bufferingTrackPlaylist_) {
        setPlaying(bufferingTrackPlaylist_, bufferingIndex_);
        setBuffering(PModel(), QModelIndex(), true);
    }
    if (playingTrack_) {
        setVolume(volume_);
        emit trackPlaying(playingTrack_);
        emit trackPositionChanged(0, true);
    } else {
        qDebug() << "Source changed to null track!";
    }
    aboutToFinish();
}
示例#10
0
void AudioPlayer::stop()
{
    setBuffering(PModel(), QModelIndex(), true);
    audioOutput_->stop();
}