From 8a2c631a9b6731f538633a22ab7c627ab15ca12f Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 8 Feb 2018 09:14:56 -0500 Subject: [PATCH] core/audio: Add a function for getting the current pause count This will be needed by the gui to find the current count at any time, without waiting for a callback. Signed-off-by: Anna Schumaker --- core/audio.c | 5 +++++ include/core/audio.h | 1 + tests/core/audio.c | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/core/audio.c b/core/audio.c index 899ac609..25728041 100644 --- a/core/audio.c +++ b/core/audio.c @@ -316,6 +316,11 @@ bool audio_pause_after(int n) return false; } +int audio_get_pause_count(void) +{ + return audio_pause_count; +} + #ifdef CONFIG_TESTING void test_audio_eos() { diff --git a/include/core/audio.h b/include/core/audio.h index 43eebc73..fbd552b8 100644 --- a/include/core/audio.h +++ b/include/core/audio.h @@ -78,6 +78,7 @@ struct track *audio_prev(); * Returns true if the value has been changed. */ bool audio_pause_after(int); +int audio_get_pause_count(void); #ifdef CONFIG_TESTING void test_audio_eos(); diff --git a/tests/core/audio.c b/tests/core/audio.c index a55bdb3b..fd484011 100644 --- a/tests/core/audio.c +++ b/tests/core/audio.c @@ -62,6 +62,7 @@ static void test_init() g_assert_cmpuint(audio_get_volume(), ==, 100); g_assert_null(audio_cur_track()); g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_NULL); + g_assert_cmpint(audio_get_pause_count(), ==, -1); g_assert_cmpuint(load_count, ==, 0); g_assert_cmpuint(state_count, ==, 0); @@ -203,24 +204,30 @@ void test_autopause() g_assert_true(audio_pause_after(3)); g_assert_cmpint(pause_count, ==, 3); + g_assert_cmpint(audio_get_pause_count(), ==, 3); g_assert_false(audio_pause_after(-2)); g_assert_cmpint(pause_count, ==, 3); + g_assert_cmpint(audio_get_pause_count(), ==, 3); pause_count = 0; g_assert_false(audio_pause_after(3)); g_assert_cmpint(pause_count, ==, 0); + g_assert_cmpint(audio_get_pause_count(), ==, 3); g_assert_true(audio_pause_after(-1)); g_assert_cmpint(pause_count, ==, -1); + g_assert_cmpint(audio_get_pause_count(), ==, -1); g_assert_true(audio_pause_after(5)); g_assert_cmpint(pause_count, ==, 5); + g_assert_cmpint(audio_get_pause_count(), ==, 5); state_count = 0; for (i = 4; i > -1; i--) { test_audio_eos(); g_assert_cmpint(pause_count, ==, i); + g_assert_cmpint(audio_get_pause_count(), ==, i); g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING); g_assert(playlist_at(history, 0) == audio_cur_track()); } @@ -229,6 +236,7 @@ void test_autopause() test_audio_eos(); while (idle_run_task()) {} g_assert_cmpint(pause_count, ==, -1); + g_assert_cmpint(audio_get_pause_count(), ==, -1); g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED); g_assert_cmpuint(test_wait_state(), ==, 6);