Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7460 in orxonox.OLD for trunk/src/lib/sound/ogg_player.h


Ignore:
Timestamp:
May 1, 2006, 12:30:34 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: Namespaces for sound

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/ogg_player.h

    r7331 r7460  
    77#ifndef _OGG_PLAYER_H
    88#define _OGG_PLAYER_H
    9 
    10 using namespace std;
    119
    1210#include "base_object.h"
     
    2220#define OGG_PLAYER_BUFFER_SIZE (8096 * 2)
    2321
     22namespace OrxSound
     23{
     24  // the definition of a Ogg-Player
     25  class OggPlayer : public BaseObject
     26  {
     27  public:
     28    /**
     29     * An enumerator defining in what State the OggPlayer is.
     30     * The OggPlayer can be in multiple States listed here.
     31     * It can as an example be in FileOpened and Stopped.
     32     */
     33    typedef enum {
     34      None                   = 0x000,   //!< Initialized
     35      FileOpened             = 0x100,   //!< File is Opened
     36      SourceAllocated        = 0x200,   //!< Source is Allocated.
     37      BuffersAllocated       = 0x400,   //!< 2 Buffers are Allocated.
     38      Stopped                = 0x010,   //!< OggPlayer is stopped.
     39      Playing                = 0x020,   //!< OggPlayer is Playing.
     40      Paused                 = 0x040,   //!< OggPlayer is Paused.
     41      Error                  = 0x001,   //!< An Error has occured.
     42    } State;
    2443
    25 // the definition of a Ogg-Player
    26 class OggPlayer : public BaseObject
    27 {
    28 public:
    29   /**
    30    * An enumerator defining in what State the OggPlayer is.
    31    * The OggPlayer can be in multiple States listed here.
    32    * It can as an example be in FileOpened and Stopped.
    33    */
    34   typedef enum {
    35     None                   = 0x000,   //!< Initialized
    36     FileOpened             = 0x100,   //!< File is Opened
    37     SourceAllocated        = 0x200,   //!< Source is Allocated.
    38     BuffersAllocated       = 0x400,   //!< 2 Buffers are Allocated.
    39     Stopped                = 0x010,   //!< OggPlayer is stopped.
    40     Playing                = 0x020,   //!< OggPlayer is Playing.
    41     Paused                 = 0x040,   //!< OggPlayer is Paused.
    42     Error                  = 0x001,   //!< An Error has occured.
    43   } State;
     44    OggPlayer(const std::string& fileName = "");
     45    virtual ~OggPlayer();
     46    /** @param state compare this State with the internal State @returns true on match */
     47    bool operator==(OggPlayer::State state) { return this->state & state; };
    4448
    45   OggPlayer(const std::string& fileName = "");
    46   virtual ~OggPlayer();
    47   /** @param state compare this State with the internal State @returns true on match */
    48   bool operator==(OggPlayer::State state) { return this->state & state; };
     49    bool open(const std::string& fileName = "");
    4950
    50   bool open(const std::string& fileName = "");
     51    bool play();
     52    void stop();
     53    void pause();
     54    void rewind(); // convenience
     55    void jumpTo(float timeCode);
    5156
    52   bool play();
    53   void stop();
    54   void pause();
    55   void rewind(); // convenience
    56   void jumpTo(float timeCode);
     57    float length();
     58    bool isPlaying();
     59    bool getState() { return this->state; };
    5760
    58   float length();
    59   bool isPlaying();
    60   bool getState() { return this->state; };
    61 
    62   void debug() const;
    63   void printState() const;
    64   const char* getVorbisError(int code);
     61    void debug() const;
     62    void printState() const;
     63    const char* getVorbisError(int code);
    6564
    6665
    67 private:
    68   static int musicThread(void* oggPlayer);
    69   bool playback();
    70   void suspend();
    71   bool update();
     66  private:
     67    static int musicThread(void* oggPlayer);
     68    bool playback();
     69    void suspend();
     70    bool update();
    7271
    73   void release();
     72    void release();
    7473
    75   bool stream(ALuint buffer);
    76   void empty();
     74    bool stream(ALuint buffer);
     75    void empty();
    7776
    78 private:
    79   FILE*               oggFile;              //!< general file-handler, to open the sound-file
    80   OggVorbis_File      oggStream;            //!< The stream this Ogg-player is playing back
    81   vorbis_info*        vorbisInfo;           //!< The information held in the opened ogg-file
    82   vorbis_comment*     vorbisComment;        //!< Comments about the ogg-file
     77  private:
     78    FILE*               oggFile;              //!< general file-handler, to open the sound-file
     79    OggVorbis_File      oggStream;            //!< The stream this Ogg-player is playing back
     80    vorbis_info*        vorbisInfo;           //!< The information held in the opened ogg-file
     81    vorbis_comment*     vorbisComment;        //!< Comments about the ogg-file
    8382
    84   ALuint              buffers[2];           //!< buffers that handle sequentially buffering of the audio
    85   ALuint              source;               //!< The source we play back on
    86   ALenum              format;               //!< The format we play back
    87   unsigned int        state;                //!< The States the OggPlayer is in (this can be multiple entries from OggPlayer::State).
     83    ALuint              buffers[2];           //!< buffers that handle sequentially buffering of the audio
     84    ALuint              source;               //!< The source we play back on
     85    ALenum              format;               //!< The format we play back
     86    unsigned int        state;                //!< The States the OggPlayer is in (this can be multiple entries from OggPlayer::State).
    8887
    89   SDL_Thread*         musicThreadID;        //!< The Thread in which music is Played back.
    90   SDL_mutex*          musicMutex;           //!< A Mutex so that the two threads do not interfere.
    91 };
     88    SDL_Thread*         musicThreadID;        //!< The Thread in which music is Played back.
     89    SDL_mutex*          musicMutex;           //!< A Mutex so that the two threads do not interfere.
     90  };
    9291
    93 
     92}
    9493#endif /* _OGG_PLAYER_H */
Note: See TracChangeset for help on using the changeset viewer.