ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/Player.cpp
(Generate patch)

Comparing DecentralizedMedia/Player.cpp (file contents):
Revision 542 by douglas, 2005-07-03T00:31:07-07:00 vs.
Revision 547 by douglas, 2005-07-04T02:47:18-07:00

# Line 7 | Line 7
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 <signal.h>
15 +
16   #include "Player.hpp"
17  
18   inline void Sleep()
# Line 18 | Line 22 | inline void Sleep()
22          ::nanosleep(&sleep, NULL);
23   }
24  
25 < 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"))), adder(hop::BindAll(&Player::Adder, this)), copier(hop::BindAll(&Player::Copier, this, shares))
25 > 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))
26   {
27 +        api::Posix::SetSignalHandler(SIGUSR2, hop::BindAll(&Player::Change, this));
28 +
29          if (!player_.IsEmpty())
30          {
31                  player_->ClearReader();
# Line 89 | Line 95 | int Player::Adder()
95          return 0;
96   }
97  
98 < int Player::Copier(const ext::RedBlackMap<api::InternetAddress, ext::RedBlackMap<cse::String, _R<Share> > >& shares)
98 > int Player::Copier() const
99   {
100          while (!running)
101                  Sleep();
# Line 111 | Line 117 | int Player::Copier(const ext::RedBlackMa
117  
118                                  _assert(match);
119  
120 +                                {
121 +                                        api::Path parent(path);
122 +                                        ext::Stack<api::Path> stack;
123 +
124 +                                        while ((parent = parent.GetParent()) != Share::shares)
125 +                                                stack.Push(parent);
126 +
127 +                                        while (stack.Pop(parent))
128 +                                                if (!parent.Exists())
129 +                                                        parent.CreateDirectory();
130 +                                }
131 +
132                                  ext::ScopeReadLock<mta::ReaderWriterLock> readLock(sharesLock);
133  
134 <                                const _R<Share>& share(shares[api::InternetAddress(match[1], 6996)][match[2]]);
134 >                                const _R<Share>& share(shares[api::Address::Resolve(match[1], _B("6996")).First()][match[2]]);
135                          }
136                  }
137                  else _desynchronized (queueLock)
# Line 121 | Line 139 | int Player::Copier(const ext::RedBlackMa
139  
140          return 0;
141   }
142 +
143 + void Player::Change()
144 + {
145 +        position = remote.GetPlaylistPosition();
146 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines