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