source: svn/trunk/newcon3bcm2_21bu/dta/src/settop_api/bsettop_pcm.h

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 5.2 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2006, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile:  $
11 * $brcm_Revision:  $
12 * $brcm_Date: $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log:  $
19 *
20 ***************************************************************************/
21         
22#ifndef BSETTOP_PCM_H__
23#define BSETTOP_PCM_H__
24
25#include "bsettop_types.h"
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32/*=***********************************
33The PCM interface is used to write PCM data to a PCM playback
34channel.
35
36PCM playback can be used for sound effects or music (often with a
37CPU-based decoder for formats like MP3).
38
39The API is the minimal needed for streaming data. The BSEAV team also
40provides a file-based API located in BSEAV/lib/pcmfile. The file-based
41API includes WAV file support.
42**************************************/
43
44#define BPCM_PLAYBACK_CHANNELS   1
45
46/*
47Summary:
48        PCM playback state enumerations.
49Description:
50        These are the different states that the PCM playback channels can be in.
51*/
52typedef enum pcm_play_state
53{
54    ePCM_PLAY_STATE_CLOSED,
55    ePCM_PLAY_STATE_OPENED,
56    ePCM_PLAY_STATE_STARTED,
57    ePCM_PLAY_STATE_STOPPED,
58} pcm_play_state_t;
59
60/*
61Summary:
62        PCM playback handle returned by bpcm_play_open.
63Description:
64        The implementation of the handle is private.
65*/
66typedef struct bpcm_play *bpcm_play_t;
67/*
68Summary:
69        PCM audio settings which are used in bpcm_play_settings and bpcm_record_settings.
70Description:
71        The total bitrate of the PCM stream is:
72        bits_per_second = bits_per_sample * sample_rate * channels.
73*/
74typedef struct bpcm_settings {
75        unsigned bits_per_sample;       /* Either 8 or 16 */
76        unsigned sample_rate;   /* Samples per channel per second. Either 32000, 44100, 48000. */
77        unsigned channels;              /* Either 1 (mono) or 2 (stereo) */
78} bpcm_settings;
79
80/*
81Summary:
82        PCM play settings passed to bpcm_play_start.
83Description:
84        Even though there is no more data than just bpcm_settings, we've added this
85        to support future API extensions.
86*/
87typedef struct bpcm_play_settings {
88        bpcm_settings pcm;      /* PCM format */
89        bsettop_callback callback; /* This callback notifies the user that there is
90                space available in the pcm playback buffer. The user may call bpcm_play_get_buffer
91                but should not call bpcm_play_write_complete. After receiving a callback,
92                no additional callback will be received until bpcm_play_write_complete
93                is called. */
94        void *callback_context; /* User defined context which is passed into the
95                above callback function. */
96} bpcm_play_settings;
97
98/*
99Summary:
100        Open a PCM playback channel.
101
102*/
103        bpcm_play_t bpcm_play_open(
104                bobject_t id                            /* id corresponds to the pcm playback channel. */
105                );
106
107
108/*
109Summary:
110        Close a PCM playback channel.
111Description:
112        Playback must already be stopped.
113*/
114
115        void bpcm_play_close(
116                bpcm_play_t pcmplay
117                );
118
119/*
120Summary:
121        Start playing PCM audio.
122*/
123
124bresult bpcm_play_start(
125        bpcm_play_t pcmplay,
126        bdisplay_t display,                                     /* which output to play to */
127        bpcm_play_settings *settings
128        );
129
130/*
131Summary:
132        Status information returned by bpcm_play_get_status
133*/
134typedef struct bpcm_play_status {
135    unsigned int index; /* Which pcm playback channel is playing? */
136        pcm_play_state_t state; /* The state of the pcm playback channel. */
137        unsigned queued_bytes;  /* Number of bytes waiting to be played. */
138        unsigned long fifo_size;                        /* Size in bytes of the pcm buffer */
139        void *buffer_base;              /* Pointer to the base of the pcm buffer.
140                                           This can be used for calculating your exact position
141                                           in the buffer for alignment considerations. */
142} bpcm_play_status;
143
144/*
145Summary:
146        Get status information.
147*/
148
149bresult bpcm_play_get_status(
150        bpcm_play_t pcmplay,
151        bpcm_play_status *status
152        );
153
154/**
155Summary:
156Get space available in the pcm playback buffer.
157
158Description:
159This is a non-destructive call. You can call it as many times as you want.
160After writing data into the buffer, you should call bpcm_play_write_complete
161to report how much of the buffer was used.  On loop around length will be limited
162to the buffer size minus the write offset then the next call will return the delta
163between the read and write pointers.
164**/
165
166bresult bpcm_play_get_buffer(
167        bpcm_play_t pcmplay,
168        void **data,
169        size_t *length
170        );
171
172/**
173Summary:
174update the ringbuffer write offset
175
176Description call to update the rinbuffer write offset.  On loop around
177of the ringbuffer the amount_written should not extend past the end of buffer.
178This matches the behaivior of bpcm_play_get_buffer.
179**/
180
181bresult bpcm_play_write_complete(
182        bpcm_play_t pcmplay,
183        size_t amount_written
184        );
185
186/*
187Summary:
188Stop PCM playback
189*/
190bresult bpcm_play_stop(
191        bpcm_play_t pcmplay
192        );
193
194/*
195Summary:
196        Required to initialize the bpcm_settings structure.
197*/
198void bpcm_play_settings_init(
199        bpcm_play_settings *settings,   /* [out] */
200        bpcm_play_t pcmplay             /* required for possible resource-dependent defaults */
201        );
202
203#ifdef CONFIG_PCM_TEST
204void bpcm_play_test();
205#endif
206
207#ifdef __cplusplus
208}
209#endif
210
211#endif /* BSETTOP_PCM_H__ */
Note: See TracBrowser for help on using the repository browser.