pnmixer-rust/alsa_card/struct.AlsaCard.html

200 lines
17 KiB
HTML
Raw Normal View History

2017-07-14 23:24:09 +00:00
<!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 `AlsaCard` struct in crate `pnmixerlib`.">
<meta name="keywords" content="rust, rustlang, rust-lang, AlsaCard">
<title>pnmixerlib::alsa_card::AlsaCard - 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 struct">
<!--[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'>Struct AlsaCard</p><div class="block items"><ul><li><a href="#fields">Fields</a></li><li><a href="#methods">Methods</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='../index.html'>pnmixerlib</a>::<wbr><a href='index.html'>alsa_card</a></p><script>window.sidebarCurrent = {name: 'AlsaCard', ty: 'struct', 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'>Struct <a href='../index.html'>pnmixerlib</a>::<wbr><a href='index.html'>alsa_card</a>::<wbr><a class="struct" href=''>AlsaCard</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'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../../src/pnmixerlib/alsa_card.rs.html#42-56' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct AlsaCard {
pub card: <a class="struct" href="../../alsa/card/struct.Card.html" title="struct alsa::card::Card">Card</a>,
pub mixer: <a class="struct" href="../../alsa/mixer/struct.Mixer.html" title="struct alsa::mixer::Mixer">Mixer</a>,
pub selem_id: <a class="struct" href="../../alsa/mixer/struct.SelemId.html" title="struct alsa::mixer::SelemId">SelemId</a>,
pub watch_ids: <a class="struct" href="https://doc.rust-lang.org/nightly/core/cell/struct.Cell.html" title="struct core::cell::Cell">Cell</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>&gt;&gt;,
pub cb: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html" title="struct alloc::rc::Rc">Rc</a>&lt;<a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="enum" href="../../pnmixerlib/alsa_card/enum.AlsaEvent.html" title="enum pnmixerlib::alsa_card::AlsaEvent">AlsaEvent</a>)&gt;,
// some fields omitted
}</pre><div class='docblock'><p>A fairly high-level alsa card struct. We save some redundant
information in order to access it more easily, in addition to
some information that is not purely alsa related (like callbacks).</p>
</div><h2 id='fields' class='fields'>Fields</h2><span id='structfield.card' class="structfield">
<span id='card.v' class='invisible'>
<code>card: <a class="struct" href="../../alsa/card/struct.Card.html" title="struct alsa::card::Card">Card</a></code>
</span></span><div class='docblock'><p>The raw alsa card.</p>
</div><span id='structfield.mixer' class="structfield">
<span id='mixer.v' class='invisible'>
<code>mixer: <a class="struct" href="../../alsa/mixer/struct.Mixer.html" title="struct alsa::mixer::Mixer">Mixer</a></code>
</span></span><div class='docblock'><p>The raw mixer.</p>
</div><span id='structfield.selem_id' class="structfield">
<span id='selem_id.v' class='invisible'>
<code>selem_id: <a class="struct" href="../../alsa/mixer/struct.SelemId.html" title="struct alsa::mixer::SelemId">SelemId</a></code>
</span></span><div class='docblock'><p>The simple element ID. <code>Selem</code> doesn&#39;t implement the Copy trait
so we save the ID instead and can get the <code>Selem</code> by lookup.</p>
</div><span id='structfield.watch_ids' class="structfield">
<span id='watch_ids.v' class='invisible'>
<code>watch_ids: <a class="struct" href="https://doc.rust-lang.org/nightly/core/cell/struct.Cell.html" title="struct core::cell::Cell">Cell</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>&gt;&gt;</code>
</span></span><div class='docblock'><p>Watch IDs from polling the alsa card. We need them when we
drop the card, so we can unregister the polling.</p>
</div><span id='structfield.cb' class="structfield">
<span id='cb.v' class='invisible'>
<code>cb: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html" title="struct alloc::rc::Rc">Rc</a>&lt;<a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="enum" href="../../pnmixerlib/alsa_card/enum.AlsaEvent.html" title="enum pnmixerlib::alsa_card::AlsaEvent">AlsaEvent</a>)&gt;</code>
</span></span><div class='docblock'><p>Callback for the various <code>AlsaEvent</code>s.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class="struct" href="../../pnmixerlib/alsa_card/struct.AlsaCard.html" title="struct pnmixerlib::alsa_card::AlsaCard">AlsaCard</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/pnmixerlib/alsa_card.rs.html#59-260' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>fn <a href='#method.new' class='fnname'>new</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;card_name: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;elem_name: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;cb: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html" title="struct alloc::rc::Rc">Rc</a>&lt;<a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="enum" href="../../pnmixerlib/alsa_card/enum.AlsaEvent.html" title="enum pnmixerlib::alsa_card::AlsaEvent">AlsaEvent</a>)&gt;<br>) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a>&lt;<a class="struct" href="../../pnmixerlib/alsa_card/struct.AlsaCard.html" title="struct pnmixerlib::alsa_card::AlsaCard">AlsaCard</a>&gt;&gt;</code></span></h4>
<div class='docblock'><p>Create a new alsa card. Tries very hard to get a valid, playable
card and mixer, so this is not a &#39;strict&#39; function.</p>
<h2 id='card_name' class='section-header'><a href='#card_name'><code>card_name</code></a></h2>
<p>If a card name is provided, it will be tried. If <code>None</code> is provided
or the given card name does not exist or is not playable, any other
playable card is tried.</p>
<h2 id='elem_name' class='section-header'><a href='#elem_name'><code>elem_name</code></a></h2>
<p>If an elem name is provided, it will be tried. If <code>None</code> is provided
or the given elem name does not exist or is not playable, any other
playable elem is tried.</p>
<h2 id='cb' class='section-header'><a href='#cb'><code>cb</code></a></h2>
<p>Callback for the various <code>AlsaEvent</code>s.</p>
<h1 id='returns' class='section-header'><a href='#returns'>Returns</a></h1>
<p><code>Ok(Box&lt;AlsaCard&gt;)</code> on success, <code>Err(error)</code> otherwise.</p>
</div><h4 id='method.card_name' class="method"><span id='card_name.v' class='invisible'><code>fn <a href='#method.card_name' class='fnname'>card_name</a>(&amp;self) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</code></span></h4>
<div class='docblock'><p>Get the name of the alsa card.</p>
</div><h4 id='method.chan_name' class="method"><span id='chan_name.v' class='invisible'><code>fn <a href='#method.chan_name' class='fnname'>chan_name</a>(&amp;self) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</code></span></h4>
<div class='docblock'><p>Get the name of the channel.</p>
</div><h4 id='method.selem' class="method"><span id='selem.v' class='invisible'><code>fn <a href='#method.selem' class='fnname'>selem</a>(&amp;self) -&gt; <a class="struct" href="../../alsa/mixer/struct.Selem.html" title="struct alsa::mixer::Selem">Selem</a></code></span></h4>
<div class='docblock'><p>Get the <code>Selem</code>, looked up by the <code>SelemId</code>.</p>
</div><h4 id='method.get_vol' class="method"><span id='get_vol.v' class='invisible'><code>fn <a href='#method.get_vol' class='fnname'>get_vol</a>(&amp;self) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>&gt;</code></span></h4>
<div class='docblock'><p>Get the current volume. The returned value corresponds to the
volume range and might need to be interpreted (such as converting
to percentage). This always gets
the volume of the <code>FrontRight</code> channel, because the seems to be
the safest bet.</p>
</div><h4 id='method.set_vol' class="method"><span id='set_vol.v' class='invisible'><code>fn <a href='#method.set_vol' class='fnname'>set_vol</a>(&amp;self, new_vol: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">()</a>&gt;</code></span></h4>
<div class='docblock'><p>Sets the volume of the current card configuration.</p>
<h2 id='new_vol' class='section-header'><a href='#new_vol'><code>new_vol</code></a></h2>
<p>The volume corresponding to the volume range of the <code>Selem</code>. This
might need to be translated properly first from other formats
(like percentage).</p>
</div><h4 id='method.get_volume_range' class="method"><span id='get_volume_range.v' class='invisible'><code>fn <a href='#method.get_volume_range' class='fnname'>get_volume_range</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
<div class='docblock'><p>Gets the volume range of the currently selected card configuration.</p>
<h1 id='returns-1' class='section-header'><a href='#returns-1'>Returns</a></h1>
<p><code>(min, max)</code></p>
</div><h4 id='method.has_mute' class="method"><span id='has_mute.v' class='invisible'><code>fn <a href='#method.has_mute' class='fnname'>has_mute</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>Whether the current card configuration can be muted.</p>
</div><h4 id='method.get_mute' class="method"><span id='get_mute.v' class='invisible'><code>fn <a href='#method.get_mute' class='fnname'>get_mute</a>(&amp;self) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</code></span></h4>
<div class='docblock'><p>Get the mute state of the current card configuration.</p>
</div><h4 id='method.set_mute' class="method"><span id='set_mute.v' class='invisible'><code>fn <a href='#method.set_mute' class='fnname'>set_mute</a>(&amp;self, mute: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="../../pnmixerlib/errors/type.Result.html" title="type pnmixerlib::errors::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">()</a>&gt;</code></span></h4>
<div class='docblock'><p>Set the mute state of the current card configuration.</p>
<h2 id='mute' class='section-header'><a href='#mute'><code>mute</code></a></h2>
<p>Passing <code>true</code> here means the card will be muted.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="../../pnmixerlib/alsa_card/struct.AlsaCard.html" title="struct pnmixerlib::alsa_card::AlsaCard">AlsaCard</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/pnmixerlib/alsa_card.rs.html#263-269' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.drop' class="method"><span id='drop.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop' class='fnname'>drop</a>(&amp;mut self)</code></span></h4>
<div class='docblock'><p>Destructs the watch IDs corresponding to the current poll descriptors.</p>
</div></div></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>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</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 = "pnmixerlib";
</script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>