#
# Define direct use case (no channel split or routing changes) macros
#

#
# Macro DirectUseCase
#
# Arguments:
#   Id - Use Case identifier (e.g. "Direct" or "Direct1")
#   [CardName] - optional, default is global CardName
#   [Comment] - optional, default is compibed from identifier and CardName
#   [PlaybackChannels] - optional, playback channels or/and
#   [CaptureChannels] - optional, capture channels
#   [PlaybackRate] - optional, in Hz
#   [CaptureRate] - optional, in Hz
#

DefineMacro.DirectUseCase {
	If.cardname {
		Condition {
			Type String
			Empty "${var:-__CardName}"
		}
		True.Define.__CardName "${CardName}"
	}
	If.comment {
		Condition {
			Type String
			Empty "${var:-__Comment}"
		}
		True.Define.__Comment "${var:__Id} ${var:__CardName}"
	}
	SectionUseCase."${var:__Id}" {
		Comment "Direct ${var:__CardName}"
		Config.SectionDevice."Direct" {
			Comment "Direct ${CardName}"
			Value {
				If.p {
					Condition {
						Type String
						Empty "${var:-__PlaybackChannels}"
					}
					False {
						PlaybackPriority 1000
						PlaybackChannels "${var:__PlaybackChannels}"
						PlaybackPCM "hw:${CardId}"
					}
				}
				If.c {
					Condition {
						Type String
						Empty "${var:-__CaptureChannels}"
					}
					False {
						CapturePriority 1000
						CaptureChannels "${var:__CaptureChannels}"
						CapturePCM "hw:${CardId}"
					}
				}
			}
			If.prate {
				Condition {
					Type String
					Empty "${var:-__PlaybackRate}"
				}
				False.Value.PlaybackRate "${var:-__PlaybackRate}"
			}
			If.crate {
				Condition {
					Type String
					Empty "${var:-__CaptureRate}"
				}
				False.Value.CaptureRate "${var:-__CaptureRate}"
			}
		}
	}
}
