History

ao: don't call driver->set_paused after reset

This commit adds a state `hw_paused` for pull-based AO. `driver->set_paused(false)` is only called if `hw_paused` is true. `hw_paused` is cleared after `ao_reset`, so `set_paused` will not be called after a reset; instead, `driver->start()` will be called, which properly starts the AO.

Misaki Kasumi committed 2 years ago

Commit 4d03efb1 parent d31543a1 file · +6 −2Browse files

Unified · Split

audio/out/buffer.c+6−2
@@ -59,6 +59,7 @@ struct buffer_state { · 58 unmodified lines
5959 bool streaming; // AO streaming active
6060 bool playing; // logically playing audio from buffer
6161 bool paused; // logically paused
62+ bool hw_paused; // driver->set_pause() was used successfully
6263
6364 int64_t end_time_ns; // absolute output time of last played sample
6465 int64_t queued_time_ns; // duration of samples that have been queued to
@@ -70,7 +71,6 @@ struct buffer_state { · 5 unmodified lines
7071 bool initial_unblocked;
7172
7273 // "Push" AOs only (AOs with driver->write).
73− bool hw_paused; // driver->set_pause() was used successfully
7474 bool recover_pause; // non-hw_paused: needs to recover delay
7575 struct mp_pcm_state prepause_state;
7676 mp_thread thread; // thread shoveling data to AO
@@ -386,6 +386,7 @@ void ao_set_paused(struct ao *ao, bool paused, bool eof) · 309 unmodified lines
386386 struct buffer_state *p = ao->buffer_state;
387387 bool wakeup = false;
388388 bool do_change_state = false;
389+ bool is_hw_paused;
389390
390391 // If we are going to pause on eof and ao is still playing,
391392 // be sure to drain the ao first for gapless.
@@ -410,6 +411,7 @@ void ao_set_paused(struct ao *ao, bool paused, bool eof) · 18 unmodified lines
410411 // See ao_reset() why this is done outside of the lock.
411412 do_change_state = true;
412413 p->streaming = false;
414+ is_hw_paused = p->hw_paused = !!ao->driver->set_pause;
413415 }
414416 }
415417 wakeup = true;
@@ -422,6 +424,8 @@ void ao_set_paused(struct ao *ao, bool paused, bool eof) · 6 unmodified lines
422424 if (!p->streaming)
423425 do_change_state = true;
424426 p->streaming = true;
427+ is_hw_paused = p->hw_paused;
428+ p->hw_paused = false;
425429 }
426430 wakeup = true;
427431 }
@@ -430,7 +434,7 @@ void ao_set_paused(struct ao *ao, bool paused, bool eof) · 2 unmodified lines
430434 mp_mutex_unlock(&p->lock);
431435
432436 if (do_change_state) {
433− if (ao->driver->set_pause) {
437+ if (is_hw_paused) {
434438 if (paused) {
435439 ao->driver->set_pause(ao, true);
436440 p->queued_time_ns = p->end_time_ns - mp_time_ns();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t