aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/media.erl12
1 files changed, 5 insertions, 7 deletions
diff --git a/server/media.erl b/server/media.erl
index fbdaa7e..561a2c7 100644
--- a/server/media.erl
+++ b/server/media.erl
@@ -1,5 +1,5 @@
-module(media).
--export([init/0,insert/3, ask/2, all/0, play/3, vote/2, devote/2, lock_process/2]).
+-export([init/0,insert/3, ask/2, all/0, play/2, vote/2, devote/2, lock_process/2]).
-define(TESTPATTERN, "../ac/*.mp3").
-define(TIMEOUT, 100000000).
@@ -68,7 +68,7 @@ search_best([], _, Track) -> {Track#track.artist, Track#track.title}.
% if nothing is playable anymore just reset them and start playing again...
-reset_all([Head|Rest) ->
+reset_all([Head|Rest]) ->
unlock(Head#track.artist, Head#track.title),
reset_all(Rest);
reset_all([]) -> ok.
@@ -100,7 +100,7 @@ play(Artist, Title) ->
{_, Title, Artist, _, _, Fp} = Head,
Port = erlang:open_port({spawn_executable, "/usr/bin/mplayer"}, [{args, [Fp]}, exit_status]),
reset_votes(Artist, Title),
- lock_process(Artist, Title),
+ spawn(media, lock_process, [Artist, Title]),
io:format("playing: ~s, Artist: ~s~n", [Title, Artist]),
receive
@@ -143,8 +143,7 @@ reset_votes(Artist, Title) ->
lock(Artist, Title) ->
F = fun() ->
[Head|_] = ask(Artist, Title),
- Votes = Head#track.lock = true,
- New = Head#track{lock = Votes},
+ New = Head#track{locked = true},
mnesia:write(New)
end,
mnesia:transaction(F).
@@ -152,8 +151,7 @@ lock(Artist, Title) ->
unlock(Artist, Title) ->
F = fun() ->
[Head|_] = ask(Artist, Title),
- Votes = Head#track.lock = false,
- New = Head#track{lock = Votes},
+ New = Head#track{locked = false},
mnesia:write(New)
end,
mnesia:transaction(F).