Changeset 7304 in orxonox.OLD for trunk/src/lib/sound
- Timestamp:
- Apr 16, 2006, 8:27:32 PM (19 years ago)
- Location:
- trunk/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/ogg_player.cc
r7303 r7304 40 40 this->buffers[0] = 0; 41 41 this->buffers[1] = 0; 42 this->musicThread = NULL; 42 43 43 44 if (!fileName.empty()) … … 135 136 return true; 136 137 } 138 139 140 141 int OggPlayer::createAudioThread(void* oggPlayer) 142 { 143 if (oggPlayer == NULL) 144 return -1; 145 OggPlayer* ogg = (OggPlayer*)oggPlayer; 146 PRINTF(4)("STARTIG AUDIO THREAD\n"); 147 148 ogg->playback(); 149 150 while (ogg->state & Playing) 151 { 152 ogg->update(); 153 SDL_Delay(1); 154 } 155 PRINTF(4)("End the AudioThread\n"); 156 } 157 137 158 138 159 /** … … 171 192 this->state &= ! FileOpened; 172 193 } 173 } 174 194 195 // Kill the Music Thread. 196 if (this->musicThread != NULL) 197 { 198 assert (!(this->state & Playing)); 199 SDL_WaitThread(this->musicThread, NULL); 200 this->musicThread = NULL; 201 } 202 } 203 204 205 bool OggPlayer::play() 206 { 207 if (this->musicThread == NULL) 208 this->musicThread = SDL_CreateThread(OggPlayer::createAudioThread, (void*)this); 209 } 175 210 176 211 /** -
trunk/src/lib/sound/ogg_player.h
r7303 r7304 15 15 #include <ogg/ogg.h> 16 16 #include <vorbis/vorbisfile.h> 17 #include <SDL_thread.h> 17 18 18 19 struct File; … … 31 32 bool open(const std::string& fileName); 32 33 void release(); 33 void debug(); 34 bool playback(); 34 bool play(); 35 35 bool playing(); 36 36 bool update(); … … 38 38 void jumpTo(float timeCode); 39 39 40 void debug(); 40 41 void printState(); 42 43 static int createAudioThread(void* oggPlayer); 44 41 45 42 46 protected: … … 45 49 const char* errorString(int code); 46 50 47 public: 48 typedef enum { 49 None = 0x000, 50 FileOpened = 0x100, 51 SourceAllocated = 0x200, 52 BuffersAllocated = 0x400, 53 Stopped = 0x010, 54 Playing = 0x020, 55 Paused = 0x040, 56 Error = 0x001, 57 } State; 51 private: 52 bool playback(); 53 54 55 public: 56 typedef enum { 57 None = 0x000, 58 FileOpened = 0x100, 59 SourceAllocated = 0x200, 60 BuffersAllocated = 0x400, 61 Stopped = 0x010, 62 Playing = 0x020, 63 Paused = 0x040, 64 Error = 0x001, 65 } State; 58 66 59 67 private: … … 67 75 ALenum format; //!< The format we play back 68 76 unsigned int state; 69 //bool trackLoaded; //!< If a Track has been loaded. 77 78 SDL_Thread* musicThread; //!< The Thread in which music is Played back. 70 79 }; 71 80
Note: See TracChangeset
for help on using the changeset viewer.