mirror of https://github.com/odrling/Aegisub
Playing in video mode will now play the audio as well even if it hasn't been previously loaded into audio mode (experimental).
Originally committed to SVN as r452.
This commit is contained in:
parent
a1a840155b
commit
1114029be1
|
@ -71,6 +71,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent,VideoDisplay *display)
|
||||||
diagUpdated = false;
|
diagUpdated = false;
|
||||||
NeedCommit = false;
|
NeedCommit = false;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
temporary = false;
|
||||||
blockUpdate = false;
|
blockUpdate = false;
|
||||||
dontReadTimes = false;
|
dontReadTimes = false;
|
||||||
holding = false;
|
holding = false;
|
||||||
|
@ -917,7 +918,26 @@ __int64 AudioDisplay::GetSampleAtMS(__int64 ms) {
|
||||||
// Play
|
// Play
|
||||||
void AudioDisplay::Play(int start,int end) {
|
void AudioDisplay::Play(int start,int end) {
|
||||||
// Check provider
|
// Check provider
|
||||||
if (!provider) return;
|
if (!provider) {
|
||||||
|
// Load temporary provider from video
|
||||||
|
if (video->loaded) {
|
||||||
|
try {
|
||||||
|
// Get provider
|
||||||
|
provider = AudioProvider::GetAudioProvider(video->videoName, this, video->provider,0);
|
||||||
|
|
||||||
|
// Get player
|
||||||
|
player = AudioPlayer::GetAudioPlayer();
|
||||||
|
player->SetDisplayTimer(&UpdateTimer);
|
||||||
|
player->SetProvider(provider);
|
||||||
|
player->OpenStream();
|
||||||
|
temporary = true;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!provider) return;
|
||||||
|
}
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
__int64 num_samples = provider->GetNumSamples();
|
__int64 num_samples = provider->GetNumSamples();
|
||||||
|
|
|
@ -119,6 +119,7 @@ public:
|
||||||
|
|
||||||
bool NeedCommit;
|
bool NeedCommit;
|
||||||
bool loaded;
|
bool loaded;
|
||||||
|
bool temporary;
|
||||||
int w,h;
|
int w,h;
|
||||||
AudioBox *box;
|
AudioBox *box;
|
||||||
AudioKaraoke *karaoke;
|
AudioKaraoke *karaoke;
|
||||||
|
|
|
@ -162,7 +162,7 @@ void AudioProvider::GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Get provider
|
// Get provider
|
||||||
AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider) {
|
AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider,int cache) {
|
||||||
// Prepare provider
|
// Prepare provider
|
||||||
AudioProvider *provider = NULL;
|
AudioProvider *provider = NULL;
|
||||||
|
|
||||||
|
@ -181,15 +181,15 @@ AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change provider to RAM/HD cache if needed
|
// Change provider to RAM/HD cache if needed
|
||||||
int cacheMode = Options.AsInt(_T("Audio Cache"));
|
if (cache == -1) cache = Options.AsInt(_T("Audio Cache"));
|
||||||
if (cacheMode) {
|
if (cache) {
|
||||||
AudioProvider *final = NULL;
|
AudioProvider *final = NULL;
|
||||||
|
|
||||||
// Convert to RAM
|
// Convert to RAM
|
||||||
if (cacheMode == 1) final = new RAMAudioProvider(provider);
|
if (cache == 1) final = new RAMAudioProvider(provider);
|
||||||
|
|
||||||
// Convert to HD
|
// Convert to HD
|
||||||
if (cacheMode == 2) final = new HDAudioProvider(provider);
|
if (cache == 2) final = new HDAudioProvider(provider);
|
||||||
|
|
||||||
// Reassign
|
// Reassign
|
||||||
if (final) {
|
if (final) {
|
||||||
|
|
|
@ -76,5 +76,5 @@ public:
|
||||||
int GetBytesPerSample();
|
int GetBytesPerSample();
|
||||||
|
|
||||||
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale);
|
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale);
|
||||||
static AudioProvider *GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider);
|
static AudioProvider *GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider,int cache=-1);
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,6 +90,7 @@ Please visit http://aegisub.net to download latest version
|
||||||
- Implemented an Attached files list, where you can attach new fonts and graphics, extract them, or remove them from the script file. (AMZ)
|
- Implemented an Attached files list, where you can attach new fonts and graphics, extract them, or remove them from the script file. (AMZ)
|
||||||
- The Font Collector can now collect fonts as script attachments. (AMZ)
|
- The Font Collector can now collect fonts as script attachments. (AMZ)
|
||||||
- Added recent menu to Video Timecodes. (AMZ)
|
- Added recent menu to Video Timecodes. (AMZ)
|
||||||
|
- Playing in video mode will now play the audio as well even if it hasn't been previously loaded into audio mode (experimental). (AMZ)
|
||||||
|
|
||||||
|
|
||||||
= 1.09 beta - 2006.01.16 ===========================
|
= 1.09 beta - 2006.01.16 ===========================
|
||||||
|
|
|
@ -92,6 +92,7 @@ END_EVENT_TABLE()
|
||||||
VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||||
: wxWindow (parent, id, pos, size, style, name)
|
: wxWindow (parent, id, pos, size, style, name)
|
||||||
{
|
{
|
||||||
|
audio = NULL;
|
||||||
provider = NULL;
|
provider = NULL;
|
||||||
curLine = NULL;
|
curLine = NULL;
|
||||||
backbuffer = NULL;
|
backbuffer = NULL;
|
||||||
|
@ -202,9 +203,7 @@ void VideoDisplay::SetVideo(const wxString &filename) {
|
||||||
length = provider->GetFrameCount();
|
length = provider->GetFrameCount();
|
||||||
fps = provider->GetFPS();
|
fps = provider->GetFPS();
|
||||||
VFR_Input.SetCFR(fps);
|
VFR_Input.SetCFR(fps);
|
||||||
|
if (VFR_Output.GetFrameRateType() != VFR) VFR_Output.SetCFR(fps);
|
||||||
if (!VFR_Output.IsLoaded())
|
|
||||||
VFR_Output.SetCFR(fps);
|
|
||||||
|
|
||||||
// Set range of slider
|
// Set range of slider
|
||||||
ControlSlider->SetRange(0,length-1);
|
ControlSlider->SetRange(0,length-1);
|
||||||
|
@ -236,6 +235,15 @@ void VideoDisplay::Reset() {
|
||||||
int _w,_h;
|
int _w,_h;
|
||||||
GetSize(&_w,&_h);
|
GetSize(&_w,&_h);
|
||||||
SetSizeHints(_w,_h,_w,_h);
|
SetSizeHints(_w,_h,_w,_h);
|
||||||
|
|
||||||
|
// Remove temporary audio provider
|
||||||
|
if (audio && audio->temporary) {
|
||||||
|
delete audio->provider;
|
||||||
|
audio->provider = NULL;
|
||||||
|
delete audio->player;
|
||||||
|
audio->player = NULL;
|
||||||
|
audio->temporary = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDisplay::RefreshSubtitles() {
|
void VideoDisplay::RefreshSubtitles() {
|
||||||
|
@ -821,8 +829,6 @@ void VideoDisplay::Play() {
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
IsPlaying = true;
|
IsPlaying = true;
|
||||||
StartTime = clock();
|
|
||||||
PlayTime = StartTime;
|
|
||||||
StartFrame = frame_n;
|
StartFrame = frame_n;
|
||||||
EndFrame = -1;
|
EndFrame = -1;
|
||||||
|
|
||||||
|
@ -830,6 +836,8 @@ void VideoDisplay::Play() {
|
||||||
audio->Play(VFR_Output.GetTimeAtFrame(StartFrame),-1);
|
audio->Play(VFR_Output.GetTimeAtFrame(StartFrame),-1);
|
||||||
|
|
||||||
// Start timer
|
// Start timer
|
||||||
|
StartTime = clock();
|
||||||
|
PlayTime = StartTime;
|
||||||
Playback.SetOwner(this,VIDEO_PLAY_TIMER);
|
Playback.SetOwner(this,VIDEO_PLAY_TIMER);
|
||||||
Playback.Start(1);
|
Playback.Start(1);
|
||||||
}
|
}
|
||||||
|
@ -842,6 +850,9 @@ void VideoDisplay::PlayLine() {
|
||||||
AssDialogue *curline = grid->GetDialogue(grid->editBox->linen);
|
AssDialogue *curline = grid->GetDialogue(grid->editBox->linen);
|
||||||
if (!curline) return;
|
if (!curline) return;
|
||||||
|
|
||||||
|
// Start playing audio
|
||||||
|
audio->Play(curline->Start.GetMS(),curline->End.GetMS());
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
IsPlaying = true;
|
IsPlaying = true;
|
||||||
StartFrame = VFR_Output.GetFrameAtTime(curline->Start.GetMS(),true);
|
StartFrame = VFR_Output.GetFrameAtTime(curline->Start.GetMS(),true);
|
||||||
|
@ -855,9 +866,6 @@ void VideoDisplay::PlayLine() {
|
||||||
StartTime = clock();
|
StartTime = clock();
|
||||||
PlayTime = StartTime;
|
PlayTime = StartTime;
|
||||||
|
|
||||||
// Start playing audio
|
|
||||||
audio->Play(curline->Start.GetMS(),curline->End.GetMS());
|
|
||||||
|
|
||||||
// Start timer
|
// Start timer
|
||||||
Playback.SetOwner(this,VIDEO_PLAY_TIMER);
|
Playback.SetOwner(this,VIDEO_PLAY_TIMER);
|
||||||
Playback.Start(1);
|
Playback.Start(1);
|
||||||
|
@ -902,6 +910,9 @@ void VideoDisplay::OnPlayTimer(wxTimerEvent &event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Next frame is before or over 2 frames ahead, so force audio resync
|
||||||
|
if (nextFrame < frame_n || nextFrame > frame_n + 2) audio->player->SetCurrentPosition(audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame)));
|
||||||
|
|
||||||
// Jump to next frame
|
// Jump to next frame
|
||||||
PlayNextFrame = nextFrame;
|
PlayNextFrame = nextFrame;
|
||||||
JumpToFrame(nextFrame);
|
JumpToFrame(nextFrame);
|
||||||
|
@ -910,7 +921,10 @@ void VideoDisplay::OnPlayTimer(wxTimerEvent &event) {
|
||||||
if (nextFrame % 10 == 0) {
|
if (nextFrame % 10 == 0) {
|
||||||
__int64 audPos = audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame));
|
__int64 audPos = audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame));
|
||||||
__int64 curPos = audio->player->GetCurrentPosition();
|
__int64 curPos = audio->player->GetCurrentPosition();
|
||||||
if (abs(int(audPos-curPos)) > audio->provider->GetSampleRate() / 10) audio->player->SetCurrentPosition(audPos);
|
int delta = int(audPos-curPos);
|
||||||
|
if (delta < 0) delta = -delta;
|
||||||
|
int maxDelta = audio->provider->GetSampleRate();
|
||||||
|
if (delta > maxDelta) audio->player->SetCurrentPosition(audPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue