1 |
// Player |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#ifndef _Player_hpp_ |
8 |
#define _Player_hpp_ |
9 |
|
10 |
#include <cxx/platform.hpp> |
11 |
|
12 |
#ifdef MENES_PRAGMA_ONCE |
13 |
#pragma once |
14 |
#endif |
15 |
|
16 |
#include <api/process.hpp> |
17 |
#include <api/threads.hpp> |
18 |
#include <mta/locks.hpp> |
19 |
|
20 |
#include <queue> |
21 |
|
22 |
#include "BeepRemote.hpp" |
23 |
#include "MediaFile.hpp" |
24 |
#include "Share.hpp" |
25 |
|
26 |
class Player |
27 |
{ |
28 |
private: |
29 |
enum State { STOPPED, PLAYING, PAUSED } state; |
30 |
BeepRemote remote; |
31 |
_R<api::Process> player_; |
32 |
int position; |
33 |
mta::ReaderWriterLock playlistLock; |
34 |
_L<MediaFile> playlist; |
35 |
mutable api::ThreadMutex queueLock; |
36 |
mutable std::queue<api::Path> queue; |
37 |
mutable mta::ReaderWriterLock sharesLock; |
38 |
ext::RedBlackMap<api::Address, ext::RedBlackMap<cse::String, _R<Share> > > shares; |
39 |
bool running; |
40 |
_S<api::Thread> adder, copier; |
41 |
int Adder(); |
42 |
int Copier() const; |
43 |
void Change(); |
44 |
public: |
45 |
Player(const _R<Connector>& connector, int player); |
46 |
~Player(); |
47 |
_finline int GetPosition() const { return position; } |
48 |
_finline const _L<MediaFile>& GetPlaylist() const { return playlist; }; |
49 |
void Add(const _R<Share>& share); |
50 |
}; |
51 |
|
52 |
#endif//_Player_hpp_ |