Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
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 /* --- object type macros --- */
8 #define BSE_TYPE_PCM_DEVICE (BSE_TYPE_ID (BsePcmDevice))
9 #define BSE_PCM_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE, BsePcmDevice))
10 #define BSE_PCM_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_PCM_DEVICE, BsePcmDeviceClass))
11 #define BSE_IS_PCM_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE))
12 #define BSE_IS_PCM_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE))
13 #define BSE_PCM_DEVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE, BsePcmDeviceClass))
14 
15 
16 /* --- capabilities --- */
17 #define BSE_PCM_FREQ_MIN BSE_PCM_FREQ_8000
18 #define BSE_PCM_FREQ_MAX BSE_PCM_FREQ_192000
19 typedef enum /*< skip >*/
20 {
21  BSE_PCM_CMODE_MONO = 1,
22  BSE_PCM_CMODE_STEREO
23 } BsePcmChannelMode;
24 
25 struct BsePcmHandle {
26  guint readable : 1;
27  guint writable : 1;
28  guint n_channels; /* should be req_n_channels */
29  guint mix_freq; /* should be req_mix_freq within 1% tolerance */
30  guint block_length; /* in frames, filled in after open() before i/o */
31  Bse::Spinlock spinlock;
32  gsize (*read) (BsePcmHandle *handle,
33  gfloat *values); /* n_channels * block_length values */
34  void (*write) (BsePcmHandle *handle,
35  const gfloat *values); /* n_channels * block_length values */
36  gboolean (*check_io) (BsePcmHandle *handle,
37  glong *timeoutp);
38  guint (*latency) (BsePcmHandle *handle);
39 };
41  /* requested caps */
42  guint req_n_channels;
43  guint req_mix_freq;
44  guint req_latency_ms; /* latency in milliseconds */
45  guint req_block_length; /* in frames, a guess at block_length after open() */
46  /* operational handle */
47  BsePcmHandle *handle;
48 };
50 {};
51 
52 void bse_pcm_device_request (BsePcmDevice *pdev,
53  guint n_channels,
54  guint mix_freq,
55  guint latency_ms,
56  guint block_length); /* in frames */
57 guint bse_pcm_device_get_mix_freq (BsePcmDevice *pdev);
58 BsePcmHandle* bse_pcm_device_get_handle (BsePcmDevice *pdev,
59  guint block_length);
60 gsize bse_pcm_handle_read (BsePcmHandle *handle,
61  gsize n_values,
62  gfloat *values);
63 void bse_pcm_handle_write (BsePcmHandle *handle,
64  gsize n_values,
65  const gfloat *values);
66 gboolean bse_pcm_handle_check_io (BsePcmHandle *handle,
67  glong *timeoutp);
68 guint bse_pcm_handle_latency (BsePcmHandle *handle);
69 
70 
71 /* --- misc utils --- */
72 guint bse_pcm_device_frequency_align (gint mix_freq);
73 
74 
75 #endif /* __BSE_PCM_DEVICE_H__ */
Definition: bsepcmdevice.hh:49
Definition: bsepcmdevice.hh:40
Definition: bsepcmdevice.hh:25
Definition: bsedevice.hh:31
Definition: bsedevice.hh:36