Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int changeFile(const char* ep_file, struct playbackInfo_t* playbackInfo)
/* If file is NULL, then only thread termination was requested. */
if(ep_file == NULL || playbackInfo == NULL)
return 0;

//playbackInfo->file = strdup(ep_file);
if (memccpy(playbackInfo->file, ep_file, '\0', sizeof(playbackInfo->file)) == NULL)
{
Expand Down Expand Up @@ -265,7 +265,7 @@ static int listDir(int from, int max, int select, struct dirList_t dirList)
*
* \return Number of files in current working folder, -1 on failure with
* errno set.
*/
*/
int getNumberFiles(void)
{
DIR *dp;
Expand Down Expand Up @@ -294,6 +294,7 @@ int main(int argc, char **argv)
int fileMax;
int fileNum = 0;
int from = 0;
bool shufflemode = false;
Thread watchdogThread;
Handle playbackFailEvent;
struct watchdogInfo watchdogInfoIn;
Expand Down Expand Up @@ -418,6 +419,16 @@ int main(int argc, char **argv)
keyLComboPressed = true;
continue;
}

if(kDown & KEY_RIGHT)
{
shufflemode = !shufflemode;
if (shufflemode) {
puts("Shuffle mode is on.");
} else {
puts("Shuffle mode is off.");
}
}
}
// if R is pressed first
if ((kHeld & KEY_R) && (kDown & KEY_L))
Expand Down Expand Up @@ -637,7 +648,16 @@ int main(int argc, char **argv)
error = 0;
continue;
}
fileNum += 1;
if (shufflemode) {
fileNum = rand() % fileMax;

if (fileNum >= fileMax || dirList.dirNum >= fileNum) {
error = 0;
continue;
}
} else {
fileNum += 1;
}
consoleSelect(&topScreenInfo);
consoleClear();
consoleSelect(&topScreenLog);
Expand All @@ -664,9 +684,9 @@ int main(int argc, char **argv)
unsigned hr, min, sec;
size_t seconds_played;

seconds_played = playbackInfo.samples_played / playbackInfo.samples_per_second;
seconds_played = playbackInfo.samples_played / playbackInfo.samples_per_second;

hr = (seconds_played/3600);
hr = (seconds_played/3600);
min = (seconds_played - (3600*hr))/60;
sec = (seconds_played -(3600*hr)-(min*60));

Expand All @@ -678,9 +698,9 @@ int main(int argc, char **argv)
unsigned hr, min, sec;
size_t seconds_total;

seconds_total = playbackInfo.samples_total / playbackInfo.samples_per_second;
seconds_total = playbackInfo.samples_total / playbackInfo.samples_per_second;

hr = (seconds_total/3600);
hr = (seconds_total/3600);
min = (seconds_total - (3600*hr))/60;
sec = (seconds_total -(3600*hr)-(min*60));

Expand Down