summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-17 23:48:09 +0200
committerwm4 <wm4@nowhere>2014-04-17 23:48:09 +0200
commit5059039c95f51cfe33f828a66d55b1255ab1626d (patch)
tree5ff63cdba84e0531a234ecd4f12d8dca8596e305 /audio
parent0ab3482f73a199b2e839ad4ec0a4b21adc1e75d5 (diff)
downloadmpv-5059039c95f51cfe33f828a66d55b1255ab1626d.tar.bz2
mpv-5059039c95f51cfe33f828a66d55b1255ab1626d.tar.xz
player: unrangle one aspect of audio EOF handling
For some reason, the buffered_audio variable was used to "cache" the ao_get_delay() result. But I can't really see any reason why this should be done, and it just seems to complicate everything. One reason might be that the value should be checked only if the AO buffers have been recently filled (as otherwise the delay could go low and trigger an accidental EOF condition), but this didn't work anyway, since buffered_audio is set from ao_get_delay() anyway at a later point if it was unset. And in both cases, the value is used _after_ filling the audio buffers anyway. Simplify it. Also, move the audio EOF condition to a separate function. (Note that ao_eof_reached() probably could/should whether the last ao_play() call had AOPLAY_FINAL_CHUNK set to avoid accidental EOF on underflows, but for now let's keep the code equivalent.)
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao.c5
-rw-r--r--audio/out/ao.h6
-rw-r--r--audio/out/internal.h5
3 files changed, 11 insertions, 5 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 55fcac1a24..313f4f7554 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -327,6 +327,11 @@ void ao_drain(struct ao *ao)
}
}
+bool ao_eof_reached(struct ao *ao)
+{
+ return ao_get_delay(ao) < AO_EOF_DELAY;
+}
+
bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s,
struct mp_chmap *map)
{
diff --git a/audio/out/ao.h b/audio/out/ao.h
index 056cdf7295..59de0c08b1 100644
--- a/audio/out/ao.h
+++ b/audio/out/ao.h
@@ -49,11 +49,6 @@ typedef struct ao_control_vol {
float right;
} ao_control_vol_t;
-// If ao_get_delay() reaches this value after ao_play() was called with the
-// AOPLAY_FINAL_CHUNK flag set, the playback core expects that the audio has
-// all been played.
-#define AO_EOF_DELAY 0.05
-
struct ao;
struct mpv_global;
struct input_ctx;
@@ -77,5 +72,6 @@ void ao_reset(struct ao *ao);
void ao_pause(struct ao *ao);
void ao_resume(struct ao *ao);
void ao_drain(struct ao *ao);
+bool ao_eof_reached(struct ao *ao);
#endif /* MPLAYER_AUDIO_OUT_H */
diff --git a/audio/out/internal.h b/audio/out/internal.h
index 4214c6c1d6..cc3abb14f5 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -27,6 +27,11 @@
// Minimum buffer size in seconds.
#define MIN_BUFFER 0.2
+// If ao_get_delay() reaches this value after ao_play() was called with the
+// AOPLAY_FINAL_CHUNK flag set, the playback core expects that the audio has
+// all been played.
+#define AO_EOF_DELAY 0.05
+
/* global data used by ao.c and ao drivers */
struct ao {
int samplerate;