gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r9955: Change some methods and membe


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9955: Change some methods and member names in sound stuff (readability)
Date: Wed, 08 Oct 2008 10:25:38 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9955
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Wed 2008-10-08 10:25:38 +0200
message:
  Change some methods and member names in sound stuff (readability)
modified:
  libmedia/ffmpeg/sound_handler_sdl.cpp
  libmedia/ffmpeg/sound_handler_sdl.h
=== modified file 'libmedia/ffmpeg/sound_handler_sdl.cpp'
--- a/libmedia/ffmpeg/sound_handler_sdl.cpp     2008-10-08 07:31:25 +0000
+++ b/libmedia/ffmpeg/sound_handler_sdl.cpp     2008-10-08 08:25:38 +0000
@@ -237,7 +237,7 @@
 
 // Play the index'd sample.
 void
-SDL_sound_handler::play_sound(int sound_handle, int loop_count, int offset, 
long start_position, const std::vector<sound_envelope>* envelopes)
+SDL_sound_handler::play_sound(int sound_handle, int loopCount, int offset, 
long start_position, const std::vector<sound_envelope>* envelopes)
 {
        boost::mutex::scoped_lock lock(_mutex);
 
@@ -267,15 +267,16 @@
                return;
        }
 
-       // Make a "active_sound" for this sound which is later placed on the 
vector of instances of this sound being played
+       // Make a "active_sound" for this sound which is later placed
+    // on the vector of instances of this sound being played
        std::auto_ptr<active_sound> sound ( new active_sound() );
 
        // Set source data to the active_sound
        sound->set_data(sounddata);
 
        // Set the given options of the sound
-       if (start_position < 0) sound->position = 0;
-       else sound->position = start_position;
+       if (start_position < 0) sound->decodingPosition = 0;
+       else sound->decodingPosition = start_position;
 
        if (offset < 0) sound->offset = 0;
        else sound->offset = (sounddata->soundinfo->isStereo() ? offset : 
offset*2); // offset is stored as stereo
@@ -283,7 +284,7 @@
        sound->envelopes = envelopes;
 
        // Set number of loop we should do. -1 is infinte loop, 0 plays it 
once, 1 twice etc.
-       sound->loop_count = loop_count;
+       sound->loopCount = loopCount;
 
        sound->decoder = NULL;
 
@@ -601,7 +602,7 @@
 
 // Pointer handling and checking functions
 boost::uint8_t*
-active_sound::get_raw_data_ptr(unsigned long int pos)
+active_sound::getDecodedData(unsigned long int pos)
 {
        if ( _decodedData.get() )
        {
@@ -612,15 +613,15 @@
 }
 
 boost::uint8_t*
-active_sound::get_data_ptr(unsigned long int pos)
+active_sound::getEncodedData(unsigned long int pos)
 {
-       assert(_undecodedData);
-       return _undecodedData->data(pos);
+       assert(_encodedData);
+       return _encodedData->data(pos);
 }
 
 void active_sound::set_data(sound_data* idata)
 {
-       _undecodedData = idata;
+       _encodedData = idata;
 }
 
 void active_sound::deleteDecodedData()
@@ -667,12 +668,12 @@
        unsigned int startpos = 0;
        // Make sure we start adjusting at the right sample
        if (sound.current_env == 0 && 
(*sound.envelopes)[sound.current_env].m_mark44 > sound.samples_played) {
-               startpos = sound.raw_position + 
((*sound.envelopes)[sound.current_env].m_mark44 - sound.samples_played)*2;
+               startpos = sound.playbackPosition + 
((*sound.envelopes)[sound.current_env].m_mark44 - sound.samples_played)*2;
        } else {
-               startpos = sound.raw_position;
+               startpos = sound.playbackPosition;
        }
 
-       boost::int16_t* data = 
reinterpret_cast<boost::int16_t*>(sound.get_raw_data_ptr(startpos));
+       boost::int16_t* data = 
reinterpret_cast<boost::int16_t*>(sound.getDecodedData(startpos));
 
        for (unsigned int i=0; i < length/2; i+=2) {
                float left = 
static_cast<float>((*sound.envelopes)[sound.current_env].m_level0 / 32768.0);
@@ -710,7 +711,7 @@
        SDL_MixAudio(static_cast<Uint8*>(stream),static_cast<const 
Uint8*>(data), mix_length, SDL_MIX_MAXVOLUME);
 
        // Update sound info
-       sound.raw_position += mix_length;
+       sound.playbackPosition += mix_length;
 
        // Sample size is always 2
        sound.samples_played += mix_length / 2;
@@ -875,28 +876,30 @@
 
 /*private*/
 void
-SDL_sound_handler::mixActiveSound(active_sound& sound, sound_data& sounddata, 
Uint8* buffer, unsigned int buffer_length)
+SDL_sound_handler::mixActiveSound(active_sound& sound, sound_data& sounddata,
+        Uint8* buffer, unsigned int buffer_length)
 {
        // If there exist no decoder, then we can't decode!
        if (sound.decoder == NULL) return;
 
-       int volume = int(sounddata.volume*getFinalVolume()/100.0); // 
concatenate global volume
+    // concatenate global volume
+       int volume = int(sounddata.volume*getFinalVolume()/100.0);
 
        // When the current sound don't have enough decoded data to fill the 
buffer, 
        // we first mix what is already decoded, then decode some more data, and
        // mix some more until the buffer is full. If a sound loops the magic
        // happens here ;)
        //
-       if (sound.rawDataSize() - sound.raw_position < buffer_length 
-               && (sound.position < sound.dataSize() || sound.loop_count != 0))
+       if (sound.decodedDataSize() - sound.playbackPosition < buffer_length 
+               && (sound.decodingPosition < sound.encodedDataSize() || 
sound.loopCount != 0))
        {
                // First we mix what is decoded
                unsigned int index = 0;
-               if (sound.rawDataSize() - sound.raw_position > 0)
+               if (sound.decodedDataSize() - sound.playbackPosition > 0)
                {
-                       index = sound.rawDataSize() - sound.raw_position;
+                       index = sound.decodedDataSize() - 
sound.playbackPosition;
 
-                       do_mixing(buffer, sound, 
sound.get_raw_data_ptr(sound.raw_position),
+                       do_mixing(buffer, sound, 
sound.getDecodedData(sound.playbackPosition),
                                index, volume);
 
                }
@@ -913,14 +916,14 @@
                {
 
                        // If we need to loop, we reset the data pointer
-                       if (sound.dataSize() == sound.position && 
sound.loop_count != 0) {
-                               sound.loop_count--;
-                               sound.position = 0;
+                       if (sound.encodedDataSize() == sound.decodingPosition 
&& sound.loopCount != 0) {
+                               sound.loopCount--;
+                               sound.decodingPosition = 0;
                                sound.samples_played = 0;
                        }
 
                        // Test if we will get problems... Should not happen...
-                       assert(sound.dataSize() > sound.position);
+                       assert(sound.encodedDataSize() > 
sound.decodingPosition);
                        
                        // temp raw buffer
                        Uint8* tmp_raw_buffer=0;
@@ -931,16 +934,20 @@
                        bool parse = true;
                        if (sounddata.soundinfo->getFormat() == 
AUDIO_CODEC_ADPCM) {
                                parse = false;
-                               if (sounddata.m_frames_size.size() > 0) 
inputSize = sounddata.m_frames_size[sound.position];
-                               else inputSize = sound.dataSize() - 
sound.position;
+                               if (sounddata.m_frames_size.size() > 0) {
+                    inputSize = 
sounddata.m_frames_size[sound.decodingPosition];
+                }
+                               else {
+                    inputSize = sound.encodedDataSize() - 
sound.decodingPosition;
+                }
                        } else {
-                               inputSize = sound.dataSize() - sound.position;
+                               inputSize = sound.encodedDataSize() - 
sound.decodingPosition;
                        }
 
-                       tmp_raw_buffer = 
sound.decoder->decode(sound.get_data_ptr(sound.position), 
+                       tmp_raw_buffer = 
sound.decoder->decode(sound.getEncodedData(sound.decodingPosition), 
                                        inputSize, tmp_raw_buffer_size, 
decodedBytes, parse);
 
-                       sound.position += decodedBytes;
+                       sound.decodingPosition += decodedBytes;
 
                        // tmp_raw_buffer ownership transferred here
                        sound.appendDecodedData(tmp_raw_buffer, 
tmp_raw_buffer_size);
@@ -948,15 +955,15 @@
                        decoded_size += tmp_raw_buffer_size;
 
                        // no more to decode from this sound, so we break the 
loop
-                       if ((sound.dataSize() <= sound.position && 
sound.loop_count == 0)
+                       if ((sound.encodedDataSize() <= sound.decodingPosition 
&& sound.loopCount == 0)
                     || (tmp_raw_buffer_size == 0 && decodedBytes == 0)) {
-                               sound.position = sound.dataSize();
+                               sound.decodingPosition = 
sound.encodedDataSize();
                                break;
                        }
 
                } // end of "decode min. bufferlength data" while loop
 
-               sound.raw_position = 0;
+               sound.playbackPosition = 0;
 
                // Determine how much should be mixed
                unsigned int mix_length = 0;
@@ -965,21 +972,21 @@
                } else { 
                        mix_length = decoded_size;
                }
-               if (sound.rawDataSize() < 2)
+               if (sound.decodedDataSize() < 2)
                {
                        log_error("Something went terribly wrong during mixing 
of an active sound");
                        return; // something went terrible wrong
                }
-               do_mixing(buffer+index, sound, sound.get_raw_data_ptr(0), 
mix_length, volume);
+               do_mixing(buffer+index, sound, sound.getDecodedData(0), 
mix_length, volume);
 
        }
 
        // When the current sound has enough decoded data to fill 
        // the buffer, we do just that.
-       else if (sound.rawDataSize() > sound.raw_position && 
sound.rawDataSize() - sound.raw_position > buffer_length )
+       else if (sound.decodedDataSize() > sound.playbackPosition && 
sound.decodedDataSize() - sound.playbackPosition > buffer_length )
        {
 
-               do_mixing(buffer, sound, 
sound.get_raw_data_ptr(sound.raw_position), 
+               do_mixing(buffer, sound, 
sound.getDecodedData(sound.playbackPosition), 
                        buffer_length, volume);
 
        }
@@ -987,14 +994,14 @@
        // When the current sound doesn't have anymore data to decode,
        // and doesn't loop (anymore), but still got unplayed data,
        // we put the last data on the stream
-       else if (sound.rawDataSize() - sound.raw_position <= buffer_length && 
sound.rawDataSize() > sound.raw_position+1)
+       else if (sound.decodedDataSize() - sound.playbackPosition <= 
buffer_length && sound.decodedDataSize() > sound.playbackPosition+1)
        {
        
 
-               do_mixing(buffer, sound, 
sound.get_raw_data_ptr(sound.raw_position), 
-                       sound.rawDataSize() - sound.raw_position, volume);
+               do_mixing(buffer, sound, 
sound.getDecodedData(sound.playbackPosition), 
+                       sound.decodedDataSize() - sound.playbackPosition, 
volume);
 
-               sound.raw_position = sound.rawDataSize();
+               sound.playbackPosition = sound.decodedDataSize();
        } 
 }
 
@@ -1014,7 +1021,7 @@
                mixActiveSound(*sound, sounddata, buffer, buffer_length);
 
                // Sound is done, remove it from the active list
-               if (sound->position == sound->dataSize() && sound->raw_position 
== sound->rawDataSize() && sound->loop_count == 0)
+               if (sound->decodingPosition == sound->encodedDataSize() && 
sound->playbackPosition == sound->decodedDataSize() && sound->loopCount == 0)
                {
                        i = sounddata.eraseActiveSound(i);
 

=== modified file 'libmedia/ffmpeg/sound_handler_sdl.h'
--- a/libmedia/ffmpeg/sound_handler_sdl.h       2008-10-06 13:44:15 +0000
+++ b/libmedia/ffmpeg/sound_handler_sdl.h       2008-10-08 08:25:38 +0000
@@ -150,13 +150,13 @@
        active_sound()
                :
                decoder(0),
-               position(0),
-               raw_position(0),
-               loop_count(0),
+               decodingPosition(0),
+               playbackPosition(0),
+               loopCount(0),
                offset(0),
                current_env(0),
                samples_played(0),
-               _undecodedData(0)
+               _encodedData(0)
        {}
 
        ~active_sound()
@@ -168,15 +168,15 @@
        /// The decoder object used to convert the data into the playable format
        AudioDecoder* decoder;
 
-       /// Current decoding position in the stream
-       unsigned long position;
+       /// Current decoding position in the encoded stream
+       unsigned long decodingPosition;
 
-       /// Current playing position in the decoded stream
-       unsigned long raw_position;
+       /// Current playback position in the decoded stream
+       unsigned long playbackPosition;
 
        /// Numbers of loops: -1 means loop forever, 0 means play once.
        /// For every loop completed, it is decremented.
-       long loop_count;
+       long loopCount;
 
        /// Offset to make playback start in-sync, only used with mp3 streams.
        unsigned int offset;
@@ -199,13 +199,13 @@
        ///
        void set_data(sound_data* newUndecodedData);
 
-       /// Returns the data pointer in the undecoded datastream
+       /// Returns the data pointer in the encoded datastream
        /// for the given position. Boundaries are checked.
-       boost::uint8_t* get_data_ptr(unsigned long int pos);
+       boost::uint8_t* getEncodedData(unsigned long int pos);
 
        /// Returns the data pointer in the decoded datastream
        /// for the given position. Boundaries are checked.
-       boost::uint8_t* get_raw_data_ptr(unsigned long int pos);
+       boost::uint8_t* getDecodedData(unsigned long int pos);
 
        /// Release resources associated with decoded data, if any.
        //
@@ -254,7 +254,7 @@
                delete [] data; // ownership transferred...
        }
 
-       size_t rawDataSize() const
+       size_t decodedDataSize() const
        {
                if ( _decodedData.get() )
                {
@@ -263,19 +263,19 @@
                else return 0;
        }
   
-       size_t dataSize() const
+       size_t encodedDataSize() const
        {
-               return _undecodedData ? _undecodedData->size() : 0;
+               return _encodedData ? _encodedData->size() : 0;
        }
   
 private:
 
-       /// The undecoded data
-       sound_data* _undecodedData;
+       /// The encoded data
+       sound_data* _encodedData;
 
        /// The decoded buffer
        //
-       /// If NULL, the _undecodedData will be considered
+       /// If NULL, the _encodedData will be considered
        /// decoded instead
        ///
        std::auto_ptr<SimpleBuffer> _decodedData;
@@ -350,7 +350,7 @@
                                         unsigned int sample_count, int 
handle_id);
 
        /// Play the index'd sample.
-       virtual void    play_sound(int sound_handle, int loop_count, int offset,
+       virtual void    play_sound(int sound_handle, int loopCount, int offset,
                                   long start_position, const 
std::vector<sound_envelope>* envelopes);
 
        /// Stop the index'd sample.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]