VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioHlp.h@ 89551

Last change on this file since 89551 was 89342, checked in by vboxsync, 3 years ago

Audio: Removed unused PDMAUDIOFMT type and associated translators. bugref:9890

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: AudioHlp.h 89342 2021-05-28 10:27:05Z vboxsync $ */
2/** @file
3 * Audio helper routines.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_Audio_AudioHlp_h
19#define VBOX_INCLUDED_SRC_Audio_AudioHlp_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <limits.h>
25
26#include <iprt/circbuf.h>
27#include <iprt/critsect.h>
28#include <iprt/file.h>
29#include <iprt/path.h>
30
31#include <VBox/vmm/pdmaudioifs.h>
32
33/** @name Audio calculation helper methods.
34 * @{ */
35uint32_t AudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels);
36/** @} */
37
38/** @name Audio PCM properties helper methods.
39 * @{ */
40bool AudioHlpPcmPropsAreValid(PCPDMAUDIOPCMPROPS pProps);
41/** @} */
42
43/** @name Audio configuration helper methods.
44 * @{ */
45bool AudioHlpStreamCfgIsValid(PCPDMAUDIOSTREAMCFG pCfg);
46/** @} */
47
48
49/** @name AUDIOHLPFILE_FLAGS_XXX
50 * @{ */
51/** No flags defined. */
52#define AUDIOHLPFILE_FLAGS_NONE UINT32_C(0)
53/** Keep the audio file even if it contains no audio data. */
54#define AUDIOHLPFILE_FLAGS_KEEP_IF_EMPTY RT_BIT_32(0)
55/** Audio file flag validation mask. */
56#define AUDIOHLPFILE_FLAGS_VALID_MASK UINT32_C(0x1)
57/** @} */
58
59/** Audio file default open flags. */
60#define AUDIOHLPFILE_DEFAULT_OPEN_FLAGS (RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE)
61
62/**
63 * Audio file types.
64 */
65typedef enum AUDIOHLPFILETYPE
66{
67 /** The customary invalid zero value. */
68 AUDIOHLPFILETYPE_INVALID = 0,
69 /** Unknown type, do not use. */
70 AUDIOHLPFILETYPE_UNKNOWN,
71 /** Raw (PCM) file. */
72 AUDIOHLPFILETYPE_RAW,
73 /** Wave (.WAV) file. */
74 AUDIOHLPFILETYPE_WAV,
75 /** Hack to blow the type up to 32-bit. */
76 AUDIOHLPFILETYPE_32BIT_HACK = 0x7fffffff
77} AUDIOHLPFILETYPE;
78
79/** @name Audio file (name) helper methods.
80 * @{ */
81int AudioHlpFileNameSanitize(char *pszPath, size_t cbPath);
82int AudioHlpFileNameGet(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName,
83 uint32_t uInstance, AUDIOHLPFILETYPE enmType, uint32_t fFlags);
84/** @} */
85
86/** @name AUDIOHLPFILENAME_FLAGS_XXX
87 * @{ */
88/** No flags defined. */
89#define AUDIOHLPFILENAME_FLAGS_NONE UINT32_C(0)
90/** Adds an ISO timestamp to the file name. */
91#define AUDIOHLPFILENAME_FLAGS_TS RT_BIT(0)
92/** @} */
93
94/**
95 * Audio file handle.
96 */
97typedef struct AUDIOHLPFILE
98{
99 /** Type of the audio file. */
100 AUDIOHLPFILETYPE enmType;
101 /** Audio file flags, AUDIOHLPFILE_FLAGS_XXX. */
102 uint32_t fFlags;
103 /** Actual file handle. */
104 RTFILE hFile;
105 /** Data needed for the specific audio file type implemented.
106 * Optional, can be NULL. */
107 void *pvData;
108 /** Data size (in bytes). */
109 size_t cbData;
110 /** File name and path. */
111 char szName[RTPATH_MAX];
112} AUDIOHLPFILE;
113/** Pointer to an audio file handle. */
114typedef AUDIOHLPFILE *PAUDIOHLPFILE;
115
116/** @name Audio file methods.
117 * @{ */
118int AudioHlpFileCreateAndOpen(PAUDIOHLPFILE *ppFile, const char *pszDir, const char *pszName,
119 uint32_t iInstance, PCPDMAUDIOPCMPROPS pProps);
120int AudioHlpFileCreateAndOpenEx(PAUDIOHLPFILE *ppFile, AUDIOHLPFILETYPE enmType, const char *pszDir, const char *pszName,
121 uint32_t iInstance, uint32_t fFilename, uint32_t fCreate,
122 PCPDMAUDIOPCMPROPS pProps, uint64_t fOpen);
123int AudioHlpFileCreate(AUDIOHLPFILETYPE enmType, const char *pszFile, uint32_t fFlags, PAUDIOHLPFILE *ppFile);
124void AudioHlpFileDestroy(PAUDIOHLPFILE pFile);
125int AudioHlpFileOpen(PAUDIOHLPFILE pFile, uint32_t fOpen, PCPDMAUDIOPCMPROPS pProps);
126int AudioHlpFileClose(PAUDIOHLPFILE pFile);
127int AudioHlpFileDelete(PAUDIOHLPFILE pFile);
128size_t AudioHlpFileGetDataSize(PAUDIOHLPFILE pFile);
129bool AudioHlpFileIsOpen(PAUDIOHLPFILE pFile);
130int AudioHlpFileWrite(PAUDIOHLPFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags);
131/** @} */
132
133#define AUDIO_MAKE_FOURCC(c0, c1, c2, c3) RT_H2LE_U32_C(RT_MAKE_U32_FROM_U8(c0, c1, c2, c3))
134
135#endif /* !VBOX_INCLUDED_SRC_Audio_AudioHlp_h */
136
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette