summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-28 23:41:58 -0500
committersanine <sanine.not@pm.me>2022-08-28 23:41:58 -0500
commita0e405532e276bc1b2c9cae0e44295b17d987151 (patch)
tree06567f45b861756456c03651d07b78127d46a68f
parentd232fd1b3add3a93b81fc040d8b7e165590930cf (diff)
add channel_pause() and channel_resume()
-rw-r--r--src/channel.c12
-rw-r--r--src/channel.test.c26
2 files changed, 38 insertions, 0 deletions
diff --git a/src/channel.c b/src/channel.c
index b9242c4..0141569 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -28,6 +28,18 @@ void channel_reset(struct channel_t *chan)
}
+void channel_pause(struct channel_t *chan)
+{
+ p_atomic_int_set(&(chan->paused), true);
+}
+
+
+void channel_resume(struct channel_t *chan)
+{
+ p_atomic_int_set(&(chan->paused), false);
+}
+
+
void channel_get_next_sample(float *left, float *right, struct channel_t *chan)
{
bool active = p_atomic_int_get(&(chan->active));
diff --git a/src/channel.test.c b/src/channel.test.c
index 532d153..4fddf45 100644
--- a/src/channel.test.c
+++ b/src/channel.test.c
@@ -81,6 +81,29 @@ void test_channel_reset()
}
+void test_channel_pause()
+{
+ struct channel_t chan;
+ chan.paused = false;
+
+ channel_pause(&chan);
+
+ lily_assert_int_equal(chan.paused, true);
+}
+
+
+void test_channel_resume()
+{
+ struct channel_t chan;
+ chan.paused = true;
+
+ channel_resume(&chan);
+
+ lily_assert_int_equal(chan.paused, false);
+}
+
+
+/* get_next_sample tests */
void test_channel_get_next_sample_inactive()
{
lily_mock_use(&mock_p_mutex_trylock);
@@ -192,6 +215,9 @@ void suite_channel()
{
lily_run_test(test_channel_init);
lily_run_test(test_channel_reset);
+ lily_run_test(test_channel_pause);
+ lily_run_test(test_channel_resume);
+
lily_run_test(test_channel_get_next_sample_inactive);
lily_run_test(test_channel_get_next_sample_paused);
lily_run_test(test_channel_get_next_sample_normal);