Browse Source

tags/2021-05-28
jules 17 years ago
parent
commit
f4a4404e87
9 changed files with 33 additions and 25 deletions
  1. +1
    -2
      build/linux/platform_specific_code/juce_linux_Audio.cpp
  2. +1
    -2
      build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp
  3. +1
    -1
      build/win32/platform_specific_code/juce_win32_ASIO.cpp
  4. +1
    -1
      build/win32/platform_specific_code/juce_win32_DirectSound.cpp
  5. +8
    -6
      src/juce_appframework/audio/devices/juce_AudioDeviceManager.cpp
  6. +2
    -2
      src/juce_appframework/audio/devices/juce_AudioDeviceManager.h
  7. +9
    -6
      src/juce_appframework/audio/devices/juce_AudioIODevice.h
  8. +2
    -2
      src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp
  9. +8
    -3
      src/juce_appframework/audio/midi/juce_MidiBuffer.cpp

+ 1
- 2
build/linux/platform_specific_code/juce_linux_Audio.cpp View File

@@ -814,8 +814,7 @@ public:
internal->setCallback (callback);
if (callback != 0)
callback->audioDeviceAboutToStart (internal->sampleRate,
internal->bufferSize);
callback->audioDeviceAboutToStart (this);
isStarted = (callback != 0);
}


+ 1
- 2
build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp View File

@@ -1001,8 +1001,7 @@ public:
if (internal != 0 && ! isStarted)
{
if (callback != 0)
callback->audioDeviceAboutToStart (getCurrentSampleRate(),
getCurrentBufferSizeSamples());
callback->audioDeviceAboutToStart (this);
isStarted = true;
internal->start (callback);


+ 1
- 1
build/win32/platform_specific_code/juce_win32_ASIO.cpp View File

@@ -763,7 +763,7 @@ public:
{
if (callback != 0)
{
callback->audioDeviceAboutToStart (currentSampleRate, currentBlockSizeSamples);
callback->audioDeviceAboutToStart (this);
const ScopedLock sl (callbackLock);
currentCallback = callback;


+ 1
- 1
build/win32/platform_specific_code/juce_win32_DirectSound.cpp View File

@@ -1162,7 +1162,7 @@ public:
return;
}
call->audioDeviceAboutToStart (sampleRate, bufferSizeSamples);
call->audioDeviceAboutToStart (this);
const ScopedLock sl (startStopLock);
callback = call;


+ 8
- 6
src/juce_appframework/audio/devices/juce_AudioDeviceManager.cpp View File

@@ -414,8 +414,7 @@ void AudioDeviceManager::setAudioCallback (AudioIODeviceCallback* newCallback)
lastCallback->audioDeviceStopped();
if (newCallback != 0)
newCallback->audioDeviceAboutToStart (currentAudioDevice->getCurrentSampleRate(),
currentAudioDevice->getCurrentBufferSizeSamples());
newCallback->audioDeviceAboutToStart (currentAudioDevice);
}
currentCallback = newCallback;
@@ -446,10 +445,13 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
}
}
void AudioDeviceManager::audioDeviceAboutToStartInt (double sampleRate, int blockSize)
void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device)
{
cpuUsageMs = 0;
const double sampleRate = device->getCurrentSampleRate();
const int blockSize = device->getCurrentBufferSizeSamples();
if (sampleRate > 0.0 && blockSize > 0)
{
const double msPerBlock = 1000.0 * blockSize / sampleRate;
@@ -457,7 +459,7 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (double sampleRate, int bloc
}
if (currentCallback != 0)
currentCallback->audioDeviceAboutToStart (sampleRate, blockSize);
currentCallback->audioDeviceAboutToStart (device);
sendChangeMessage (this);
}
@@ -603,9 +605,9 @@ void AudioDeviceManager::CallbackHandler::audioDeviceIOCallback (const float** i
owner->audioDeviceIOCallbackInt (inputChannelData, totalNumInputChannels, outputChannelData, totalNumOutputChannels, numSamples);
}
void AudioDeviceManager::CallbackHandler::audioDeviceAboutToStart (double sampleRate, int blockSize)
void AudioDeviceManager::CallbackHandler::audioDeviceAboutToStart (AudioIODevice* device)
{
owner->audioDeviceAboutToStartInt (sampleRate, blockSize);
owner->audioDeviceAboutToStartInt (device);
}
void AudioDeviceManager::CallbackHandler::audioDeviceStopped()


+ 2
- 2
src/juce_appframework/audio/devices/juce_AudioDeviceManager.h View File

@@ -369,7 +369,7 @@ private:
int totalNumOutputChannels,
int numSamples);
void audioDeviceAboutToStart (double sampleRate, int blockSize);
void audioDeviceAboutToStart (AudioIODevice*);
void audioDeviceStopped();
@@ -385,7 +385,7 @@ private:
float** outputChannelData,
int totalNumOutputChannels,
int numSamples);
void audioDeviceAboutToStartInt (double sampleRate, int blockSize);
void audioDeviceAboutToStartInt (AudioIODevice* const device);
void audioDeviceStoppedInt();
void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message);


+ 9
- 6
src/juce_appframework/audio/devices/juce_AudioIODevice.h View File

@@ -35,6 +35,7 @@
#include "../../../juce_core/text/juce_StringArray.h"
#include "../../../juce_core/containers/juce_BitArray.h"
#include "../../../juce_core/containers/juce_OwnedArray.h"
class AudioIODevice;
//==============================================================================
@@ -103,13 +104,15 @@ public:
callback has just been added to an audio device, or after the device has been
restarted because of a sample-rate or block-size change.
@param sampleRate the sample rate it's going to use
@param numSamplesPerBlock the intended block size - this isn't a guaranteed
figure; see the notes about numSamples in the
audioDeviceIOCallback() method.
You can use this opportunity to find out the sample rate and block size
that the device is going to use by calling the AudioIODevice::getCurrentSampleRate()
and AudioIODevice::getCurrentBufferSizeSamples() on the supplied pointer.
@param device the audio IO device that will be used to drive the callback.
Note that if you're going to store this this pointer, it is
only valid until the next time that audioDeviceStopped is called.
*/
virtual void audioDeviceAboutToStart (double sampleRate,
int numSamplesPerBlock) = 0;
virtual void audioDeviceAboutToStart (AudioIODevice* device) = 0;
/** Called to indicate that the device has stopped.
*/


+ 2
- 2
src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp View File

@@ -316,7 +316,7 @@ void AudioSampleBuffer::addFrom (const int destChannel,
int numSamples,
const float gain) throw()
{
jassert (&source != this);
jassert (&source != this || sourceChannel != destChannel);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (((unsigned int) sourceChannel) < (unsigned int) source.numChannels);
@@ -409,7 +409,7 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
const int sourceStartSample,
int numSamples) throw()
{
jassert (&source != this);
jassert (&source != this || sourceChannel != destChannel);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (((unsigned int) sourceChannel) < (unsigned int) source.numChannels);


+ 8
- 3
src/juce_appframework/audio/midi/juce_MidiBuffer.cpp View File

@@ -53,9 +53,14 @@ MidiBuffer::MidiBuffer (const MidiBuffer& other) throw()
const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw()
{
bytesUsed = other.bytesUsed;
ensureAllocatedSize (bytesUsed);
memcpy (elements, other.elements, bytesUsed);
if (this != &other)
{
bytesUsed = other.bytesUsed;
ensureAllocatedSize (bytesUsed);
if (bytesUsed > 0)
memcpy (elements, other.elements, bytesUsed);
}
return *this;
}


Loading…
Cancel
Save