diff options
author | Michael Wittig <michael.wittig@fu-berlin.de> | 2010-10-14 15:48:48 +0200 |
---|---|---|
committer | Michael Wittig <michael.wittig@fu-berlin.de> | 2010-10-14 15:48:48 +0200 |
commit | e25c2d52d30bc1c0c68612ff48a2cd889631f937 (patch) | |
tree | c7999788de3850a6fbe25dbb40b33c5aa5485efa /server | |
parent | 6054521e117539d2a5d16f08a6b107e13c9dc370 (diff) | |
download | erlang-e25c2d52d30bc1c0c68612ff48a2cd889631f937.tar.gz erlang-e25c2d52d30bc1c0c68612ff48a2cd889631f937.tar.xz erlang-e25c2d52d30bc1c0c68612ff48a2cd889631f937.zip |
maaaaaan fertig werden
Diffstat (limited to 'server')
-rw-r--r-- | server/media.erl | 12 |
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). |