src/multimedia/audio/qaudio_symbian_p.h
changeset 19 fcece45ef507
child 25 e24348a560a6
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtMultimedia module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 //
       
    43 //  W A R N I N G
       
    44 //  -------------
       
    45 //
       
    46 // This file is not part of the Qt API.  It exists for the convenience
       
    47 // of other Qt classes.  This header file may change from version to
       
    48 // version without notice, or even be removed.
       
    49 //
       
    50 // We mean it.
       
    51 //
       
    52 
       
    53 #ifndef QAUDIO_SYMBIAN_P_H
       
    54 #define QAUDIO_SYMBIAN_P_H
       
    55 
       
    56 #include <QtCore/qnamespace.h>
       
    57 #include <QtMultimedia/qaudioformat.h>
       
    58 #include <QtMultimedia/qaudio.h>
       
    59 #include <sounddevice.h>
       
    60 
       
    61 QT_BEGIN_NAMESPACE
       
    62 
       
    63 namespace SymbianAudio {
       
    64 
       
    65 /**
       
    66  * Default values used by audio input and output classes, when underlying
       
    67  * DevSound instance has not yet been created.
       
    68  */
       
    69 
       
    70 const int DefaultBufferSize = 4096; // bytes
       
    71 const int DefaultNotifyInterval = 1000; // ms
       
    72 
       
    73 /**
       
    74  * Enumeration used to track state of internal DevSound instances.
       
    75  * Values are translated to the corresponding QAudio::State values by
       
    76  * SymbianAudio::Utils::stateNativeToQt.
       
    77  */
       
    78 enum State {
       
    79         ClosedState
       
    80     ,   InitializingState
       
    81     ,   ActiveState
       
    82     ,   IdleState
       
    83     ,   SuspendedState
       
    84 };
       
    85 
       
    86 /*
       
    87  * Helper class for querying DevSound codec / format support
       
    88  */
       
    89 class DevSoundCapabilities {
       
    90 public:
       
    91     DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode);
       
    92     ~DevSoundCapabilities();
       
    93 
       
    94     const RArray<TFourCC>& fourCC() const   { return m_fourCC; }
       
    95     const TMMFCapabilities& caps() const    { return m_caps; }
       
    96 
       
    97 private:
       
    98     void constructL(CMMFDevSound &devsound, QAudio::Mode mode);
       
    99 
       
   100 private:
       
   101     RArray<TFourCC> m_fourCC;
       
   102     TMMFCapabilities m_caps;
       
   103 };
       
   104 
       
   105 namespace Utils {
       
   106 
       
   107 /**
       
   108  * Convert native audio capabilities to QAudio lists.
       
   109  */
       
   110 void capabilitiesNativeToQt(const DevSoundCapabilities &caps,
       
   111                             QList<int> &frequencies,
       
   112                             QList<int> &channels,
       
   113                             QList<int> &sampleSizes,
       
   114                             QList<QAudioFormat::Endian> &byteOrders,
       
   115                             QList<QAudioFormat::SampleType> &sampleTypes);
       
   116 
       
   117 /**
       
   118  * Check whether format is supported.
       
   119  */
       
   120 bool isFormatSupported(const QAudioFormat &format,
       
   121                        const DevSoundCapabilities &caps);
       
   122 
       
   123 /**
       
   124  * Convert QAudioFormat to native format types.
       
   125  *
       
   126  * Note that, despite the name, DevSound uses TMMFCapabilities to specify
       
   127  * single formats as well as capabilities.
       
   128  *
       
   129  * Note that this function does not modify outputFormat.iBufferSize.
       
   130  */
       
   131 bool formatQtToNative(const QAudioFormat &inputFormat,
       
   132                       TUint32 &outputFourCC,
       
   133                       TMMFCapabilities &outputFormat);
       
   134 
       
   135 /**
       
   136  * Convert internal states to QAudio states.
       
   137  */
       
   138 QAudio::State stateNativeToQt(State nativeState,
       
   139                               QAudio::State initializingState);
       
   140 
       
   141 /**
       
   142  * Convert data length to number of samples.
       
   143  */
       
   144 qint64 bytesToSamples(const QAudioFormat &format, qint64 length);
       
   145 
       
   146 /**
       
   147  * Convert number of samples to data length.
       
   148  */
       
   149 qint64 samplesToBytes(const QAudioFormat &format, qint64 samples);
       
   150 
       
   151 } // namespace Utils
       
   152 } // namespace SymbianAudio
       
   153 
       
   154 QT_END_NAMESPACE
       
   155 
       
   156 #endif