<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qaudiodeviceinfo.cpp --> <title>QAudioDeviceInfo Class | Qt Multimedia 5.11</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtmultimedia-index.html">Qt Multimedia</a></td><td ><a href="qtmultimedia-modules.html">C++ Classes</a></td><td >QAudioDeviceInfo</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QAudioDeviceInfo Class</h1> <!-- $$$QAudioDeviceInfo-brief --> <p>The <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> class provides an interface to query audio devices and their functionality. <a href="#details">More...</a></p> <!-- @@@QAudioDeviceInfo --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QAudioDeviceInfo></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += multimedia</td></tr></table></div><ul> <li><a href="qaudiodeviceinfo-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#QAudioDeviceInfo-1">QAudioDeviceInfo</a></b>(const QAudioDeviceInfo &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#dtor.QAudioDeviceInfo">~QAudioDeviceInfo</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#deviceName">deviceName</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#isFormatSupported">isFormatSupported</a></b>(const QAudioFormat &<i>settings</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#isNull">isNull</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QAudioFormat </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#nearestFormat">nearestFormat</a></b>(const QAudioFormat &<i>settings</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QAudioFormat </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#preferredFormat">preferredFormat</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QList<QAudioFormat::Endian> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#supportedByteOrders">supportedByteOrders</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QList<int> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#supportedChannelCounts">supportedChannelCounts</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#supportedCodecs">supportedCodecs</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QList<int> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#supportedSampleRates">supportedSampleRates</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QList<int> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#supportedSampleSizes">supportedSampleSizes</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QList<QAudioFormat::SampleType> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#supportedSampleTypes">supportedSampleTypes</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#operator-not-eq">operator!=</a></b>(const QAudioDeviceInfo &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QAudioDeviceInfo &</td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#operator-eq">operator=</a></b>(const QAudioDeviceInfo &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#operator-eq-eq">operator==</a></b>(const QAudioDeviceInfo &<i>other</i>) const</td></tr> </table></div> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QList<QAudioDeviceInfo> </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#availableDevices">availableDevices</a></b>(QAudio::Mode <i>mode</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QAudioDeviceInfo </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#defaultInputDevice">defaultInputDevice</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QAudioDeviceInfo </td><td class="memItemRight bottomAlign"><b><a href="qaudiodeviceinfo.html#defaultOutputDevice">defaultOutputDevice</a></b>()</td></tr> </table></div> <a name="details"></a> <!-- $$$QAudioDeviceInfo-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> class provides an interface to query audio devices and their functionality.</p> <p><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> lets you query for audio devices--such as sound cards and USB headsets--that are currently available on the system. The audio devices available are dependent on the platform or audio plugins installed.</p> <p>A <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> is used by Qt to construct classes that communicate with the device--such as <a href="qaudioinput.html">QAudioInput</a>, and <a href="qaudiooutput.html">QAudioOutput</a>.</p> <p>You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte order, channel, codec, frequency, sample rate, and sample type. A format is represented by the <a href="qaudioformat.html">QAudioFormat</a> class.</p> <p>The values supported by the device for each of these parameters can be fetched with <a href="qaudiodeviceinfo.html#supportedByteOrders">supportedByteOrders</a>(), <a href="qaudiodeviceinfo.html#supportedChannelCounts">supportedChannelCounts</a>(), <a href="qaudiodeviceinfo.html#supportedCodecs">supportedCodecs</a>(), <a href="qaudiodeviceinfo.html#supportedSampleRates">supportedSampleRates</a>(), <a href="qaudiodeviceinfo.html#supportedSampleSizes">supportedSampleSizes</a>(), and <a href="qaudiodeviceinfo.html#supportedSampleTypes">supportedSampleTypes</a>(). The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with <a href="qaudiodeviceinfo.html#isFormatSupported">isFormatSupported</a>(), or fetch a supported format that is as close as possible to the format with <a href="qaudiodeviceinfo.html#nearestFormat">nearestFormat</a>(). For instance:</p> <pre class="cpp"> <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> format; format<span class="operator">.</span>setSampleRate(<span class="number">44100</span>); <span class="comment">// ... other format parameters</span> format<span class="operator">.</span>setSampleType(<span class="type"><a href="qaudioformat.html">QAudioFormat</a></span><span class="operator">::</span>SignedInt); <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> info(<span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span><span class="operator">::</span>defaultOutputDevice()); <span class="keyword">if</span> (<span class="operator">!</span>info<span class="operator">.</span>isFormatSupported(format)) format <span class="operator">=</span> info<span class="operator">.</span>nearestFormat(format); </pre> <p>The static functions <a href="qaudiodeviceinfo.html#defaultInputDevice">defaultInputDevice</a>(), <a href="qaudiodeviceinfo.html#defaultOutputDevice">defaultOutputDevice</a>(), and <a href="qaudiodeviceinfo.html#availableDevices">availableDevices</a>() let you get a list of all available devices. Devices are fetched according to the value of mode this is specified by the <a href="qaudio.html">QAudio</a>::Mode enum. The <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> returned are only valid for the <a href="qaudio.html">QAudio</a>::Mode.</p> <p>For instance:</p> <pre class="cpp"> foreach (<span class="keyword">const</span> <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> <span class="operator">&</span>deviceInfo<span class="operator">,</span> <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span><span class="operator">::</span>availableDevices(<span class="type">QAudio</span><span class="operator">::</span>AudioOutput)) <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"Device name: "</span> <span class="operator"><</span><span class="operator"><</span> deviceInfo<span class="operator">.</span>deviceName(); </pre> <p>In this code sample, we loop through all devices that are able to output sound, i.e., play an audio stream in a supported format. For each device we find, we simply print the <a href="qaudiodeviceinfo.html#deviceName">deviceName</a>().</p> </div> <p><b>See also </b><a href="qaudiooutput.html">QAudioOutput</a> and <a href="qaudioinput.html">QAudioInput</a>.</p> <!-- @@@QAudioDeviceInfo --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QAudioDeviceInfo[overload1]$$$QAudioDeviceInfo --> <h3 class="fn" id="QAudioDeviceInfo"><a name="QAudioDeviceInfo"></a>QAudioDeviceInfo::<span class="name">QAudioDeviceInfo</span>()</h3> <p>Constructs an empty <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> object.</p> <!-- @@@QAudioDeviceInfo --> <!-- $$$QAudioDeviceInfo$$$QAudioDeviceInfoconstQAudioDeviceInfo& --> <h3 class="fn" id="QAudioDeviceInfo-1"><a name="QAudioDeviceInfo-1"></a>QAudioDeviceInfo::<span class="name">QAudioDeviceInfo</span>(const <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> &<i>other</i>)</h3> <p>Constructs a copy of <i>other</i>.</p> <!-- @@@QAudioDeviceInfo --> <!-- $$$~QAudioDeviceInfo[overload1]$$$~QAudioDeviceInfo --> <h3 class="fn" id="dtor.QAudioDeviceInfo"><a name="dtor.QAudioDeviceInfo"></a>QAudioDeviceInfo::<span class="name">~QAudioDeviceInfo</span>()</h3> <p>Destroy this audio device info.</p> <!-- @@@~QAudioDeviceInfo --> <!-- $$$availableDevices[overload1]$$$availableDevicesQAudio::Mode --> <h3 class="fn" id="availableDevices"><a name="availableDevices"></a><code>[static] </code><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span>> QAudioDeviceInfo::<span class="name">availableDevices</span>(<span class="type">QAudio::Mode</span> <i>mode</i>)</h3> <p>Returns a list of audio devices that support <i>mode</i>.</p> <!-- @@@availableDevices --> <!-- $$$defaultInputDevice[overload1]$$$defaultInputDevice --> <h3 class="fn" id="defaultInputDevice"><a name="defaultInputDevice"></a><code>[static] </code><span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> QAudioDeviceInfo::<span class="name">defaultInputDevice</span>()</h3> <p>Returns the information for the default input audio device. All platform and audio plugin implementations provide a default audio device to use.</p> <!-- @@@defaultInputDevice --> <!-- $$$defaultOutputDevice[overload1]$$$defaultOutputDevice --> <h3 class="fn" id="defaultOutputDevice"><a name="defaultOutputDevice"></a><code>[static] </code><span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> QAudioDeviceInfo::<span class="name">defaultOutputDevice</span>()</h3> <p>Returns the information for the default output audio device. All platform and audio plugin implementations provide a default audio device to use.</p> <!-- @@@defaultOutputDevice --> <!-- $$$deviceName[overload1]$$$deviceName --> <h3 class="fn" id="deviceName"><a name="deviceName"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QAudioDeviceInfo::<span class="name">deviceName</span>() const</h3> <p>Returns the human readable name of the audio device.</p> <p>Device names vary depending on the platform/audio plugin being used.</p> <p>They are a unique string identifier for the audio device.</p> <p>eg. default, Intel, U0x46d0x9a4</p> <!-- @@@deviceName --> <!-- $$$isFormatSupported[overload1]$$$isFormatSupportedconstQAudioFormat& --> <h3 class="fn" id="isFormatSupported"><a name="isFormatSupported"></a><span class="type">bool</span> QAudioDeviceInfo::<span class="name">isFormatSupported</span>(const <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> &<i>settings</i>) const</h3> <p>Returns true if the supplied <i>settings</i> are supported by the audio device described by this <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a>.</p> <!-- @@@isFormatSupported --> <!-- $$$isNull[overload1]$$$isNull --> <h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QAudioDeviceInfo::<span class="name">isNull</span>() const</h3> <p>Returns whether this <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> object holds a valid device definition.</p> <!-- @@@isNull --> <!-- $$$nearestFormat[overload1]$$$nearestFormatconstQAudioFormat& --> <h3 class="fn" id="nearestFormat"><a name="nearestFormat"></a><span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> QAudioDeviceInfo::<span class="name">nearestFormat</span>(const <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> &<i>settings</i>) const</h3> <p>Returns the closest <a href="qaudioformat.html">QAudioFormat</a> to the supplied <i>settings</i> that the system supports.</p> <p>These settings are provided by the platform/audio plugin being used.</p> <p>They are also dependent on the <a href="qaudio.html">QAudio</a>::Mode being used.</p> <!-- @@@nearestFormat --> <!-- $$$preferredFormat[overload1]$$$preferredFormat --> <h3 class="fn" id="preferredFormat"><a name="preferredFormat"></a><span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> QAudioDeviceInfo::<span class="name">preferredFormat</span>() const</h3> <p>Returns the default audio format settings for this device.</p> <p>These settings are provided by the platform/audio plugin being used.</p> <p>They are also dependent on the <a href="qaudio.html">QAudio</a>::Mode being used.</p> <p>A typical audio system would provide something like:</p> <ul> <li>Input settings: 8000Hz mono 8 bit.</li> <li>Output settings: 44100Hz stereo 16 bit little endian.</li> </ul> <!-- @@@preferredFormat --> <!-- $$$supportedByteOrders[overload1]$$$supportedByteOrders --> <h3 class="fn" id="supportedByteOrders"><a name="supportedByteOrders"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type"><a href="qaudioformat.html#Endian-enum">QAudioFormat::Endian</a></span>> QAudioDeviceInfo::<span class="name">supportedByteOrders</span>() const</h3> <p>Returns a list of supported byte orders.</p> <!-- @@@supportedByteOrders --> <!-- $$$supportedChannelCounts[overload1]$$$supportedChannelCounts --> <h3 class="fn" id="supportedChannelCounts"><a name="supportedChannelCounts"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type">int</span>> QAudioDeviceInfo::<span class="name">supportedChannelCounts</span>() const</h3> <p>Returns a list of supported channel counts.</p> <p>This is typically 1 for mono sound, or 2 for stereo sound.</p> <!-- @@@supportedChannelCounts --> <!-- $$$supportedCodecs[overload1]$$$supportedCodecs --> <h3 class="fn" id="supportedCodecs"><a name="supportedCodecs"></a><span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> QAudioDeviceInfo::<span class="name">supportedCodecs</span>() const</h3> <p>Returns a list of supported codecs.</p> <p>All platform and plugin implementations should provide support for:</p> <p>"audio/pcm" - Linear PCM</p> <p>For writing plugins to support additional codecs refer to:</p> <p>http://www.iana.org/assignments/media-types/audio/</p> <!-- @@@supportedCodecs --> <!-- $$$supportedSampleRates[overload1]$$$supportedSampleRates --> <h3 class="fn" id="supportedSampleRates"><a name="supportedSampleRates"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type">int</span>> QAudioDeviceInfo::<span class="name">supportedSampleRates</span>() const</h3> <p>Returns a list of supported sample rates (in Hertz).</p> <!-- @@@supportedSampleRates --> <!-- $$$supportedSampleSizes[overload1]$$$supportedSampleSizes --> <h3 class="fn" id="supportedSampleSizes"><a name="supportedSampleSizes"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type">int</span>> QAudioDeviceInfo::<span class="name">supportedSampleSizes</span>() const</h3> <p>Returns a list of supported sample sizes (in bits).</p> <p>Typically this will include 8 and 16 bit sample sizes.</p> <!-- @@@supportedSampleSizes --> <!-- $$$supportedSampleTypes[overload1]$$$supportedSampleTypes --> <h3 class="fn" id="supportedSampleTypes"><a name="supportedSampleTypes"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type"><a href="qaudioformat.html#SampleType-enum">QAudioFormat::SampleType</a></span>> QAudioDeviceInfo::<span class="name">supportedSampleTypes</span>() const</h3> <p>Returns a list of supported sample types.</p> <!-- @@@supportedSampleTypes --> <!-- $$$operator!=[overload1]$$$operator!=constQAudioDeviceInfo& --> <h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QAudioDeviceInfo::<span class="name">operator!=</span>(const <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> &<i>other</i>) const</h3> <p>Returns true if this <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> class represents a different audio device than <i>other</i></p> <!-- @@@operator!= --> <!-- $$$operator=[overload1]$$$operator=constQAudioDeviceInfo& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> &QAudioDeviceInfo::<span class="name">operator=</span>(const <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> &<i>other</i>)</h3> <p>Sets the <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> object to be equal to <i>other</i>.</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQAudioDeviceInfo& --> <h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QAudioDeviceInfo::<span class="name">operator==</span>(const <span class="type"><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">QAudioDeviceInfo</a></span> &<i>other</i>) const</h3> <p>Returns true if this <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> class represents the same audio device as <i>other</i>.</p> <!-- @@@operator== --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>