mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-31 03:00:05 +00:00
This commit is contained in:
parent
5ff699eee1
commit
f4a4404e87
9 changed files with 33 additions and 25 deletions
|
|
@ -814,8 +814,7 @@ public:
|
|||
internal->setCallback (callback);
|
||||
|
||||
if (callback != 0)
|
||||
callback->audioDeviceAboutToStart (internal->sampleRate,
|
||||
internal->bufferSize);
|
||||
callback->audioDeviceAboutToStart (this);
|
||||
|
||||
isStarted = (callback != 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1001,8 +1001,7 @@ public:
|
|||
if (internal != 0 && ! isStarted)
|
||||
{
|
||||
if (callback != 0)
|
||||
callback->audioDeviceAboutToStart (getCurrentSampleRate(),
|
||||
getCurrentBufferSizeSamples());
|
||||
callback->audioDeviceAboutToStart (this);
|
||||
|
||||
isStarted = true;
|
||||
internal->start (callback);
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@ public:
|
|||
{
|
||||
if (callback != 0)
|
||||
{
|
||||
callback->audioDeviceAboutToStart (currentSampleRate, currentBlockSizeSamples);
|
||||
callback->audioDeviceAboutToStart (this);
|
||||
|
||||
const ScopedLock sl (callbackLock);
|
||||
currentCallback = callback;
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
call->audioDeviceAboutToStart (sampleRate, bufferSizeSamples);
|
||||
call->audioDeviceAboutToStart (this);
|
||||
|
||||
const ScopedLock sl (startStopLock);
|
||||
callback = call;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue