when pressing "next" key multiples times, first song is selected

Hi,
When I want to go several songs forward, I usually hit the next key (n) several times very quickly. After a few hits (between, 3 and 10), cursor stops going forward, but instead, it goes back to first song of the playlist :(

So, I investigated, and I think I known where the problem comes from:

When you press "next" while a song is playing, you go in function cmd_next (interface.c); curr_file.state is checked. As a song is playing right now, curr_file.state is not STATE_STOP. So you go out from decode_loop, you go back in play_thread (audio.c), you arrive at the end of the big while loop, you execute update_state, and therefore, curr_file.state is set to STATE_STOP.

Then, the big while loop loops one more time, you call player, then play_file, and just before you call decode_loop, curr_file.state is set to STATE_PLAY again (in audio_state_started_playing function)

My problem arises when I press next key after update_state, but before audio_state_started_playing. A new song is being loaded, and status is STATE_STOP. So, in function cmd_next, the second branch of the if test is triggered, and first song is selected again.

I tried to move the call to audio_state_started_playing at the beginning of play_file, and the problem seemed to have dispappeared. But it was just to test if problem really came from that race solution, may be it is not a solution. I did not investigate more, but I guess play_file function loads files from cache or from disk. As only one file is cached, it will have to get songs from disk if I hit "next" several times in a row. So, race condition I described is very likely to occur.

Unfortunately, I'm not good developer enough to correct that, and to submit a patch, but I hope this will help.

And also, thanks for mocp, it's a really nice music player :)

Thanks. Can't get it right now, but I will have more time on weekend. :)
--
Damian Pietras - MOC developer

I've fxed that, the patch is here.

A race with precaching was fixed some time ago, but is not yet included

--
Damian Pietras - MOC developer

I've tried the patch, and it works fine, thanks