mirror of https://github.com/odrling/Aegisub
Pass around newly created AudioTimingControllers in a unique_ptr
This commit is contained in:
parent
f83f8b73a0
commit
c53e8f6139
|
@ -216,14 +216,12 @@ bool AudioController::IsAudioOpen() const
|
|||
return player && provider;
|
||||
}
|
||||
|
||||
void AudioController::SetTimingController(AudioTimingController *new_controller)
|
||||
void AudioController::SetTimingController(std::unique_ptr<AudioTimingController> new_controller)
|
||||
{
|
||||
if (timing_controller.get() != new_controller) {
|
||||
timing_controller.reset(new_controller);
|
||||
if (timing_controller)
|
||||
{
|
||||
timing_controller->AddUpdatedPrimaryRangeListener(&AudioController::OnTimingControllerUpdatedPrimaryRange, this);
|
||||
}
|
||||
timing_controller = std::move(new_controller);
|
||||
if (timing_controller)
|
||||
{
|
||||
timing_controller->AddUpdatedPrimaryRangeListener(&AudioController::OnTimingControllerUpdatedPrimaryRange, this);
|
||||
}
|
||||
|
||||
AnnounceTimingControllerChanged();
|
||||
|
|
|
@ -228,14 +228,11 @@ public:
|
|||
|
||||
/// @brief Return the current timing controller
|
||||
/// @return The current timing controller or 0
|
||||
AudioTimingController * GetTimingController() const { return timing_controller.get(); }
|
||||
AudioTimingController *GetTimingController() const { return timing_controller.get(); }
|
||||
|
||||
/// @brief Change the current timing controller
|
||||
/// @param new_mode The new timing controller or 0. This may be the same
|
||||
/// object as the current timing controller, to signal that the timing
|
||||
/// controller has changed the object being timed, e.g. changed to a new
|
||||
/// dialogue line.
|
||||
void SetTimingController(AudioTimingController *new_controller);
|
||||
/// @param new_mode The new timing controller or nullptr
|
||||
void SetTimingController(std::unique_ptr<AudioTimingController> new_controller);
|
||||
|
||||
/// @brief Save a portion of the decoded loaded audio to a wav file
|
||||
/// @param filename File to save to
|
||||
|
|
|
@ -179,12 +179,11 @@ public:
|
|||
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedStyleRanges, AddUpdatedStyleRangesListener)
|
||||
};
|
||||
|
||||
|
||||
/// @brief Create a standard dialogue audio timing controller
|
||||
/// @param c Project context
|
||||
AudioTimingController *CreateDialogueTimingController(agi::Context *c);
|
||||
std::unique_ptr<AudioTimingController> CreateDialogueTimingController(agi::Context *c);
|
||||
|
||||
/// @brief Create a karaoke audio timing controller
|
||||
/// @param c Project context
|
||||
/// @param kara Karaoke model
|
||||
AudioTimingController *CreateKaraokeTimingController(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed);
|
||||
std::unique_ptr<AudioTimingController> CreateKaraokeTimingController(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed);
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "selection_controller.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <boost/range/algorithm.hpp>
|
||||
#include <cstdint>
|
||||
#include <wx/pen.h>
|
||||
|
@ -407,9 +409,9 @@ public:
|
|||
AudioTimingControllerDialogue(agi::Context *c);
|
||||
};
|
||||
|
||||
AudioTimingController *CreateDialogueTimingController(agi::Context *c)
|
||||
std::unique_ptr<AudioTimingController> CreateDialogueTimingController(agi::Context *c)
|
||||
{
|
||||
return new AudioTimingControllerDialogue(c);
|
||||
return agi::util::make_unique<AudioTimingControllerDialogue>(c);
|
||||
}
|
||||
|
||||
AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)
|
||||
|
|
|
@ -34,11 +34,12 @@
|
|||
#include "selection_controller.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <deque>
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/adaptor/sliced.hpp>
|
||||
#include <deque>
|
||||
|
||||
/// @class KaraokeMarker
|
||||
/// @brief AudioMarker implementation for AudioTimingControllerKaraoke
|
||||
|
@ -149,9 +150,9 @@ public:
|
|||
AudioTimingControllerKaraoke(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed);
|
||||
};
|
||||
|
||||
AudioTimingController *CreateKaraokeTimingController(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed)
|
||||
std::unique_ptr<AudioTimingController> CreateKaraokeTimingController(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed)
|
||||
{
|
||||
return new AudioTimingControllerKaraoke(c, kara, file_changed);
|
||||
return agi::util::make_unique<AudioTimingControllerKaraoke>(c, kara, file_changed);
|
||||
}
|
||||
|
||||
AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed)
|
||||
|
|
Loading…
Reference in New Issue