static void asx_parse_ref(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { char *href; href = asx_get_attrib("HREF",attribs); if(href == NULL) { asx_warning_attrib_required(parser,"REF" ,"HREF" ); return; } #if 0 // replace http my mmshttp to avoid infinite loops // disabled since some playlists for e.g. WinAMP use asx as well // "-user-agent NSPlayer/4.1.0.3856" is a possible workaround if (strncmp(href, "http://", 7) == 0) { char *newref = malloc(3 + strlen(href) + 1); strcpy(newref, "mms"); strcpy(newref + 3, href); free(href); href = newref; } #endif play_tree_add_file(pt,href); mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding file %s to element entry\n",href); free(href); }
static play_tree_t* parse_textplain(play_tree_parser_t* p) { char* line; char *c; int embedded; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying plaintext playlist...\n"); play_tree_parser_stop_keeping(p); while((line = play_tree_parser_get_line(p)) != NULL) { strstrip(line); if(line[0] == '\0' || line[0] == '#' || (line[0] == '/' && line[1] == '/')) continue; //Special check for embedded smil or ram reference in file embedded = 0; if (strlen(line) > 5) for(c = line; c[0]; c++ ) if ( ((c[0] == '.') && //start with . and next have smil with optional ? or & (tolower(c[1]) == 's') && (tolower(c[2])== 'm') && (tolower(c[3]) == 'i') && (tolower(c[4]) == 'l') && (!c[5] || c[5] == '?' || c[5] == '&')) || // or ((c[0] == '.') && // start with . and next have smi or ram with optional ? or & ( ((tolower(c[1]) == 's') && (tolower(c[2])== 'm') && (tolower(c[3]) == 'i')) || ((tolower(c[1]) == 'r') && (tolower(c[2])== 'a') && (tolower(c[3]) == 'm')) ) && (!c[4] || c[4] == '?' || c[4] == '&')) ) { entry=embedded_playlist_parse(line); embedded = 1; break; } if (!embedded) { //regular file link entry = play_tree_new(); play_tree_add_file(entry,line); } if (entry != NULL) { if(!list) list = entry; else play_tree_append_entry(last_entry,entry); last_entry = entry; } } if(!list) return NULL; entry = play_tree_new(); play_tree_set_child(entry,list); return entry; }
static play_tree_t* parse_m3u(play_tree_parser_t* p) { char* line; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying extended m3u playlist...\n"); if (!(line = play_tree_parser_get_line(p))) return NULL; strstrip(line); if(strcasecmp(line,"#EXTM3U")) return NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected extended m3u playlist format\n"); play_tree_parser_stop_keeping(p); while((line = play_tree_parser_get_line(p)) != NULL) { strstrip(line); if(line[0] == '\0') continue; /* EXTM3U files contain such lines: * #EXTINF:<seconds>, <title> * followed by a line with the filename * for now we have no place to put that * so we just skip that extra-info ::atmos */ if(line[0] == '#') { #if 0 /* code functional */ if(strncasecmp(line,"#EXTINF:",8) == 0) { mp_msg(MSGT_PLAYTREE,MSGL_INFO,"[M3U] Duration: %dsec Title: %s\n", strtol(line+8,&line,10), line+2); } #endif continue; } entry = play_tree_new(); play_tree_add_file(entry,line); if(!list) list = entry; else play_tree_append_entry(last_entry,entry); last_entry = entry; } if(!list) return NULL; entry = play_tree_new(); play_tree_set_child(entry,list); return entry; }
static void asx_parse_ref(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { char *href; href = asx_get_attrib("HREF",attribs); if(href == NULL) { asx_warning_attrib_required(parser,"REF" ,"HREF" ); return; } play_tree_add_file(pt,href); mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding file %s to element entry\n",href); free(href); }
//Add a new file as a new entry void pt_add_file(play_tree_t** ppt, const char* filename) { play_tree_t *pt = *ppt, *entry = play_tree_new(); #ifdef MP_DEBUG assert(entry!=NULL); #endif play_tree_add_file(entry, filename); if (pt) play_tree_append_entry(pt, entry); else { pt=entry; *ppt=pt; } play_tree_set_params_from(entry,pt); }
int playtree_update(MPContext * mpctx) { int i, seek = 0, n = 0; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; need_update_playtree = 0; if(playlist->trackcount <= 0) return -1; if(!mpctx->playtree_iter || !mpctx->playtree) return -1; for(i = 0; i<(playlist->trackcount); i++) { if(!seek) n++; if(!stricmp(filename, playlist->tracks[i]->filename)) seek = 1; entry = play_tree_new(); play_tree_add_file(entry, playlist->tracks[i]->filename); if(list) play_tree_append_entry(last_entry,entry); else list = entry; last_entry = entry; } entry = play_tree_new(); play_tree_set_child(entry,list); if (entry) { // Go back to the starting point. while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) /* NOP */ ; play_tree_free_list(mpctx->playtree->child, 1); play_tree_set_child(mpctx->playtree, entry); pt_iter_goto_head(mpctx->playtree_iter); mpctx->eof = PT_NEXT_SRC; if(seek && n > 0) { play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter); if (play_tree_iter_step(i, n, 0) == PLAY_TREE_ITER_ENTRY) mpctx->eof = PT_NEXT_ENTRY; play_tree_iter_free(i); if (mpctx->eof == PT_NEXT_ENTRY) mpctx->play_tree_step = n; } } return 0; }
/* Reference Ini-Format: Each entry is assumed a reference */ static play_tree_t* parse_ref_ini(play_tree_parser_t* p) { char *line,*v; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying reference-ini playlist...\n"); if (!(line = play_tree_parser_get_line(p))) return NULL; strstrip(line); if(strcasecmp(line,"[Reference]")) return NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected reference-ini playlist format\n"); play_tree_parser_stop_keeping(p); line = play_tree_parser_get_line(p); if(!line) return NULL; while(line) { strstrip(line); if(strncasecmp(line,"Ref",3) == 0) { v = pls_entry_get_value(line+3); if(!v) mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); else { mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",v); entry = play_tree_new(); play_tree_add_file(entry,v); if(list) play_tree_append_entry(last_entry,entry); else list = entry; last_entry = entry; } } line = play_tree_parser_get_line(p); } if(!list) return NULL; entry = play_tree_new(); play_tree_set_child(entry,list); return entry; }
/** \ingroup ConfigParsers */ play_tree_t* m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv) { int i,j,start_title=-1,end_title=-1; char *opt,*splitpos=NULL; char entbuf[15]; int no_more_opts = 0; int opt_exit = 0; // flag indicating whether mplayer should exit without playing anything play_tree_t *last_parent, *last_entry = NULL, *root; #ifdef MP_DEBUG assert(config != NULL); assert(argv != NULL); assert(argc >= 1); #endif config->mode = M_COMMAND_LINE; mode = GLOBAL; #ifdef CONFIG_MACOSX_FINDER root=macosx_finder_args(config, argc, argv); if(root) return root; #endif last_parent = root = play_tree_new(); for (i = 1; i < argc; i++) { //next: opt = argv[i]; /* check for -- (no more options id.) except --help! */ if ((*opt == '-') && (*(opt+1) == '-') && (*(opt+2) == 0)) { no_more_opts = 1; if (i+1 >= argc) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGivenOnCommandLine); goto err_out; } continue; } if((opt[0] == '{') && (opt[1] == '\0')) { play_tree_t* entry = play_tree_new(); UNSET_GLOBAL; if(last_parent->flags & PLAY_TREE_RND) entry->flags |= PLAY_TREE_RND; if(last_entry == NULL) { play_tree_set_child(last_parent,entry); } else { play_tree_append_entry(last_entry,entry); last_entry = NULL; } last_parent = entry; continue; } if((opt[0] == '}') && (opt[1] == '\0')) { if( ! last_parent || ! last_parent->parent) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "too much }-\n"); goto err_out; } last_entry = last_parent; last_parent = last_entry->parent; continue; } if ((no_more_opts == 0) && (*opt == '-') && (*(opt+1) != 0)) /* option */ { int tmp = 0; /* remove trailing '-' */ opt++; mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt); // We handle here some specific option // Loop option when it apply to a group if(strcasecmp(opt,"loop") == 0 && (! last_entry || last_entry->child) ) { int l; char* end = NULL; l = (i+1<argc) ? strtol(argv[i+1],&end,0) : 0; if(!end || *end != '\0') { mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_TheLoopOptionMustBeAnInteger, argv[i+1]); tmp = ERR_OUT_OF_RANGE; } else { play_tree_t* pt = last_entry ? last_entry : last_parent; l = l <= 0 ? -1 : l; pt->loop = l; tmp = 1; } } else if(strcasecmp(opt,"shuffle") == 0) { if(last_entry && last_entry->child) last_entry->flags |= PLAY_TREE_RND; else last_parent->flags |= PLAY_TREE_RND; } else if(strcasecmp(opt,"noshuffle") == 0) { if(last_entry && last_entry->child) last_entry->flags &= ~PLAY_TREE_RND; else last_parent->flags &= ~PLAY_TREE_RND; } else { const m_option_t* mp_opt = NULL; play_tree_t* entry = NULL; tmp = is_entry_option(opt,(i+1<argc) ? argv[i + 1] : NULL,&entry); if(tmp > 0) { // It's an entry if(entry) { add_entry(&last_parent,&last_entry,entry); if((last_parent->flags & PLAY_TREE_RND) && entry->child) entry->flags |= PLAY_TREE_RND; UNSET_GLOBAL; } else if(mode == LOCAL) // Entry is empty we have to drop his params mode = DROP_LOCAL; } else if(tmp == 0) { // 'normal' options mp_opt = m_config_get_option(config,opt); if (mp_opt != NULL) { // Option exist if(mode == GLOBAL || (mp_opt->flags & M_OPT_GLOBAL)) tmp = (i+1<argc) ? m_config_set_option(config, opt, argv[i + 1]) : m_config_set_option(config, opt, NULL); else { tmp = m_config_check_option(config, opt, (i+1<argc) ? argv[i + 1] : NULL); if(tmp >= 0 && mode != DROP_LOCAL) { play_tree_t* pt = last_entry ? last_entry : last_parent; play_tree_set_param(pt,opt, argv[i + 1]); } } } else { tmp = M_OPT_UNKNOWN; mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_UnknownOptionOnCommandLine, opt); } } } if (tmp <= M_OPT_EXIT) { opt_exit = 1; tmp = M_OPT_EXIT - tmp; } else if (tmp < 0) { mp_msg(MSGT_CFGPARSER, MSGL_FATAL, MSGTR_ErrorParsingOptionOnCommandLine, opt); goto err_out; } i += tmp; } else /* filename */ { int is_dvdnav = strstr(argv[i],"dvdnav://") != NULL; play_tree_t* entry = play_tree_new(); mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Adding file %s\n",argv[i]); // if required expand DVD filename entries like dvd://1-3 into component titles if ( strstr(argv[i],"dvd://") != NULL || is_dvdnav) { int offset = is_dvdnav ? 9 : 6; splitpos=strstr(argv[i]+offset,"-"); if(splitpos != NULL) { start_title=strtol(argv[i]+offset,NULL,10); if (start_title<0) { //entries like dvd://-2 start title implied 1 end_title=abs(start_title); start_title=1; } else { end_title=strtol(splitpos+1,NULL,10); } if (dvd_range(start_title) && dvd_range(end_title) && (start_title<end_title)) { for (j=start_title;j<=end_title;j++) { if (j!=start_title) entry=play_tree_new(); snprintf(entbuf,sizeof(entbuf),is_dvdnav ? "dvdnav://%d" : "dvd://%d",j); play_tree_add_file(entry,entbuf); add_entry(&last_parent,&last_entry,entry); last_entry = entry; } } else { mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_InvalidPlayEntry, argv[i]); } } else { // dvd:// or dvd://x entry play_tree_add_file(entry,argv[i]); } } else { play_tree_add_file(entry,argv[i]); } // Lock stdin if it will be used as input if(strcasecmp(argv[i],"-") == 0) m_config_set_option(config,"noconsolecontrols",NULL); add_entry(&last_parent,&last_entry,entry); UNSET_GLOBAL; // We start entry specific options } } if (opt_exit) goto err_out; if(last_parent != root) mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Missing }- ?\n"); return root; err_out: play_tree_free(root,1); return NULL; }
static play_tree_t* parse_smil(play_tree_parser_t* p) { int entrymode=0; char* line,source[512],*pos,*s_start,*s_end,*src_line; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; int is_rmsmil = 0; unsigned int npkt, ttlpkt; mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying smil playlist...\n"); // Check if smil while((line = play_tree_parser_get_line(p)) != NULL) { strstrip(line); if(line[0] == '\0') // Ignore empties continue; if (strncasecmp(line,"<?xml",5)==0) // smil in xml continue; if (strncasecmp(line,"<!DOCTYPE smil",13)==0) // smil in xml continue; if (strncasecmp(line,"<smil",5)==0 || strncasecmp(line,"<?wpl",5)==0 || strncasecmp(line,"(smil-document",14)==0) break; // smil header found else return NULL; //line not smil exit } if (!line) return NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected smil playlist format\n"); play_tree_parser_stop_keeping(p); if (strncasecmp(line,"(smil-document",14)==0) { mp_msg(MSGT_PLAYTREE,MSGL_V,"Special smil-over-realrtsp playlist header\n"); is_rmsmil = 1; if (sscanf(line, "(smil-document (ver 1.0)(npkt %u)(ttlpkt %u", &npkt, &ttlpkt) != 2) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: header parsing failure, assuming single packet.\n"); npkt = ttlpkt = 1; } if (ttlpkt == 0 || npkt > ttlpkt) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: bad packet counters (npkk = %u, ttlpkt = %u), assuming single packet.\n", npkt, ttlpkt); npkt = ttlpkt = 1; } } //Get entries from smil src_line = line; line = NULL; do { strstrip(src_line); if (line) { free(line); line = NULL; } /* If we're parsing smil over realrtsp and this is not the last packet and * this is the last line in the packet (terminating with ") ) we must get * the next line, strip the header, and concatenate it to the current line. */ if (is_rmsmil && npkt != ttlpkt && strstr(src_line,"\")")) { char *payload; line = strdup(src_line); if(!(src_line = play_tree_parser_get_line(p))) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: can't get line from packet %u/%u.\n", npkt, ttlpkt); break; } strstrip(src_line); // Skip header, packet starts after " if(!(payload = strchr(src_line,'\"'))) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: can't find start of packet, using complete line.\n"); payload = src_line; } else payload++; // Skip ") at the end of the last line from the current packet line[strlen(line)-2] = 0; line = realloc(line, strlen(line)+strlen(payload)+1); strcat (line, payload); npkt++; } else line = strdup(src_line); /* Unescape \" to " for smil-over-rtsp */ if (is_rmsmil && line[0] != '\0') { int i, j; for (i = 0; i < strlen(line); i++) if (line[i] == '\\' && line[i+1] == '"') for (j = i; line[j]; j++) line[j] = line[j+1]; } pos = line; while (pos) { if (!entrymode) { // all entries filled so far while ((pos=strchr(pos, '<'))) { if (strncasecmp(pos,"<video",6)==0 || strncasecmp(pos,"<audio",6)==0 || strncasecmp(pos,"<media",6)==0) { entrymode=1; break; // Got a valid tag, exit '<' search loop } pos++; } } if (entrymode) { //Entry found but not yet filled pos = strstr(pos,"src="); // Is source present on this line if (pos != NULL) { entrymode=0; if (pos[4] != '"' && pos[4] != '\'') { mp_msg(MSGT_PLAYTREE,MSGL_V,"Unknown delimiter %c in source line %s\n", pos[4], line); break; } s_start=pos+5; s_end=strchr(s_start,pos[4]); if (s_end == NULL) { mp_msg(MSGT_PLAYTREE,MSGL_V,"Error parsing this source line %s\n",line); break; } if (s_end-s_start> 511) { mp_msg(MSGT_PLAYTREE,MSGL_V,"Cannot store such a large source %s\n",line); break; } strncpy(source,s_start,s_end-s_start); source[(s_end-s_start)]='\0'; // Null terminate entry = play_tree_new(); play_tree_add_file(entry,source); if(!list) //Insert new entry list = entry; else play_tree_append_entry(last_entry,entry); last_entry = entry; pos = s_end; } } } } while((src_line = play_tree_parser_get_line(p)) != NULL); if (line) free(line); if(!list) return NULL; // Nothing found entry = play_tree_new(); play_tree_set_child(entry,list); return entry; }
static play_tree_t* parse_pls(play_tree_parser_t* p) { char *line,*v; pls_entry_t* entries = NULL; int n_entries = 0,max_entry=0,num; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying Winamp playlist...\n"); while((line = play_tree_parser_get_line(p))) { strstrip(line); if(strlen(line)) break; } if (!line) return NULL; if(strcasecmp(line,"[playlist]")) return NULL; mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected Winamp playlist format\n"); play_tree_parser_stop_keeping(p); line = play_tree_parser_get_line(p); if(!line) return NULL; strstrip(line); if(strncasecmp(line,"NumberOfEntries",15) == 0) { v = pls_entry_get_value(line); n_entries = atoi(v); if(n_entries < 0) mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Invalid number of entries: very funny!!!\n"); else mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Playlist claims to have %d entries. Let's see.\n",n_entries); line = play_tree_parser_get_line(p); } while(line) { strstrip(line); if(line[0] == '\0') { line = play_tree_parser_get_line(p); continue; } if(strncasecmp(line,"File",4) == 0) { num = pls_read_entry(line+4,&entries,&max_entry,&v); if(num < 0) mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); else entries[num-1].file = strdup(v); } else if(strncasecmp(line,"Title",5) == 0) { num = pls_read_entry(line+5,&entries,&max_entry,&v); if(num < 0) mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); else entries[num-1].title = strdup(v); } else if(strncasecmp(line,"Length",6) == 0) { num = pls_read_entry(line+6,&entries,&max_entry,&v); if(num < 0) mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); else entries[num-1].length = strdup(v); } else mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Unknown entry type %s\n",line); line = play_tree_parser_get_line(p); } for(num = 0; num < max_entry ; num++) { if(entries[num].file == NULL) mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Entry %d don't have a file !!!!\n",num+1); else { mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",entries[num].file); entry = play_tree_new(); play_tree_add_file(entry,entries[num].file); free(entries[num].file); if(list) play_tree_append_entry(last_entry,entry); else list = entry; last_entry = entry; } if(entries[num].title) { // When we have info in playtree we add this info free(entries[num].title); } if(entries[num].length) { // When we have info in playtree we add this info free(entries[num].length); } } free(entries); entry = play_tree_new(); play_tree_set_child(entry,list); return entry; }
static pascal OSErr AppleEventHandlerProc(const AppleEvent *theAppleEvent, AppleEvent* reply, SInt32 handlerRefcon) { OSErr err=errAEEventNotHandled, res=noErr; AEDescList docList; long itemsInList; AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, NULL, FALSE); if((res=AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList))==noErr) { if((res=AECountItems(&docList, &itemsInList))==noErr) { Size currentSize=0; int valid=0,i; char *parm=NULL; play_tree_t *last_entry=NULL; files=play_tree_new(); for(i=1;i<=itemsInList;++i) { for(;;) { OSErr e; Size actualSize=0; AEKeyword keywd; DescType returnedType; if((e=AEGetNthPtr(&docList, i, typeFileURL, &keywd, &returnedType, (Ptr)parm, currentSize, &actualSize))==noErr) { if(actualSize>=currentSize) { currentSize=actualSize+1; parm=realloc(parm, currentSize); } else { parm[actualSize]=0; valid=1; break; } } else { valid=0; break; } } if(valid) { URL_t *url=url_new(parm); if(url && !strcmp(url->protocol,"file") && !strcmp(url->hostname,"localhost")) { play_tree_t *entry=play_tree_new(); url_unescape_string(url->file, url->file); play_tree_add_file(entry, url->file); add_entry(&files, &last_entry, entry); } url_free(url); } } if(parm) free(parm); err=noErr; } else mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AECountItems() error %d\n", res); AEDisposeDesc(&docList); } else mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AEGetParamDesc() error %d\n", res); QuitApplicationEventLoop(); return err; }
int playtree_update_play(MPContext * mpctx, int index) { int i; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; need_update_playtree = 0; if(playlist->trackcount <= 0) return -1; for(i = 0; i<(playlist->trackcount); i++) { entry = play_tree_new(); play_tree_add_file(entry, playlist->tracks[i]->filename); if(list) play_tree_append_entry(last_entry,entry); else list = entry; last_entry = entry; } entry = play_tree_new(); play_tree_set_child(entry,list); if (entry) { if(!mpctx->playtree_iter || !mpctx->playtree) { if (mpctx->playtree) // the playtree is always a node with one child. let's clear it play_tree_free_list(mpctx->playtree->child, 1); else mpctx->playtree=play_tree_new(); // .. or make a brand new playtree if (!mpctx->playtree) return -1; // couldn't make playtree! play_tree_set_child(mpctx->playtree, entry); /* Make iterator start at the top the of tree. */ mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree, mconfig); if (!mpctx->playtree_iter) return; // find the first real item in the tree if (play_tree_iter_step(mpctx->playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) { // no items! play_tree_iter_free(mpctx->playtree_iter); mpctx->playtree_iter = NULL; } else { mpctx->eof = PT_NEXT_ENTRY; if(index > 0 && index < playlist->trackcount) { mpctx->play_tree_step = index; play_tree_iter_step(mpctx->playtree_iter,mpctx->play_tree_step,0); } filename = play_tree_iter_get_file(mpctx->playtree_iter, mpctx->eof); mp_input_queue_cmd(mp_input_parse_cmd("stop")); } } else { // Go back to the starting point. while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) /* NOP */ ; play_tree_free_list(mpctx->playtree->child, 1); play_tree_set_child(mpctx->playtree, entry); pt_iter_goto_head(mpctx->playtree_iter); mpctx->eof = PT_NEXT_SRC; loop_break = 1; if(index > 0 && index < playlist->trackcount) { play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter); if (play_tree_iter_step(i, index, 0) == PLAY_TREE_ITER_ENTRY) mpctx->eof = PT_NEXT_ENTRY; play_tree_iter_free(i); if (mpctx->eof == PT_NEXT_ENTRY) mpctx->play_tree_step = index; } } } return 0; }