1 /*
2  INTEL CONFIDENTIAL
3  Copyright 2009 Intel Corporation All Rights Reserved.
4  The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets and proprietary and confidential information of Intel or its suppliers and licensors. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intel’s prior express written permission.
5 
6  No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing.
7 */
8 
9 #ifndef __MIX_AUDIO_H__
10 #define __MIX_AUDIO_H__
11 
12 #include <glib-object.h>
13 #include "mixacp.h"
14 #include "mixaip.h"
15 #include "mixdrmparams.h"
16 #include "mixresult.h"
17 #include "mixaudiotypes.h"
18 
19 /*
20  * Type macros.
21  */
22 #define MIX_TYPE_AUDIO                  (mix_audio_get_type ())
23 #define MIX_AUDIO(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIX_TYPE_AUDIO, MixAudio))
24 #define MIX_IS_AUDIO(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIX_TYPE_AUDIO))
25 #define MIX_AUDIO_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), MIX_TYPE_AUDIO, MixAudioClass))
26 #define MIX_IS_AUDIO_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), MIX_TYPE_AUDIO))
27 #define MIX_AUDIO_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), MIX_TYPE_AUDIO, MixAudioClass))
28 
29 typedef struct _MixAudio        MixAudio;
30 typedef struct _MixAudioClass   MixAudioClass;
31 
32 /**
33  * MixStreamState:
34  * @MIX_STREAM_NULL: Stream is not allocated.
35  * @MIX_STREAM_STOPPED: Stream is at STOP state. This is the only state DNR is allowed.
36  * @MIX_STREAM_PLAYING: Stream is at Playing state.
37  * @MIX_STREAM_PAUSED: Stream is Paused.
38  * @MIX_STREAM_DRAINING: Stream is draining -- remaining of the buffer in the device are playing. This state is special due to the limitation that no other control operations are allowed at this state. Stream will become @MIX_STREAM_STOPPED automatically when this data draining has completed.
39  * @MIX_STREAM_LAST: Last index in the enumeration.
40  *
41  * Stream State during Decode and Render or Encode mode. These states do not apply to Decode and Return mode.
42  */
43 typedef enum {
44   MIX_STREAM_NULL=0,
45   MIX_STREAM_STOPPED,
46   MIX_STREAM_PLAYING,
47   MIX_STREAM_PAUSED,
48   MIX_STREAM_DRAINING,
49   MIX_STREAM_LAST
50 } MixStreamState;
51 
52 /**
53  * MixState:
54  * @MIX_STATE_UNINITIALIZED: MIX is not initialized.
55  * @MIX_STATE_INITIALIZED: MIX is initialized.
56  * @MIX_STATE_CONFIGURED: MIX is configured successfully.
57  * @MIX_STATE_LAST: Last index in the enumeration.
58  *
59  * The varies states the device is in.
60  */
61 typedef enum {
62   MIX_STATE_NULL=0,
63   MIX_STATE_UNINITIALIZED,
64   MIX_STATE_INITIALIZED,
65   MIX_STATE_CONFIGURED,
66   MIX_STATE_LAST
67 } MixState;
68 
69 /**
70  * MixCodecMode:
71  * @MIX_CODING_INVALID: Indicates device uninitialied for any mode.
72  * @MIX_CODING_ENCODE: Indicates device is opened for encoding.
73  * @MIX_CODING_DECODE: Indicates device is opened for decoding.
74  * @MIX_CODING_LAST: Last index in the enumeration.
75  *
76  * Mode where device is operating on. See mix_audio_initialize().
77  */
78 typedef enum {
79   MIX_CODING_INVALID=0,
80   MIX_CODING_ENCODE,
81   MIX_CODING_DECODE,
82   MIX_CODING_LAST
83 } MixCodecMode;
84 
85 /**
86  * MixVolType:
87  * @MIX_VOL_PERCENT: volume is expressed in percentage.
88  * @MIX_VOL_DECIBELS: volume is expressed in decibel.
89  * @MIX_VOL_LAST: last entry.
90  *
91  * See mix_audio_getvolume() and mix_audio_setvolume().
92  */
93 typedef enum {
94   MIX_VOL_PERCENT=0,
95   MIX_VOL_DECIBELS,
96   MIX_VOL_LAST
97 } MixVolType;
98 
99 /**
100  * MixVolRamp:
101  * @MIX_RAMP_LINEAR: volume is expressed in percentage.
102  * @MIX_RAMP_EXPONENTIAL: volume is expressed in decibel.
103  * @MIX_RAMP_LAST: last entry.
104  *
105  * See mix_audio_getvolume() and mix_audio_setvolume().
106  */
107 typedef enum
108 {
109   MIX_RAMP_LINEAR = 0,
110   MIX_RAMP_EXPONENTIAL,
111   MIX_RAMP_LAST
112 } MixVolRamp;
113 
114 /**
115  * MixIOVec:
116  * @data: data pointer
117  * @size: size of buffer in @data
118  *
119  * Scatter-gather style structure. To be used by mix_audio_decode() method for input and output buffer.
120  */
121 typedef struct {
122   guchar *data;
123   gint size;
124 } MixIOVec;
125 
126 /**
127  * MixDeviceState:
128  * @MIX_AUDIO_DEV_CLOSED: TBD
129  * @MIX_AUDIO_DEV_OPENED: TBD
130  * @MIX_AUDIO_DEV_ALLOCATED: TBD
131  *
132  * Device state.
133  */
134 typedef enum {
135   MIX_AUDIO_DEV_CLOSED=0,
136   MIX_AUDIO_DEV_OPENED,
137   MIX_AUDIO_DEV_ALLOCATED
138 } MixDeviceState;
139 
140 /**
141  * MixAudioClass:
142  * @parent_class: Parent class;
143  *
144  * MI-X Audio object class
145  */
146 struct _MixAudioClass
147 {
148   /*< public >*/
149   GObjectClass parent_class;
150 
151   /*< virtual public >*/
152   MIX_RESULT (*initialize) (MixAudio *mix, MixCodecMode mode, MixAudioInitParams *aip, MixDrmParams *drminitparams);
153   MIX_RESULT (*configure) (MixAudio *mix, MixAudioConfigParams *audioconfigparams, MixDrmParams *drmparams);
154   MIX_RESULT (*decode) (MixAudio *mix, const MixIOVec *iovin, gint iovincnt, guint64 *insize, MixIOVec *iovout, gint iovoutcnt, guint64 *outsize);
155   MIX_RESULT (*capture_encode) (MixAudio *mix, MixIOVec *iovout, gint iovoutcnt);
156   MIX_RESULT (*start) (MixAudio *mix);
157   MIX_RESULT (*stop_drop) (MixAudio *mix);
158   MIX_RESULT (*stop_drain) (MixAudio *mix);
159   MIX_RESULT (*pause) (MixAudio *mix);
160   MIX_RESULT (*resume) (MixAudio *mix);
161   MIX_RESULT (*get_timestamp) (MixAudio *mix, guint64 *msecs);
162   MIX_RESULT (*set_mute) (MixAudio *mix, gboolean mute);
163   MIX_RESULT (*get_mute) (MixAudio *mix, gboolean* muted);
164   MIX_RESULT (*get_max_vol) (MixAudio *mix, gint *maxvol);
165   MIX_RESULT (*get_min_vol) (MixAudio *mix, gint *minvol);
166   MIX_RESULT (*get_volume) (MixAudio *mix, gint *currvol, MixVolType type);
167   MIX_RESULT (*set_volume) (MixAudio *mix, gint currvol, MixVolType type, gulong msecs, MixVolRamp ramptype);
168   MIX_RESULT (*deinitialize) (MixAudio *mix);
169   MIX_RESULT (*get_stream_state) (MixAudio *mix, MixStreamState *streamState);
170   MIX_RESULT (*get_state) (MixAudio *mix, MixState *state);
171   MIX_RESULT (*is_am_available) (MixAudio *mix, MixAudioManager am, gboolean *avail);
172   MIX_RESULT (*get_output_configuration) (MixAudio *mix, MixAudioConfigParams **audioconfigparams);
173 };
174 
175 /**
176  * MixAudio:
177  * @parent: Parent object.
178  * @streamState: Current state of the stream
179  * @decodeMode: Current decode mode of the device. This value is valid only when @codingMode equals #MIX_CODING_DECODE.
180  * @fileDescriptor: File Descriptor to the opened device.
181  * @state: State of the current #MixAudio session.
182  * @codecMode: Current codec mode of the session.
183  * @useIAM: Is current stream configured to use Intel Audio Manager.
184  * @encoding: <emphasis>Not Used.</emphasis>
185  *
186  * MI-X Audio object
187  */
188 struct _MixAudio
189 {
190   /*< public >*/
191   GObject parent;
192 
193   /*< public >*/
194 
195   /*< private >*/
196   MixStreamState streamState;
197   gchar *encoding;
198   MixState state;
199   MixCodecMode codecMode;
200   gboolean useIAM;
201   int fileDescriptor;
202   gint streamID;
203   guint32 amStreamID;
204   GStaticRecMutex streamlock; // lock that must be acquired to invoke stream method.
205   GStaticRecMutex controllock; // lock that must be acquired to call control function.
206   MixAudioConfigParams *audioconfigparams;
207   gboolean am_registered;
208   MixDeviceState deviceState;
209 
210   guint64 ts_last;
211   guint64 ts_elapsed;
212   guint64 bytes_written;
213 };
214 
215 /**
216  * mix_audio_get_type:
217  * @returns: type
218  *
219  * Get the type of object.
220  */
221 GType mix_audio_get_type (void);
222 
223 /**
224  * mix_audio_new:
225  * @returns: A newly allocated instance of #MixAudio
226  *
227  * Use this method to create new instance of #MixAudio
228  */
229 MixAudio *mix_audio_new(void);
230 
231 /**
232  * mix_audio_ref:
233  * @mix: object to add reference
234  * @returns: the MixAudio instance where reference count has been increased.
235  *
236  * Add reference count.
237  */
238 MixAudio *mix_audio_ref(MixAudio *mix);
239 
240 /**
241  * mix_audio_unref:
242  * @obj: object to unref.
243  *
244  * Decrement reference count of the object.
245  */
246 #define mix_audio_unref(obj) g_object_unref (G_OBJECT(obj))
247 
248 /* Class Methods */
249 
250 /**
251  * mix_audio_get_version:
252  * @returns: #MIX_RESULT_SUCCESS
253  *
254  * Returns the version of the MI-X library.
255  *
256  */
257 MIX_RESULT mix_audio_get_version(guint* major, guint *minor);
258 
259 /**
260  * mix_audio_initialize:
261  * @mix: #MixAudio object.
262  * @mode: Requested #MixCodecMode.
263  * @aip: Audio initialization parameters.
264  * @drminitparams: <emphasis>Optional.</emphasis> DRM initialization param if applicable.
265  * @returns: #MIX_RESULT_SUCCESS on successful initilaization. #MIX_RESULT_ALREADY_INIT if session is already initialized.
266  *
267  * This function will initialize an encode or decode session with this #MixAudio instance.  During this call, the device will be opened. If the device is not available, an error is returned to the caller so that an alternative (e.g. software decoding) can be configured instead. Use mix_audio_deinitialize() to close the device.
268  *
269  * A previous initialized session must be de-initialized using mix_audio_deinitialize() before it can be initialized again.
270  */
271 MIX_RESULT mix_audio_initialize(MixAudio *mix, MixCodecMode mode, MixAudioInitParams *aip, MixDrmParams *drminitparams);
272 
273 /**
274  * mix_audio_configure:
275  * @mix: #MixAudio object.
276  * @audioconfigparams: a #MixAudioConfigParams derived object containing information for the specific stream type.
277  * @drmparams: <emphasis>Optional.</emphasis> DRM initialization param if applicable.
278  * @returns: Result indicates successful or not.
279  *
280  * This function can be used to configure a stream for the current session.  The caller can use this function to do the following:
281  *
282  * <itemizedlist>
283  * <listitem>Choose decoding mode (direct-render or decode-return)</listitem>
284  * <listitem>Provide DRM parameters (using DRMparams object)</listitem>
285  * <listitem>Provide stream parameters (using STRMparams objects)</listitem>
286  * <listitem>Provide a stream name for the Intel Smart Sound Technology stream</listitem>
287  * </itemizedlist>
288  *
289  * SST stream parameters will be set during this call, and stream resources allocated in SST.
290  *
291  * <note>
292  * <title>Intel Audio Manager support:</title>
293  * <para>If Intel Audio Manager support is enabled, and if @mode is specified to #MIX_DECODE_DIRECTRENDER, the SST stream will be registered with Intel Audio Manager in the context of this call, using the stream name provided in @streamname. Application will receive a notification from Intel Audio Manager that the stream has been created during or soon after this call. The application should be ready to handle either possibility.  A stream ID (associated with the stream name) will be provided by Intel Audio Manager which will be used for subsequent notifications from Intel Audio Manager or calls to Intel Audio Manager for muting, pause and resume. See mix_audio_getstreamid()</para>
294  * <para>If a stream is already registered with Intel Audio Manager, application must pass the same @streamname argument to retain the session. Otherwise, the existing stream will be unregistered and a new stream will be registered with the new @streamname.
295  * </para>
296  * </note>
297  *
298  * If @mode is specified to #MIX_DECODE_DIRECTRENDER but direct-render mode is not available (due to end user use of alternative output device), an error indication will be returned to the caller so that an alternate pipeline configuration can be created (e.g. including a Pulse Audio sink, and support for output buffers).  In this case, the caller will need to call mix_audio_configure() again to with @mode specify as #MIX_DECODE_DECODERETURN to request decode-return mode.
299  *
300  * This method can be called multiple times if reconfiguration of the stream is needed. However, this method must be called when the stream is in #MIX_STREAM_STOPPED state.
301  *
302  */
303 MIX_RESULT mix_audio_configure(MixAudio *mix, MixAudioConfigParams *audioconfigparams, MixDrmParams *drmparams);
304 
305 /**
306  * mix_audio_decode:
307  * @mix: #MixAudio object.
308  * @iovin: a pointer to an array of #MixIOVec structure that contains the input buffers
309  * @iovincnt: the number of entry in the @iovin array
310  * @iovout: a pointer to an arrya of #MixIOVec structure that represent the output buffer. During input, each size in the #MixIOVec array represents the available buffer size pointed to by data. Upon return, each size value will be updated to reflect how much data has been filled. This parameter is ignored if stream is configured to #MIX_DECODE_DIRECTRENDER. See mix_audio_configure() for more detail.
311  * @iovoutcnt: in/out parameter which when input, it contains the number of entry available in the @iovout array. Upon return, this value will be updated to reflect how many entry in the @iovout array has been populated with data. This parameter is ignored if stream is configured to #MIX_DECODE_DIRECTRENDER. See mix_audio_configure() for more detail.
312  * @outsize: Total number of bytes returned for the decode session. This parameter is ignored if stream is configured to #MIX_DECODE_DIRECTRENDER.
313  * @returns: #MIX_RESULT
314  *
315  * This function is used to initiate HW accelerated decoding of encoded data buffers.  This function may be used in two major modes, direct-render or decode-return.
316  *
317  * With direct-render, input buffers are provided by the caller which hold encoded audio data, and no output buffers are provided.  The encoded data is decoded, and the decoded data is sent directly to the output speaker.  This allows very low power audio rendering and is the best choice of operation for longer battery life.
318  *
319  * <note>
320  * <title>Intel Audio Manager Support</title>
321  * However, if the user has connected a different target output device, such as Bluetooth headphones, this mode cannot be used as the decoded audio must be directed to the Pulse Audio stack where the output to Bluetooth device can be supported, per Intel Audio Manager guidelines.  This mode is called decode-return, and requires the caller to provide output buffers for the decoded data.
322  * </note>
323  *
324  * Input buffers in both modes are one or more user space buffers using a scatter/gather style vector interface.
325  *
326  * Output buffers for the decode-return mode are one or more user space buffers in a scatter style vector interface.  Buffers will be filled in order and lengths of data filled will be returned.
327  *
328  * This call will block until data has been completely copied or queued to the driver.  All user space buffers may be used or released when this call returns.
329  *
330  * Note: If the stream is configured as #MIX_DECODE_DIRECTRENDER, and whenever the stream in #MIX_STREAM_STOPPED state, the call to mix_audio_decode() will not start the playback until mix_audio_start() is called. This behavior would allow application to queue up data but delay the playback until appropriate time.
331  *
332  */
333 MIX_RESULT mix_audio_decode(MixAudio *mix, const MixIOVec *iovin, gint iovincnt, guint64 *insize, MixIOVec *iovout, gint iovoutcnt, guint64 *outsize);
334 
335 /**
336  * mix_audio_capture_encode:
337  * @mix: #MixAudio object.
338  * @iovout: Capture audio samples.
339  * @iovoutcnt: Number of entry in the input vector @iovout.
340  * @returns: #MIX_RESULT
341  *
342  * To read encoded data from device.
343  *
344  * <comment>
345  * NOTE: May need to rename to "read_encoded" or other name. Since "encode" seems to mean taking raw audio and convert to compressed audio.
346  * </comment>
347  */
348 MIX_RESULT mix_audio_capture_encode(MixAudio *mix, MixIOVec *iovout, gint iovoutcnt);
349 
350 /**
351  * mix_audio_start:
352  * @mix: #MixAudio object.
353  * @returns: #MIX_RESULT_SUCCESS if the resulting state is either #MIX_STREAM_PLAYING or #MIX_STREAM_PAUSED. Fail code otherwise.
354  *
355  * If the stream is configured to #MIX_DECODE_DIRECTRENDER, application use this call to change the stream out of the #MIX_STREAM_STOPPED state. If mix_audio_decode() is called and blocking in a seperate thread prior to this call. This method causes the device to start rendering data.
356  *
357  * In #MIX_DECODE_DECODERETURN, this method is no op.
358  */
359 MIX_RESULT mix_audio_start(MixAudio *mix);
360 
361 /**
362  * mix_audio_stop_drop:
363  * @mix: #MixAudio object.
364  * @returns: #MIX_RESULT_SUCCESS if the resulting state has successfully reached #MIX_STREAM_STOPPED. Fail code otherwise.
365  *
366  * If the stream is configured to #MIX_DECODE_DIRECTRENDER, application uses this function to stop the processing and playback of audio.
367  *
368  * All remaining frames to be decoded or rendered will be discarded and playback will stop immediately, unblocks any pending mix_audio_decode().
369  *
370  * If #MIX_STOP_DRAIN is requested, the call will block with stream state set to #MIX_STREAM_DRAINING, and return only until all remaining frame in previously submitted buffers are decoded and rendered. When #MIX_STOP_DRAIN returns successfully, the stream would have reached #MIX_STREAM_STOPPED successfully.
371  *
372  * After this call, timestamp retrived by mix_audio_gettimestamp() is reset to zero.
373  *
374  * Note that this method returns #MIX_RESULT_WRONG_STATE if the stream is in #MIX_STREAM_DRAINING state.
375  *
376  */
377 MIX_RESULT mix_audio_stop_drop(MixAudio *mix);
378 
379 /**
380  * mix_audio_stop_drain:
381  * @mix: #MixAudio object.
382  * @returns: #MIX_RESULT_SUCCESS if the resulting state has successfully reached #MIX_STREAM_STOPPED. Fail code otherwise.
383  *
384  * If the stream is configured to #MIX_DECODE_DIRECTRENDER, application uses this function to stop the processing and playback of audio.
385  *
386  * The call will block with stream state set to #MIX_STREAM_DRAINING, and return only until all remaining frame in previously submitted buffers are decoded and rendered.
387  *
388  * Note that this method blocks until #MIX_STREAM_STOPPED is reached if it is called when the stream is already in #MIX_STREAM_DRAINING state.
389  *
390  */
391 MIX_RESULT mix_audio_stop_drain(MixAudio *mix);
392 
393 /**
394  * mix_audio_pause:
395  * @mix: #MixAudio object.
396  * @returns: #MIX_RESULT_SUCCESS if #MIX_STREAM_PAUSED state is reached successfully. #MIX_RESULT_WRONG_STATE if operation is not allowed with the current state.
397  *
398  * If the stream is configured to #MIX_DECODE_DIRECTRENDER, application uses this call to change the stream state from #MIX_STREAM_PLAYING to #MIX_STREAM_PAUSED. Note that this method returns sucessful only when the resulting state reaches #MIX_STREAM_PAUSED. Meaning it will return fail code if it is called in a state such as #MIX_STREAM_STOPPED, where transitioning to #MIX_STREAM_PAUSED is not possible.
399  *
400  * In some situation, where there is potential race condition with the DRAINING operation, this method may return MIX_RESULT_NEED_RETRY to indicate last operation result is inclusive and request caller to call again.
401  */
402 MIX_RESULT mix_audio_pause(MixAudio *mix);
403 
404 /**
405  * mix_audio_resume:
406  * @mix: #MixAudio object.
407  * @returns: #MIX_RESULT_SUCCESS if #MIX_STREAM_PLAYING state is reached successfully. #MIX_RESULT_WRONG_STATE if operation is not allowed with the current state.
408  *
409  * If the stream is configured to #MIX_DECODE_DIRECTRENDER, application uses this call to change the stream state to #MIX_STREAM_PLAYING. Note that this method returns sucessful only when the resulting state reaches #MIX_STREAM_PAUSED. Meaning it will return fail code if it is called in a state such as #MIX_STREAM_DRAINING, where transitioning to #MIX_STREAM_PLAYING is not possible.
410  *
411  */
412 MIX_RESULT mix_audio_resume(MixAudio *mix);
413 
414 
415 /**
416  * mix_audio_get_timestamp:
417  * @mix: #MixAudio object.
418  * @msecs: play time in milliseconds.
419  * @returns: #MIX_RESULT_SUCCESS if the timestamp is available. #MIX_RESULT_WRONG_MODE if operation is not allowed with the current mode.
420  *
421  * This function can be used to retrieve the current timestamp for audio playback in milliseconds.  The timestamp will reflect the amount of audio data rendered since the start of stream, or since the last stop.  Note that the timestamp is always reset to zero when the stream enter #MIX_STREAM_STOPPED state. The timestamp is an unsigned long value, so the value will wrap when the timestamp reaches #ULONG_MAX. This function is only valid in direct-render mode.
422  */
423 MIX_RESULT mix_audio_get_timestamp(MixAudio *mix, guint64 *msecs);
424 
425 /**
426  * mix_audio_set_mute:
427  * @mix: #MixAudio object.
428  * @mute: Turn mute on/off.
429  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
430  *
431  * This function is used to mute and unmute audio playback. While muted, playback would continue but silently. This function is only valid when the session is configured to #MIX_DECODE_DIRECTRENDER mode.
432  *
433  * Note that playback volumn may change due to change of global settings while stream is muted.
434  */
435 MIX_RESULT mix_audio_set_mute(MixAudio *mix, gboolean mute);
436 
437 /**
438  * mix_audio_get_mute:
439  * @mix: #MixAudio object.
440  * @muted: current mute state.
441  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
442  *
443  * Get Mute.
444  */
445 MIX_RESULT mix_audio_get_mute(MixAudio *mix, gboolean* muted);
446 
447 /**
448  * mix_audio_get_max_vol:
449  * @mix: #MixAudio object.
450  * @maxvol: pointer to receive max volumn.
451  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
452  *
453  * This function can be used if the application will be setting the audio volume using decibels instead of percentage.  The maximum volume in decibels supported by the driver will be returned.  This value can be used to determine the upper bound of the decibel range in calculating volume levels.  This value is a signed integer. This function is only valid if stream is configured to #MIX_DECODE_DIRECTRENDER mode.
454  *
455  */
456 MIX_RESULT mix_audio_get_max_vol(MixAudio *mix, gint *maxvol);
457 
458 /**
459  * mix_audio_get_min_vol:
460  * @mix: #MixAudio object.
461  * @minvol: pointer to receive max volumn.
462  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
463  *
464  * This function can be used if the application will be setting the audio volume using decibels instead of percentage.  The minimum volume in decibels supported by the driver will be returned.  This value can be used to determine the lower bound of the decibel range in calculating volume levels.  This value is a signed integer. This function is only valid if stream is configured to #MIX_DECODE_DIRECTRENDER mode.
465  *
466  */
467 MIX_RESULT mix_audio_get_min_vol(MixAudio *mix, gint *minvol);
468 
469 /**
470  * mix_audio_get_volume:
471  * @mix: #MixAudio object.
472  * @currvol: Current volume. Note that if @type equals #MIX_VOL_PERCENT, this value will be return within the range of 0 to 100 inclusive.
473  * @type: The type represented by @currvol.
474  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
475  *
476  * This function returns the current volume setting in either decibels or percentage. This function is only valid if stream is configured to #MIX_DECODE_DIRECTRENDER mode.
477  *
478  */
479 MIX_RESULT mix_audio_get_volume(MixAudio *mix, gint *currvol, MixVolType type);
480 
481 /**
482  * mix_audio_set_volume:
483  * @mix: #MixAudio object.
484  * @currvol: Current volume. Note that if @type equals #MIX_VOL_PERCENT, this value will be trucated to within the range of 0 to 100 inclusive.
485  * @type: The type represented by @currvol.
486  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
487  *
488  * This function sets the current volume setting in either decibels or percentage.  This function is only valid if the stream is configured to #MIX_DECODE_DIRECTRENDER mode.
489  *
490  */
491 MIX_RESULT mix_audio_set_volume(MixAudio *mix, gint currvol, MixVolType type, gulong msecs, MixVolRamp ramptype);
492 
493 /**
494  * mix_audio_deinitialize:
495  * @mix: #MixAudio object.
496  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
497  *
498  * This function will uninitialize a session with this MI-X instance.  During this call, the SST device will be closed and resources including mmapped buffers would be freed.This function should be called by the application once mix_audio_init() has been called.
499  *
500  * <note>
501  * <title>Intel Audio Manager Support</title>
502  * The SST stream would be unregistered with Intel Audio Manager if it was registered.
503  * </note>
504  *
505  * Note that if this method should not fail normally. If it does return failure, the state of this object and the underlying mechanism is compromised and application should not attempt to reuse this object.
506  */
507 MIX_RESULT mix_audio_deinitialize(MixAudio *mix);
508 
509 /**
510  * mix_audio_get_stream_state:
511  * @mix: #MixAudio object.
512  * @streamState: pointer to receive stream state.
513  * @returns: #MIX_RESULT
514  *
515  * Get the stream state of the current stream.
516  */
517 MIX_RESULT mix_audio_get_stream_state(MixAudio *mix, MixStreamState *streamState);
518 
519 /**
520  * mix_audio_get_state:
521  * @mix: #MixAudio object.
522  * @state: pointer to receive state
523  * @returns: Current device state.
524  *
525  * Get the device state of the audio session.
526  */
527 MIX_RESULT mix_audio_get_state(MixAudio *mix, MixState *state);
528 
529 /**
530  * mix_audio_am_is_enabled:
531  * @mix: #MixAudio object.
532  * @returns: boolean indicates if Intel Audio Manager is enabled with the current session.
533  *
534  * This method checks if the current session is configure to use Intel Audio Manager. Note that Intel Audio Manager is considered disabled if the stream has not be initialized to use the service explicitly.
535  */
536 gboolean mix_audio_am_is_enabled(MixAudio *mix);
537 
538 // Real implementation for Base class
539 //MIX_RESULT mix_audio_get_version(guint* major, guint *minor);
540 
541 /**
542  * mix_audio_is_am_available:
543  * @mix: TBD
544  * @am: TBD
545  * @avail: TBD
546  * @returns: TBD
547  *
548  * Check if AM is available.
549  */
550 MIX_RESULT mix_audio_is_am_available(MixAudio *mix, MixAudioManager am, gboolean *avail);
551 
552 /**
553  * mix_audio_get_output_configuration:
554  * @mix: #MixAudio object.
555  * @audioconfigparams: double pointer to hold output configuration.
556  * @returns: #MIX_RESULT_SUCCESS on success or other fail code.
557  *
558  * This method retrieve the current configuration. This can be called after initialization. If a stream has been configured, it returns the corresponding derive object of MixAudioConfigParams.
559  */
560 MIX_RESULT mix_audio_get_output_configuration(MixAudio *mix, MixAudioConfigParams **audioconfigparams);
561 
562 /**
563  * mix_audio_get_stream_byte_decoded:
564  * @mix: #MixAudio object.
565  * @msecs: stream byte decoded..
566  * @returns: #MIX_RESULT_SUCCESS if the value is available. #MIX_RESULT_WRONG_MODE if operation is not allowed with the current mode.
567  *
568  * Retrive the culmulative byte decoded.
569  *
570  * <remark>Not Implemented.</remark>
571  */
572 MIX_RESULT mix_audio_get_stream_byte_decoded(MixAudio *mix, guint64 *byte);
573 
574 #endif /* __MIX_AUDIO_H__ */
575