Logo Search packages:      
Sourcecode: scummvm version File versions

int Audio::MixerImpl::mixCallback ( byte *  samples,
uint  len 
)

The mixer callback function, to be called at regular intervals by the backend (e.g. from an audio mixing thread). All the actual mixing work is done from here.

Returns:
number of sample pairs processed (which can still be silence!)

Definition at line 257 of file mixer.cpp.

References Audio::Channel::mix().

                                                  {
      assert(samples);

      Common::StackLock lock(_mutex);

      int16 *buf = (int16 *)samples;
      len >>= 2;

      // Since the mixer callback has been called, the mixer must be ready...
      _mixerReady = true;

      //  zero the buf
      memset(buf, 0, 2 * len * sizeof(int16));

      // mix all channels
      int res = 0, tmp;
      for (int i = 0; i != NUM_CHANNELS; i++)
            if (_channels[i]) {
                  if (_channels[i]->isFinished()) {
                        delete _channels[i];
                        _channels[i] = 0;
                  } else if (!_channels[i]->isPaused()) {
                        tmp = _channels[i]->mix(buf, len);

                        if (tmp > res)
                              res = tmp;
                  }
            }

      return res;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index