diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-14 14:42:13 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-14 14:42:13 +0200 |
commit | 6f2124d3e49257ef0d275b83e7c2b4f84f1a3bde (patch) | |
tree | ce49a706a6a50a1e4fcdd191cef0e51a2af35b8c /server | |
parent | 8b8794d0db80e0d79e38c28146ca0d3d60764839 (diff) | |
parent | 9ab54bfaed55119fc24275136c249936e81939f8 (diff) | |
download | erlang-6f2124d3e49257ef0d275b83e7c2b4f84f1a3bde.tar.gz erlang-6f2124d3e49257ef0d275b83e7c2b4f84f1a3bde.tar.xz erlang-6f2124d3e49257ef0d275b83e7c2b4f84f1a3bde.zip |
Merge branch 'master' of ssh://git.animux.de/erlang
Diffstat (limited to 'server')
-rw-r--r-- | server/media.erl | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/server/media.erl b/server/media.erl index d20c8e9..755d965 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]). +-export([init/0,insert/3, ask/2, all/0, play/3, vote/2, devote/2, lock_process/2]). -define(TESTPATTERN, "../ac/*.mp3"). -define(TIMEOUT, 10000). @@ -91,14 +91,7 @@ play(Artist, Title, Callback) -> [Head|_] = ask(Artist, Title), {_, Title, Artist, _, _, Fp} = Head, Port = erlang:open_port({spawn_executable, "/usr/bin/mplayer"}, [{args, [Fp]}, exit_status]), - - % lock the song - F = fun() -> - New = Head#track{locked = 1}, - mnesia:write(New) - end, - mnesia:transaction(F), - + spawn(media, lock_process,[Artist,Title]), io:format("playing: ~s, Artist: ~s~n", [Title, Artist]), receive {Port, {exit_status, 0}} -> start_playing(); @@ -146,7 +139,7 @@ unlock(Artist, Title) -> end, mnesia:transaction(F). -lock_prozess(Artist, Title) -> +lock_process(Artist, Title) -> lock(Artist, Title), receive |