1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 09:00:52 +02:00

Usage of the fuller C++11 library, now that we can on Mac

This commit is contained in:
Paul Licameli 2018-05-10 01:32:09 -04:00
commit a06e845b2f
101 changed files with 211 additions and 779 deletions

View File

@ -45,6 +45,7 @@
#include <algorithm>
#include <wx/string.h>
#include <wx/arrstr.h>
#include <type_traits>
// ----------------------------------------------------------------------------
// TODO: I'd imagine this header may be replaced by other public headers. But,
@ -90,7 +91,7 @@ public:
size_t as_size_t() const {
wxASSERT(value >= 0);
wxASSERT(value <= std::numeric_limits<size_t>::max());
wxASSERT(static_cast<std::make_unsigned<type>::type>(value) <= std::numeric_limits<size_t>::max());
return value;
}

View File

@ -986,11 +986,7 @@ wxT("POSSIBILITY OF SUCH DAMAGES.\n"));
void AboutDialog::AddCredit(wxString &&description, Role role)
{
#ifdef __AUDACITY_OLD_STD__
creditItems.push_back(AboutDialogCreditItem{ std::move(description), role });
#else
creditItems.emplace_back(std::move(description), role);
#endif
}
wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role)

View File

@ -32,14 +32,9 @@ struct AboutDialogCreditItem {
: description(description_), role(role_)
{}
#ifdef __AUDACITY_OLD_STD__
AboutDialogCreditItem(const AboutDialogCreditItem&) = default;
AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) = default;
#else
// No copy, use the move
AboutDialogCreditItem(const AboutDialogCreditItem&) PROHIBITED;
AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) PROHIBITED;
#endif
// Move constructor, because wxString lacks one
AboutDialogCreditItem(AboutDialogCreditItem &&moveMe)

View File

@ -1083,7 +1083,7 @@ bool AudacityApp::OnExceptionInMainLoop()
// Use CallAfter to delay this to the next pass of the event loop,
// rather than risk doing it inside stack unwinding.
auto pProject = ::GetActiveProject();
std::shared_ptr< AudacityException > pException { e.Move().release() };
auto pException = std::current_exception();
CallAfter( [=] // Capture pException by value!
{
@ -1097,7 +1097,9 @@ bool AudacityApp::OnExceptionInMainLoop()
pProject->RedrawProject();
// Give the user an alert
pException->DelayedHandlerAction();
try { std::rethrow_exception( pException ); }
catch( AudacityException &e )
{ e.DelayedHandlerAction(); }
} );

View File

@ -85,12 +85,6 @@ wxString SimpleMessageBoxException::ErrorMessage() const
return message;
}
std::unique_ptr< AudacityException > SimpleMessageBoxException::Move()
{
return std::unique_ptr< AudacityException >
{ safenew SimpleMessageBoxException{ std::move( *this ) } };
}
// This is meant to be invoked via wxEvtHandler::CallAfter
void MessageBoxException::DelayedHandlerAction()
{

View File

@ -30,11 +30,6 @@ public:
AudacityException() {}
virtual ~AudacityException() = 0;
// This is intended as a "polymorphic move copy constructor"
// which leaves this "empty".
// We would not need this if we had std::exception_ptr
virtual std::unique_ptr< AudacityException > Move() = 0;
// Action to do in the main thread at idle time of the event loop.
virtual void DelayedHandlerAction() = 0;
@ -88,8 +83,6 @@ public:
SimpleMessageBoxException &operator = (
SimpleMessageBoxException && ) PROHIBITED;
std::unique_ptr< AudacityException > Move() override;
// Format a default, internationalized error message for this exception.
virtual wxString ErrorMessage() const override;
@ -170,11 +163,15 @@ R GuardedCall
catch ( AudacityException &e ) {
auto end = finally([&]{
// At this point, e is the "current" exception, but not "uncaught"
// unless it was rethrown by handler. handler might also throw some
// other exception object.
if (!std::uncaught_exception()) {
auto pException =
std::shared_ptr< AudacityException > { e.Move().release() };
auto pException = std::current_exception(); // This points to e
wxTheApp->CallAfter( [=] { // capture pException by value
delayedHandler( pException.get() );
try { std::rethrow_exception(pException); }
catch( AudacityException &e )
{ delayedHandler( &e ); }
} );
}
});

View File

@ -21,9 +21,7 @@
#include <wx/hashmap.h>
#include <wx/mstream.h>
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
//
// Show auto recovery dialog if there are projects to recover. Should be

View File

@ -180,7 +180,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ {
struct ReadUnlocker { void operator () ( const BlockFile *p ) const {
if (p) p->UnlockRead(); } };
using ReadLockBase =
movable_ptr_with_deleter< const BlockFile, ReadUnlocker >;
std::unique_ptr< const BlockFile, ReadUnlocker >;
public:
class ReadLock : public ReadLockBase
@ -189,14 +189,6 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ {
ReadLock ( const BlockFile *p, const BlockFile::ReadUnlocker &u )
: ReadLockBase { p, u } {}
public:
#ifdef __AUDACITY_OLD_STD__
ReadLock (const ReadLock &that) : ReadLockBase( that ) {}
ReadLock &operator= (const ReadLock &that)
{
*((ReadLockBase*)this) = that;
return *this;
}
#endif
ReadLock(ReadLock&&that) : ReadLockBase{ std::move(that) } {}
using Suspension = std::unique_ptr< const BlockFile, ReadLocker >;
Suspension Suspend() const

View File

@ -58,9 +58,7 @@ AliasedFile s.
#include "WaveClip.h"
#include "widgets/ErrorDialog.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
using AliasedFileHash = std::unordered_map<wxString, AliasedFile*>;

View File

@ -22,9 +22,7 @@
#include "xml/XMLTagHandler.h"
#include "wxFileNameWrapper.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
class wxHashTable;
class BlockArray;

View File

@ -15,12 +15,6 @@ FileException::~FileException()
{
}
std::unique_ptr< AudacityException > FileException::Move()
{
return std::unique_ptr< AudacityException >
{ safenew FileException{ std::move( *this ) } };
}
wxString FileException::ErrorMessage() const
{
wxString format;

View File

@ -37,8 +37,6 @@ public:
~FileException() override;
protected:
std::unique_ptr< AudacityException > Move() override;
// Format a default, internationalized error message for this exception.
wxString ErrorMessage() const override;

View File

@ -14,12 +14,6 @@ InconsistencyException::~InconsistencyException()
{
}
std::unique_ptr< AudacityException > InconsistencyException::Move()
{
return std::unique_ptr< AudacityException >
{ safenew InconsistencyException{ std::move( *this ) } };
}
wxString InconsistencyException::ErrorMessage() const
{
// Shorten the path

View File

@ -48,8 +48,6 @@ public:
unsigned GetLine() const { return line; }
private:
std::unique_ptr< AudacityException > Move() override;
// Format a default, internationalized error message for this exception.
wxString ErrorMessage() const override;

View File

@ -42,9 +42,7 @@
#include "AudacityApp.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
using LangHash = std::unordered_map<wxString, wxString>;

View File

@ -13,410 +13,8 @@
#undef __AUDACITY_OLD_STD__
// JKC:
// This is completely the wrong way to test for new stdlib (supporting std::hash etc)
// We should instead use configure checks or test if __cplusplus is bigger that some value.
//
// On the other hand, as we are moving to wxWidgets 3.1.1, macOSX 10.7+ is required.
// And we could just assume/require building with C++11 and remove the body of this
// ifdef - i.e. no longer support those workarounds.
//
// Macports have provided some really useful information about possibilities for
// building with newer compilers and older SDKs. So the option of building with old
// compilers and old SDKs may not be needed at all, making the shift to requiring
// C++11 have little to no downside. So as of 13th April 2018 the code in this
// ifdef's days are numbered.
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED <= __MAC_10_6
#define __AUDACITY_OLD_STD__
#include <math.h>
inline long long int llrint(float __x) { return __builtin_llrintf(__x); }
inline long long int llrint(double __x) { return __builtin_llrintl(__x); }
inline long long int llrint(long double __x) { return __builtin_llrintl(__x); }
#include <cmath>
using std::isnan;
using std::isinf;
// Need this to define move() and forward()
#include <tr1/type_traits>
// To define make_shared
#include <tr1/memory>
// To define function
#include <tr1/functional>
// To define unordered_set
#include <tr1/unordered_set>
// To define unordered_map and hash
#include <tr1/unordered_map>
#include <tr1/tuple>
namespace std {
using std::tr1::unordered_set;
using std::tr1::hash;
using std::tr1::unordered_map;
using std::tr1::function;
using std::tr1::shared_ptr;
using std::tr1::weak_ptr;
using std::tr1::static_pointer_cast;
using std::tr1::remove_reference;
using std::tr1::is_unsigned;
using std::tr1::is_const;
using std::tr1::add_const;
using std::tr1::add_pointer;
using std::tr1::remove_pointer;
using std::tr1::tuple;
using std::tr1::get;
template<typename T> struct add_rvalue_reference {
using type = T&&;
};
template<typename X> struct default_delete
{
default_delete() {}
// Allow copy from other deleter classes
template<typename Y>
default_delete(const default_delete<Y>& that)
{
// Break compilation if Y* does not convert to X*
// I should figure out the right use of enable_if instead
// Note: YPtr avoids bogus compiler warning for C99 compound literals
using YPtr = Y*;
static_assert((static_cast<X*>(YPtr{}), true),
"Pointer types not convertible");
}
inline void operator() (void *p) const
{
delete static_cast<X*>(p);
}
};
// Specialization for arrays
template<typename X> struct default_delete<X[]>
{
// Do not allow copy from other deleter classes
inline void operator() (void *p) const
{
delete[] static_cast<X*>(p);
}
};
struct nullptr_t
{
void* __lx;
struct __nat {int __for_bool_;};
nullptr_t() : __lx(0) {}
nullptr_t(int __nat::*) : __lx(0) {}
operator int __nat::*() const {return 0;}
template <class _Tp>
operator _Tp* () const {return 0;}
template <class _Tp, class _Up>
operator _Tp _Up::* () const {return 0;}
friend bool operator==(nullptr_t, nullptr_t) {return true;}
friend bool operator!=(nullptr_t, nullptr_t) {return false;}
friend bool operator<(nullptr_t, nullptr_t) {return false;}
friend bool operator<=(nullptr_t, nullptr_t) {return true;}
friend bool operator>(nullptr_t, nullptr_t) {return false;}
friend bool operator>=(nullptr_t, nullptr_t) {return true;}
};
inline nullptr_t __get_nullptr_t() {return nullptr_t(0);}
#define nullptr std::__get_nullptr_t()
// "Cast" anything as an rvalue reference.
template<typename T> inline typename remove_reference<T>::type&& move(T&& t)
{ return static_cast<typename std::remove_reference<T>::type&&>(t); }
template<typename T, typename D = default_delete<T>> class unique_ptr
: private D // use empty base optimization
{
public:
// Default constructor
unique_ptr() {}
// Implicit constrution from nullptr
unique_ptr(nullptr_t) {}
// Explicit constructor from pointer and optional deleter
explicit unique_ptr(T *p_)
: p{ p_ } {}
explicit unique_ptr(T *p_, const D &d)
: D(d), p{ p_ } {}
// Template constructors for upcasting
template<typename U>
explicit unique_ptr(U* p_)
: p{ p_ } {}
template<typename U>
explicit unique_ptr(U* p_, const D& d)
: D(d), p{ p_ } {}
// Copy is disallowed
unique_ptr(const unique_ptr &) PROHIBITED;
unique_ptr& operator= (const unique_ptr &) PROHIBITED;
// But move is allowed!
unique_ptr(unique_ptr &&that)
: D(move(that.get_deleter())), p{ that.release() } { }
unique_ptr& operator= (unique_ptr &&that)
{
if (this != &that) {
get_deleter()(p);
((D&)*this) = move(that.get_deleter());
p = that.release();
}
return *this;
}
// Assign null
unique_ptr& operator= (nullptr_t)
{
get_deleter()(p);
p = nullptr;
return *this;
}
// Template versions of move for upcasting
template<typename U, typename E>
unique_ptr(unique_ptr<U, E> &&that)
: D(move(that.get_deleter())), p{ that.release() } { }
template<typename U, typename E>
unique_ptr& operator= (unique_ptr<U, E> &&that)
{
// Skip the self-assignment test -- self-assignment should go to the non-template overload
get_deleter()(p);
p = that.release();
get_deleter() = move(that.get_deleter());
return *this;
}
D& get_deleter() { return *this; }
const D& get_deleter() const { return *this; }
~unique_ptr() { get_deleter()(p); }
T* operator -> () const { return p; }
T& operator * () const { return *p; }
T* get() const { return p; }
// So you can say if(p)
explicit operator bool() const { return p != nullptr; }
// Give up ownership, don't destroy
T* release() { T* result = p; p = nullptr; return result; }
void reset(T* __p = nullptr)
{
T* old__p = p;
p = __p;
if (old__p != nullptr)
{
get_deleter()(old__p);
}
}
void swap(unique_ptr& that)
{
std::swap(p, that.p);
std::swap(get_deleter(), that.get_deleter());
}
private:
T *p{};
};
// Now specialize the class for array types
template<typename T, typename D> class unique_ptr<T[], D>
: private D // use empty base optimization
{
public:
// Default constructor
unique_ptr() {}
// Implicit constrution from nullptr
unique_ptr(nullptr_t) {}
// Explicit constructor from pointer
explicit unique_ptr(T *p_)
: p{ p_ } {}
explicit unique_ptr(T *p_, const D &d)
: D( d ), p{ p_ } {}
// NO template constructor for upcasting!
// Copy is disallowed
unique_ptr(const unique_ptr &) PROHIBITED;
unique_ptr& operator= (const unique_ptr &)PROHIBITED;
// But move is allowed!
unique_ptr(unique_ptr &&that)
: D( move(that.get_deleter()) ), p{ that.release() } { }
unique_ptr& operator= (unique_ptr &&that)
{
if (this != &that) {
get_deleter()(p);
p = that.release();
((D&)*this) = move(that.get_deleter());
}
return *this;
}
// Assign null
unique_ptr& operator= (nullptr_t)
{
get_deleter()(p);
p = nullptr;
return *this;
}
D& get_deleter() { return *this; }
const D& get_deleter() const { return *this; }
// NO template versions of move for upcasting!
~unique_ptr() { get_deleter()(p); }
// No operator ->, but [] instead
T& operator [] (size_t n) const { return p[n]; }
T& operator * () const { return *p; }
T* get() const { return p; }
// So you can say if(p)
explicit operator bool() const { return p != nullptr; }
// Give up ownership, don't destroy
T* release() { T* result = p; p = nullptr; return result; }
void reset(T* __p = nullptr)
{
T* old__p = p;
p = __p;
if (old__p != nullptr)
{
get_deleter()(old__p);
}
}
void swap(unique_ptr& that)
{
std::swap(p, that.p);
std::swap(get_deleter(), that.get_deleter());
}
private:
T *p{};
};
// Equality operators for unique_ptr, don't need the specializations for array case
template<typename U, typename E>
inline bool operator== (nullptr_t, const unique_ptr<U, E>& ptr)
{
return ptr.get() == nullptr;
}
template<typename U, typename E>
inline bool operator== (const unique_ptr<U, E>& ptr, nullptr_t)
{
return ptr.get() == nullptr;
}
template<typename U, typename E, typename V, typename F>
inline bool operator == (const unique_ptr<U, E> &ptr1,
const unique_ptr<V, F> &ptr2)
{
return ptr1.get() == ptr2.get();
}
template<typename U, typename E> inline bool operator != (nullptr_t, const unique_ptr<U, E> &ptr) { return !(ptr == nullptr); }
template<typename U, typename E> inline bool operator != (const unique_ptr<U, E> &ptr, nullptr_t) { return !(ptr == nullptr); }
template<typename U, typename E, typename V, typename F> inline bool operator != (const unique_ptr<U, E>& ptr1, const unique_ptr<V, F> &ptr2)
{ return !(ptr1 == ptr2); }
// Forward -- pass along rvalue references as rvalue references, anything else as it is
// (Because the appropriate overload is taken, and "reference collapse" applies to the return type)
template<typename T> inline T&& forward(typename remove_reference<T>::type& t)
{ return static_cast<T&&>(t); }
template<typename T> inline T&& forward(typename remove_reference<T>::type&& t)
{ return static_cast<T&&>(t); }
// Declared but never defined, and typically used in decltype constructs
template<typename T>
typename std::add_rvalue_reference<T>::type declval() //noexcept
;
// We need make_shared for ourselves, because the library doesn't use variadics
template<typename X, typename... Args> inline shared_ptr<X> make_shared(Args&&... args)
{
return shared_ptr<X>{ safenew X(forward<Args>(args)...) };
}
// From LLVM c++11 and modified
#include <cstddef>
template<class _Ep>
class initializer_list
{
const _Ep* __begin_;
size_t __size_;
initializer_list(const _Ep* __b, size_t __s)
: __begin_(__b),
__size_(__s)
{}
public:
typedef _Ep value_type;
typedef const _Ep& reference;
typedef const _Ep& const_reference;
typedef size_t size_type;
typedef const _Ep* iterator;
typedef const _Ep* const_iterator;
initializer_list() : __begin_(nullptr), __size_(0) {}
size_t size() const {return __size_;}
const _Ep* begin() const {return __begin_;}
const _Ep* end() const {return __begin_ + __size_;}
};
template<class _Ep>
inline
const _Ep*
begin(initializer_list<_Ep> __il)
{
return __il.begin();
}
template<class _Ep>
inline
const _Ep*
end(initializer_list<_Ep> __il)
{
return __il.end();
}
}
#else
// To define function
#include <functional>
#endif
#if !(_MSC_VER >= 1800 || __cplusplus >= 201402L)
/* replicate the very useful C++14 make_unique for those build environments
that don't implement it yet.
@ -1185,27 +783,20 @@ make_value_transform_iterator(const Iterator &iterator, Function function)
return { iterator, NewFunction{ function } };
}
#if !wxCHECK_VERSION(3, 1, 0)
// For using std::unordered_map on wxString
namespace std
{
#ifdef __AUDACITY_OLD_STD__
namespace tr1
{
#endif
#if !wxCHECK_VERSION(3, 1, 0)
template<typename T> struct hash;
template<> struct hash< wxString > {
size_t operator () (const wxString &str) const // noexcept
{
auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch
using Hasher = hash< decltype(stdstr) >;
return Hasher{}( stdstr );
}
};
#endif
#ifdef __AUDACITY_OLD_STD__
}
#endif
template<typename T> struct hash;
template<> struct hash< wxString > {
size_t operator () (const wxString &str) const // noexcept
{
auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch
using Hasher = hash< decltype(stdstr) >;
return Hasher{}( stdstr );
}
};
}
#endif
#endif // __AUDACITY_MEMORY_X_H__

View File

@ -1437,7 +1437,7 @@ void MixerBoard::LoadMusicalInstruments()
auto bmp = std::make_unique<wxBitmap>(data.bitmap);
dc.SelectObject(*bmp);
AColor::Bevel(dc, false, bev);
mMusicalInstruments.push_back(make_movable<MusicalInstrument>(
mMusicalInstruments.push_back(std::make_unique<MusicalInstrument>(
std::move(bmp), data.name
));
};

View File

@ -163,7 +163,7 @@ public:
wxArrayString mKeywords;
};
using MusicalInstrumentArray = std::vector<movable_ptr<MusicalInstrument>>;
using MusicalInstrumentArray = std::vector<std::unique_ptr<MusicalInstrument>>;

View File

@ -287,7 +287,7 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler)
ModulePrefs::SetModuleStatus( files[i], kModuleFailed );
#endif
auto umodule = make_movable<Module>(files[i]);
auto umodule = std::make_unique<Module>(files[i]);
if (umodule->Load()) // it will get rejected if there are version problems
{
auto module = umodule.get();
@ -421,7 +421,7 @@ void ModuleManager::InitializeBuiltins()
ModuleInterface *ModuleManager::LoadModule(const wxString & path)
{
auto lib = make_movable<wxDynamicLibrary>();
auto lib = std::make_unique<wxDynamicLibrary>();
if (lib->Load(path, wxDL_NOW))
{

View File

@ -66,13 +66,13 @@ struct ModuleInterfaceDeleter {
void operator ()(ModuleInterface *pInterface) const;
};
using ModuleInterfaceHandle = movable_ptr_with_deleter<
using ModuleInterfaceHandle = std::unique_ptr<
ModuleInterface, ModuleInterfaceDeleter
>;
typedef std::map<wxString, ModuleMain *> ModuleMainMap;
typedef std::map<wxString, ModuleInterfaceHandle> ModuleMap;
typedef std::map<ModuleInterface *, movable_ptr<wxDynamicLibrary>> LibraryMap;
typedef std::map<ModuleInterface *, std::unique_ptr<wxDynamicLibrary>> LibraryMap;
class ModuleManager final : public ModuleManagerInterface
{
@ -126,7 +126,7 @@ private:
ModuleMap mDynModules;
LibraryMap mLibs;
std::vector<movable_ptr<Module>> mModules;
std::vector<std::unique_ptr<Module>> mModules;
};
#endif /* __AUDACITY_MODULEMANAGER_H__ */

View File

@ -56,9 +56,7 @@ for shared and private configs - which need to move out.
#include "Experimental.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
using ProviderMap = std::unordered_map<wxString, wxArrayString>;

View File

@ -96,7 +96,7 @@ TaskProfile* Profiler::GetOrCreateTaskProfile(const char* fileName, int lineNum)
return mTasks[i].get();
}
auto tp = make_movable<TaskProfile>();
auto tp = std::make_unique<TaskProfile>();
mTasks.push_back(std::move(tp));
return mTasks.back().get();
}

View File

@ -60,7 +60,7 @@ class Profiler
TaskProfile* GetTaskProfileByDescription(const char* description);
//List of current Task to do.
std::vector<movable_ptr<TaskProfile>> mTasks;
std::vector<std::unique_ptr<TaskProfile>> mTasks;
//mutex for above variable
ODLock mTasksMutex;

View File

@ -3402,7 +3402,7 @@ void AudacityProject::EnqueueODTasks()
TrackListIterator triter(GetTracks());
tr = triter.First();
std::vector<movable_ptr<ODTask>> newTasks;
std::vector<std::unique_ptr<ODTask>> newTasks;
//std::vector<ODDecodeTask*> decodeTasks;
unsigned int createdODTasks=0;
while (tr) {
@ -3422,16 +3422,16 @@ void AudacityProject::EnqueueODTasks()
//we want at most one instance of each class for the project
while((odFlags|createdODTasks) != createdODTasks)
{
movable_ptr<ODTask> newTask;
std::unique_ptr<ODTask> newTask;
#ifdef EXPERIMENTAL_OD_FLAC
if(!(createdODTasks&ODTask::eODFLAC) && (odFlags & ODTask::eODFLAC)) {
newTask = make_movable<ODDecodeFlacTask>();
newTask = std::make_unique<ODDecodeFlacTask>();
createdODTasks = createdODTasks | ODTask::eODFLAC;
}
else
#endif
if(!(createdODTasks&ODTask::eODPCMSummary) && (odFlags & ODTask::eODPCMSummary)) {
newTask = make_movable<ODComputeSummaryTask>();
newTask = std::make_unique<ODComputeSummaryTask>();
createdODTasks= createdODTasks | ODTask::eODPCMSummary;
}
else {
@ -4039,7 +4039,7 @@ bool AudacityProject::DoSave
// (Otherwise the NEW project would be fine, but the old one would
// be empty of all of its files.)
std::vector<movable_ptr<WaveTrack::Locker>> lockers;
std::vector<std::unique_ptr<WaveTrack::Locker>> lockers;
if (mLastSavedTracks) {
lockers.reserve(mLastSavedTracks->size());
TrackListIterator iter(mLastSavedTracks.get());
@ -4047,7 +4047,7 @@ bool AudacityProject::DoSave
while (t) {
if (t->GetKind() == Track::Wave)
lockers.push_back(
make_movable<WaveTrack::Locker>(
std::make_unique<WaveTrack::Locker>(
static_cast<const WaveTrack*>(t)));
t = iter.Next();
}
@ -4666,7 +4666,7 @@ void AudacityProject::PopState(const UndoState &state)
TrackListIterator iter(tracks);
Track *t = iter.First();
bool odUsed = false;
movable_ptr<ODComputeSummaryTask> computeTask;
std::unique_ptr<ODComputeSummaryTask> computeTask;
while (t)
{
@ -4686,7 +4686,7 @@ void AudacityProject::PopState(const UndoState &state)
{
if(!odUsed)
{
computeTask = make_movable<ODComputeSummaryTask>();
computeTask = std::make_unique<ODComputeSummaryTask>();
odUsed=true;
}
// PRL: Is it correct to add all tracks to one task, even if they

View File

@ -102,7 +102,7 @@ HFFT InitializeFFT(size_t fftlen)
enum : size_t { MAX_HFFT = 10 };
// Maintain a pool:
static std::vector< movable_ptr<FFTParam> > hFFTArray(MAX_HFFT);
static std::vector< std::unique_ptr<FFTParam> > hFFTArray(MAX_HFFT);
wxCriticalSection getFFTMutex;
/* Get a handle to the FFT tables of the desired length */

View File

@ -41,9 +41,7 @@
#include "widgets/wxPanelWrapper.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
class wxButton;
class wxChoice;

View File

@ -36,9 +36,7 @@ UndoManager
#include "UndoManager.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_set>
#endif
using ConstBlockFilePtr = const BlockFile*;
using Set = std::unordered_set<ConstBlockFilePtr>;
@ -290,7 +288,7 @@ void UndoManager::PushState(const TrackList * l,
// Assume tags was duplicted before any changes.
// Just save a NEW shared_ptr to it.
stack.push_back(
make_movable<UndoStackElem>
std::make_unique<UndoStackElem>
(std::move(tracksCopy),
longDescription, shortDescription, selectedRegion, tags)
);

View File

@ -72,7 +72,7 @@ struct UndoState {
SelectedRegion selectedRegion; // by value
};
using UndoStack = std::vector <movable_ptr<UndoStackElem>>;
using UndoStack = std::vector <std::unique_ptr<UndoStackElem>>;
using SpaceArray = std::vector <unsigned long long> ;

View File

@ -13,12 +13,6 @@ UserException::~UserException()
{
}
std::unique_ptr< AudacityException > UserException::Move()
{
return std::unique_ptr< AudacityException >
{ safenew UserException{ std::move( *this ) } };
}
void UserException::DelayedHandlerAction()
{
}

View File

@ -30,9 +30,6 @@ public:
~UserException() override;
void DelayedHandlerAction() override;
private:
std::unique_ptr< AudacityException > Move() override;
};
#endif

View File

@ -333,7 +333,7 @@ WaveClip::WaveClip(const WaveClip& orig,
if ( copyCutlines )
for (const auto &clip: orig.mCutLines)
mCutLines.push_back
( make_movable<WaveClip>( *clip, projDirManager, true ) );
( std::make_unique<WaveClip>( *clip, projDirManager, true ) );
mIsPlaceholder = orig.GetIsPlaceholder();
}
@ -377,7 +377,7 @@ WaveClip::WaveClip(const WaveClip& orig,
if (cutlinePosition >= t0 && cutlinePosition <= t1)
{
auto newCutLine =
make_movable< WaveClip >( *clip, projDirManager, true );
std::make_unique< WaveClip >( *clip, projDirManager, true );
newCutLine->SetOffset( cutlinePosition - t0 );
mCutLines.push_back(std::move(newCutLine));
}
@ -1552,7 +1552,7 @@ XMLTagHandler *WaveClip::HandleXMLChild(const wxChar *tag)
{
// Nested wave clips are cut lines
mCutLines.push_back(
make_movable<WaveClip>(mSequence->GetDirManager(),
std::make_unique<WaveClip>(mSequence->GetDirManager(),
mSequence->GetSampleFormat(), mRate, 0 /*colourindex*/));
return mCutLines.back().get();
}
@ -1608,7 +1608,7 @@ void WaveClip::Paste(double t0, const WaveClip* other)
for (const auto &cutline: pastedClip->mCutLines)
{
newCutlines.push_back(
make_movable<WaveClip>
std::make_unique<WaveClip>
( *cutline, mSequence->GetDirManager(),
// Recursively copy cutlines of cutlines. They don't need
// their offsets adjusted.
@ -1745,7 +1745,7 @@ void WaveClip::ClearAndAddCutLine(double t0, double t1)
const double clip_t0 = std::max( t0, GetStartTime() );
const double clip_t1 = std::min( t1, GetEndTime() );
auto newClip = make_movable< WaveClip >
auto newClip = std::make_unique< WaveClip >
(*this, mSequence->GetDirManager(), true, clip_t0, clip_t1);
newClip->SetOffset( clip_t0 - mOffset );

View File

@ -141,7 +141,7 @@ WaveTrack::WaveTrack(const WaveTrack &orig):
for (const auto &clip : orig.mClips)
mClips.push_back
( make_movable<WaveClip>( *clip, mDirManager, true ) );
( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
}
// Copy the track metadata but not the contents.
@ -625,7 +625,7 @@ Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const
//wxPrintf("copy: clip %i is in copy region\n", (int)clip);
newTrack->mClips.push_back
(make_movable<WaveClip>(*clip, mDirManager, ! forClipboard));
(std::make_unique<WaveClip>(*clip, mDirManager, ! forClipboard));
WaveClip *const newClip = newTrack->mClips.back().get();
newClip->Offset(-t0);
}
@ -637,7 +637,7 @@ Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const
const double clip_t0 = std::max(t0, clip->GetStartTime());
const double clip_t1 = std::min(t1, clip->GetEndTime());
auto newClip = make_movable<WaveClip>
auto newClip = std::make_unique<WaveClip>
(*clip, mDirManager, ! forClipboard, clip_t0, clip_t1);
//wxPrintf("copy: clip_t0=%f, clip_t1=%f\n", clip_t0, clip_t1);
@ -657,7 +657,7 @@ Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const
if (forClipboard &&
newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0)
{
auto placeholder = make_movable<WaveClip>(mDirManager,
auto placeholder = std::make_unique<WaveClip>(mDirManager,
newTrack->GetSampleFormat(),
static_cast<int>(newTrack->GetRate()),
0 /*colourindex*/);
@ -1049,7 +1049,7 @@ void WaveTrack::HandleClear(double t0, double t1,
// Don't modify this clip in place, because we want a strong
// guarantee, and might modify another clip
clipsToDelete.push_back( clip.get() );
auto newClip = make_movable<WaveClip>( *clip, mDirManager, true );
auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
newClip->ClearAndAddCutLine( t0, t1 );
clipsToAdd.push_back( std::move( newClip ) );
}
@ -1064,7 +1064,7 @@ void WaveTrack::HandleClear(double t0, double t1,
// Don't modify this clip in place, because we want a strong
// guarantee, and might modify another clip
clipsToDelete.push_back( clip.get() );
auto newClip = make_movable<WaveClip>( *clip, mDirManager, true );
auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
newClip->Clear(clip->GetStartTime(), t1);
newClip->Offset(t1-clip->GetStartTime());
@ -1076,7 +1076,7 @@ void WaveTrack::HandleClear(double t0, double t1,
// Don't modify this clip in place, because we want a strong
// guarantee, and might modify another clip
clipsToDelete.push_back( clip.get() );
auto newClip = make_movable<WaveClip>( *clip, mDirManager, true );
auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
newClip->Clear(t0, clip->GetEndTime());
clipsToAdd.push_back( std::move( newClip ) );
@ -1087,12 +1087,12 @@ void WaveTrack::HandleClear(double t0, double t1,
// left
clipsToAdd.push_back
( make_movable<WaveClip>( *clip, mDirManager, true ) );
( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
clipsToAdd.back()->Clear(t0, clip->GetEndTime());
// right
clipsToAdd.push_back
( make_movable<WaveClip>( *clip, mDirManager, true ) );
( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
WaveClip *const right = clipsToAdd.back().get();
right->Clear(clip->GetStartTime(), t1);
right->Offset(t1 - clip->GetStartTime());
@ -1106,7 +1106,7 @@ void WaveTrack::HandleClear(double t0, double t1,
// Don't modify this clip in place, because we want a strong
// guarantee, and might modify another clip
clipsToDelete.push_back( clip.get() );
auto newClip = make_movable<WaveClip>( *clip, mDirManager, true );
auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
// clip->Clear keeps points < t0 and >= t1 via Envelope::CollapseRegion
newClip->Clear(t0,t1);
@ -1339,7 +1339,7 @@ void WaveTrack::Paste(double t0, const Track *src)
if (!clip->GetIsPlaceholder())
{
auto newClip =
make_movable<WaveClip>( *clip, mDirManager, true );
std::make_unique<WaveClip>( *clip, mDirManager, true );
newClip->Resample(mRate);
newClip->Offset(t0);
newClip->MarkChanged();
@ -1395,7 +1395,7 @@ void WaveTrack::InsertSilence(double t, double len)
if (mClips.empty())
{
// Special case if there is no clip yet
auto clip = make_movable<WaveClip>(mDirManager, mFormat, mRate, this->GetWaveColorIndex());
auto clip = std::make_unique<WaveClip>(mDirManager, mFormat, mRate, this->GetWaveColorIndex());
clip->InsertSilence(0, len);
// use NOFAIL-GUARANTEE
mClips.push_back( std::move( clip ) );
@ -2228,7 +2228,7 @@ Sequence* WaveTrack::GetSequenceAtX(int xcoord)
WaveClip* WaveTrack::CreateClip()
{
mClips.push_back(make_movable<WaveClip>(mDirManager, mFormat, mRate, GetWaveColorIndex()));
mClips.push_back(std::make_unique<WaveClip>(mDirManager, mFormat, mRate, GetWaveColorIndex()));
return mClips.back().get();
}
@ -2388,7 +2388,7 @@ void WaveTrack::SplitAt(double t)
if (c->WithinClip(t))
{
t = LongSamplesToTime(TimeToLongSamples(t)); // put t on a sample
auto newClip = make_movable<WaveClip>( *c, mDirManager, true );
auto newClip = std::make_unique<WaveClip>( *c, mDirManager, true );
c->Clear(t, c->GetEndTime());
newClip->Clear(c->GetStartTime(), t);

View File

@ -14,12 +14,6 @@ NotYetAvailableException::~NotYetAvailableException()
{
}
std::unique_ptr< AudacityException > NotYetAvailableException::Move()
{
return std::unique_ptr< AudacityException >
{ safenew NotYetAvailableException{ std::move( *this ) } };
}
wxString NotYetAvailableException::ErrorMessage() const
{
return wxString::Format(

View File

@ -25,7 +25,6 @@ public:
~NotYetAvailableException();
protected:
std::unique_ptr< AudacityException > Move() override;
wxString ErrorMessage() const override;
};

View File

@ -59,9 +59,7 @@ ShuttleGui.
#include "../Experimental.h"
#include "../commands/ScreenshotCommand.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
#include "../commands/CommandContext.h"
AudacityCommand::AudacityCommand()

View File

@ -24,11 +24,11 @@ IdentInterfaceSymbol BatchEvalCommandType::BuildName()
void BatchEvalCommandType::BuildSignature(CommandSignature &signature)
{
auto commandNameValidator = make_movable<DefaultValidator>();
auto commandNameValidator = std::make_unique<DefaultValidator>();
signature.AddParameter(wxT("CommandName"), wxT(""), std::move(commandNameValidator));
auto paramValidator = make_movable<DefaultValidator>();
auto paramValidator = std::make_unique<DefaultValidator>();
signature.AddParameter(wxT("ParamString"), wxT(""), std::move(paramValidator));
auto macroValidator = make_movable<DefaultValidator>();
auto macroValidator = std::make_unique<DefaultValidator>();
signature.AddParameter(wxT("MacroName"), wxT(""), std::move(macroValidator));
}

View File

@ -28,38 +28,38 @@ CommandDirectory::CommandDirectory()
{
// Create the command map.
// First we have commands which return information
//AddCommand(make_movable<MessageCommandType>());
AddCommand(make_movable<BatchEvalCommandType>());
//AddCommand(std::make_unique<MessageCommandType>());
AddCommand(std::make_unique<BatchEvalCommandType>());
// Legacy adapter commands that previously was needed to
// access menu items.
//AddCommand(make_movable<ExecMenuCommandType>());
//AddCommand(std::make_unique<ExecMenuCommandType>());
// Not needed. Sets selected/solo/mute on multiple tracks.
//AddCommand(make_movable<SetProjectInfoCommandType>());
//AddCommand(std::make_unique<SetProjectInfoCommandType>());
// Moved to AudacityCommand
// AddCommand(make_movable<OpenProjectCommandType>());
// AddCommand(make_movable<SaveProjectCommandType>());
// AddCommand(make_movable<ImportCommandType>());
// AddCommand(make_movable<ExportCommandType>());
// AddCommand(make_movable<HelpCommandType>());
// AddCommand(make_movable<GetInfoCommandType>("GetAll"));
// AddCommand(make_movable<GetInfoCommandType>("GetCommands"));
// AddCommand(make_movable<GetInfoCommandType>("GetMenus"));
// AddCommand(make_movable<GetInfoCommandType>("GetMenusPlus"));
// AddCommand(make_movable<GetInfoCommandType>("GetBoxes"));
// AddCommand(make_movable<GetInfoCommandType>("GetClips"));
// AddCommand(std::make_unique<OpenProjectCommandType>());
// AddCommand(std::make_unique<SaveProjectCommandType>());
// AddCommand(std::make_unique<ImportCommandType>());
// AddCommand(std::make_unique<ExportCommandType>());
// AddCommand(std::make_unique<HelpCommandType>());
// AddCommand(std::make_unique<GetInfoCommandType>("GetAll"));
// AddCommand(std::make_unique<GetInfoCommandType>("GetCommands"));
// AddCommand(std::make_unique<GetInfoCommandType>("GetMenus"));
// AddCommand(std::make_unique<GetInfoCommandType>("GetMenusPlus"));
// AddCommand(std::make_unique<GetInfoCommandType>("GetBoxes"));
// AddCommand(std::make_unique<GetInfoCommandType>("GetClips"));
// AddCommand(make_movable<GetTrackInfoCommandType>());
// AddCommand(make_movable<GetProjectInfoCommandType>());
// AddCommand(make_movable<CompareAudioCommandType>());
// AddCommand(make_movable<GetPreferenceCommandType>());
// AddCommand(make_movable<SetPreferenceCommandType>());
// AddCommand(make_movable<ScreenshotCommandType>());
// AddCommand(make_movable<SelectCommandType>());
// AddCommand(make_movable<SetTrackInfoCommandType>());
// AddCommand(std::make_unique<GetTrackInfoCommandType>());
// AddCommand(std::make_unique<GetProjectInfoCommandType>());
// AddCommand(std::make_unique<CompareAudioCommandType>());
// AddCommand(std::make_unique<GetPreferenceCommandType>());
// AddCommand(std::make_unique<SetPreferenceCommandType>());
// AddCommand(std::make_unique<ScreenshotCommandType>());
// AddCommand(std::make_unique<SelectCommandType>());
// AddCommand(std::make_unique<SetTrackInfoCommandType>());
}
@ -77,7 +77,7 @@ OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const
return iter->second.get();
}
void CommandDirectory::AddCommand(movable_ptr<OldStyleCommandType> &&type)
void CommandDirectory::AddCommand(std::unique_ptr<OldStyleCommandType> &&type)
{
wxASSERT(type != NULL);
// Internal string is shown but only in assertion message

View File

@ -44,7 +44,7 @@ public:
OldStyleCommandType *LookUp(const wxString &cmdName) const;
/// Register a type of command with the directory.
void AddCommand(movable_ptr<OldStyleCommandType> &&type);
void AddCommand(std::unique_ptr<OldStyleCommandType> &&type);
/// Get a pointer to the singleton instance
static CommandDirectory *Get();

View File

@ -566,11 +566,7 @@ std::unique_ptr<wxMenuBar> CommandManager::AddMenuBar(const wxString & sMenu)
}
auto result = std::make_unique<wxMenuBar>();
#ifdef __AUDACITY_OLD_STD__
mMenuBarList.push_back(MenuBarListEntry{sMenu, result.get()});
#else
mMenuBarList.emplace_back(sMenu, result.get());
#endif
return result;
}
@ -635,7 +631,7 @@ void CommandManager::EndMenu()
wxMenu* CommandManager::BeginSubMenu(const wxString & tName)
{
mSubMenuList.push_back
(make_movable< SubMenuListEntry > ( tName, std::make_unique<wxMenu>() ));
(std::make_unique< SubMenuListEntry > ( tName, std::make_unique<wxMenu>() ));
mbSeparatorAllowed = false;
return mSubMenuList.back()->menu.get();
}
@ -1018,7 +1014,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & nameIn,
{
// Make a unique_ptr or shared_ptr as appropriate:
auto entry = make_movable<CommandListEntry>();
auto entry = std::make_unique<CommandListEntry>();
wxString labelPrefix;
if (!mSubMenuList.empty()) {

View File

@ -28,9 +28,7 @@
#include "audacity/Types.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
using CommandParameter = wxString;
class TranslatedInternalString;
@ -92,29 +90,14 @@ struct CommandListEntry
using MenuBarList = std::vector < MenuBarListEntry >;
// to do: remove the extra indirection when Mac compiler moves to newer version
using SubMenuList = std::vector < movable_ptr<SubMenuListEntry> >;
using SubMenuList = std::vector < std::unique_ptr<SubMenuListEntry> >;
// This is an array of pointers, not structures, because the hash maps also point to them,
// so we don't want the structures to relocate with vector operations.
using CommandList = std::vector<movable_ptr<CommandListEntry>>;
using CommandList = std::vector<std::unique_ptr<CommandListEntry>>;
namespace std
{
#ifdef __AUDACITY_OLD_STD__
namespace tr1
{
template<typename T> struct hash;
template<> struct hash< NormalizedKeyString > {
size_t operator () (const NormalizedKeyString &str) const // noexcept
{
auto &stdstr = str.Raw(); // no allocations, a cheap fetch
using Hasher = hash< wxString >;
return Hasher{}( stdstr );
}
};
}
#else
// in std, not in tr1.
template<> struct hash< NormalizedKeyString > {
size_t operator () (const NormalizedKeyString &str) const // noexcept
{
@ -123,7 +106,6 @@ namespace std
return Hasher{}( stdstr );
}
};
#endif
}
using CommandKeyHash = std::unordered_map<NormalizedKeyString, CommandListEntry*>;

View File

@ -29,10 +29,10 @@ typedef std::map<wxString, bool> ParamBoolMap;
// Map from parameter name to a suitable Validator
// to do: use hash
typedef std::map<wxString, movable_ptr<Validator>> ValidatorMap;
typedef std::map<wxString, std::unique_ptr<Validator>> ValidatorMap;
// Map from command name to type
// to do: use hash
typedef std::map<wxString, movable_ptr<OldStyleCommandType>> CommandMap;
typedef std::map<wxString, std::unique_ptr<OldStyleCommandType>> CommandMap;
#endif /* End of include guard: __COMMANDMISC__ */

View File

@ -24,7 +24,7 @@ CommandSignature::~CommandSignature()
void CommandSignature::AddParameter(const wxString &name,
const wxVariant &dft,
movable_ptr<Validator> &&valid)
std::unique_ptr<Validator> &&valid)
{
wxASSERT_MSG(valid->Validate(dft),
wxT("Invalid command signature: the default value of '")

View File

@ -41,7 +41,7 @@ public:
// valid: a suitable validator (caller doesn't need to DELETE it)
void AddParameter(const wxString &name,
const wxVariant &dft,
movable_ptr<Validator> &&valid);
std::unique_ptr<Validator> &&valid);
// Methods for accessing the signature
ParamValueMap GetDefaults() const;

View File

@ -36,7 +36,7 @@ threshold of difference in two selected tracks
#include "CommandContext.h"
extern void RegisterCompareAudio( Registrar & R){
R.AddCommand( make_movable<CompareAudioCommand>() );
R.AddCommand( std::make_unique<CompareAudioCommand>() );
// std::unique_ptr<CommandOutputTargets> &&target
// return std::make_shared<CompareAudioCommand>(*this, std::move(target));

View File

@ -68,9 +68,7 @@ greater use in future.
#include "../Experimental.h"
#include "../commands/ScreenshotCommand.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
static const int kDummyID = 20000;
static const int kSaveAsID = 20001;
@ -2127,12 +2125,7 @@ Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack
// So it's okay that we cast it back to const
mpOrigTrack =
pEffect->mTracks->Replace(const_cast<LabelTrack*>(pOrigTrack),
#ifdef __AUDACITY_OLD_STD__
std::shared_ptr<Track>(newTrack.release())
#else
std::move(newTrack)
#endif
);
std::move(newTrack) );
}
Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that)

View File

@ -25,9 +25,7 @@
#include "../PluginManager.h"
#include "Effect.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
class AudacityCommand;
class CommandContext;

View File

@ -343,7 +343,7 @@ private:
FloatVector mRealFFTs;
FloatVector mImagFFTs;
};
std::vector<movable_ptr<Record>> mQueue;
std::vector<std::unique_ptr<Record>> mQueue;
};
/****************************************************************//**
@ -801,7 +801,7 @@ EffectNoiseReduction::Worker::Worker
mQueue.resize(mHistoryLen);
for (unsigned ii = 0; ii < mHistoryLen; ++ii)
mQueue[ii] = make_movable<Record>(mSpectrumSize);
mQueue[ii] = std::make_unique<Record>(mSpectrumSize);
// Create windows

View File

@ -62,8 +62,7 @@ public:
std::unique_ptr<WaveTrack> outputLeftTrack;
std::unique_ptr<WaveTrack> outputRightTrack;
wxFileName failedFileName;
bool error{ false };
std::exception_ptr mpException {};
};
class SBSMSEffectInterface final : public SBSMSInterfaceSliding {
@ -100,23 +99,16 @@ long resampleCB(void *cb_data, SBSMSFrame *data)
// I don't know if we can safely propagate errors through sbsms, and it
// does not seem to let us report error codes, so use this roundabout to
// stop the effect early.
// This would be easier with std::exception_ptr but we don't have that yet.
try {
r->leftTrack->Get(
(samplePtr)(r->leftBuffer.get()), floatSample, r->offset, blockSize);
r->rightTrack->Get(
(samplePtr)(r->rightBuffer.get()), floatSample, r->offset, blockSize);
}
catch ( const FileException& e ) {
if ( e.cause == FileException::Cause::Read )
r->failedFileName = e.fileName;
data->size = 0;
r->error = true;
return 0;
}
catch ( ... ) {
// Save the exception object for re-throw when out of the library
r->mpException = std::current_exception();
data->size = 0;
r->error = true;
return 0;
}
@ -425,15 +417,13 @@ bool EffectSBSMS::Process()
if (TrackProgress(nWhichTrack, frac))
return false;
}
if (rb.failedFileName.IsOk())
// re-construct an exception
// I wish I had std::exception_ptr instead
// and could re-throw any AudacityException
throw FileException{
FileException::Cause::Read, rb.failedFileName };
else if (rb.error)
// well, what?
bGoodResult = false;
{
auto pException = rb.mpException;
rb.mpException = {};
if (pException)
std::rethrow_exception(pException);
}
if (bGoodResult) {
rb.outputLeftTrack->Flush();

View File

@ -1455,7 +1455,7 @@ bool VSTEffect::RealtimeInitialize()
bool VSTEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate)
{
mSlaves.push_back(make_movable<VSTEffect>(mPath, this));
mSlaves.push_back(std::make_unique<VSTEffect>(mPath, this));
VSTEffect *const slave = mSlaves.back().get();
slave->SetBlockSize(mBlockSize);

View File

@ -64,7 +64,7 @@ struct __CFBundle;
//
///////////////////////////////////////////////////////////////////////////////
using VSTEffectArray = std::vector < movable_ptr<VSTEffect> > ;
using VSTEffectArray = std::vector < std::unique_ptr<VSTEffect> > ;
DECLARE_LOCAL_EVENT_TYPE(EVT_SIZEWINDOW, -1);
DECLARE_LOCAL_EVENT_TYPE(EVT_UPDATEDISPLAY, -1);

View File

@ -1346,7 +1346,7 @@ bool AudioUnitEffect::RealtimeInitialize()
bool AudioUnitEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate)
{
auto slave = make_movable<AudioUnitEffect>(mPath, mName, mComponent, this);
auto slave = std::make_unique<AudioUnitEffect>(mPath, mName, mComponent, this);
if (!slave->SetHost(NULL))
return false;

View File

@ -34,7 +34,7 @@
class AudioUnitEffect;
using AudioUnitEffectArray = std::vector<movable_ptr<AudioUnitEffect>>;
using AudioUnitEffectArray = std::vector<std::unique_ptr<AudioUnitEffect>>;
class AudioUnitEffectExportDialog;
class AudioUnitEffectImportDialog;

View File

@ -38,9 +38,7 @@
#include "LoadLV2.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
#define LV2EFFECTS_VERSION wxT("1.0.0.0")
/* i18n-hint: abbreviates
@ -294,7 +292,7 @@ private:
bool mUseGUI;
std::vector< movable_ptr_with_deleter<char, freer> > mURIMap;
std::vector< std::unique_ptr<char, freer> > mURIMap;
LV2_URI_Map_Feature mUriMapFeature;
LV2_URID_Map mURIDMapFeature;
@ -308,7 +306,7 @@ private:
LV2_Options_Interface *mOptionsInterface;
std::vector<LV2_Options_Option> mOptions;
std::vector<movable_ptr<LV2_Feature>> mFeatures;
std::vector<std::unique_ptr<LV2_Feature>> mFeatures;
LV2_Feature *mInstanceAccessFeature;
LV2_Feature *mParentFeature;

View File

@ -43,9 +43,7 @@ Functions that find and load all LV2 plugins on the system.
#include "LoadLV2.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
// ============================================================================
// Module registration entry point

View File

@ -967,8 +967,7 @@ bool NyquistEffect::TransferDataFromWindow()
bool NyquistEffect::ProcessOne()
{
mError = false;
mFailedFileName.Clear();
mpException = {};
nyx_rval rval;
@ -1393,15 +1392,12 @@ bool NyquistEffect::ProcessOne()
}
// See if GetCallback found read errors
if (mFailedFileName.IsOk())
// re-construct an exception
// I wish I had std::exception_ptr instead
// and could re-throw any AudacityException
throw FileException{
FileException::Cause::Read, mFailedFileName };
else if (mError)
// what, then?
success = false;
{
auto pException = mpException;
mpException = {};
if (pException)
std::rethrow_exception( pException );
}
if (!success)
return false;
@ -2156,14 +2152,9 @@ int NyquistEffect::GetCallback(float *buffer, int ch,
mCurBuffer[ch].ptr(), floatSample,
mCurBufferStart[ch], mCurBufferLen[ch]);
}
catch ( const FileException& e ) {
if ( e.cause == FileException::Cause::Read )
mFailedFileName = e.fileName;
mError = true;
return -1;
}
catch ( ... ) {
mError = true;
// Save the exception object for re-throw when out of the library
mpException = std::current_exception();
return -1;
}
}

View File

@ -275,8 +275,7 @@ private:
wxTextCtrl *mCommandText;
wxCheckBox *mVersionCheckBox;
bool mError{ false };
wxFileName mFailedFileName;
std::exception_ptr mpException {};
DECLARE_EVENT_TABLE()

View File

@ -43,10 +43,6 @@
#include "../../LabelTrack.h"
#include "../../WaveTrack.h"
#ifdef __AUDACITY_OLD_STD__
#include <list>
#endif
enum
{
ID_Program = 10000,

View File

@ -325,7 +325,7 @@ int Exporter::FindFormatIndex(int exportindex)
return 0;
}
void Exporter::RegisterPlugin(movable_ptr<ExportPlugin> &&ExportPlugin)
void Exporter::RegisterPlugin(std::unique_ptr<ExportPlugin> &&ExportPlugin)
{
mPlugins.push_back(std::move(ExportPlugin));
}

View File

@ -146,7 +146,7 @@ private:
std::vector<FormatInfo> mFormatInfos;
};
using ExportPluginArray = std::vector < movable_ptr< ExportPlugin > > ;
using ExportPluginArray = std::vector < std::unique_ptr< ExportPlugin > > ;
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API);
//----------------------------------------------------------------------------
@ -161,7 +161,7 @@ public:
void SetFileDialogTitle( const wxString & DialogTitle );
void SetDefaultFormat( const wxString & Format ){ mFormatName = Format;};
void RegisterPlugin(movable_ptr<ExportPlugin> &&plugin);
void RegisterPlugin(std::unique_ptr<ExportPlugin> &&plugin);
bool Process(AudacityProject *project, bool selectedOnly,
double t0, double t1);

View File

@ -545,8 +545,8 @@ wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format)
return safenew ExportCLOptions(parent, format);
}
movable_ptr<ExportPlugin> New_ExportCL()
std::unique_ptr<ExportPlugin> New_ExportCL()
{
return make_movable<ExportCL>();
return std::make_unique<ExportCL>();
}

View File

@ -19,6 +19,6 @@ class ExportPlugin;
* factory method New_ExportCL() which creates a NEW ExportCL object and
* returns a pointer to it. The rest of the class declaration is in ExportCL.cpp
*/
movable_ptr<ExportPlugin> New_ExportCL();
std::unique_ptr<ExportPlugin> New_ExportCL();
#endif

View File

@ -1095,9 +1095,9 @@ wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format)
return ExportPlugin::OptionsCreate(parent, format);
}
movable_ptr<ExportPlugin> New_ExportFFmpeg()
std::unique_ptr<ExportPlugin> New_ExportFFmpeg()
{
return make_movable<ExportFFmpeg>();
return std::make_unique<ExportFFmpeg>();
}
#endif

View File

@ -18,6 +18,6 @@ class ExportPlugin;
* factory method New_ExportFFmpeg() which creates a NEW ExportFFmpeg object and
* returns a pointer to it. The rest of the class declaration is in ExportFFmpeg.cpp
*/
movable_ptr<ExportPlugin> New_ExportFFmpeg();
std::unique_ptr<ExportPlugin> New_ExportFFmpeg();
#endif

View File

@ -22,9 +22,7 @@ LRN
#include "../FileNames.h"
#include "../widgets/wxPanelWrapper.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
/// Identifiers for pre-set export types.

View File

@ -450,9 +450,9 @@ bool ExportFLAC::GetMetadata(AudacityProject *project, const Tags *tags)
return true;
}
movable_ptr<ExportPlugin> New_ExportFLAC()
std::unique_ptr<ExportPlugin> New_ExportFLAC()
{
return make_movable<ExportFLAC>();
return std::make_unique<ExportFLAC>();
}
#endif // USE_LIBFLAC

View File

@ -18,7 +18,7 @@ class ExportPlugin;
* factory method New_ExportFLAC() which creates a NEW ExportFLAC object and
* returns a pointer to it. The rest of the class declaration is in ExportFLAC.cpp
*/
movable_ptr<ExportPlugin> New_ExportFLAC();
std::unique_ptr<ExportPlugin> New_ExportFLAC();
#endif

View File

@ -464,9 +464,9 @@ void ExportMP2::AddFrame(struct id3_tag *tp, const wxString & n, const wxString
}
#endif
movable_ptr<ExportPlugin> New_ExportMP2()
std::unique_ptr<ExportPlugin> New_ExportMP2()
{
return make_movable<ExportMP2>();
return std::make_unique<ExportMP2>();
}
#endif // #ifdef USE_LIBTWOLAME

View File

@ -19,7 +19,7 @@ class ExportPlugin;
* factory method New_ExportMP2() which creates a NEW ExportMP2 object and
* returns a pointer to it. The rest of the class declaration is in ExportMP2.cpp
*/
movable_ptr<ExportPlugin> New_ExportMP2();
std::unique_ptr<ExportPlugin> New_ExportMP2();
#endif

View File

@ -2158,9 +2158,9 @@ void ExportMP3::AddFrame(struct id3_tag *tp, const wxString & n, const wxString
}
#endif
movable_ptr<ExportPlugin> New_ExportMP3()
std::unique_ptr<ExportPlugin> New_ExportMP3()
{
return make_movable<ExportMP3>();
return std::make_unique<ExportMP3>();
}
//----------------------------------------------------------------------------

View File

@ -20,7 +20,7 @@ class wxWindow;
/** Factory method New_ExportMP3() which creates a NEW ExportMP3 object and
* returns a pointer to it. The rest of the class declaration is in ExportMP3.cpp
*/
movable_ptr<ExportPlugin> New_ExportMP3();
std::unique_ptr<ExportPlugin> New_ExportMP3();
//----------------------------------------------------------------------------
// Get MP3 library versioqn

View File

@ -400,9 +400,9 @@ bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, c
return true;
}
movable_ptr<ExportPlugin> New_ExportOGG()
std::unique_ptr<ExportPlugin> New_ExportOGG()
{
return make_movable<ExportOGG>();
return std::make_unique<ExportOGG>();
}
#endif // USE_LIBVORBIS

View File

@ -18,7 +18,7 @@ class ExportPlugin;
* factory method New_ExportOGG() which creates a NEW ExportOGG object and
* returns a pointer to it. The rest of the class declaration is in ExportOGG.cpp
*/
movable_ptr<ExportPlugin> New_ExportOGG();
std::unique_ptr<ExportPlugin> New_ExportOGG();
#endif

View File

@ -909,7 +909,7 @@ bool ExportPCM::CheckFileName(wxFileName &filename, int format)
return ExportPlugin::CheckFileName(filename, format);
}
movable_ptr<ExportPlugin> New_ExportPCM()
std::unique_ptr<ExportPlugin> New_ExportPCM()
{
return make_movable<ExportPCM>();
return std::make_unique<ExportPCM>();
}

View File

@ -18,7 +18,7 @@ class ExportPlugin;
* factory method New_ExportPCM() which creates a NEW ExportPCM object and
* returns a pointer to it. The rest of the class declaration is in ExportPCM.cpp
*/
movable_ptr<ExportPlugin> New_ExportPCM();
std::unique_ptr<ExportPlugin> New_ExportPCM();
#endif

View File

@ -124,13 +124,8 @@ void Importer::GetSupportedImportFormats(FormatList *formatList)
{
for(const auto &importPlugin : mImportPluginList)
{
#ifdef __AUDACITY_OLD_STD__
formatList->push_back(Format{importPlugin->GetPluginFormatDescription(),
importPlugin->GetSupportedExtensions()});
#else
formatList->emplace_back(importPlugin->GetPluginFormatDescription(),
importPlugin->GetSupportedExtensions());
#endif
}
}
@ -167,7 +162,7 @@ void Importer::ReadImportItems()
if (toker.CountTokens() != 2)
break;
auto new_item = make_movable<ExtImportItem>();
auto new_item = std::make_unique<ExtImportItem>();
/* First token is the filtering condition, second - the filter list */
condition = toker.GetNextToken();
@ -312,9 +307,9 @@ void Importer::WriteImportItems()
} while( true );
}
movable_ptr<ExtImportItem> Importer::CreateDefaultImportItem()
std::unique_ptr<ExtImportItem> Importer::CreateDefaultImportItem()
{
auto new_item = make_movable<ExtImportItem>();
auto new_item = std::make_unique<ExtImportItem>();
new_item->extensions.Add(wxT("*"));
new_item->mime_types.Add(wxT("*"));

View File

@ -44,7 +44,7 @@ public:
class ExtImportItem;
using FormatList = std::vector<Format> ;
using ExtImportItems = std::vector< movable_ptr<ExtImportItem> >;
using ExtImportItems = std::vector< std::unique_ptr<ExtImportItem> >;
class ExtImportItem
{
@ -134,7 +134,7 @@ public:
* Allocates NEW ExtImportItem, fills it with default data
* and returns a pointer to it.
*/
movable_ptr<ExtImportItem> CreateDefaultImportItem();
std::unique_ptr<ExtImportItem> CreateDefaultImportItem();
static bool IsMidi(const wxString &fName);

View File

@ -285,7 +285,7 @@ private:
void GetFFmpegImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &WXUNUSED(unusableImportPluginList))
{
importPluginList.push_back( make_movable<FFmpegImportPlugin>() );
importPluginList.push_back( std::make_unique<FFmpegImportPlugin>() );
}
@ -584,13 +584,13 @@ ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
//at this point we know the file is good and that we have to load the number of channels in mScs[s]->m_stream->codec->channels;
//so for OD loading we create the tracks and releasee the modal lock after starting the ODTask.
if (mUsingOD) {
std::vector<movable_ptr<ODDecodeFFmpegTask>> tasks;
std::vector<std::unique_ptr<ODDecodeFFmpegTask>> tasks;
//append blockfiles to each stream and add an individual ODDecodeTask for each one.
s = -1;
for (const auto &stream : mChannels) {
++s;
auto odTask =
make_movable<ODDecodeFFmpegTask>(mScs, ODDecodeFFmpegTask::FromList(mChannels), mContext, s);
std::make_unique<ODDecodeFFmpegTask>(mScs, ODDecodeFFmpegTask::FromList(mChannels), mContext, s);
odTask->CreateFileDecoder(mFilename);
//each stream has different duration. We need to know it if seeking is to be allowed.

View File

@ -62,7 +62,7 @@ void GetFLACImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &unusableImportPluginList)
{
unusableImportPluginList.push_back(
make_movable<UnusableImportPlugin>
std::make_unique<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
);
}
@ -182,7 +182,7 @@ private:
bool mStreamInfoDone;
ProgressResult mUpdateResult;
TrackHolders mChannels;
movable_ptr<ODDecodeFlacTask> mDecoderTask;
std::unique_ptr<ODDecodeFlacTask> mDecoderTask;
};
@ -293,7 +293,7 @@ FLAC__StreamDecoderWriteStatus MyFLACFile::write_callback(const FLAC__Frame *fra
void GetFLACImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &WXUNUSED(unusableImportPluginList))
{
importPluginList.push_back( make_movable<FLACImportPlugin>() );
importPluginList.push_back( std::make_unique<FLACImportPlugin>() );
}
@ -358,7 +358,7 @@ FLACImportFileHandle::FLACImportFileHandle(const wxString & name)
bool FLACImportFileHandle::Init()
{
#ifdef EXPERIMENTAL_OD_FLAC
mDecoderTask = make_movable<ODDecodeFlacTask>();
mDecoderTask = std::make_unique<ODDecodeFlacTask>();
ODFlacDecoder* odDecoder = (ODFlacDecoder*)mDecoderTask->CreateFileDecoder(mFilename);
if(!odDecoder || !odDecoder->ReadHeader())
@ -522,7 +522,7 @@ ProgressResult FLACImportFileHandle::Import(TrackFactory *trackFactory,
{
//if we have 3 more channels, they get imported on seperate tracks, so we add individual tasks for each.
ODManager::Instance()->AddNewTask(std::move(mDecoderTask));
mDecoderTask = make_movable<ODDecodeFlacTask>(); //TODO: see if we need to use clone to keep the metadata.
mDecoderTask = std::make_unique<ODDecodeFlacTask>(); //TODO: see if we need to use clone to keep the metadata.
}
}
//if we have mono or a linked track (stereo), we add ONE task for the one linked wave track

View File

@ -16,8 +16,8 @@ class ImportPlugin;
class UnusableImportPlugin;
using ImportPluginList =
std::vector< movable_ptr<ImportPlugin> >;
std::vector< std::unique_ptr<ImportPlugin> >;
using UnusableImportPluginList =
std::vector< movable_ptr<UnusableImportPlugin> >;
std::vector< std::unique_ptr<UnusableImportPlugin> >;
#endif

View File

@ -232,7 +232,7 @@ private:
bool mAsyncDone; //!< true = 1st async-done message received
GMutex mStreamsLock; //!< Mutex protecting the mStreams array
std::vector<movable_ptr<GStreamContext>> mStreams; //!< Array of pointers to stream contexts
std::vector<std::unique_ptr<GStreamContext>> mStreams; //!< Array of pointers to stream contexts
};
/// A representative of GStreamer loader in
@ -299,7 +299,7 @@ GetGStreamerImportPlugin(ImportPluginList &importPluginList,
nano);
// Instantiate plugin
auto plug = make_movable<GStreamerImportPlugin>();
auto plug = std::make_unique<GStreamerImportPlugin>();
// No supported extensions...no gstreamer plugins installed
if (plug->GetSupportedExtensions().GetCount() == 0)
@ -569,7 +569,7 @@ GStreamerImportFileHandle::OnPadAdded(GstPad *pad)
{
// Allocate a NEW stream context
auto uc = make_movable<GStreamContext>();
auto uc = std::make_unique<GStreamContext>();
c = uc.get();
if (!c)
{

View File

@ -171,7 +171,7 @@ LOFImportFileHandle::LOFImportFileHandle
void GetLOFImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{
importPluginList.push_back( make_movable<LOFImportPlugin>() );
importPluginList.push_back( std::make_unique<LOFImportPlugin>() );
}
wxString LOFImportPlugin::GetPluginFormatDescription()

View File

@ -62,7 +62,7 @@ void GetMP3ImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &unusableImportPluginList)
{
unusableImportPluginList.push_back(
make_movable<UnusableImportPlugin>
std::make_unique<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
);
}
@ -159,7 +159,7 @@ private:
void GetMP3ImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{
importPluginList.push_back( make_movable<MP3ImportPlugin>() );
importPluginList.push_back( std::make_unique<MP3ImportPlugin>() );
}
/* The MAD callbacks */

View File

@ -60,7 +60,7 @@ void GetOGGImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &unusableImportPluginList)
{
unusableImportPluginList.push_back(
make_movable<UnusableImportPlugin>
std::make_unique<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
);
}
@ -163,7 +163,7 @@ private:
void GetOGGImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{
importPluginList.push_back( make_movable<OggImportPlugin>() );
importPluginList.push_back( std::make_unique<OggImportPlugin>() );
}
wxString OggImportPlugin::GetPluginFormatDescription()

View File

@ -117,7 +117,7 @@ private:
void GetPCMImportPlugin(ImportPluginList & importPluginList,
UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{
importPluginList.push_back( make_movable<PCMImportPlugin>() );
importPluginList.push_back( std::make_unique<PCMImportPlugin>() );
}
wxString PCMImportPlugin::GetPluginFormatDescription()
@ -436,7 +436,7 @@ ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory,
if(useOD)
{
auto computeTask = make_movable<ODComputeSummaryTask>();
auto computeTask = std::make_unique<ODComputeSummaryTask>();
bool moreThanStereo = mInfo.channels>2;
for (const auto &channel : channels)
{
@ -445,7 +445,7 @@ ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory,
{
//if we have 3 more channels, they get imported on seperate tracks, so we add individual tasks for each.
ODManager::Instance()->AddNewTask(std::move(computeTask));
computeTask = make_movable<ODComputeSummaryTask>();
computeTask = std::make_unique<ODComputeSummaryTask>();
}
}
//if we have a linked track, we add ONE task.

View File

@ -41,7 +41,7 @@ void GetQTImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &unusableImportPluginList)
{
unusableImportPluginList.push_back(
make_movable<UnusableImportPlugin>
std::make_unique<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
);
}
@ -173,7 +173,7 @@ class QTImportFileHandle final : public ImportFileHandle
void GetQTImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList &unusableImportPluginList)
{
importPluginList.push_back( make_movable<QTImportPlugin>() );
importPluginList.push_back( std::make_unique<QTImportPlugin>() );
}
wxString QTImportPlugin::GetPluginFormatDescription()

View File

@ -21,28 +21,8 @@ class wxWindow;
#include <vector>
#ifdef __AUDACITY_OLD_STD__
class TrackHolder : public std::shared_ptr < WaveTrack >
{
public:
// shared_ptr can construct from unique_ptr&& in newer std, but not older,
// so define it here
TrackHolder &operator=(std::unique_ptr<WaveTrack> &&that)
{
reset(that.release());
return *this;
}
};
using TrackHolders = std::vector<TrackHolder>;
#else
using TrackHolders = std::vector<std::unique_ptr<WaveTrack>>;
#endif
void ImportRaw(wxWindow *parent, const wxString &fileName,
TrackFactory *trackFactory, TrackHolders &outTracks);

View File

@ -35,9 +35,9 @@ ODComputeSummaryTask::ODComputeSummaryTask()
mHasUpdateRan=false;
}
movable_ptr<ODTask> ODComputeSummaryTask::Clone() const
std::unique_ptr<ODTask> ODComputeSummaryTask::Clone() const
{
auto clone = make_movable<ODComputeSummaryTask>();
auto clone = std::make_unique<ODComputeSummaryTask>();
clone->mDemandSample = GetDemandSample();
// This std::move is needed to "upcast" the pointer type
return std::move(clone);

View File

@ -36,7 +36,7 @@ class ODComputeSummaryTask final : public ODTask
ODComputeSummaryTask();
virtual ~ODComputeSummaryTask(){};
movable_ptr<ODTask> Clone() const override;
std::unique_ptr<ODTask> Clone() const override;
///Subclasses should override to return respective type.
unsigned int GetODType() override { return eODPCMSummary; }

View File

@ -82,7 +82,7 @@ public:
bool SeekingAllowed() ;
private:
void InsertCache(movable_ptr<FFMpegDecodeCache> &&cache);
void InsertCache(std::unique_ptr<FFMpegDecodeCache> &&cache);
//puts the actual audio samples into the blockfile's data array
int FillDataFromCache(samplePtr & data, sampleFormat outFormat, sampleCount & start, size_t& len, unsigned int channel);
@ -100,7 +100,7 @@ private:
ScsPtr mScs; //!< Pointer to array of pointers to stream contexts.
ODDecodeFFmpegTask::Streams mChannels;
std::shared_ptr<FFmpegContext> mContext; //!< Format description, also contains metadata and some useful info
std::vector<movable_ptr<FFMpegDecodeCache>> mDecodeCache;
std::vector<std::unique_ptr<FFMpegDecodeCache>> mDecodeCache;
int mNumSamplesInCache;
sampleCount mCurrentPos; //the index of the next sample to be decoded
size_t mCurrentLen; //length of the last packet decoded
@ -140,9 +140,9 @@ ODDecodeFFmpegTask::~ODDecodeFFmpegTask()
}
movable_ptr<ODTask> ODDecodeFFmpegTask::Clone() const
std::unique_ptr<ODTask> ODDecodeFFmpegTask::Clone() const
{
auto clone = make_movable<ODDecodeFFmpegTask>(mScs, Streams{ mChannels }, mContext, mStreamIndex);
auto clone = std::make_unique<ODDecodeFFmpegTask>(mScs, Streams{ mChannels }, mContext, mStreamIndex);
clone->mDemandSample=GetDemandSample();
//the decoders and blockfiles should not be copied. They are created as the task runs.
@ -157,7 +157,7 @@ ODFileDecoder* ODDecodeFFmpegTask::CreateFileDecoder(const wxString & fileName)
{
// Open the file for import
auto decoder =
make_movable<ODFFmpegDecoder>(fileName, mScs, ODDecodeFFmpegTask::Streams{ mChannels },
std::make_unique<ODFFmpegDecoder>(fileName, mScs, ODDecodeFFmpegTask::Streams{ mChannels },
mContext, mStreamIndex);
mDecoders.push_back(std::move(decoder));
@ -394,7 +394,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
// Is there a proof size_t will not overflow size_t?
// Result is surely nonnegative.
auto amt = (actualDecodeStart - start).as_size_t();
auto cache = make_movable<FFMpegDecodeCache>();
auto cache = std::make_unique<FFMpegDecodeCache>();
//wxPrintf("skipping/zeroing %i samples. - now:%llu (%f), last:%llu, lastlen:%lu, start %llu, len %lu\n",amt,actualDecodeStart, actualDecodeStartdouble, mCurrentPos, mCurrentLen, start, len);
@ -607,7 +607,7 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing)
//TODO- consider growing/unioning a few cache buffers like WaveCache does.
//however we can't use wavecache as it isn't going to handle our stereo interleaved part, and isn't for samples
//However if other ODDecode tasks need this, we should do a NEW class for caching.
auto cache = make_movable<FFMpegDecodeCache>();
auto cache = std::make_unique<FFMpegDecodeCache>();
//len is number of samples per channel
// wxASSERT(sc->m_stream->codec->channels > 0);
cache->numChannels = std::max<unsigned>(0, sc->m_stream->codec->channels);
@ -623,7 +623,7 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing)
return ret;
}
void ODFFmpegDecoder::InsertCache(movable_ptr<FFMpegDecodeCache> &&cache) {
void ODFFmpegDecoder::InsertCache(std::unique_ptr<FFMpegDecodeCache> &&cache) {
int searchStart = 0;
int searchEnd = mDecodeCache.size(); //size() is also a valid insert index.
int guess = 0;

View File

@ -37,7 +37,7 @@ public:
ODDecodeFFmpegTask(const ScsPtr &scs, Streams &&channels, const std::shared_ptr<FFmpegContext> &context, int streamIndex);
virtual ~ODDecodeFFmpegTask();
movable_ptr<ODTask> Clone() const override;
std::unique_ptr<ODTask> Clone() const override;
///Creates an ODFileDecoder that decodes a file of filetype the subclass handles.
ODFileDecoder* CreateFileDecoder(const wxString & fileName) override;

View File

@ -33,9 +33,9 @@ ODDecodeFlacTask::~ODDecodeFlacTask()
}
movable_ptr<ODTask> ODDecodeFlacTask::Clone() const
std::unique_ptr<ODTask> ODDecodeFlacTask::Clone() const
{
auto clone = make_movable<ODDecodeFlacTask>();
auto clone = std::make_unique<ODDecodeFlacTask>();
clone->mDemandSample = GetDemandSample();
//the decoders and blockfiles should not be copied. They are created as the task runs.
@ -304,7 +304,7 @@ ODFileDecoder* ODDecodeFlacTask::CreateFileDecoder(const wxString & fileName)
}
// Open the file for import
auto decoder = std::make_movable<ODFlacDecoder>(fileName);
auto decoder = std::std::make_unique<ODFlacDecoder>(fileName);
*/
/*
bool success = decoder->Init();
@ -313,7 +313,7 @@ ODFileDecoder* ODDecodeFlacTask::CreateFileDecoder(const wxString & fileName)
}
*/
// Open the file for import
auto decoder = make_movable<ODFlacDecoder>(fileName);
auto decoder = std::make_unique<ODFlacDecoder>(fileName);
mDecoders.push_back(std::move(decoder));
return mDecoders.back().get();

View File

@ -51,7 +51,7 @@ class ODDecodeFlacTask final : public ODDecodeTask
virtual ~ODDecodeFlacTask();
movable_ptr<ODTask> Clone() const override;
std::unique_ptr<ODTask> Clone() const override;
///Creates an ODFileDecoder that decodes a file of filetype the subclass handles.
ODFileDecoder* CreateFileDecoder(const wxString & fileName) override;

View File

@ -90,7 +90,7 @@ protected:
std::vector<std::weak_ptr<ODDecodeBlockFile>> mBlockFiles;
std::vector<movable_ptr<ODFileDecoder>> mDecoders;
std::vector<std::unique_ptr<ODFileDecoder>> mDecoders;
int mMaxBlockFiles;

View File

@ -142,7 +142,7 @@ void ODManager::RemoveTaskIfInQueue(ODTask* task)
///
///@param task the task to add
///@param lockMutex locks the mutexes if true (default). This function is used within other ODManager calls, which many need to set this to false.
void ODManager::AddNewTask(movable_ptr<ODTask> &&mtask, bool lockMutex)
void ODManager::AddNewTask(std::unique_ptr<ODTask> &&mtask, bool lockMutex)
{
auto task = mtask.get();
ODWaveTrackTaskQueue* queue = NULL;
@ -168,7 +168,7 @@ void ODManager::AddNewTask(movable_ptr<ODTask> &&mtask, bool lockMutex)
{
//Make a NEW one, add it to the local track queue, and to the immediate running task list,
//since this task is definitely at the head
auto newqueue = make_movable<ODWaveTrackTaskQueue>();
auto newqueue = std::make_unique<ODWaveTrackTaskQueue>();
newqueue->AddTask(std::move(mtask));
mQueues.push_back(std::move(newqueue));
if(lockMutex)

View File

@ -62,7 +62,7 @@ class ODManager final
void DecrementCurrentThreads();
///Adds a wavetrack, creates a queue member.
void AddNewTask(movable_ptr<ODTask> &&mtask, bool lockMutex=true);
void AddNewTask(std::unique_ptr<ODTask> &&mtask, bool lockMutex=true);
///Wakes the queue loop up by signalling its condition variable.
void SignalTaskQueueLoop();
@ -140,7 +140,7 @@ class ODManager final
static std::unique_ptr<ODManager> pMan;
//List of tracks and their active and inactive tasks.
std::vector<movable_ptr<ODWaveTrackTaskQueue>> mQueues;
std::vector<std::unique_ptr<ODWaveTrackTaskQueue>> mQueues;
ODLock mQueuesMutex;
//List of current Task to do.

View File

@ -55,7 +55,7 @@ class ODTask /* not final */
virtual ~ODTask(){};
//clones everything except information about the tracks.
virtual movable_ptr<ODTask> Clone() const = 0;
virtual std::unique_ptr<ODTask> Clone() const = 0;
///Subclasses should override to return respective type.
virtual unsigned int GetODType(){return eODNone;}

View File

@ -101,7 +101,7 @@ void ODWaveTrackTaskQueue::AddWaveTrack(WaveTrack* track)
mTracksMutex.Unlock();
}
void ODWaveTrackTaskQueue::AddTask(movable_ptr<ODTask> &&mtask)
void ODWaveTrackTaskQueue::AddTask(std::unique_ptr<ODTask> &&mtask)
{
ODTask *task = mtask.get();

View File

@ -72,7 +72,7 @@ class ODWaveTrackTaskQueue final
int GetNumWaveTracks();
///Add a task to the queue.
void AddTask(movable_ptr<ODTask> &&mtask);
void AddTask(std::unique_ptr<ODTask> &&mtask);
//returns true if either tracks or tasks are empty
bool IsEmpty();
@ -106,7 +106,7 @@ class ODWaveTrackTaskQueue final
ODLock mTracksMutex;
///the list of tasks associated with the tracks. This class owns these tasks.
std::vector<movable_ptr<ODTask>> mTasks;
std::vector<std::unique_ptr<ODTask>> mTasks;
ODLock mTasksMutex;
};

View File

@ -312,7 +312,7 @@ protected:
void ExpandingToolBar::RecursivelyPushEventHandlers(wxWindow *win)
{
if (!mWindowHash[win]) {
mHandlers.push_back(make_movable<ExpandingToolBarEvtHandler>
mHandlers.push_back(std::make_unique<ExpandingToolBarEvtHandler>
(this, win, win->GetEventHandler()));
mWindowHash[win] = 1;
}

View File

@ -23,9 +23,7 @@
#include "ImageRoll.h"
#include "wxPanelWrapper.h"
#ifndef __AUDACITY_OLD_STD__
#include <unordered_map>
#endif
class wxDragImage;
@ -125,7 +123,7 @@ class ExpandingToolBar final : public wxPanelWrapper
DECLARE_EVENT_TABLE()
friend class ExpandingToolBarEvtHandler;
std::vector< movable_ptr< ExpandingToolBarEvtHandler > > mHandlers;
std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > mHandlers;
};
class ToolBarGrabber final : public wxPanelWrapper

Some files were not shown because too many files have changed in this diff Show More