ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/soundplay_includes/Playlist.h
Revision: 1.1
Committed: 2001-01-14T13:17:35Z (23 years, 8 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
now also works as a SoundPlay plugin under BeOS

File Contents

# Content
1
2
3 #ifndef _PLAYLIST_H
4 #define _PLAYLIST_H
5
6 #include <List.h>
7 #include <Entry.h>
8 #include <SupportKit.h>
9 #include <Message.h>
10
11
12 // messages that you receive when watching a playlist
13 enum {
14 PLAYLIST_ADD = 'pl\0\1', // something was added to the playlist
15 PLAYLIST_REMOVE = 'pl\0\2', // something was removed from the playlist
16 PLAYLIST_EMPTY = 'pl\0\3', // playlist was emptied
17 PLAYLIST_DESTROYED = 'pl\0\4', // playlist no longer exists. Note that you can only
18 // receive this if a playlist goes away for which you
19 // registered as a listener, but didn't keep a PlaylistPtr
20 // for. Needless to say, this is a Bad Thing.
21 PLAYLIST_LOST_CONTROLS = 'pl\0\5', // playlist lost its set of controls
22 PLAYLIST_GAINED_CONTROLS = 'pl\0\6', // playlist gained a set of controls
23 PLAYLIST_CURRENT = 'pl\0\7', // the "current item" changed
24 PLAYLIST_SORTED = 'pl\1\0', // the playlist just got sorted. You'll want to rescan it now
25 PLAYLIST_ITEM_RENAMED = 'pl\1\1' // an item in the playlist got renamed
26 };
27
28
29 class _PlayListEntry;
30 class AudioFile;
31 struct file_info;
32
33
34 // Never EVER use this class directly!!!
35 // ALWAYS go through the PlaylistPtr class defined below.
36 class PrivatePlaylist
37 {
38 public:
39 status_t RestoreFromMessage(const BMessage *mes, int32 index=0);
40 void SaveToMessage(BMessage &mes) const;
41
42 void MakeEmpty();
43 int32 CountItems() const;
44 int32 Add(const entry_ref &ref, int32 index= -1);
45 int32 Add(const char *path, int32 index= -1);
46 status_t AddDir(const entry_ref &ref, int32 index=-1);
47 status_t AddDir(const char *path, int32 index=-1);
48 status_t InsertRefsFromMessage(BMessage *message, char *refname, int32 index);
49 status_t AddRefsFromMessage(BMessage *message, char *refname);
50 status_t SetName(int32 ID, const char *name);
51
52 int32 IDForItemAt(int32 index) const;
53 const char* PathForItem(int32 ID) const;
54 const char* NameForItem(int32 ID) const;
55 status_t Remove(int32 ID);
56
57 const char* CurrentPath() const;
58 const char* CurrentName() const;
59
60 status_t Shuffle();
61 status_t Sort();
62 status_t SortByPath();
63
64 int32 CurrentIndex() const;
65 int32 CurrentID() const;
66 status_t GetInfo(int32 id, file_info *info);
67
68 status_t AddListener(BHandler *handler);
69 status_t RemoveListener(BHandler *handler);
70
71 void Play(void);
72 void Pause(void);
73 float Pitch(void);
74 void SetPitch(float);
75 double Position(void);
76 void SetPosition(double);
77 float Volume(void);
78 void SetVolume(float);
79 void PlayFile(int32 ID);
80 void PlayNext();
81 void PlayPrevious(bool reverse=false);
82
83 bool Lock();
84 void Unlock();
85 bool IsLocked();
86
87 bool HasControls();
88 status_t AddControls();
89 bool IsValid();
90
91 private:
92 #ifdef PLAYLIST_SECRET_INNER_WORKINGS
93 PLAYLIST_SECRET_INNER_WORKINGS
94 #endif
95 PrivatePlaylist();
96 ~PrivatePlaylist();
97
98 void pInit();
99 void pAddDirToList(const entry_ref &ref, int32 index=-1);
100 void pAddPlayListToList(const entry_ref *ref, int32 index);
101 static const char* pNameForItem(_PlayListEntry *);
102 static const char* pPathForItem(_PlayListEntry *);
103 _PlayListEntry *pItemForID(int32 ID) const;
104 int32 pIndexForID(int32 ID) const;
105 status_t pAddPlaylistEntry(_PlayListEntry *pe, int32 index);
106 status_t pNotify(uint32 what, int32 who, int32 where);
107 status_t pDropNotification();
108 status_t pFlushNotification();
109 void pCheckLock() const;
110 void pSetControlSet(class audio*);
111 status_t SetCurrentIndex(int32 index);
112 static int pSortFunc(const void *item1,const void *item2);
113 static int pSortPathFunc(const void *item1,const void *item2);
114 static int pShuffleFunc(const void *item1,const void *item2);
115
116 sem_id locksem;
117 thread_id lockthread;
118 int32 lockcount;
119 bool isshuffled;
120 int32 numitems;
121 int32 currentindex;
122 BList entrylist;
123 BList listeners;
124 BMessage notification;
125 unsigned refcounter;
126 AudioFile *audiofile;
127 audio *controlset;
128 _PlayListEntry *cache;
129 };
130
131
132 // A PlaylistPtr acts as a pointer to a playlist. You dereference a
133 // PlaylistPtr using regular pointer semantics to access the playlist's functions.
134 // Note that as long as you have a PlaylistPtr for a playlist,
135 // that playlist will remain valid. Its associated controls might go
136 // away (i.e. the playlist gets removed from the controller/window),
137 // but you can still work with the files in the playlist, or add it
138 // to the controller again.
139 class PlaylistPtr
140 {
141 public:
142 PlaylistPtr(PrivatePlaylist* p=NULL);
143 PlaylistPtr(const PlaylistPtr& p);
144 PlaylistPtr(int32 ID);
145 ~PlaylistPtr();
146
147 PrivatePlaylist* operator-> () { return ppl; }
148 PrivatePlaylist& operator* () { return *ppl; }
149 PlaylistPtr& operator= (const PlaylistPtr& p);
150 bool operator==(const PlaylistPtr &p) const;
151 bool operator!=(const PlaylistPtr &p) const;
152
153 private:
154 PrivatePlaylist* ppl;
155 };
156
157 #endif