aboutsummaryrefslogtreecommitdiff
path: root/audio/audio_int.h
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2019-09-19 23:24:09 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-09-23 12:28:47 +0200
commitff095e5231a189a0a4e57fc13b51590bff816552 (patch)
treed4a0963aace11e84b012de8ab402249391c5837f /audio/audio_int.h
parentdfc543438404c0a6ac62ed6e7226233d398d7934 (diff)
audio: api for mixeng code free backends
This will make it possible to skip mixeng with audio playback and recording, allowing us to free ourselves from the limitations of the current mixeng (stereo, int64 samples only). In this case, HW and SW voices will be essentially the same, for every SW voice we will create a HW voice, since we can no longer mix multiple voices together. Some backends expect us to call a function when we have data ready write()/read() style, while others provide a buffer and expects us to directly write/read it, so for optimal performance audio_pcm_ops provide methods for both cases. Previously backends asked mixeng for more data in run_out/run_it, now instead mixeng or the frontends will call the backends, so that's why two sets of functions required. audio.c contains glue code between the two styles, so backends only ever have to implement one style and frontends are free to call whichever is more convenient for them. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 15a33c03a62228922d851f7324c52f73cb8d2414.1568927990.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/audio_int.h')
-rw-r--r--audio/audio_int.h43
1 files changed, 36 insertions, 7 deletions
diff --git a/audio/audio_int.h b/audio/audio_int.h
index a674c5374a..8fb1ca8a8d 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -65,6 +65,8 @@ typedef struct HWVoiceOut {
uint64_t ts_helper;
struct st_sample *mix_buf;
+ void *buf_emul;
+ size_t pos_emul, pending_emul, size_emul;
size_t samples;
QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
@@ -87,6 +89,8 @@ typedef struct HWVoiceIn {
uint64_t ts_helper;
struct st_sample *conv_buf;
+ void *buf_emul;
+ size_t pos_emul, pending_emul, size_emul;
size_t samples;
QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
@@ -147,17 +151,42 @@ struct audio_driver {
};
struct audio_pcm_ops {
- int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque);
- void (*fini_out)(HWVoiceOut *hw);
+ int (*init_out)(HWVoiceOut *hw, audsettings *as, void *drv_opaque);
+ void (*fini_out)(HWVoiceOut *hw);
size_t (*run_out)(HWVoiceOut *hw, size_t live);
- int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
-
- int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaque);
- void (*fini_in) (HWVoiceIn *hw);
+ size_t (*write) (HWVoiceOut *hw, void *buf, size_t size);
+ /*
+ * get a buffer that after later can be passed to put_buffer_out; optional
+ * returns the buffer, and writes it's size to size (in bytes)
+ * this is unrelated to the above buffer_size_out function
+ */
+ void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size);
+ /*
+ * put back the buffer returned by get_buffer_out; optional
+ * buf must be equal the pointer returned by get_buffer_out,
+ * size may be smaller
+ */
+ size_t (*put_buffer_out)(HWVoiceOut *hw, void *buf, size_t size);
+ int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
+
+ int (*init_in) (HWVoiceIn *hw, audsettings *as, void *drv_opaque);
+ void (*fini_in) (HWVoiceIn *hw);
size_t (*run_in)(HWVoiceIn *hw);
- int (*ctl_in) (HWVoiceIn *hw, int cmd, ...);
+ size_t (*read) (HWVoiceIn *hw, void *buf, size_t size);
+ void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size);
+ void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size);
+ int (*ctl_in) (HWVoiceIn *hw, int cmd, ...);
};
+void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size);
+void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size);
+void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size);
+size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size);
+size_t audio_generic_put_buffer_out_nowrite(HWVoiceOut *hw, void *buf,
+ size_t size);
+size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size);
+size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size);
+
struct capture_callback {
struct audio_capture_ops ops;
void *opaque;