Add a subtitles save slot to AudioController which stores the audio URI in the subtitles

Originally committed to SVN as r5659.
This commit is contained in:
Thomas Goyne 2011-09-28 19:51:35 +00:00
parent 74ae9189a2
commit 6bf4a95428
3 changed files with 30 additions and 5 deletions

View File

@ -45,12 +45,14 @@
#include <libaegisub/io.h>
#include "ass_file.h"
#include "audio_controller.h"
#include "audio_provider_dummy.h"
#include "audio_timing.h"
#include "compat.h"
#include "include/aegisub/audio_player.h"
#include "include/aegisub/audio_provider.h"
#include "include/aegisub/context.h"
#include "main.h"
#include "selection_controller.h"
#include "standard_paths.h"
@ -139,8 +141,10 @@ public:
}
};
AudioController::AudioController()
: player(0)
AudioController::AudioController(agi::Context *context)
: context(context)
, subtitle_save_slot(context->ass->AddFileSaveListener(&AudioController::OnSubtitlesSave, this))
, player(0)
, provider(0)
, keyframes_marker_provider(new AudioMarkerProviderKeyframes(this))
, playback_mode(PM_NotPlaying)
@ -360,6 +364,18 @@ void AudioController::OnTimingControllerUpdatedStyleRanges()
/// @todo redraw and stuff, probably
}
void AudioController::OnSubtitlesSave()
{
if (IsAudioOpen())
{
context->ass->SetScriptInfo("Audio URI", audio_url);
}
else
{
context->ass->SetScriptInfo("Audio URI", "");
}
}
void AudioController::PlayRange(const SampleRange &range)
{
if (!IsAudioOpen()) return;

View File

@ -54,6 +54,7 @@
class AudioPlayer;
class AudioProvider;
namespace agi { struct Context; }
// Declared below
class AudioControllerAudioEventListener;
@ -176,7 +177,12 @@ public:
/// possible in the existing design is needed, the controller should be
/// extended in some way to allow it.
class AudioController : public wxEvtHandler, public AudioMarkerProvider, public AudioLabelProvider {
private:
/// Project context this controller belongs to
agi::Context *context;
/// Slot for subtitles save signal
agi::signal::Connection subtitle_save_slot;
/// A new audio stream was opened (and any previously open was closed)
agi::signal::Signal<AudioProvider*> AnnounceAudioOpen;
@ -233,6 +239,9 @@ private:
/// @brief Timing controller signals that the rendering style ranges have changed
void OnTimingControllerUpdatedStyleRanges();
/// Subtitles save slot which adds the audio uri to the subtitles
void OnSubtitlesSave();
#ifdef wxHAS_POWER_EVENTS
/// Handle computer going into suspend mode by stopping audio and closing device
void OnComputerSuspending(wxPowerEvent &event);
@ -243,7 +252,7 @@ private:
public:
/// @brief Constructor
AudioController();
AudioController(agi::Context *context);
/// @brief Destructor
~AudioController();

View File

@ -124,7 +124,7 @@ FrameMain::FrameMain (wxArrayString args)
context->local_scripts = new Automation4::LocalScriptManager(context.get());
StartupLog("Initializing context controls");
context->audioController = new AudioController;
context->audioController = new AudioController(context.get());
context->audioController->AddAudioOpenListener(&FrameMain::OnAudioOpen, this);
context->audioController->AddAudioCloseListener(&FrameMain::OnAudioClose, this);