Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
17 changes: 16 additions & 1 deletion modules/yup_audio_basics/midi/yup_MidiFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,22 @@ void MidiFile::setTicksPerQuarterNote (int ticks) noexcept

void MidiFile::setSmpteTimeFormat (int framesPerSecond, int subframeResolution) noexcept
{
timeFormat = (short) (((-framesPerSecond) << 8) | subframeResolution);
switch (framesPerSecond)
{
case 24:
case 25:
case 29:
case 30:
break;

default:
framesPerSecond = 25;
break;
}

const int8 smpteByte = static_cast<int8> (-framesPerSecond);

timeFormat = static_cast<int16> ((static_cast<uint8> (smpteByte) << 8) | static_cast<uint8> (subframeResolution));
}

//==============================================================================
Expand Down
25 changes: 13 additions & 12 deletions modules/yup_audio_devices/native/yup_CoreAudio_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ struct CoreAudioClasses

CoreAudioIODevice& owner;
int bitDepth = 32;
int xruns = 0;
std::atomic<int> xruns { 0 };
Array<double> sampleRates;
Array<int> bufferSizes;
AudioDeviceID deviceID;
Expand Down Expand Up @@ -1158,12 +1158,12 @@ struct CoreAudioClasses
{
auto& intern = *static_cast<CoreAudioInternal*> (inClientData);

const auto xruns = std::count_if (pa, pa + numAddresses, [] (const AudioObjectPropertyAddress& x)
const auto xruns = (int) std::count_if (pa, pa + numAddresses, [] (const AudioObjectPropertyAddress& x)
{
return x.mSelector == kAudioDeviceProcessorOverload;
});

intern.xruns += xruns;
intern.xruns.fetch_add (xruns);

const auto detailsChanged = std::any_of (pa, pa + numAddresses, [] (const AudioObjectPropertyAddress& x)
{
Expand Down Expand Up @@ -1318,7 +1318,7 @@ struct CoreAudioClasses

int getCurrentBufferSizeSamples() override { return internal->getBufferSize(); }

int getXRunCount() const noexcept override { return internal->xruns; }
int getXRunCount() const noexcept override { return internal->xruns.load (std::memory_order_relaxed); }

int getIndexOfDevice (bool asInput) const { return deviceType->getDeviceNames (asInput).indexOf (getName()); }

Expand All @@ -1341,7 +1341,7 @@ struct CoreAudioClasses
int bufferSizeSamples) override
{
isOpen_ = true;
internal->xruns = 0;
internal->xruns.store (0);

inputChannelsRequested = inputChannels;
outputChannelsRequested = outputChannels;
Expand Down Expand Up @@ -1650,10 +1650,12 @@ struct CoreAudioClasses
d->close();
}

void restart (AudioIODeviceCallback* cb)
void restart()
{
const ScopedLock sl (closeLock);

AudioIODeviceCallback* cb = previousCallback;

close();

auto newSampleRate = sampleRateRequested;
Expand Down Expand Up @@ -1763,22 +1765,22 @@ struct CoreAudioClasses

int getXRunCount() const noexcept override
{
return xruns.load();
return xruns.load (std::memory_order_relaxed);
}

private:
static constexpr auto invalidSampleTime = std::numeric_limits<std::uint64_t>::max();

WeakReference<CoreAudioIODeviceType> owner;
CriticalSection callbackLock;
CriticalSection closeLock;
AudioIODeviceCallback* callback = nullptr;
AudioIODeviceCallback* previousCallback = nullptr;
double currentSampleRate = 0;
int currentBufferSize = 0;
bool active = false;
String lastError;
AudioSampleBuffer fifo, scratchBuffer;
CriticalSection closeLock;
int targetLatency = 0;
std::atomic<int> xruns { -1 };
std::atomic<uint64_t> lastValidReadPosition { invalidSampleTime };
Expand All @@ -1791,7 +1793,7 @@ struct CoreAudioClasses
{
stopTimer();

restart (previousCallback);
restart();
}

void shutdown (const String& error)
Expand Down Expand Up @@ -1965,7 +1967,7 @@ struct CoreAudioClasses
for (auto& d : getDeviceWrappers())
d->sampleTime.store (invalidSampleTime);

++xruns;
xruns.fetch_add (1);
}

void handleAudioDeviceAboutToStart (AudioIODevice* device)
Expand Down Expand Up @@ -2132,8 +2134,7 @@ struct CoreAudioClasses
};

/* If the current AudioIODeviceCombiner::callback is nullptr, it sets itself as the callback
and forwards error related callbacks to the provided callback
*/
and forwards error related callbacks to the provided callback. */
class ScopedErrorForwarder final : public AudioIODeviceCallback
{
public:
Expand Down
2 changes: 1 addition & 1 deletion modules/yup_audio_devices/yup_audio_devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ YUP_END_IGNORE_WARNINGS_MSVC
#include <iasiodrv.h>
#include "native/yup_ASIO_windows.cpp"
#endif
// clang-format oon
// clang-format on

//==============================================================================
#elif YUP_LINUX || YUP_BSD
Expand Down
8 changes: 4 additions & 4 deletions modules/yup_audio_gui/yup_audio_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

#ifdef YUP_AUDIO_GUI_H_INCLUDED
/* When you add this cpp file to your project, you mustn't include it in a file where you've
already included any other headers - just put it inside a file on its own, possibly with your config
flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
header files that the compiler may be using.
*/
already included any other headers - just put it inside a file on its own, possibly with your config
flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
header files that the compiler may be using.
*/
#error "Incorrect use of YUP cpp file"
#endif

Expand Down
4 changes: 3 additions & 1 deletion modules/yup_core/containers/yup_FixedSizeFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ template <size_t len, typename Ret, typename... Args>
class FixedSizeFunction<len, Ret (Args...)>
{
private:
using Storage = std::aligned_storage_t<len>;
using Storage = struct {
alignas (alignof (std::max_align_t)) std::byte data[len];
};

template <typename Item>
using Decay = std::decay_t<Item>;
Expand Down
19 changes: 19 additions & 0 deletions modules/yup_core/text/yup_StringPairArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ StringPairArray::StringPairArray (bool shouldIgnoreCase)
{
}

StringPairArray::StringPairArray (const std::initializer_list<KeyValuePair>& stringPairs)
{
for (const auto& item : stringPairs)
{
keys.add (item.key);
values.add (item.value);
}
}

StringPairArray::StringPairArray (bool shouldIgnoreCase, const std::initializer_list<KeyValuePair>& stringPairs)
: ignoreCase (shouldIgnoreCase)
{
for (const auto& item : stringPairs)
{
keys.add (item.key);
values.add (item.value);
}
}

StringPairArray::StringPairArray (const StringPairArray& other)
: keys (other.keys)
, values (other.values)
Expand Down
Loading
Loading