app: migrate the viewer panel to the facade playback engine

This commit is contained in:
2026-07-20 18:55:04 +08:00
parent d63131cb12
commit 1384ad1e95
10 changed files with 215 additions and 925 deletions
+16 -2
View File
@@ -282,6 +282,9 @@ void pull_loop(OakEnginePlaybackState *state)
state->paused_ts.store(end_ts);
state->last_start_ts.store(end_ts);
state->state.store(k_state_stopped);
if (olive::AudioManager::instance()) {
olive::AudioManager::instance()->stop_output();
}
break;
}
@@ -307,6 +310,11 @@ void stop_and_join(OakEnginePlaybackState *state)
state->pull_thread.join();
}
}
// Do not leave buffered audio playing out after a pause/stop (an
// output stream stays active and audible otherwise).
if (olive::AudioManager::instance()) {
olive::AudioManager::instance()->stop_output();
}
}
} // namespace
@@ -424,8 +432,10 @@ int oakengine_playback_start(OakEnginePlayback *self, int64_t start_ts,
state->next_audio_time.store(start_ts * state->time_base.to_double());
state->wall_timer.restart();
if (olive::AudioManager::instance()) {
// Restart the master clock at zero for this run (the viewer does
// the same in finish_play_preprocess()).
// Flush whatever a previous run left in the output, then restart
// the master clock at zero for this run (the viewer did the same
// in finish_play_preprocess()).
olive::AudioManager::instance()->clear_buffered_output();
olive::AudioManager::instance()->reset_output_clock();
}
state->anchor_clock.store(master_clock_seconds(state));
@@ -453,6 +463,10 @@ int oakengine_playback_pause(OakEnginePlayback *self)
if (state->renderer) {
oakengine_renderer_cancel(state->renderer);
}
// Do not leave buffered audio playing out while paused.
if (olive::AudioManager::instance()) {
olive::AudioManager::instance()->stop_output();
}
}
return OAKENGINE_OK;
}