static inline int common_proc_get_radio(char *page, char **start, off_t offset, int count, int *eof, void *data) { int len = snprintf(page, count, DRV_DESCRIPTION ", v" DRV_VERSION "\n" " auto-off is %s, auto-load is %s\n", ONOFF(autooff), ONOFF(autoload)); len += snprintf(page+len, count-len, " radio state is %s\n", RADIO_ONOFF(rfkill_get_radio())); *eof = 1; return len; }
/** * adds a new title to the current playlist * * Core functionality of the mixplay architecture: * - does not play the same artist twice in a row * - prefers titles with lower playcount * * returns the head of the (new/current) playlist */ mpplaylist *addNewTitle( mpplaylist *pl, mptitle *root ) { mptitle *runner=NULL; mptitle *guard=NULL; unsigned long num=0; char *lastpat; unsigned int pcount=getConfig()->playcount; unsigned int cycles=0; int valid=0; /* 0 - nothing checked 1 - namecheck okay 2 - playcount okay 3 - all okay -1 - stuffing */ if( pl != NULL ) { while( pl->next != NULL ) { pl=pl->next; } runner=pl->title; lastpat=pl->title->artist ; } else { valid=1; runner=root; } /* select a random title from the database */ /* skip forward until a title is found that is neither DNP nor MARK */ num = countTitles( MP_ALL, MP_DNP|MP_MARK|MP_CNTD ); runner=skipTitles( runner, rand()%num ); if( runner==NULL ) { if( pl == NULL ) { addMessage( 0, "No titles in database and no playlist to add them to.." ); return NULL; } runner=pl->title; addMessage( 0, "Next round!" ); newCount( ); /* Try again */ num = countTitles( MP_ALL, MP_DNP|MP_MARK|MP_CNTD ); runner=skipTitles( runner, rand()%num ); if( runner == NULL ) { addMessage( 0, "No more titles in the database!?" ); return NULL; } } cycles=0; while( ( valid & 3 ) != 3 ) { if( lastpat == NULL ) valid |=1; /* title did not pass namecheck */ if( ( valid & 1 ) != 1 ) { guard=runner; while( checkSim( runner->artist, lastpat ) ) { addMessage( 3, "%s = %s", runner->artist, lastpat ); activity( "Nameskipping" ); runner=skipOver( runner->next, 1 ); /* hopefully this will not happen */ if( (runner == guard ) || ( runner == NULL ) ) { addMessage( 0, "Only %s left..", lastpat ); newCount( ); return( addNewTitle( pl, root ) ); } } addMessage( 3, "%s != %s", runner->artist, lastpat ); if( guard != runner ) { valid=1; /* we skipped and need to check playcount */ } else { valid |= 1; /* we did not skip, so if playcount was fine it's still fine */ } } guard=runner; /* title did not pass playcountcheck and we are not in stuffing mode */ while( (valid & 2 ) != 2 ) { if( runner->flags & MP_FAV ) { if ( runner-> playcount <= 2*pcount ) { valid|=2; } } else { if ( runner->playcount <= pcount ) { valid|=2; } } if( ( valid & 2 ) != 2 ) { activity( "Playcountskipping" ); /* simply pick a new title at random to avoid edge cases */ runner=skipTitles( runner, rand()%num ); valid=0; if( (runner == NULL ) || ( guard == runner ) ) { pcount++; /* allow more replays */ getConfig()->playcount=pcount; addMessage( 1, "Increasing maxplaycount to %li", pcount ); runner=guard; } } } if( ++cycles > 10 ) { addMessage( 1, "Looks like we ran into a loop" ); cycles=0; pcount++; /* allow replays */ getConfig()->playcount=pcount; addMessage( 1, "Increasing maxplaycount to %li", pcount ); } } /* while( valid != 3 ) */ addMessage( 3, "[+] (%i/%li/%3s) %s", runner->playcount, pcount, ONOFF( runner->flags&MP_FAV ), runner->display ); /* count again in case this is a favourite */ if( runner->flags & MP_FAV ) { runner->flags &= ~MP_CNTD; } addMessage(2,"Added %2d %5d - %s", runner->playcount, runner->key, runner->display ); return appendToPL( runner, pl, -1 ); }