BEAST/BSE - Better Audio System and Sound Engine  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bsepcmdevice.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_PCM_DEVICE_H__
3 #define __BSE_PCM_DEVICE_H__
4 
5 #include <bse/bsedevice.hh>
6 
7 G_BEGIN_DECLS
8 
9 /* --- object type macros --- */
10 #define BSE_TYPE_PCM_DEVICE (BSE_TYPE_ID (BsePcmDevice))
11 #define BSE_PCM_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE, BsePcmDevice))
12 #define BSE_PCM_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_PCM_DEVICE, BsePcmDeviceClass))
13 #define BSE_IS_PCM_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE))
14 #define BSE_IS_PCM_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE))
15 #define BSE_PCM_DEVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE, BsePcmDeviceClass))
16 
17 
18 /* --- capabilities --- */
19 #define BSE_PCM_FREQ_MIN BSE_PCM_FREQ_8000
20 #define BSE_PCM_FREQ_MAX BSE_PCM_FREQ_192000
21 typedef enum /*< skip >*/
22 {
23  BSE_PCM_CMODE_MONO = 1,
24  BSE_PCM_CMODE_STEREO
25 } BsePcmChannelMode;
26 
27 struct BsePcmHandle {
28  guint readable : 1;
29  guint writable : 1;
30  guint n_channels; /* should be req_n_channels */
31  guint mix_freq; /* should be req_mix_freq within 1% tolerance */
32  guint block_length; /* in frames, filled in after open() before i/o */
33  Bse::Spinlock spinlock;
34  gsize (*read) (BsePcmHandle *handle,
35  gfloat *values); /* n_channels * block_length values */
36  void (*write) (BsePcmHandle *handle,
37  const gfloat *values); /* n_channels * block_length values */
38  gboolean (*check_io) (BsePcmHandle *handle,
39  glong *timeoutp);
40  guint (*latency) (BsePcmHandle *handle);
41 };
43  /* requested caps */
44  guint req_n_channels;
45  guint req_mix_freq;
46  guint req_latency_ms; /* latency in milliseconds */
47  guint req_block_length; /* in frames, a guess at block_length after open() */
48  /* operational handle */
49  BsePcmHandle *handle;
50 };
52 {};
53 
54 void bse_pcm_device_request (BsePcmDevice *pdev,
55  guint n_channels,
56  guint mix_freq,
57  guint latency_ms,
58  guint block_length); /* in frames */
59 guint bse_pcm_device_get_mix_freq (BsePcmDevice *pdev);
60 BsePcmHandle* bse_pcm_device_get_handle (BsePcmDevice *pdev,
61  guint block_length);
62 gsize bse_pcm_handle_read (BsePcmHandle *handle,
63  gsize n_values,
64  gfloat *values);
65 void bse_pcm_handle_write (BsePcmHandle *handle,
66  gsize n_values,
67  const gfloat *values);
68 gboolean bse_pcm_handle_check_io (BsePcmHandle *handle,
69  glong *timeoutp);
70 guint bse_pcm_handle_latency (BsePcmHandle *handle);
71 
72 
73 /* --- misc utils --- */
74 guint bse_pcm_device_frequency_align (gint mix_freq);
75 
76 
77 G_END_DECLS
78 
79 #endif /* __BSE_PCM_DEVICE_H__ */
Definition: bsepcmdevice.hh:51
Definition: bsepcmdevice.hh:42
Definition: bsepcmdevice.hh:27
Definition: bsedevice.hh:33
Definition: bsedevice.hh:38