Exemplo n.º 1
0
//------------------------------------------------------------------------------
// serialize() -- print the value of this object to the output stream sout.
//------------------------------------------------------------------------------
std::ostream& List::serialize(std::ostream& sout, const int, const bool) const
{
    std::cout << "{" << std::endl;
    for (const Item* p = getFirstItem(); p != nullptr; p = p->getNext() ) {
        if (p->getValue() != nullptr) p->getValue()->serialize(sout,4);
        else std::cout << "<BAD VALUE>" << std::endl;
    }
    std::cout << "}" << std::endl;
    return sout;
}
FXFoldingItem *FOX16_GuiSortingList::getItem(int index) {
  FXFoldingItem *ti;
  int i=index;

  ti=getFirstItem();
  while(ti && i) {
    ti=ti->getNext();
    i--;
  }

  return ti;
}
Exemplo n.º 3
0
//------------------------------------------------------------------------------
// operator==    Returns true if two lists are equal.
//------------------------------------------------------------------------------
bool List::operator==(const List& l) const
{
   if (entries() != l.entries()) return false;

   const Item* tt = getFirstItem();
   const Item* ll = l.getFirstItem();
   while (tt != nullptr) {
      if (tt->getValue() != ll->getValue()) return false;
      tt = tt->getNext();
      ll = ll->getNext();
   }
   return true;
}
Exemplo n.º 4
0
JsonItem *Json::getItem ( char *name ) {
	JsonItem *ji = getFirstItem();
	// traverse the json
	for ( ; ji ; ji = ji->m_next ) {
		// just get STRINGS or NUMS
		if ( ji->m_type != JT_STRING && ji->m_type != JT_NUMBER ) 
			continue;
		// check name
		char *name2   = ji->m_name;
		if ( strcmp(name2,name) == 0 ) return ji;
	}
	return NULL;
}
Exemplo n.º 5
0
//------------------------------------------------------------------------------
// getPosition1() -- Returns the object at the n'th position; w/o next pointer
//------------------------------------------------------------------------------
const Object* List::getPosition1(const unsigned int n) const
{
    if (n < 1 || n > num) return nullptr;
    unsigned int i = 1;
    const Item* p = getFirstItem();
    while (i < n && p != nullptr) {
        p = p->getNext();
        i++;
    }
    if (p != nullptr)
        return p->getValue();
    else
        return nullptr;
}
Exemplo n.º 6
0
void Showplan::onMessage() {
    const char* routine = "Showplan::onMessage";
	L_INFO(LOG_DB,"Showplan received message");
	mLock.lock();
    if (conf->getParam("next_on_showplan") == ""
                        && getSize() > 0
                        && getLastItem().getHash() != mActive) {
        L_INFO(LOG_DB,"Processing track load event");
        if (!mIsItemActive) {
            mActive = getFirstItem().getHash();
        }
        else {
        	getItemByHash(mActive).setState(DpsShowItem::Finished);
            try {
        	   mActive = getNextItem(getItemByHash(mActive)).getHash();
            }
            catch (int e) {
                cout << "Caught exception - no next item." << endl;
            }
			// while we have a script selected...
//            while (activePoint->getType() == 1
//                    && activePoint != lstShowPlan->lastItem()) {
//                activePoint = (ShowPlanItem*)activePoint->nextSibling();
//            }
        }
        getItemByHash(mActive).setState(DpsShowItem::Loaded);
        mIsItemActive = true;
        //??
        lstShowPlan->ensureItemVisible(lstShowPlan->selectedItem());
        //if (lstShowPlan->selectedItem()) {
        //    selectionChanged(lstShowPlan->selectedItem());
        //}
		mLock.unlock();
        showplanUpdated();
    }
	else {
		mLock.unlock();
	}	
	L_INFO(LOG_DB,"Finished Showplan onMessage");
}
Exemplo n.º 7
0
void Showplan::updateNextTrack() {
    mLock.lock();
    if (getSize() == 0) {
		conf->setParam("next_on_showplan","");
		mLock.unlock();
		return;
	}

	DpsShowItem x;
    if ( ! mIsItemActive ) {
        x = getFirstItem();
    }
    else {
        try {
            x = getNextItem(getItemByHash(mActive));
        }
        catch (DpsShowPlan::Error&) {
            mLock.unlock();
            return;
        }
    }

	try {
        while (1) {
        	if ( x.hasAudio() ) {
            	conf->setParam("next_on_showplan", x.getAudioItem()["md5"]);
                break;
        	}
            if (x == getLastItem()) {
                break;
            }
            x = getNextItem(x);
        }
	}
	catch (DpsShowPlan::Error&) {
		
	}

    mLock.unlock();
}
Exemplo n.º 8
0
unsigned int List::getNumberList(int values[], const unsigned int max) const
{
    unsigned int n = 0;
    for (const Item* p = getFirstItem(); p != nullptr && n < max; p = p->getNext() ) {
        const Object* p1 = p->getValue();
        const Pair* gp = dynamic_cast<const Pair*>(p1);
        if (gp != nullptr) {
            // when the item is a Pair, use the object it contains.
            p1 = gp->object();
        }
        const Number* pp = dynamic_cast<const Number*>(p1);
        if (pp != nullptr) {
            // when we have a number
            values[n++] = pp->getInt();
        }
        else {
            // when we do not have a number
            values[n++] = 0;
        }
    }
    return n;
}
Exemplo n.º 9
0
/**
 * Return the first item of the queue without removing it.
 *
 * @return The first object from the queue.
 */
RexxInternalObject *QueueClass::peek()
{
    return getFirstItem();
}
PlayItem * playlist_next(fsl_player_handle handle, options* opt)
{
    fsl_player* pplayer = NULL;
    pplayer = (fsl_player*)handle;
    fsl_player_drm_format drm_format;
    PlayItem * current = opt->current;
    PlayItem * next = getNextItem(current);

    switch( opt->repeat )
    {
        case FSL_PLAYER_REPEAT_NONE:
        {
            if( next )
            {
                opt->current = next;
                printf("%s\n", opt->current->name);
                pplayer->klass->stop(pplayer);
                pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format);
                pplayer->klass->play(pplayer);
            }
            else
            {
                //gcore_register_callback(gcore, NULL, NULL,0);
                // if not repeated mode or no next item, exit.
                //printf("%s(): No more multimedia files, exit.\n", __FUNCTION__);
                //player_exit(pplayer);
            }
            break;
        }
        case FSL_PLAYER_REPEAT_PLAYLIST:
        {
            if( next )
            {
                opt->current = next;
                printf("%s\n", opt->current->name);
                pplayer->klass->stop(pplayer);
                pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format);
                pplayer->klass->play(pplayer);
            }
            else
            {
                if (opt->play_times>0){
                  opt->play_times--;
                  if (opt->play_times==0) break;
                }
                next = getFirstItem(opt->pl);
                opt->current = next;
                pplayer->klass->stop(pplayer);
                pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format);
                pplayer->klass->play(pplayer);
            }
            break;
        }
        case FSL_PLAYER_REPEAT_CURRENT:
        {
						next = opt->current;
            pplayer->klass->stop(pplayer);
            pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format);
            pplayer->klass->play(pplayer);
            break;
        }
        default:
        {
            break;
        }
    }
    return next;
}
fsl_player_s32 parse_options(fsl_player_config* pconfig, options * opt, fsl_player_s32 argc, fsl_player_s8* argv[])
{
    fsl_player_s32 ret = -1;
    fsl_player_s32 i;

    opt->pl = createPlayList(NULL);
    if (opt->pl==NULL){
        printf("Can not create Playlist!!\n");
        goto err;
    }

    opt->play_times = -1;

    for (i=1;i<argc;i++){
        if (strlen(argv[i])) {
            if (argv[i][0]=='-'){
                if ((strcmp(argv[i], "-h")==0)||(strcmp(argv[i], "--help")==0)){
                    printf("Usage of command line player:\n");
                    printf("    %s file_list\n", argv[0]);
                    ret = 1;
                    goto err;
                }

                if ((strcmp(argv[i], "--playbin")==0)){
                    pconfig->playbin_version = 1;
                    continue;
                }

                if ((strncmp(argv[i], "--visual", 8)==0)){
                    opt->enable_visual = 1;
                    if (argv[i][8]=='='){
                      pconfig->visual_name = &(argv[i][9]);
                    }
                    continue;
                }

                if (strcmp(argv[i], "--quiet")==0){
                    opt->info_interval_in_sec = 0;
                    continue;
                }

                if (strncmp(argv[i], "-r", 2)==0){
                  if (argv[i][2]=='='){
                    opt->play_times = atoi(&(argv[i][3]));
                  }
                  opt->repeat = FSL_PLAYER_REPEAT_PLAYLIST;
                  continue;
                }

                if (strncmp(argv[i], "--repeat", 8)==0){
                  if (argv[i][8]=='='){
                    opt->play_times = atoi(&(argv[i][9]));
                  }
                  opt->repeat = FSL_PLAYER_REPEAT_PLAYLIST;
                  continue;
                }

                if (strncmp(argv[i], "--timeout", 9)==0){
                  if (argv[i][9]=='='){
                    pconfig->timeout_second = atoi(&(argv[i][10]));
                  }
                  continue;
                }

                if ((strncmp(argv[i], "--video-sink", 12)==0)){
                  if (argv[i][12]=='='){
                    pconfig->video_sink_name = (&(argv[i][13]));
                  }
                  continue;
                }

                if ((strncmp(argv[i], "--audio-sink", 12)==0)){
                  if (argv[i][12]=='='){
                    pconfig->audio_sink_name = (&(argv[i][13]));
                  }
                  continue;
                }


                if ((strncmp(argv[i], "--info-interval", 14)==0)){
                  if (argv[i][14]=='='){
                    opt->info_interval_in_sec = atoi(&(argv[i][15]));
                  }
                  continue;
                }

                if ((strcmp(argv[i], "--handle-buffering")==0)){
                    opt->handle_buffering = 1;
                    pconfig->features &= (~GPLAYCORE_FEATURE_AUTO_BUFFERING);
                    continue;
                }

                if ((strcmp(argv[i], "--fade")==0)){
                    pconfig->features |= (GPLAYCORE_FEATURE_AUDIO_FADE);
                    continue;
                }


                if ((strcmp(argv[i], "--handle-redirect")==0)){
                    opt->handle_redirect= 1;
                    pconfig->features &= (~ GPLAYCORE_FEATURE_AUTO_REDIRECT_URI);
                    continue;
                }

                continue;
            }else{

              addItemAtTail(opt->pl, argv[i],0);
              continue;
            }
        }

    }

    opt->current=getFirstItem(opt->pl);
    if (opt->current==NULL){
        printf("NO File specified!!\n");
        goto err;
    }

    ret = 0;
    return ret;

err:
    if (opt->pl){
        destroyPlayList(opt->pl);
        opt->pl=NULL;
    }
    return ret;
}