Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2007, 9:20:44 PM (16 years ago)
Author:
nicolape
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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       
Note: See TracChangeset for help on using the changeset viewer.