| 1 |
/* |
| 2 |
* Copyright © 2023 Mozilla Foundation |
| 3 |
* |
| 4 |
* This program is made available under an ISC-style license. See the |
| 5 |
* accompanying file LICENSE for details. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef CUBEB_AUDIO_DUMP |
| 9 |
#define CUBEB_AUDIO_DUMP |
| 10 |
|
| 11 |
#include "cubeb/cubeb.h" |
| 12 |
|
| 13 |
#if defined(__cplusplus) |
| 14 |
extern "C" { |
| 15 |
#endif |
| 16 |
|
| 17 |
typedef struct cubeb_audio_dump_stream * cubeb_audio_dump_stream_t; |
| 18 |
typedef struct cubeb_audio_dump_session * cubeb_audio_dump_session_t; |
| 19 |
|
| 20 |
// Start audio dumping session |
| 21 |
// This can only be called if the other API functions |
| 22 |
// aren't currently being called: synchronized externally. |
| 23 |
// This is not real-time safe. |
| 24 |
// |
| 25 |
// This is generally called when deciding to start logging some audio. |
| 26 |
// |
| 27 |
// Returns 0 in case of success. |
| 28 |
int |
| 29 |
cubeb_audio_dump_init(cubeb_audio_dump_session_t * session); |
| 30 |
|
| 31 |
// End audio dumping session |
| 32 |
// This can only be called if the other API functions |
| 33 |
// aren't currently being called: synchronized externally. |
| 34 |
// |
| 35 |
// This is generally called when deciding to stop logging some audio. |
| 36 |
// |
| 37 |
// This is not real-time safe. |
| 38 |
// Returns 0 in case of success. |
| 39 |
int |
| 40 |
cubeb_audio_dump_shutdown(cubeb_audio_dump_session_t session); |
| 41 |
|
| 42 |
// Register a stream for dumping to a file |
| 43 |
// This can only be called if cubeb_audio_dump_write |
| 44 |
// isn't currently being called: synchronized externally. |
| 45 |
// |
| 46 |
// This is generally called when setting up a system-level stream side (either |
| 47 |
// input or output). |
| 48 |
// |
| 49 |
// This is not real-time safe. |
| 50 |
// Returns 0 in case of success. |
| 51 |
int |
| 52 |
cubeb_audio_dump_stream_init(cubeb_audio_dump_session_t session, |
| 53 |
cubeb_audio_dump_stream_t * stream, |
| 54 |
cubeb_stream_params stream_params, |
| 55 |
const char * name); |
| 56 |
|
| 57 |
// Unregister a stream for dumping to a file |
| 58 |
// This can only be called if cubeb_audio_dump_write |
| 59 |
// isn't currently being called: synchronized externally. |
| 60 |
// |
| 61 |
// This is generally called when a system-level audio stream side |
| 62 |
// (input/output) has been stopped and drained, and the audio callback isn't |
| 63 |
// going to be called. |
| 64 |
// |
| 65 |
// This is not real-time safe. |
| 66 |
// Returns 0 in case of success. |
| 67 |
int |
| 68 |
cubeb_audio_dump_stream_shutdown(cubeb_audio_dump_session_t session, |
| 69 |
cubeb_audio_dump_stream_t stream); |
| 70 |
|
| 71 |
// Start dumping. |
| 72 |
// cubeb_audio_dump_write can now be called. |
| 73 |
// |
| 74 |
// This starts dumping the audio to disk. Generally this is called when |
| 75 |
// cubeb_stream_start is caled is called, but can be called at the beginning of |
| 76 |
// the application. |
| 77 |
// |
| 78 |
// This is not real-time safe. |
| 79 |
// Returns 0 in case of success. |
| 80 |
int |
| 81 |
cubeb_audio_dump_start(cubeb_audio_dump_session_t session); |
| 82 |
|
| 83 |
// Stop dumping. |
| 84 |
// cubeb_audio_dump_write can't be called at this point. |
| 85 |
// |
| 86 |
// This stops dumping the audio to disk cubeb_stream_stop is caled is called, |
| 87 |
// but can be called before exiting the application. |
| 88 |
// |
| 89 |
// This is not real-time safe. |
| 90 |
// Returns 0 in case of success. |
| 91 |
int |
| 92 |
cubeb_audio_dump_stop(cubeb_audio_dump_session_t session); |
| 93 |
|
| 94 |
// Dump some audio samples for audio stream id. |
| 95 |
// |
| 96 |
// This is generally called from the real-time audio callback. |
| 97 |
// |
| 98 |
// This is real-time safe. |
| 99 |
// Returns 0 in case of success. |
| 100 |
int |
| 101 |
cubeb_audio_dump_write(cubeb_audio_dump_stream_t stream, void * audio_samples, |
| 102 |
uint32_t count); |
| 103 |
|
| 104 |
#ifdef __cplusplus |
| 105 |
}; |
| 106 |
#endif |
| 107 |
|
| 108 |
#endif |