MacOS fixes

This commit is contained in:
Nikita Lisitsa 2023-01-16 23:53:34 +03:00
parent 8e286a2cc0
commit fdcf0d5b88
12 changed files with 38 additions and 11 deletions

View file

@ -26,7 +26,9 @@ namespace psemek::audio
: samples_{seconds_to_samples(seconds)}
{}
duration(duration const & other) = default;
duration(duration const & other)
: samples_{other.samples_}
{}
float seconds() const
{
@ -38,6 +40,12 @@ namespace psemek::audio
return samples_;
}
duration & operator = (duration const & other)
{
samples_ = other.samples_;
return *this;
}
duration & operator += (duration const & other)
{
samples_ += other.samples_;

View file

@ -1,7 +1,7 @@
#include <psemek/audio/effect/fade_in.hpp>
#include <psemek/audio/constants.hpp>
#include <cmath>
#include <algorithm>
namespace psemek::audio
{

View file

@ -1,7 +1,7 @@
#include <psemek/audio/effect/fade_out.hpp>
#include <psemek/audio/constants.hpp>
#include <cmath>
#include <algorithm>
namespace psemek::audio
{

View file

@ -2,6 +2,7 @@
#include <psemek/audio/detail/smooth.hpp>
#include <atomic>
#include <algorithm>
namespace psemek::audio
{

View file

@ -1,5 +1,7 @@
#include <psemek/audio/effect/truncate.hpp>
#include <algorithm>
namespace psemek::audio
{

View file

@ -29,7 +29,11 @@ namespace psemek::audio
channel_ptr output;
impl();
~impl();
~impl()
{
SDL_CloseAudioDevice(device);
}
static void callback(void * userdata, std::uint8_t * stream, int len);
};
@ -54,11 +58,6 @@ namespace psemek::audio
SDL_PauseAudioDevice(device, 0);
}
engine::impl::~impl()
{
SDL_CloseAudioDevice(device);
}
void engine::impl::callback(void * userdata, std::uint8_t * dst_u8, int len)
{
static std::string const profiler_str = "audio";

View file

@ -3,6 +3,7 @@
#include <psemek/geom/constants.hpp>
#include <cmath>
#include <algorithm>
#include <optional>
namespace psemek::geom

View file

@ -5,6 +5,7 @@
#include <psemek/io/memory_stream.hpp>
#include <stdexcept>
#include <unordered_map>
namespace psemek::gfx
{

View file

@ -9,6 +9,9 @@
#include <psemek/util/not_implemented.hpp>
#include <psemek/util/unused.hpp>
#include <vector>
#include <array>
namespace psemek::phys3d
{

View file

@ -110,6 +110,6 @@ namespace psemek::util
} \
template <typename Char, typename Traits> \
inline ::std::basic_ostream<Char, Traits> & operator << (::std::basic_ostream<Char, Traits> & os, name value) { return os << to_string(value); } \
inline ::psemek::util::enum_range<name> BOOST_PP_CAT(name, _values) () { return {0, BOOST_PP_SEQ_SIZE(values)}; }
inline ::psemek::util::enum_range<name> BOOST_PP_CAT(name, _values) () { return {{0}, {BOOST_PP_SEQ_SIZE(values)}}; }

View file

@ -60,7 +60,19 @@ namespace psemek::util
inline auto operator <=> (hstring const & str1, hstring const & str2)
{
#ifdef __clang__
// libc++ in MacOSX12.3.sdk doesn't have operator <=> for string views
auto view1 = str1.view();
auto view2 = str2.view();
if (std::lexicographical_compare(view1.begin(), view1.end(), view2.begin(), view2.end()))
return std::strong_ordering::less;
else if (std::equal(view1.begin(), view1.end(), view2.begin(), view2.end()))
return std::strong_ordering::equal;
else
return std::strong_ordering::greater;
#else
return str1.view() <=> str2.view();
#endif
}
}

View file

@ -6,7 +6,7 @@
namespace psemek::util
{
static void ignore(int) {}
[[maybe_unused]] static void ignore(int) {}
static void do_open_url(std::string url)
{