Changeset 6521 in vbox
- Timestamp:
- Jan 28, 2008 8:13:46 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27540
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/audio.c
r6140 r6521 238 238 #endif 239 239 240 static inline int audio_bits_to_index (int bits) 241 { 242 switch (bits) { 243 case 8: 244 return 0; 245 246 case 16: 247 return 1; 248 249 case 32: 250 return 2; 251 252 default: 253 audio_bug ("bits_to_index", 1); 254 AUD_log (NULL, "invalid bits %d\n", bits); 255 return 0; 256 } 257 } 258 240 259 void *audio_calloc (const char *funcname, int nmemb, size_t size) 241 260 { … … 571 590 void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as) 572 591 { 573 int bits = 8, sign = 0 ;592 int bits = 8, sign = 0, shift = 0; 574 593 575 594 switch (as->fmt) { … … 583 602 case AUD_FMT_U16: 584 603 bits = 16; 604 shift = 1; 585 605 break; 586 606 … … 589 609 case AUD_FMT_U32: 590 610 bits = 32; 611 shift = 2; 591 612 break; 592 613 } … … 596 617 info->sign = sign; 597 618 info->nchannels = as->nchannels; 598 info->shift = (as->nchannels == 2) + (bits == 16);619 info->shift = (as->nchannels == 2) + shift; 599 620 info->align = (1 << info->shift) - 1; 600 621 info->bytes_per_second = info->freq << info->shift; … … 612 633 } 613 634 else { 614 if (info->bits == 8) { 635 switch (info->bits) { 636 case 8: 615 637 memset (buf, 0x80, len << info->shift); 616 } 617 else { 618 int i; 619 uint16_t *p = buf; 620 int shift = info->nchannels - 1; 621 short s = INT16_MAX; 622 623 if (info->swap_endianness) { 624 s = bswap16 (s); 625 } 626 627 for (i = 0; i < len << shift; i++) { 628 p[i] = s; 629 } 638 break; 639 640 case 16: 641 { 642 int i; 643 uint16_t *p = buf; 644 int shift = info->nchannels - 1; 645 short s = INT16_MAX; 646 647 if (info->swap_endianness) { 648 s = bswap16 (s); 649 } 650 651 for (i = 0; i < len << shift; i++) { 652 p[i] = s; 653 } 654 } 655 break; 656 657 case 32: 658 { 659 int i; 660 uint32_t *p = buf; 661 int shift = info->nchannels - 1; 662 int32_t s = INT32_MAX; 663 664 if (info->swap_endianness) { 665 s = bswap32 (s); 666 } 667 668 for (i = 0; i < len << shift; i++) { 669 p[i] = s; 670 } 671 } 672 break; 673 674 default: 675 AUD_log (NULL, "audio_pcm_info_clear_buf: invalid bits %d\n", 676 info->bits); 677 break; 630 678 } 631 679 } … … 1740 1788 [hw->info.sign] 1741 1789 [hw->info.swap_endianness] 1742 [ hw->info.bits == 16];1790 [audio_bits_to_index (hw->info.bits)]; 1743 1791 1744 1792 LIST_INSERT_HEAD (&s->cap_head, cap, entries); -
trunk/src/VBox/Devices/Audio/audio_template.h
r1 r6521 165 165 [sw->info.sign] 166 166 [sw->info.swap_endianness] 167 [ sw->info.bits == 16];167 [audio_bits_to_index (sw->info.bits)]; 168 168 169 169 sw->name = qemu_strdup (name); … … 290 290 [hw->info.sign] 291 291 [hw->info.swap_endianness] 292 [ hw->info.bits == 16];292 [audio_bits_to_index (hw->info.bits)]; 293 293 294 294 if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) { … … 353 353 sw = audio_calloc (AUDIO_FUNC, 1, sizeof (*sw)); 354 354 if (!sw) { 355 #if defined __STDC_VERSION__ && __STDC_VERSION__ > 199901L356 355 dolog ("Could not allocate soft voice `%s' (%zu bytes)\n", 357 356 sw_name ? sw_name : "unknown", sizeof (*sw)); 358 #else359 dolog ("Could not allocate soft voice `%s' (%u bytes)\n",360 sw_name ? sw_name : "unknown", sizeof (*sw));361 #endif362 357 goto err1; 363 358 } -
trunk/src/VBox/Devices/Audio/mixeng.c
r355 r6521 92 92 #undef SHIFT 93 93 94 /* Unsigned 16 bit */ 94 95 #define IN_T uint16_t 95 96 #define IN_MIN 0 … … 111 112 #undef SHIFT 112 113 113 t_sample *mixeng_conv[2][2][2][2] = { 114 /* Signed 32 bit */ 115 #define IN_T int32_t 116 #define IN_MIN INT32_MIN 117 #define IN_MAX INT32_MAX 118 #define SIGNED 119 #define SHIFT 32 120 #define ENDIAN_CONVERSION natural 121 #define ENDIAN_CONVERT(v) (v) 122 #include "mixeng_template.h" 123 #undef ENDIAN_CONVERT 124 #undef ENDIAN_CONVERSION 125 #define ENDIAN_CONVERSION swap 126 #define ENDIAN_CONVERT(v) bswap32 (v) 127 #include "mixeng_template.h" 128 #undef ENDIAN_CONVERT 129 #undef ENDIAN_CONVERSION 130 #undef SIGNED 131 #undef IN_MAX 132 #undef IN_MIN 133 #undef IN_T 134 #undef SHIFT 135 136 /* Unsigned 32 bit */ 137 #define IN_T uint32_t 138 #define IN_MIN 0 139 #define IN_MAX UINT32_MAX 140 #define SHIFT 32 141 #define ENDIAN_CONVERSION natural 142 #define ENDIAN_CONVERT(v) (v) 143 #include "mixeng_template.h" 144 #undef ENDIAN_CONVERT 145 #undef ENDIAN_CONVERSION 146 #define ENDIAN_CONVERSION swap 147 #define ENDIAN_CONVERT(v) bswap32 (v) 148 #include "mixeng_template.h" 149 #undef ENDIAN_CONVERT 150 #undef ENDIAN_CONVERSION 151 #undef IN_MAX 152 #undef IN_MIN 153 #undef IN_T 154 #undef SHIFT 155 156 t_sample *mixeng_conv[2][2][2][3] = { 114 157 { 115 158 { 116 159 { 117 160 conv_natural_uint8_t_to_mono, 118 conv_natural_uint16_t_to_mono 161 conv_natural_uint16_t_to_mono, 162 conv_natural_uint32_t_to_mono 119 163 }, 120 164 { 121 165 conv_natural_uint8_t_to_mono, 122 conv_swap_uint16_t_to_mono 166 conv_swap_uint16_t_to_mono, 167 conv_swap_uint32_t_to_mono, 123 168 } 124 169 }, … … 126 171 { 127 172 conv_natural_int8_t_to_mono, 128 conv_natural_int16_t_to_mono 173 conv_natural_int16_t_to_mono, 174 conv_natural_int32_t_to_mono 129 175 }, 130 176 { 131 177 conv_natural_int8_t_to_mono, 132 conv_swap_int16_t_to_mono 178 conv_swap_int16_t_to_mono, 179 conv_swap_int32_t_to_mono 133 180 } 134 181 } … … 138 185 { 139 186 conv_natural_uint8_t_to_stereo, 140 conv_natural_uint16_t_to_stereo 187 conv_natural_uint16_t_to_stereo, 188 conv_natural_uint32_t_to_stereo 141 189 }, 142 190 { 143 191 conv_natural_uint8_t_to_stereo, 144 conv_swap_uint16_t_to_stereo 192 conv_swap_uint16_t_to_stereo, 193 conv_swap_uint32_t_to_stereo 145 194 } 146 195 }, … … 148 197 { 149 198 conv_natural_int8_t_to_stereo, 150 conv_natural_int16_t_to_stereo 199 conv_natural_int16_t_to_stereo, 200 conv_natural_int32_t_to_stereo 151 201 }, 152 202 { 153 203 conv_natural_int8_t_to_stereo, 154 conv_swap_int16_t_to_stereo 204 conv_swap_int16_t_to_stereo, 205 conv_swap_int32_t_to_stereo, 155 206 } 156 207 } … … 158 209 }; 159 210 160 f_sample *mixeng_clip[2][2][2][ 2] = {211 f_sample *mixeng_clip[2][2][2][3] = { 161 212 { 162 213 { 163 214 { 164 215 clip_natural_uint8_t_from_mono, 165 clip_natural_uint16_t_from_mono 216 clip_natural_uint16_t_from_mono, 217 clip_natural_uint32_t_from_mono 166 218 }, 167 219 { 168 220 clip_natural_uint8_t_from_mono, 169 clip_swap_uint16_t_from_mono 221 clip_swap_uint16_t_from_mono, 222 clip_swap_uint32_t_from_mono 170 223 } 171 224 }, … … 173 226 { 174 227 clip_natural_int8_t_from_mono, 175 clip_natural_int16_t_from_mono 228 clip_natural_int16_t_from_mono, 229 clip_natural_int32_t_from_mono 176 230 }, 177 231 { 178 232 clip_natural_int8_t_from_mono, 179 clip_swap_int16_t_from_mono 233 clip_swap_int16_t_from_mono, 234 clip_swap_int32_t_from_mono 180 235 } 181 236 } … … 185 240 { 186 241 clip_natural_uint8_t_from_stereo, 187 clip_natural_uint16_t_from_stereo 242 clip_natural_uint16_t_from_stereo, 243 clip_natural_uint32_t_from_stereo 188 244 }, 189 245 { 190 246 clip_natural_uint8_t_from_stereo, 191 clip_swap_uint16_t_from_stereo 247 clip_swap_uint16_t_from_stereo, 248 clip_swap_uint32_t_from_stereo 192 249 } 193 250 }, … … 195 252 { 196 253 clip_natural_int8_t_from_stereo, 197 clip_natural_int16_t_from_stereo 254 clip_natural_int16_t_from_stereo, 255 clip_natural_int32_t_from_stereo 198 256 }, 199 257 { 200 258 clip_natural_int8_t_from_stereo, 201 clip_swap_int16_t_from_stereo 259 clip_swap_int16_t_from_stereo, 260 clip_swap_int32_t_from_stereo 202 261 } 203 262 } -
trunk/src/VBox/Devices/Audio/mixeng.h
r355 r6521 46 46 typedef void (f_sample) (void *dst, const st_sample_t *src, int samples); 47 47 48 extern t_sample *mixeng_conv[2][2][2][ 2];49 extern f_sample *mixeng_clip[2][2][2][ 2];48 extern t_sample *mixeng_conv[2][2][2][3]; 49 extern f_sample *mixeng_clip[2][2][2][3]; 50 50 51 51 void *st_rate_start (int inrate, int outrate); -
trunk/src/VBox/Devices/Audio/mixeng_template.h
r355 r6521 36 36 #else 37 37 #ifdef VBOX 38 #ifdef SIGNED39 38 #define VOL(a, b) ((ASMMult2xS32RetS64(a, b) >> 31)) 40 #else41 #define VOL(a, b) ((ASMMult2xU32RetU64(a, b) >> 31))42 #endif43 39 #else /* !VBOX */ 44 40 #ifdef FLOAT_MIXENG
Note:
See TracChangeset
for help on using the changeset viewer.