aboutsummaryrefslogtreecommitdiffstats
path: root/src/gaudio/gaudio_driver_record.h
blob: dcba9bd1f3dca8c46bea696c38442a78f4a0ed8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * This file is subject to the terms of the GFX License. If a copy of
 * the license was not distributed with this file, you can obtain one at:
 *
 *              http://ugfx.io/license.html
 */

/**
 * @file    src/gaudio/gaudio_driver_record.h
 * @brief   GAUDIO - Audio Recording driver header file.
 *
 * @defgroup GAUDIO_Driver_Record Driver Recording
 * @ingroup GAUDIO
 *
 * @brief Recording driver interface for the GAUDIO module.
 *
 * @{
 */

#ifndef _GAUDIO_RECORD_LLD_H
#define _GAUDIO_RECORD_LLD_H

#include "../../gfx.h"

#if (GFX_USE_GAUDIO && GAUDIO_NEED_RECORD) || defined(__DOXYGEN__)

/*===========================================================================*/
/* Type definitions                                                          */
/*===========================================================================*/

/**
 * @brief				Get a free block of audio data that we can record into
 * @return				A pointer to the GAaudioData structure or NULL if none is currently available
 *
 * @note				Defined in the high level GAUDIO code for use by the GAUDIO record drivers.
 *
 * @iclass
 * @notapi
 */
#define gaudioRecordGetFreeBlockI()		gfxBufferGetI()

/**
 * @brief				Save a block of recorded audio data ready for the application
 *
 * @param[in] paud		The GDataBuffer block with data.
 *
 * @note				Defined in the high level GAUDIO code for use by the GAUDIO record drivers.
 *
 * @iclass
 * @notapi
 */
void gaudioRecordSaveDataBlockI(GDataBuffer *paud);

/**
 * @brief				Signal that all recording has now stopped
 *
 * @note				Defined in the high level GAUDIO code for use by the GAUDIO record drivers.
 *
 * @iclass
 * @notapi
 */
void gaudioRecordDoneI(void);

/*===========================================================================*/
/* External declarations.                                                    */
/*===========================================================================*/

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief				Initialise the record driver
 * @return				gTrue if the channel, frequency and format are valid.
 *
 * @param[in] channel	The channel to use (see the driver for the available channels provided)
 * @param[in] frequency	The sample frequency to use
 * @param[in] format	The sample format
 *
 * @note				The driver will always have been stopped and de-init before this is called.
 *
 * @api
 */
gBool gaudio_record_lld_init(gU16 channel, gU32 frequency, ArrayDataFormat format);

/**
 * @brief				Start the audio recording
 *
 * @api
 */
void gaudio_record_lld_start(void);

/**
 * @brief				Stop the audio recording.
 *
 * @note				Some drivers may only stop recording at a data block boundary.
 * @note				This routine should not return until any currently active buffers have been
 * 						saved (even if with zero length) and @p gaudioRecordDoneI() has been called.
 *
 * @api
 */
void gaudio_record_lld_stop(void);

#ifdef __cplusplus
}
#endif

#endif /* GFX_USE_GAUDIO && GAUDIO_NEED_RECORD */

#endif /* _GAUDIO_RECORD_LLD_H */
/** @} */