summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);