Fixed bug with order of queued tracks and prev-historied tracks
authorNikolay Tischenko <niktischenko@gmail.com>
Tue, 21 Sep 2010 08:31:46 +0000 (15:31 +0700)
committerNikolay Tischenko <niktischenko@gmail.com>
Tue, 21 Sep 2010 08:31:46 +0000 (15:31 +0700)
src/player/player.cpp
src/player/player.h

index 577a4dc..0f11f9d 100644 (file)
@@ -56,6 +56,8 @@ void Player::next() {
        _history.push(_current % count);
        if (!_queue.isEmpty()) {
                _current = _queue.dequeue();
        _history.push(_current % count);
        if (!_queue.isEmpty()) {
                _current = _queue.dequeue();
+       } else if (!_prev_history.isEmpty()) {
+               _current = _prev_history.pop();
        } else {
                if (_random) {
                        _current = (count + (qrand()  + qrand() + qrand()) % count) % count;
        } else {
                if (_random) {
                        _current = (count + (qrand()  + qrand() + qrand()) % count) % count;
@@ -82,7 +84,7 @@ void Player::_set_source() {
 
 void Player::prev() {
        if (_history.count() > 0) {
 
 void Player::prev() {
        if (_history.count() > 0) {
-               _queue.push_front(_current);
+               _prev_history.push(_current);
                _current = _history.pop();
                _track = _playlist.tracks().at(_current);
        }
                _current = _history.pop();
                _track = _playlist.tracks().at(_current);
        }
index e381838..a2fdbf7 100644 (file)
@@ -60,6 +60,7 @@ namespace SomePlayer {
                        bool _repeat;
                        QStack<int> _history;
                        QQueue<int> _queue;
                        bool _repeat;
                        QStack<int> _history;
                        QQueue<int> _queue;
+                       QStack<int> _prev_history;
                        Playlist _playlist;
                        Phonon::MediaObject *_player;
                        Phonon::AudioOutput *_output;
                        Playlist _playlist;
                        Phonon::MediaObject *_player;
                        Phonon::AudioOutput *_output;