Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Oct 5, 2024
1 parent 8f7c39a commit 002a57f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
33 changes: 19 additions & 14 deletions lib/tlDevice/BMDOutputCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,32 +107,37 @@ namespace tl
timeline::Playback value,
const otime::RationalTime& time)
{
std::unique_lock<std::mutex> lock(_audioMutex.mutex);
if (value != _audioMutex.playback)
if (value == _playback)
return;
_playback = value;
{
_dlOutput->FlushBufferedAudioSamples();
std::unique_lock<std::mutex> lock(_videoMutex.mutex);
_videoMutex.videoFrames.clear();
}
{
std::unique_lock<std::mutex> lock(_audioMutex.mutex);
_audioMutex.playback = value;
_audioMutex.reset = true;
_audioMutex.start = time;
_audioMutex.current = time;
}
}

void DLOutputCallback::setCurrentTime(const otime::RationalTime& time)
{
std::unique_lock<std::mutex> lock(_audioMutex.mutex);
_audioMutex.current = time;
}

void DLOutputCallback::seek(const otime::RationalTime& time)
{
if (time == _seek)
return;
_seek = time;
std::unique_lock<std::mutex> lock(_audioMutex.mutex);
_audioMutex.reset = true;
_audioMutex.start = time;
_audioMutex.current = time;
{
std::unique_lock<std::mutex> lock(_videoMutex.mutex);
_videoMutex.videoFrames.clear();
}
{
std::unique_lock<std::mutex> lock(_audioMutex.mutex);
_audioMutex.reset = true;
_audioMutex.start = time;
_audioMutex.current = time;
}
}

void DLOutputCallback::setVideo(const std::shared_ptr<DLVideoFrameWrapper>& value)
Expand Down Expand Up @@ -371,7 +376,7 @@ namespace tl
nullptr);

// Update the frame counter.
_audioThread.frame += audioList[0]->getSampleCount();
_audioThread.frame += audio->getSampleCount();
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions lib/tlDevice/BMDOutputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,6 @@ namespace tl
p.thread.dl->outputCallback->setPlayback(
playback,
currentTime - p.thread.timeRange.start_time());
p.thread.dl->outputCallback->setCurrentTime(
currentTime - p.thread.timeRange.start_time());
p.thread.dl->outputCallback->seek(
seek - p.thread.timeRange.start_time());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tlDevice/BMDOutputPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ namespace tl
const audio::Info& audioInfo);

void setPlayback(timeline::Playback, const otime::RationalTime&);
void setCurrentTime(const otime::RationalTime&);
void seek(const otime::RationalTime&);
void setVideo(const std::shared_ptr<DLVideoFrameWrapper>&);
void setVolume(float);
Expand All @@ -157,6 +156,7 @@ namespace tl
PixelType _pixelType = PixelType::None;
FrameRate _frameRate;
audio::Info _audioInfo;
timeline::Playback _playback = timeline::Playback::Stop;
otime::RationalTime _seek = time::invalidTime;

std::atomic<size_t> _refCount;
Expand Down

0 comments on commit 002a57f

Please sign in to comment.