1 |
douglas |
542 |
// Player |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#ifndef _Player_hpp_ |
8 |
|
|
#define _Player_hpp_ |
9 |
|
|
|
10 |
|
|
#include <menes/platform.hpp> |
11 |
|
|
|
12 |
|
|
#ifdef MENES_PRAGMA_ONCE |
13 |
|
|
#pragma once |
14 |
|
|
#endif |
15 |
|
|
|
16 |
|
|
#include <menes-api/process.hpp> |
17 |
|
|
#include <menes-api/threads.hpp> |
18 |
|
|
#include <menes-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 |
|
|
mta::ReaderWriterLock playlistLock; |
33 |
|
|
_L<MediaFile> playlist; |
34 |
douglas |
544 |
mutable api::ThreadMutex queueLock; |
35 |
|
|
mutable std::queue<api::Path> queue; |
36 |
|
|
mutable mta::ReaderWriterLock sharesLock; |
37 |
douglas |
542 |
ext::RedBlackMap<api::InternetAddress, ext::RedBlackMap<cse::String, _R<Share> > > shares; |
38 |
|
|
bool running; |
39 |
|
|
_S<api::Thread> adder, copier; |
40 |
|
|
int Adder(); |
41 |
douglas |
544 |
int Copier() const; |
42 |
douglas |
542 |
public: |
43 |
|
|
Player(const _R<dbi::Connection>& connection, int player); |
44 |
|
|
~Player(); |
45 |
douglas |
544 |
const _L<MediaFile>& GetPlaylist() const { return playlist; }; |
46 |
douglas |
542 |
void Add(const _R<Share>& share); |
47 |
|
|
}; |
48 |
|
|
|
49 |
|
|
#endif//_Player_hpp_ |