7 |
|
#include <menes/standard.hh> |
8 |
|
|
9 |
|
#include <menes-api/pcre/regex.hpp> |
10 |
+ |
#include <menes-api/posix/signals.hpp> |
11 |
+ |
#include <menes-ext/stack.hpp> |
12 |
|
#include <menes-hop/bind.hpp> |
13 |
|
|
14 |
|
#include "Player.hpp" |
22 |
|
|
23 |
|
Player::Player(const _R<dbi::Connection>& connection, int player) : remote(player), player_(remote.IsRunning() ? NULL : new _H<api::Process>(_B("/usr/X11R6/bin/beep-media-player"))), position(remote.GetPlaylistPosition()), adder(hop::BindAll(&Player::Adder, this)), copier(hop::BindAll(&Player::Copier, this)) |
24 |
|
{ |
25 |
+ |
api::Posix::SetSignalHandler(SIGUSR2, hop::BindAll(&Player::Change, this)); |
26 |
+ |
|
27 |
|
if (!player_.IsEmpty()) |
28 |
|
{ |
29 |
|
player_->ClearReader(); |
115 |
|
|
116 |
|
_assert(match); |
117 |
|
|
118 |
+ |
{ |
119 |
+ |
api::Path parent(path); |
120 |
+ |
ext::Stack<api::Path> stack; |
121 |
+ |
|
122 |
+ |
while ((parent = parent.GetParent()) != Share::shares) |
123 |
+ |
stack.Push(parent); |
124 |
+ |
|
125 |
+ |
while (stack.Pop(parent)) |
126 |
+ |
if (!parent.Exists()) |
127 |
+ |
parent.CreateDirectory(); |
128 |
+ |
} |
129 |
+ |
|
130 |
|
ext::ScopeReadLock<mta::ReaderWriterLock> readLock(sharesLock); |
131 |
|
|
132 |
< |
const _R<Share>& share(shares[api::InternetAddress(match[1], 6996)][match[2]]); |
132 |
> |
const _R<Share>& share(shares[api::Address::Resolve(match[1], _B("6996")).First()][match[2]]); |
133 |
|
} |
134 |
|
} |
135 |
|
else _desynchronized (queueLock) |
137 |
|
|
138 |
|
return 0; |
139 |
|
} |
140 |
+ |
|
141 |
+ |
void Player::Change() |
142 |
+ |
{ |
143 |
+ |
position = remote.GetPlaylistPosition(); |
144 |
+ |
} |