playqueue: Add a function for resetting the current pointer

This is used for the recently played playqueue to iterate backwards when
the previous() function is called.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-04 10:54:02 -05:00 committed by Anna Schumaker
parent e889ca538f
commit 8e363fe7b2
4 changed files with 27 additions and 6 deletions

View File

@ -39,6 +39,7 @@ public:
unsigned int size();
unsigned int next();
void reset_cur();
};
#endif /* OCARINA_PLAYQUEUE_H */

View File

@ -111,3 +111,8 @@ unsigned int Playqueue :: next()
}
return res;
}
void Playqueue :: reset_cur()
{
cur = -1;
}

View File

@ -139,8 +139,11 @@ void test_3()
Playqueue pqueue(PQ_ENABLED);
pqueue.set_flag(PQ_REPEAT);
test_add_tracks("3a", pqueue, 0, 15);
for (unsigned int i = 0; i < 20; i++)
for (unsigned int i = 0; i < 25; i++) {
print("Selecting id: %u\n", pqueue.next());
if (i == 4)
pqueue.reset_cur();
}
test_pqueue_status("3b", pqueue);
print("\n");
}

View File

@ -5,13 +5,21 @@ Test 0d: SUCCESS
Test 0f: SUCCESS
Test 1a: SUCCESS
Test 1b: Plist size: 40
Test 1b: size: 40, length: 5648
Test 1c: SUCCESS
Test 1d: size: 30, length: 5284
Test 1e: SUCCESS
Test 1f: size: 35, length: 6015
Test 2a: SUCCESS
Test 2b: SUCCESS
Test 3: SUCCESS
Test 3a: SUCCESS
Selecting id: 0
Selecting id: 1
Selecting id: 2
Selecting id: 3
Selecting id: 4
Selecting id: 0
Selecting id: 1
Selecting id: 2
@ -32,8 +40,9 @@ Selecting id: 0
Selecting id: 1
Selecting id: 2
Selecting id: 3
Test 3b: size: 16, length: 2153
Test 4: SUCCESS
Test 4a: SUCCESS
Selecting id: 0
Selecting id: 1
Selecting id: 2
@ -50,8 +59,9 @@ Selecting id: 12
Selecting id: 13
Selecting id: 14
Selecting id: 15
Test 4b: size: 0, length: 0
Test 5: SUCCESS
Test 5a: SUCCESS
Selecting id: 6
Selecting id: 11
Selecting id: 13
@ -82,8 +92,9 @@ Selecting id: 0
Selecting id: 1
Selecting id: 7
Selecting id: 8
Test 5b: size: 16, length: 2153
Test 6: SUCCESS
Test 6a: SUCCESS
Selecting id: 1
Selecting id: 2
Selecting id: 4
@ -100,3 +111,4 @@ Selecting id: 6
Selecting id: 12
Selecting id: 14
Selecting id: 3
Test 6b: size: 0, length: 0