Commit a350e694245c1ce9492c67db83e1fd325e767769

Authored by balrog
1 parent 58565070

Avoid arithmetics on void * in MusicPal audio code (Jan Kiszka).


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4373 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 8 deletions
hw/musicpal.c
... ... @@ -244,7 +244,7 @@ typedef struct musicpal_audio_state {
244 244 uint32_t status;
245 245 uint32_t irq_enable;
246 246 unsigned long phys_buf;
247   - void *target_buffer;
  247 + int8_t *target_buffer;
248 248 unsigned int threshold;
249 249 unsigned int play_pos;
250 250 unsigned int last_free;
... ... @@ -256,7 +256,7 @@ static void audio_callback(void *opaque, int free_out, int free_in)
256 256 {
257 257 musicpal_audio_state *s = opaque;
258 258 int16_t *codec_buffer;
259   - void *mem_buffer;
  259 + int8_t *mem_buffer;
260 260 int pos, block_size;
261 261  
262 262 if (!(s->playback_mode & MP_AUDIO_PLAYBACK_EN))
... ... @@ -277,8 +277,8 @@ static void audio_callback(void *opaque, int free_out, int free_in)
277 277 if (s->playback_mode & MP_AUDIO_MONO) {
278 278 codec_buffer = wm8750_dac_buffer(s->wm, block_size >> 1);
279 279 for (pos = 0; pos < block_size; pos += 2) {
280   - *codec_buffer++ = *(uint16_t *)mem_buffer;
281   - *codec_buffer++ = *(uint16_t *)mem_buffer;
  280 + *codec_buffer++ = *(int16_t *)mem_buffer;
  281 + *codec_buffer++ = *(int16_t *)mem_buffer;
282 282 mem_buffer += 2;
283 283 }
284 284 } else
... ... @@ -288,14 +288,14 @@ static void audio_callback(void *opaque, int free_out, int free_in)
288 288 if (s->playback_mode & MP_AUDIO_MONO) {
289 289 codec_buffer = wm8750_dac_buffer(s->wm, block_size);
290 290 for (pos = 0; pos < block_size; pos++) {
291   - *codec_buffer++ = cpu_to_le16(256 * *(int8_t *)mem_buffer);
292   - *codec_buffer++ = cpu_to_le16(256 * *(int8_t *)mem_buffer++);
  291 + *codec_buffer++ = cpu_to_le16(256 * *mem_buffer);
  292 + *codec_buffer++ = cpu_to_le16(256 * *mem_buffer++);
293 293 }
294 294 } else {
295 295 codec_buffer = wm8750_dac_buffer(s->wm, block_size >> 1);
296 296 for (pos = 0; pos < block_size; pos += 2) {
297   - *codec_buffer++ = cpu_to_le16(256 * *(int8_t *)mem_buffer++);
298   - *codec_buffer++ = cpu_to_le16(256 * *(int8_t *)mem_buffer++);
  297 + *codec_buffer++ = cpu_to_le16(256 * *mem_buffer++);
  298 + *codec_buffer++ = cpu_to_le16(256 * *mem_buffer++);
299 299 }
300 300 }
301 301 }
... ...