Don't create the audio timing controller until audio is actually opened
Originally committed to SVN as r5888.
This commit is contained in:
parent
92e10c80a2
commit
70fcece459
6 changed files with 40 additions and 14 deletions
|
@ -336,10 +336,13 @@ void AudioController::SetTimingController(AudioTimingController *new_controller)
|
|||
{
|
||||
if (timing_controller.get() != new_controller) {
|
||||
timing_controller.reset(new_controller);
|
||||
timing_controller->AddMarkerMovedListener(bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||
timing_controller->AddLabelChangedListener(bind(std::tr1::ref(AnnounceLabelChanged)));
|
||||
timing_controller->AddUpdatedPrimaryRangeListener(&AudioController::OnTimingControllerUpdatedPrimaryRange, this);
|
||||
timing_controller->AddUpdatedStyleRangesListener(bind(std::tr1::ref(AnnounceStyleRangesChanged)));
|
||||
if (timing_controller)
|
||||
{
|
||||
timing_controller->AddMarkerMovedListener(bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||
timing_controller->AddLabelChangedListener(bind(std::tr1::ref(AnnounceLabelChanged)));
|
||||
timing_controller->AddUpdatedPrimaryRangeListener(&AudioController::OnTimingControllerUpdatedPrimaryRange, this);
|
||||
timing_controller->AddUpdatedStyleRangesListener(bind(std::tr1::ref(AnnounceStyleRangesChanged)));
|
||||
}
|
||||
}
|
||||
|
||||
AnnounceTimingControllerChanged();
|
||||
|
@ -435,7 +438,7 @@ void AudioController::ResyncPlaybackPosition(int64_t new_position)
|
|||
|
||||
SampleRange AudioController::GetPrimaryPlaybackRange() const
|
||||
{
|
||||
if (timing_controller.get())
|
||||
if (timing_controller)
|
||||
{
|
||||
return timing_controller->GetPrimaryPlaybackRange();
|
||||
}
|
||||
|
@ -451,12 +454,12 @@ void AudioController::GetMarkers(const SampleRange &range, AudioMarkerVector &ma
|
|||
/// @todo Find all sources of markers
|
||||
if (keyframes_marker_provider.get()) keyframes_marker_provider->GetMarkers(range, markers);
|
||||
if (video_position_marker_provider.get()) video_position_marker_provider->GetMarkers(range, markers);
|
||||
if (timing_controller.get()) timing_controller->GetMarkers(range, markers);
|
||||
if (timing_controller) timing_controller->GetMarkers(range, markers);
|
||||
}
|
||||
|
||||
void AudioController::GetLabels(const SampleRange &range, std::vector<AudioLabel> &labels) const
|
||||
{
|
||||
if (timing_controller.get()) timing_controller->GetLabels(range, labels);
|
||||
if (timing_controller) timing_controller->GetLabels(range, labels);
|
||||
}
|
||||
|
||||
double AudioController::GetVolume() const
|
||||
|
|
|
@ -1193,7 +1193,7 @@ void AudioDisplay::OnAudioOpen(AudioProvider *_provider)
|
|||
connections.push_back(controller->AddAudioCloseListener(&AudioDisplay::OnAudioOpen, this, (AudioProvider*)0));
|
||||
connections.push_back(controller->AddPlaybackPositionListener(&AudioDisplay::OnPlaybackPosition, this));
|
||||
connections.push_back(controller->AddPlaybackStopListener(&AudioDisplay::RemoveTrackCursor, this));
|
||||
connections.push_back(controller->AddTimingControllerListener(&AudioDisplay::Refresh, this, true, (const wxRect*)0));
|
||||
connections.push_back(controller->AddTimingControllerListener(&AudioDisplay::OnStyleRangesChanged, this));
|
||||
connections.push_back(controller->AddMarkerMovedListener(&AudioDisplay::OnMarkerMoved, this));
|
||||
connections.push_back(controller->AddSelectionChangedListener(&AudioDisplay::OnSelectionChanged, this));
|
||||
connections.push_back(controller->AddStyleRangesChangedListener(&AudioDisplay::OnStyleRangesChanged, this));
|
||||
|
@ -1226,6 +1226,8 @@ void AudioDisplay::OnSelectionChanged()
|
|||
|
||||
void AudioDisplay::OnStyleRangesChanged()
|
||||
{
|
||||
if (!controller->GetTimingController()) return;
|
||||
|
||||
AudioStyleRangeMerger asrm;
|
||||
controller->GetTimingController()->GetRenderingStyles(asrm);
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
|
|||
: wxWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_SUNKEN)
|
||||
, c(c)
|
||||
, file_changed(c->ass->AddCommitListener(&AudioKaraoke::OnFileChanged, this))
|
||||
, audio_opened(c->audioController->AddAudioOpenListener(&AudioKaraoke::OnAudioOpened, this))
|
||||
, audio_closed(c->audioController->AddAudioCloseListener(&AudioKaraoke::OnAudioClosed, this))
|
||||
, active_line(0)
|
||||
, kara(new AssKaraoke)
|
||||
, enabled(false)
|
||||
|
@ -105,7 +107,6 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
|
|||
accept_button->Enable(false);
|
||||
cancel_button->Enable(false);
|
||||
enabled = false;
|
||||
c->audioController->SetTimingController(CreateDialogueTimingController(c));
|
||||
}
|
||||
|
||||
AudioKaraoke::~AudioKaraoke() {
|
||||
|
@ -127,6 +128,14 @@ void AudioKaraoke::OnFileChanged(int type) {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioKaraoke::OnAudioOpened() {
|
||||
SetEnabled(enabled);
|
||||
}
|
||||
|
||||
void AudioKaraoke::OnAudioClosed() {
|
||||
c->audioController->SetTimingController(0);
|
||||
}
|
||||
|
||||
void AudioKaraoke::SetEnabled(bool en) {
|
||||
enabled = en;
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ namespace agi { struct Context; }
|
|||
class AudioKaraoke : public wxWindow, private SelectionListener<AssDialogue> {
|
||||
agi::Context *c; ///< Project context
|
||||
agi::signal::Connection file_changed; ///< File changed slot
|
||||
agi::signal::Connection audio_opened; ///< Audio opened connection
|
||||
agi::signal::Connection audio_closed; ///< Audio closed connection
|
||||
|
||||
/// Currently active dialogue line
|
||||
AssDialogue *active_line;
|
||||
|
@ -137,6 +139,8 @@ class AudioKaraoke : public wxWindow, private SelectionListener<AssDialogue> {
|
|||
void OnMouse(wxMouseEvent &event);
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
void OnSelectedSetChanged(Selection const&, Selection const&) { }
|
||||
void OnAudioOpened();
|
||||
void OnAudioClosed();
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
|
|
|
@ -298,11 +298,11 @@ AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)
|
|||
|
||||
AudioMarkerDialogueTiming::InitPair(&active_markers[0], &active_markers[1]);
|
||||
|
||||
if (c->audioController->IsAudioOpen())
|
||||
Revert();
|
||||
|
||||
c->selectionController->AddSelectionListener(this);
|
||||
keyframes_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||
|
||||
Revert();
|
||||
RegenerateInactiveLines();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -182,8 +182,10 @@ void AudioTimingControllerKaraoke::Next() {
|
|||
--cur_syl;
|
||||
c->selectionController->NextLine();
|
||||
}
|
||||
else
|
||||
else {
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTimingControllerKaraoke::Prev() {
|
||||
|
@ -193,11 +195,13 @@ void AudioTimingControllerKaraoke::Prev() {
|
|||
if (old_line != active_line) {
|
||||
cur_syl = markers.size();
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
}
|
||||
}
|
||||
else {
|
||||
--cur_syl;
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,6 +270,7 @@ void AudioTimingControllerKaraoke::Revert() {
|
|||
}
|
||||
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
AnnounceMarkerMoved();
|
||||
}
|
||||
|
||||
|
@ -291,6 +296,7 @@ AudioMarker *AudioTimingControllerKaraoke::OnLeftClick(int64_t sample, int sensi
|
|||
cur_syl = syl;
|
||||
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -308,8 +314,10 @@ void AudioTimingControllerKaraoke::OnMarkerDrag(AudioMarker *m, int64_t new_posi
|
|||
size_t syl = marker - &markers.front() + 1;
|
||||
kara->SetStartTime(syl, ToMS(new_position));
|
||||
|
||||
if (syl == cur_syl || syl + 1 == cur_syl)
|
||||
if (syl == cur_syl || syl + 1 == cur_syl) {
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
}
|
||||
|
||||
AnnounceMarkerMoved();
|
||||
|
||||
|
|
Loading…
Reference in a new issue