Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9019 in orxonox.OLD for trunk/src/lib/sound


Ignore:
Timestamp:
Jul 2, 2006, 4:41:32 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: OggPlayer retrieves Information about the current Title
The Title Played is relayed to the Hud's Notifier

Location:
trunk/src/lib/sound
Files:
2 edited

Legend:

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

    r8362 r9019  
    3232#include "debug.h"
    3333#include "compiler.h"
     34
     35#include "helper_functions.h"
    3436
    3537#ifdef HAVE_SDL_SDL_H
     
    137139    vorbisInfo = ov_info(&oggStream, -1);
    138140    vorbisComment = ov_comment(&oggStream, -1);
     141    this->retrieveFileInfo(&oggStream);
    139142
    140143    if(vorbisInfo->channels == 1)
     
    469472      alSourceUnqueueBuffers(source, 1, &buffer);
    470473      SoundEngine::checkError("OggPlayer::empty()::unqueue Buffers", __LINE__);
     474    }
     475  }
     476
     477
     478  void OggPlayer::retrieveFileInfo(OggVorbis_File* file)
     479  {
     480    vorbis_comment* comment = ov_comment(file, -1);
     481    if (comment == NULL)
     482    {
     483      PRINTF(2)("Retrieving Comment of %s failed\n", this->getName());
     484      return;
     485    }
     486    for (int i = 0; i < comment->comments; ++i)
     487    {
     488      if (!nocaseCmp("artist=", comment->user_comments[i], 7))
     489        this->_artist = comment->user_comments[i]+7;
     490      if (!nocaseCmp("title=", comment->user_comments[i], 6))
     491        this->_title = comment->user_comments[i] + 6;
     492      if (!nocaseCmp("album=", comment->user_comments[i], 6))
     493        this->_album = comment->user_comments[i]+6;
    471494    }
    472495  }
  • trunk/src/lib/sound/ogg_player.h

    r7737 r9019  
    5959    bool getState() { return this->state; };
    6060
     61    const std::string& artist() const { return this->_artist; };
     62    const std::string& title() const { return this->_title; };
     63    const std::string& album() const { return this->_album; };
     64
     65
    6166    void debug() const;
    6267    void printState() const;
     
    7580    void empty();
    7681
     82    void retrieveFileInfo(OggVorbis_File* file);
     83
    7784  private:
    7885    FILE*               oggFile;              //!< general file-handler, to open the sound-file
     
    8895    SDL_Thread*         musicThreadID;        //!< The Thread in which music is Played back.
    8996    OrxThread::Mutex    musicMutex;           //!< A Mutex so that the two threads do not interfere.
     97
     98
     99
     100    std::string         _title;
     101    std::string         _artist;
     102    std::string         _album;
     103    std::string         _vendor;
    90104  };
    91105
Note: See TracChangeset for help on using the changeset viewer.