Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 423


Ignore:
Timestamp:
Dec 5, 2007, 9:20:44 PM (16 years ago)
Author:
nicolape
Message:
 
Location:
code/branches/FICN/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/audio/AudioManager.cc

    r420 r423  
    77                alutInit(NULL, 0);
    88
    9                 bgSound.open("ambient3");
     9                bgSound.open("ambient1");
     10
     11
     12
    1013                bgSound.display();
    11                
    12                 orxonox::Error("Sound loaded!");
    1314
    1415                if(!bgSound.playback())
    1516                {
    16         std::cout << "Ogg refused to play.";
     17        orxonox::Error("Ogg refused to play.");
    1718                }
    1819        }
     
    2627        void AudioManager::update()
    2728        {
    28                 bgSound.update();
    29     if(!bgSound.playing())
    30     {
    31         if(!bgSound.playback())
    32             std::cout << "Ogg abruptly stopped.";
    33         else
    34             std::cout << "Ogg stream was interrupted.\n";
    35     }
     29               
     30                if (bgSound.isLoaded())
     31                {
     32                        bgSound.update();
     33            if(!bgSound.playing())
     34            {
     35                if(!bgSound.playback())
     36                    orxonox::Error("Ogg abruptly stopped.");
     37                else
     38                    orxonox::Error("Ogg stream was interrupted.");
     39            }
     40                }
    3641        }
    3742       
  • code/branches/FICN/src/audio/AudioStream.cc

    r419 r423  
    77        {
    88            int result;
     9                        loaded = false;
    910           
    1011            path = "audio/ambient/" + path + ".ogg";
    1112           
    1213            if(!(oggFile = fopen(path.c_str(), "rb")))
    13                 throw std::string("Could not open Ogg file.");
    14        
     14                        {
     15                orxonox::Error("Could not open Ogg file "+path);
     16                                return;
     17                        }
     18
    1519            if((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
    1620            {
    17                 fclose(oggFile);
    18                
    19                 throw std::string("Could not open Ogg stream. ") + errorString(result);
    20             }
     21        fclose(oggFile);               
     22              orxonox::Error("Could not open Ogg stream. " + errorString(result));
     23                                return;
     24            }
     25
     26                        loaded = true;
    2127       
    2228            vorbisInfo = ov_info(&oggStream, -1);
     
    3844            alSource3f(source, AL_DIRECTION,       0.0, 0.0, 0.0);
    3945            alSourcef (source, AL_ROLLOFF_FACTOR,  0.0          );
    40             alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE      );
     46            alSourcei (source, AL_SOURCE_RELATIVE, AL_FALSE      );
    4147        }
    4248       
     
    4652        void AudioStream::release()
    4753        {
     54                if (loaded)
     55                {
    4856            alSourceStop(source);
    4957            empty();
     
    5462       
    5563            ov_clear(&oggStream);
     64                        loaded = false;
     65                }
    5666        }
    5767       
     
    6171        void AudioStream::display()
    6272        {
     73                if (loaded)
     74                {
    6375            std::cout
    6476                << "version         " << vorbisInfo->version         << "\n"
     
    7587                std::cout << "   " << vorbisComment->user_comments[i] << "\n";
    7688               
    77             std::cout << std::endl;
     89            std::cout << std::endl;     
     90                }
    7891        }
    7992       
     
    8396        bool AudioStream::playback()
    8497        {
     98                if (!loaded)
     99                {
     100                        return false;
     101                }
     102
    85103            if(playing())
    86104                return true;
     
    103121        bool AudioStream::playing()
    104122        {
     123                if (!loaded)
     124                {
     125                        return false;
     126                }
     127
    105128            ALenum state;
    106            
    107129            alGetSourcei(source, AL_SOURCE_STATE, &state);
    108            
    109130            return (state == AL_PLAYING);
    110131        }
     
    154175                else
    155176                    if(result < 0)
    156                         throw errorString(result);
     177                        orxonox::Error(errorString(result));
    157178                    else
    158179                        break;
     
    169190       
    170191       
    171        
    172        
     192
    173193        void AudioStream::empty()
    174194        {
     
    194214       
    195215                if(error != AL_NO_ERROR)
    196                         throw std::string("OpenAL error was raised.");
     216                        orxonox::Error("OpenAL error was raised.");
    197217        }
    198218       
  • code/branches/FICN/src/audio/AudioStream.h

    r411 r423  
    1919                bool playing();
    2020                bool update();
    21        
     21                                        inline bool isLoaded() { return loaded; }       
     22
    2223            protected:
    2324       
     
    3334                vorbis_info*    vorbisInfo;
    3435                vorbis_comment* vorbisComment;
    35        
     36                                        bool loaded;   
     37
    3638                ALuint buffers[2];
    3739                ALuint source;
  • code/branches/FICN/src/orxonox/core/Error.cc

    r421 r423  
    1515        Error::Error(int errorCode, std::string errorMsg)
    1616        {
    17                 std::cout << "Orxonox Error: ";
    18 
    19                 if (errorMsg!="")
     17                std::cout << "############################ "<< std::endl
     18                                                        << "#         Error "<<errorCode<< "          #"<< std::endl
     19                                                        << "############################ "<< std::endl
     20                                                        << "An error occured in Orxonox: "<< std::endl;
     21                                               
     22                if (errorMsg=="")
    2023                {
    21                         std::cout << errorMsg; 
    22                 }
    23                 else
    24                 {
    25                         std::string msg;
    2624                        switch (errorCode)
    2725                        {
    2826                                case 1:
    29                                         msg = "General error";
     27                                        errorMsg = "Some error!";
    3028                                        break;
    3129                                default:
    32                                         msg = "Unknown error!";
     30                                        errorMsg = "Unknown error!";
    3331                        }
    34                         std::cout << msg;
    3532                }
    36                 std::cout << " (Code " << errorCode << ")" << std::endl<< std::endl;
     33                std::cout << errorMsg << std::endl<< std::endl;
    3734        }
    3835}
Note: See TracChangeset for help on using the changeset viewer.