diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-15 09:19:03 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-15 09:19:03 +0200 |
commit | 89accd8f916eea3dd9e3f873350a2b8ed0c51ec4 (patch) | |
tree | 56d3c7847154dcdeeaedeb57e1d345d98e2aaca0 | |
parent | 4b73af956cd4e4a307720f9aeaa0d8d3a7ce4b45 (diff) | |
download | erlang-89accd8f916eea3dd9e3f873350a2b8ed0c51ec4.tar.gz erlang-89accd8f916eea3dd9e3f873350a2b8ed0c51ec4.tar.xz erlang-89accd8f916eea3dd9e3f873350a2b8ed0c51ec4.zip |
removed trailing whitespaces
-rw-r--r-- | server/media.erl | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/server/media.erl b/server/media.erl index 14aa53e..8c60f10 100644 --- a/server/media.erl +++ b/server/media.erl @@ -3,8 +3,8 @@ -define(TESTPATTERN, "../ac/*.mp3"). -define(TIMEOUT, 100000000). -%This module is responsible for the management of the music database. -%It keeps track of playlist items with their current voting and locked/unlocked status +%This module is responsible for the management of the music database. +%It keeps track of playlist items with their current voting and locked/unlocked status %and automatically selects the next song with the highest vote count to play back. % Since we are not willing to calculate and deliver all the id3 tags everytime they are requested, @@ -29,8 +29,8 @@ init() -> io:format("Initialisation of mnesia successful.~n"), io:format("Starting to play music~n"), start_playing(). - -% uses the algorithm of Brendon Hogger to split the id3-tags and + +% uses the algorithm of Brendon Hogger to split the id3-tags and % inserts the songs into the Database read_files([FN|Rest],Total,Fail) -> @@ -61,12 +61,12 @@ insert(Artist, Title, Filepath) -> % Of course we need a query to find out whats actually the most wished for track. % We will do it by requesting all the records from the database and then iteramte over just taking a look at the vote -% variable, so it is like list of integers. In case no tracks were voted for we just take the first track we find and play it. +% variable, so it is like list of integers. In case no tracks were voted for we just take the first track we find and play it. % Of course it is locked afterwards so another will be choosen. -search_best([Head|Rest], Max_Votes, Track) -> - if +search_best([Head|Rest], Max_Votes, Track) -> + if ((Max_Votes =< Head#track.votes) and (Head#track.locked == false)) -> search_best(Rest, Head#track.votes, Head); true -> search_best(Rest, Max_Votes, Track) @@ -109,7 +109,7 @@ play(Artist, Title) -> Port = erlang:open_port({spawn_executable, "/usr/bin/mplayer"}, [{args, [Fp]}, exit_status]), reset_votes(Artist, Title), spawn(media, lock_process, [Artist, Title]), - + io:format("playing: ~s, Artist: ~s~n", [Title, Artist]), receive {Port, {exit_status, 0}} -> cldb:update_votes(), start_playing(); @@ -149,7 +149,7 @@ reset_votes(Artist, Title) -> mnesia:write(New) end, mnesia:transaction(F). - + %locks a song so it can't be played again or voted for for that time. lock(Artist, Title) -> F = fun() -> @@ -172,10 +172,10 @@ unlock(Artist, Title) -> % If all songs are locked, all will be unlocked. lock_process(Artist, Title) -> lock(Artist, Title), - receive + receive after ?TIMEOUT -> unlock(Artist, Title) end. - + |