OSDN Git Service

67fb7a7f9b627706a3764a0b8d26b444aee7c202
[cinnamon-audio/cinnamon.git] / src / oss / cin_oss_driver.h
1 /* Copyright (c) 2019-2021 AlaskanEmily, Transnat Games
2  *
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7
8 #ifndef CIN_OSS_DRIVER_H
9 #define CIN_OSS_DRIVER_H
10 #pragma once
11
12 #include "cin_export.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #define CIN_OSS_SOUND_CHANNELS 16
19
20 #define CIN_OSS_INSERT 0
21 #define CIN_OSS_DELETE 1
22 #define CIN_OSS_PLAY 2
23 #define CIN_OSS_STOP 3
24 #define CIN_OSS_QUIT 0x80
25
26 /*****************************************************************************/
27
28 struct Cin_MixerSound;
29 typedef struct Cin_MixerSound **Cin_MixerSound_PtrPtr;
30
31 /*****************************************************************************/
32
33 struct Cin_OSS_Command;
34 typedef struct Cin_OSS_Command *Cin_OSS_Command_Ptr;
35 typedef const struct Cin_OSS_Command *Cin_OSS_Command_ConstPtr;
36
37 /*****************************************************************************/
38
39 struct Cin_Driver;
40
41 /*****************************************************************************/
42
43 CIN_PRIVATE(Cin_OSS_Command_Ptr) Cin_OSS_NewCommand(int id, int cmd);
44 CIN_PRIVATE(Cin_OSS_Command_Ptr) Cin_OSS_CommandInsertSound(
45     struct Cin_OSS_Command *cmd,
46     struct Cin_MixerSound *snd);
47
48 #define CIN_OSS_INSERT_SOUND_CMD(ID, SND) \
49     Cin_OSS_CommandInsertSound(Cin_OSS_NewCommand((ID), CIN_OSS_INSERT), (SND))
50
51 /*****************************************************************************/
52
53 CIN_PRIVATE(int) Cin_OSS_Lock(struct Cin_Driver *);
54
55 /*****************************************************************************/
56
57 CIN_PRIVATE(int) Cin_OSS_Unlock(struct Cin_Driver *);
58
59 /*****************************************************************************/
60
61 CIN_PRIVATE(int) Cin_OSS_NewID(struct Cin_Driver *);
62
63 /*****************************************************************************/
64
65 CIN_PRIVATE(int) Cin_OSS_PushCommand(struct Cin_Driver *,
66     struct Cin_OSS_Command *);
67
68 /*****************************************************************************/
69 /* Used by the the thread backend to play channels. */
70 CIN_PRIVATE_PURE(Cin_MixerSound_PtrPtr) Cin_OSS_GetChannels(
71     const struct Cin_Driver *);
72
73 /*****************************************************************************/
74
75 CIN_PRIVATE_PURE(int) Cin_OSS_GetDevice(const struct Cin_Driver *);
76
77 /*****************************************************************************/
78 /* Does not require locking. */
79 CIN_PRIVATE_PURE(unsigned) Cin_OSS_GetSampleRate(const struct Cin_Driver *);
80
81 /*****************************************************************************/
82 /* Does not require locking. */
83 CIN_PRIVATE_PURE(int) Cin_OSS_GetNumChannels(const struct Cin_Driver *);
84
85 /*****************************************************************************/
86 /* Does not require locking. */
87 CIN_PRIVATE_PURE(int) Cin_OSS_GetFormat(const struct Cin_Driver *);
88
89 /*****************************************************************************/
90 /* As with all thread functions, the driver must NOT be locked when called.
91  * returns 1 if the calling thread should die.
92  */
93 CIN_PRIVATE(int) Cin_OSS_ProcessCommands(struct Cin_Driver *);
94
95 /*****************************************************************************/
96
97 #ifdef __cplusplus
98 } // extern "C"
99 #endif
100
101 #endif /* CIN_OSS_DRIVER_H */