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

View file

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

View file

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