Media player synchronicity to beat or phase

Metronome synched play, rewind and step. saving in xml.
This commit is contained in:
Bruno Herbelin
2021-11-26 12:22:39 +01:00
parent e123d139e4
commit 1b4849f214
6 changed files with 41 additions and 22 deletions

View File

@@ -646,12 +646,17 @@ void MediaPlayer::play(bool on)
return;
// Metronome
if (metro_sync_) {
// busy with this play()
if (metro_sync_ > Metronome::SYNC_NONE) {
// busy with this delayed action
pending_ = true;
// Execute: sync to Metronome if active
Metronome::manager().executeAtBeat( std::bind([](MediaPlayer *p, bool o) {
p->execute_play_command(o); p->pending_=false; }, this, on) );
// delayed execution function
std::function<void()> playlater = std::bind([](MediaPlayer *p, bool o) {
p->execute_play_command(o); p->pending_=false; }, this, on);
// Execute: sync to Metronome
if (metro_sync_ > Metronome::SYNC_BEAT)
Metronome::manager().executeAtPhase( playlater );
else
Metronome::manager().executeAtBeat( playlater );
}
else
// execute immediately
@@ -702,11 +707,16 @@ void MediaPlayer::rewind(bool force)
// Metronome
if (metro_sync_) {
// busy with this play()
// busy with this delayed action
pending_ = true;
// Execute: sync to Metronome if active
Metronome::manager().executeAtBeat( std::bind([](MediaPlayer *p, GstClockTime t, bool f) {
p->execute_seek_command( t, f ); p->pending_=false; }, this, target, force) );
// delayed execution function
std::function<void()> rewindlater = std::bind([](MediaPlayer *p, GstClockTime t, bool f) {
p->execute_seek_command( t, f ); p->pending_=false; }, this, target, force);
// Execute: sync to Metronome
if (metro_sync_ > Metronome::SYNC_BEAT)
Metronome::manager().executeAtPhase( rewindlater );
else
Metronome::manager().executeAtBeat( rewindlater );
}
else
// execute immediately
@@ -729,11 +739,17 @@ void MediaPlayer::step()
// Metronome
if (metro_sync_) {
// busy with this play()
// busy with this delayed action
pending_ = true;
// Execute: sync to Metronome if active
Metronome::manager().executeAtBeat( std::bind([](MediaPlayer *p, GstEvent *e) {
gst_element_send_event(p->pipeline_, e); p->pending_=false; }, this, stepevent) );
// delayed execution function
std::function<void()> steplater = std::bind([](MediaPlayer *p, GstEvent *e) {
gst_element_send_event(p->pipeline_, e); p->pending_=false; }, this, stepevent) ;
// Execute: sync to Metronome
if (metro_sync_ > Metronome::SYNC_BEAT)
Metronome::manager().executeAtPhase( steplater );
else
Metronome::manager().executeAtBeat( steplater );
}
else
// execute immediately