159 lines
9.1 KiB
HTML
159 lines
9.1 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html lang="en">
|
|||
|
<head>
|
|||
|
<meta charset="utf-8">
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|||
|
<meta name="generator" content="rustdoc">
|
|||
|
<meta name="description" content="API documentation for the Rust `hctl` mod in crate `alsa`.">
|
|||
|
<meta name="keywords" content="rust, rustlang, rust-lang, hctl">
|
|||
|
|
|||
|
<title>alsa::hctl - Rust</title>
|
|||
|
|
|||
|
<link rel="stylesheet" type="text/css" href="../../normalize.css">
|
|||
|
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
|
|||
|
<link rel="stylesheet" type="text/css" href="../../main.css">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
<body class="rustdoc mod">
|
|||
|
<!--[if lte IE 8]>
|
|||
|
<div class="warning">
|
|||
|
This old browser is unsupported and will most likely display funky
|
|||
|
things.
|
|||
|
</div>
|
|||
|
<![endif]-->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<nav class="sidebar">
|
|||
|
|
|||
|
<p class='location'>Module hctl</p><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class='location'><a href='../index.html'>alsa</a></p><script>window.sidebarCurrent = {name: 'hctl', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
|
|||
|
</nav>
|
|||
|
|
|||
|
<nav class="sub">
|
|||
|
<form class="search-form js-only">
|
|||
|
<div class="search-container">
|
|||
|
<input class="search-input" name="search"
|
|||
|
autocomplete="off"
|
|||
|
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
|||
|
type="search">
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
</nav>
|
|||
|
|
|||
|
<section id='main' class="content">
|
|||
|
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>alsa</a>::<wbr><a class="mod" href=''>hctl</a></span><span class='out-of-band'><span id='render-detail'>
|
|||
|
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
|||
|
[<span class='inner'>−</span>]
|
|||
|
</a>
|
|||
|
</span><a class='srclink' href='../../src/alsa/hctl.rs.html#1-153' title='goto source code'>[src]</a></span></h1>
|
|||
|
<div class='docblock'><p>HCtl API - for mixer control and jack detection</p>
|
|||
|
|
|||
|
<h1 id='example' class='section-header'><a href='#example'>Example</a></h1>
|
|||
|
<p>Print all jacks and their status</p>
|
|||
|
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">for</span> <span class="ident">a</span> <span class="kw">in</span> ::<span class="ident">alsa</span>::<span class="ident">card</span>::<span class="ident">Iter</span>::<span class="ident">new</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span>.<span class="ident">unwrap</span>()) {
|
|||
|
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>;
|
|||
|
<span class="kw">use</span> <span class="ident">alsa</span>::<span class="ident">hctl</span>::<span class="ident">HCtl</span>;
|
|||
|
<span class="kw">let</span> <span class="ident">h</span> <span class="op">=</span> <span class="ident">HCtl</span>::<span class="ident">open</span>(<span class="kw-2">&</span><span class="ident">CString</span>::<span class="ident">new</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">"hw:{}"</span>, <span class="ident">a</span>.<span class="ident">get_index</span>())).<span class="ident">unwrap</span>(), <span class="bool-val">false</span>).<span class="ident">unwrap</span>();
|
|||
|
<span class="ident">h</span>.<span class="ident">load</span>().<span class="ident">unwrap</span>();
|
|||
|
<span class="kw">for</span> <span class="ident">b</span> <span class="kw">in</span> <span class="ident">h</span>.<span class="ident">elem_iter</span>() {
|
|||
|
<span class="kw">use</span> <span class="ident">alsa</span>::<span class="ident">ctl</span>::<span class="ident">ElemIface</span>;
|
|||
|
<span class="kw">let</span> <span class="ident">id</span> <span class="op">=</span> <span class="ident">b</span>.<span class="ident">get_id</span>().<span class="ident">unwrap</span>();
|
|||
|
<span class="kw">if</span> <span class="ident">id</span>.<span class="ident">get_interface</span>() <span class="op">!=</span> <span class="ident">ElemIface</span>::<span class="ident">Card</span> { <span class="kw">continue</span>; }
|
|||
|
<span class="kw">let</span> <span class="ident">name</span> <span class="op">=</span> <span class="ident">id</span>.<span class="ident">get_name</span>().<span class="ident">unwrap</span>();
|
|||
|
<span class="kw">if</span> <span class="op">!</span><span class="ident">name</span>.<span class="ident">ends_with</span>(<span class="string">" Jack"</span>) { <span class="kw">continue</span>; }
|
|||
|
<span class="kw">if</span> <span class="ident">name</span>.<span class="ident">ends_with</span>(<span class="string">" Phantom Jack"</span>) {
|
|||
|
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{} is always present"</span>, <span class="kw-2">&</span><span class="ident">name</span>[..<span class="ident">name</span>.<span class="ident">len</span>()<span class="op">-</span><span class="number">13</span>])
|
|||
|
}
|
|||
|
<span class="kw">else</span> { <span class="macro">println</span><span class="macro">!</span>(<span class="string">"{} is {}"</span>, <span class="kw-2">&</span><span class="ident">name</span>[..<span class="ident">name</span>.<span class="ident">len</span>()<span class="op">-</span><span class="number">5</span>],
|
|||
|
<span class="kw">if</span> <span class="ident">b</span>.<span class="ident">read</span>().<span class="ident">unwrap</span>().<span class="ident">get_boolean</span>(<span class="number">0</span>).<span class="ident">unwrap</span>() { <span class="string">"plugged in"</span> } <span class="kw">else</span> { <span class="string">"unplugged"</span> })
|
|||
|
}
|
|||
|
}
|
|||
|
}</pre>
|
|||
|
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
|||
|
<table>
|
|||
|
<tr class=' module-item'>
|
|||
|
<td><a class="struct" href="struct.Elem.html"
|
|||
|
title='struct alsa::hctl::Elem'>Elem</a></td>
|
|||
|
<td class='docblock-short'>
|
|||
|
<p><a href="http://www.alsa-project.org/alsa-doc/alsa-lib/group___h_control.html">snd_hctl_elem_t</a> wrapper</p>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class=' module-item'>
|
|||
|
<td><a class="struct" href="struct.ElemIter.html"
|
|||
|
title='struct alsa::hctl::ElemIter'>ElemIter</a></td>
|
|||
|
<td class='docblock-short'>
|
|||
|
<p>Iterates over elements for a <code>HCtl</code></p>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class=' module-item'>
|
|||
|
<td><a class="struct" href="struct.HCtl.html"
|
|||
|
title='struct alsa::hctl::HCtl'>HCtl</a></td>
|
|||
|
<td class='docblock-short'>
|
|||
|
<p><a href="http://www.alsa-project.org/alsa-doc/alsa-lib/group___h_control.html">snd_hctl_t</a> wrapper</p>
|
|||
|
</td>
|
|||
|
</tr></table></section>
|
|||
|
<section id='search' class="content hidden"></section>
|
|||
|
|
|||
|
<section class="footer"></section>
|
|||
|
|
|||
|
<aside id="help" class="hidden">
|
|||
|
<div>
|
|||
|
<h1 class="hidden">Help</h1>
|
|||
|
|
|||
|
<div class="shortcuts">
|
|||
|
<h2>Keyboard Shortcuts</h2>
|
|||
|
|
|||
|
<dl>
|
|||
|
<dt>?</dt>
|
|||
|
<dd>Show this help dialog</dd>
|
|||
|
<dt>S</dt>
|
|||
|
<dd>Focus the search field</dd>
|
|||
|
<dt>⇤</dt>
|
|||
|
<dd>Move up in search results</dd>
|
|||
|
<dt>⇥</dt>
|
|||
|
<dd>Move down in search results</dd>
|
|||
|
<dt>⏎</dt>
|
|||
|
<dd>Go to active search result</dd>
|
|||
|
<dt>+</dt>
|
|||
|
<dd>Collapse/expand all sections</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="infos">
|
|||
|
<h2>Search Tricks</h2>
|
|||
|
|
|||
|
<p>
|
|||
|
Prefix searches with a type followed by a colon (e.g.
|
|||
|
<code>fn:</code>) to restrict the search to a given type.
|
|||
|
</p>
|
|||
|
|
|||
|
<p>
|
|||
|
Accepted types are: <code>fn</code>, <code>mod</code>,
|
|||
|
<code>struct</code>, <code>enum</code>,
|
|||
|
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
|||
|
and <code>const</code>.
|
|||
|
</p>
|
|||
|
|
|||
|
<p>
|
|||
|
Search functions by type signature (e.g.
|
|||
|
<code>vec -> usize</code> or <code>* -> vec</code>)
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</aside>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<script>
|
|||
|
window.rootPath = "../../";
|
|||
|
window.currentCrate = "alsa";
|
|||
|
</script>
|
|||
|
<script src="../../main.js"></script>
|
|||
|
<script defer src="../../search-index.js"></script>
|
|||
|
</body>
|
|||
|
</html>
|