@@ -471,6 +471,21 @@ static void virtio_snd_pcm_open(VirtIOSoundPCMStream *stream)
}
}
+/*
+ * Activate/deactivate a stream.
+ *
+ * @stream: VirtIOSoundPCMStream *stream
+ * @active: whether to activate or deactivate the stream
+ */
+static void virtio_snd_pcm_set_active(VirtIOSoundPCMStream *stream, bool active)
+{
+ if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
+ AUD_set_active_out(stream->voice.out, active);
+ } else {
+ AUD_set_active_in(stream->voice.in, active);
+ }
+}
+
/*
* Close a stream and free all its resources.
*
@@ -606,11 +621,7 @@ static uint32_t virtio_snd_pcm_start_stop(VirtIOSound *s,
stream->state = VSND_PCMSTREAM_STATE_STOPPED;
}
- if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
- AUD_set_active_out(stream->voice.out, start);
- } else {
- AUD_set_active_in(stream->voice.in, start);
- }
+ virtio_snd_pcm_set_active(stream, start);
return cpu_to_le32(VIRTIO_SND_S_OK);
}