@@ -152,7 +152,7 @@ struct audio_driver {
struct audio_pcm_ops {
int (*init_out)(HWVoiceOut *hw, audsettings *as, void *drv_opaque);
void (*fini_out)(HWVoiceOut *hw);
- size_t (*write) (HWVoiceOut *hw, void *buf, size_t size);
+ size_t (*write) (HWVoiceOut *hw, const void *buf, size_t size);
void (*run_buffer_out)(HWVoiceOut *hw);
/*
* get a buffer that after later can be passed to put_buffer_out; optional
@@ -165,7 +165,7 @@ struct audio_pcm_ops {
* 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);
+ size_t (*put_buffer_out)(HWVoiceOut *hw, const void *buf, size_t size);
void (*enable_out)(HWVoiceOut *hw, bool enable);
void (*volume_out)(HWVoiceOut *hw, Volume *vol);
@@ -173,17 +173,18 @@ struct audio_pcm_ops {
void (*fini_in) (HWVoiceIn *hw);
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);
+ void (*put_buffer_in)(HWVoiceIn *hw, const void *buf, size_t size);
void (*enable_in)(HWVoiceIn *hw, bool enable);
void (*volume_in)(HWVoiceIn *hw, Volume *vol);
};
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_put_buffer_in(HWVoiceIn *hw, const void *buf, size_t size);
void audio_generic_run_buffer_out(HWVoiceOut *hw);
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_write(HWVoiceOut *hw, void *buf, size_t size);
+size_t audio_generic_put_buffer_out(HWVoiceOut *hw,
+ const void *buf, size_t size);
+size_t audio_generic_write(HWVoiceOut *hw, const void *buf, size_t size);
size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size);
struct capture_callback {
@@ -608,7 +608,7 @@ static int alsa_open(bool in, struct alsa_params_req *req,
return -1;
}
-static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len)
+static size_t alsa_write(HWVoiceOut *hw, const void *buf, size_t len)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
size_t pos = 0;
@@ -1253,7 +1253,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples)
while (samples) {
size_t proc;
size_t size = samples * hw->info.bytes_per_frame;
- void *buf = hw->pcm_ops->get_buffer_in(hw, &size);
+ const void *buf = hw->pcm_ops->get_buffer_in(hw, &size);
assert(size % hw->info.bytes_per_frame == 0);
if (size == 0) {
@@ -1425,7 +1425,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size)
return hw->buf_emul + start;
}
-void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
+void audio_generic_put_buffer_in(HWVoiceIn *hw, const void *buf, size_t size)
{
assert(size <= hw->pending_emul);
hw->pending_emul -= size;
@@ -1468,7 +1468,8 @@ void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size)
return hw->buf_emul + hw->pos_emul;
}
-size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
+size_t audio_generic_put_buffer_out(HWVoiceOut *hw,
+ const void *buf, size_t size)
{
assert(buf == hw->buf_emul + hw->pos_emul &&
size + hw->pending_emul <= hw->size_emul);
@@ -1479,7 +1480,7 @@ size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
return size;
}
-size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size)
+size_t audio_generic_write(HWVoiceOut *hw, const void *buf, size_t size)
{
size_t dst_size, copy_size;
void *dst = hw->pcm_ops->get_buffer_out(hw, &dst_size);
@@ -1491,7 +1492,7 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size)
size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)
{
- void *src = hw->pcm_ops->get_buffer_in(hw, &size);
+ const void *src = hw->pcm_ops->get_buffer_in(hw, &size);
memcpy(buf, src, size);
hw->pcm_ops->put_buffer_in(hw, src, size);
@@ -412,9 +412,10 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, const char *fn_name)
COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size),
(hw, size))
COREAUDIO_WRAPPER_FUNC(put_buffer_out, size_t,
- (HWVoiceOut *hw, void *buf, size_t size),
+ (HWVoiceOut *hw, const void *buf, size_t size),
(hw, buf, size))
-COREAUDIO_WRAPPER_FUNC(write, size_t, (HWVoiceOut *hw, void *buf, size_t size),
+COREAUDIO_WRAPPER_FUNC(write, size_t,
+ (HWVoiceOut *hw, const void *buf, size_t size),
(hw, buf, size))
#undef COREAUDIO_WRAPPER_FUNC
@@ -454,7 +454,7 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size)
return ret;
}
-static size_t dsound_put_buffer_out(HWVoiceOut *hw, void *buf, size_t len)
+static size_t dsound_put_buffer_out(HWVoiceOut *hw, const void *buf, size_t len)
{
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
@@ -41,7 +41,7 @@ typedef struct NoVoiceIn {
RateCtl rate;
} NoVoiceIn;
-static size_t no_write(HWVoiceOut *hw, void *buf, size_t len)
+static size_t no_write(HWVoiceOut *hw, const void *buf, size_t len)
{
NoVoiceOut *no = (NoVoiceOut *) hw;
return audio_rate_get_bytes(&hw->info, &no->rate, len);
@@ -402,7 +402,7 @@ static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size)
}
}
-static size_t oss_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
+static size_t oss_put_buffer_out(HWVoiceOut *hw, const void *buf, size_t size)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
if (oss->mmapped) {
@@ -415,7 +415,7 @@ static size_t oss_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
}
}
-static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len)
+static size_t oss_write(HWVoiceOut *hw, const void *buf, size_t len)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
size_t pos;
@@ -125,7 +125,7 @@ unlock_and_fail:
return NULL;
}
-static void qpa_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
+static void qpa_put_buffer_in(HWVoiceIn *hw, const void *buf, size_t size)
{
PAVoiceIn *p = (PAVoiceIn *) hw;
PAConnection *c = p->g->conn;
@@ -228,7 +228,7 @@ unlock_and_fail:
return NULL;
}
-static size_t qpa_write(HWVoiceOut *hw, void *data, size_t length)
+static size_t qpa_write(HWVoiceOut *hw, const void *data, size_t length)
{
PAVoiceOut *p = (PAVoiceOut *) hw;
PAConnection *c = p->g->conn;
@@ -256,10 +256,12 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size),
(hw, size), *size = 0, sdl_unlock)
SDL_WRAPPER_FUNC(put_buffer_out, size_t,
- (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size),
+ (HWVoiceOut *hw, const void *buf, size_t size),
+ (hw, buf, size),
/*nothing*/, sdl_unlock_and_post)
SDL_WRAPPER_FUNC(write, size_t,
- (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size),
+ (HWVoiceOut *hw, const void *buf, size_t size),
+ (hw, buf, size),
/*nothing*/, sdl_unlock_and_post)
#undef SDL_WRAPPER_FUNC
@@ -139,7 +139,7 @@ static void *line_out_get_buffer(HWVoiceOut *hw, size_t *size)
return out->frame + out->fpos;
}
-static size_t line_out_put_buffer(HWVoiceOut *hw, void *buf, size_t size)
+static size_t line_out_put_buffer(HWVoiceOut *hw, const void *buf, size_t size)
{
SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
@@ -39,7 +39,7 @@ typedef struct WAVVoiceOut {
int total_samples;
} WAVVoiceOut;
-static size_t wav_write_out(HWVoiceOut *hw, void *buf, size_t len)
+static size_t wav_write_out(HWVoiceOut *hw, const void *buf, size_t len)
{
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
int64_t bytes = audio_rate_get_bytes(&hw->info, &wav->rate, len);
The various write() and put_buffer() handlers should not modify their buffer argument. Make it const. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- audio/audio_int.h | 13 +++++++------ audio/alsaaudio.c | 2 +- audio/audio.c | 11 ++++++----- audio/coreaudio.c | 5 +++-- audio/dsoundaudio.c | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 4 ++-- audio/paaudio.c | 4 ++-- audio/sdlaudio.c | 6 ++++-- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- 11 files changed, 29 insertions(+), 24 deletions(-)