ossaudio.c (6ceb1b51f05f9e1892d082960ed602dca7b6696e) | ossaudio.c (85bc58520c0e43660cbbe51b9eb5022a0baafe9f) |
---|---|
1/* 2 * QEMU OSS audio driver 3 * 4 * Copyright (c) 2003-2005 Vassili Karpov (malc) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 56 unchanged lines hidden (view full) --- 65 int fd; 66 int nfrags; 67 int fragsize; 68 OSSConf *conf; 69} OSSVoiceIn; 70 71struct oss_params { 72 int freq; | 1/* 2 * QEMU OSS audio driver 3 * 4 * Copyright (c) 2003-2005 Vassili Karpov (malc) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 56 unchanged lines hidden (view full) --- 65 int fd; 66 int nfrags; 67 int fragsize; 68 OSSConf *conf; 69} OSSVoiceIn; 70 71struct oss_params { 72 int freq; |
73 audfmt_e fmt; | 73 AudioFormat fmt; |
74 int nchannels; 75 int nfrags; 76 int fragsize; 77}; 78 79static void GCC_FMT_ATTR (2, 3) oss_logerr (int err, const char *fmt, ...) 80{ 81 va_list ap; --- 61 unchanged lines hidden (view full) --- 143 qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL); 144} 145 146static int oss_write (SWVoiceOut *sw, void *buf, int len) 147{ 148 return audio_pcm_sw_write (sw, buf, len); 149} 150 | 74 int nchannels; 75 int nfrags; 76 int fragsize; 77}; 78 79static void GCC_FMT_ATTR (2, 3) oss_logerr (int err, const char *fmt, ...) 80{ 81 va_list ap; --- 61 unchanged lines hidden (view full) --- 143 qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL); 144} 145 146static int oss_write (SWVoiceOut *sw, void *buf, int len) 147{ 148 return audio_pcm_sw_write (sw, buf, len); 149} 150 |
151static int aud_to_ossfmt (audfmt_e fmt, int endianness) | 151static int aud_to_ossfmt (AudioFormat fmt, int endianness) |
152{ 153 switch (fmt) { | 152{ 153 switch (fmt) { |
154 case AUD_FMT_S8: | 154 case AUDIO_FORMAT_S8: |
155 return AFMT_S8; 156 | 155 return AFMT_S8; 156 |
157 case AUD_FMT_U8: | 157 case AUDIO_FORMAT_U8: |
158 return AFMT_U8; 159 | 158 return AFMT_U8; 159 |
160 case AUD_FMT_S16: | 160 case AUDIO_FORMAT_S16: |
161 if (endianness) { 162 return AFMT_S16_BE; 163 } 164 else { 165 return AFMT_S16_LE; 166 } 167 | 161 if (endianness) { 162 return AFMT_S16_BE; 163 } 164 else { 165 return AFMT_S16_LE; 166 } 167 |
168 case AUD_FMT_U16: | 168 case AUDIO_FORMAT_U16: |
169 if (endianness) { 170 return AFMT_U16_BE; 171 } 172 else { 173 return AFMT_U16_LE; 174 } 175 176 default: 177 dolog ("Internal logic error: Bad audio format %d\n", fmt); 178#ifdef DEBUG_AUDIO 179 abort (); 180#endif 181 return AFMT_U8; 182 } 183} 184 | 169 if (endianness) { 170 return AFMT_U16_BE; 171 } 172 else { 173 return AFMT_U16_LE; 174 } 175 176 default: 177 dolog ("Internal logic error: Bad audio format %d\n", fmt); 178#ifdef DEBUG_AUDIO 179 abort (); 180#endif 181 return AFMT_U8; 182 } 183} 184 |
185static int oss_to_audfmt (int ossfmt, audfmt_e *fmt, int *endianness) | 185static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, int *endianness) |
186{ 187 switch (ossfmt) { 188 case AFMT_S8: 189 *endianness = 0; | 186{ 187 switch (ossfmt) { 188 case AFMT_S8: 189 *endianness = 0; |
190 *fmt = AUD_FMT_S8; | 190 *fmt = AUDIO_FORMAT_S8; |
191 break; 192 193 case AFMT_U8: 194 *endianness = 0; | 191 break; 192 193 case AFMT_U8: 194 *endianness = 0; |
195 *fmt = AUD_FMT_U8; | 195 *fmt = AUDIO_FORMAT_U8; |
196 break; 197 198 case AFMT_S16_LE: 199 *endianness = 0; | 196 break; 197 198 case AFMT_S16_LE: 199 *endianness = 0; |
200 *fmt = AUD_FMT_S16; | 200 *fmt = AUDIO_FORMAT_S16; |
201 break; 202 203 case AFMT_U16_LE: 204 *endianness = 0; | 201 break; 202 203 case AFMT_U16_LE: 204 *endianness = 0; |
205 *fmt = AUD_FMT_U16; | 205 *fmt = AUDIO_FORMAT_U16; |
206 break; 207 208 case AFMT_S16_BE: 209 *endianness = 1; | 206 break; 207 208 case AFMT_S16_BE: 209 *endianness = 1; |
210 *fmt = AUD_FMT_S16; | 210 *fmt = AUDIO_FORMAT_S16; |
211 break; 212 213 case AFMT_U16_BE: 214 *endianness = 1; | 211 break; 212 213 case AFMT_U16_BE: 214 *endianness = 1; |
215 *fmt = AUD_FMT_U16; | 215 *fmt = AUDIO_FORMAT_U16; |
216 break; 217 218 default: 219 dolog ("Unrecognized audio format %d\n", ossfmt); 220 return -1; 221 } 222 223 return 0; --- 271 unchanged lines hidden (view full) --- 495static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, 496 void *drv_opaque) 497{ 498 OSSVoiceOut *oss = (OSSVoiceOut *) hw; 499 struct oss_params req, obt; 500 int endianness; 501 int err; 502 int fd; | 216 break; 217 218 default: 219 dolog ("Unrecognized audio format %d\n", ossfmt); 220 return -1; 221 } 222 223 return 0; --- 271 unchanged lines hidden (view full) --- 495static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, 496 void *drv_opaque) 497{ 498 OSSVoiceOut *oss = (OSSVoiceOut *) hw; 499 struct oss_params req, obt; 500 int endianness; 501 int err; 502 int fd; |
503 audfmt_e effective_fmt; | 503 AudioFormat effective_fmt; |
504 struct audsettings obt_as; 505 OSSConf *conf = drv_opaque; 506 507 oss->fd = -1; 508 509 req.fmt = aud_to_ossfmt (as->fmt, as->endianness); 510 req.freq = as->freq; 511 req.nchannels = as->nchannels; --- 150 unchanged lines hidden (view full) --- 662 663static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) 664{ 665 OSSVoiceIn *oss = (OSSVoiceIn *) hw; 666 struct oss_params req, obt; 667 int endianness; 668 int err; 669 int fd; | 504 struct audsettings obt_as; 505 OSSConf *conf = drv_opaque; 506 507 oss->fd = -1; 508 509 req.fmt = aud_to_ossfmt (as->fmt, as->endianness); 510 req.freq = as->freq; 511 req.nchannels = as->nchannels; --- 150 unchanged lines hidden (view full) --- 662 663static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) 664{ 665 OSSVoiceIn *oss = (OSSVoiceIn *) hw; 666 struct oss_params req, obt; 667 int endianness; 668 int err; 669 int fd; |
670 audfmt_e effective_fmt; | 670 AudioFormat effective_fmt; |
671 struct audsettings obt_as; 672 OSSConf *conf = drv_opaque; 673 674 oss->fd = -1; 675 676 req.fmt = aud_to_ossfmt (as->fmt, as->endianness); 677 req.freq = as->freq; 678 req.nchannels = as->nchannels; --- 265 unchanged lines hidden --- | 671 struct audsettings obt_as; 672 OSSConf *conf = drv_opaque; 673 674 oss->fd = -1; 675 676 req.fmt = aud_to_ossfmt (as->fmt, as->endianness); 677 req.freq = as->freq; 678 req.nchannels = as->nchannels; --- 265 unchanged lines hidden --- |