sdlaudio.c (21ee7686d7b63c3e58a7ccab33315a8c543c7171) sdlaudio.c (85bc58520c0e43660cbbe51b9eb5022a0baafe9f)
1/*
2 * QEMU SDL audio driver
3 *
4 * Copyright (c) 2004-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

--- 54 unchanged lines hidden (view full) ---

63
64 va_start (ap, fmt);
65 AUD_vlog (AUDIO_CAP, fmt, ap);
66 va_end (ap);
67
68 AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ());
69}
70
1/*
2 * QEMU SDL audio driver
3 *
4 * Copyright (c) 2004-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

--- 54 unchanged lines hidden (view full) ---

63
64 va_start (ap, fmt);
65 AUD_vlog (AUDIO_CAP, fmt, ap);
66 va_end (ap);
67
68 AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ());
69}
70
71static int aud_to_sdlfmt (audfmt_e fmt)
71static int aud_to_sdlfmt (AudioFormat fmt)
72{
73 switch (fmt) {
72{
73 switch (fmt) {
74 case AUD_FMT_S8:
74 case AUDIO_FORMAT_S8:
75 return AUDIO_S8;
76
75 return AUDIO_S8;
76
77 case AUD_FMT_U8:
77 case AUDIO_FORMAT_U8:
78 return AUDIO_U8;
79
78 return AUDIO_U8;
79
80 case AUD_FMT_S16:
80 case AUDIO_FORMAT_S16:
81 return AUDIO_S16LSB;
82
81 return AUDIO_S16LSB;
82
83 case AUD_FMT_U16:
83 case AUDIO_FORMAT_U16:
84 return AUDIO_U16LSB;
85
86 default:
87 dolog ("Internal logic error: Bad audio format %d\n", fmt);
88#ifdef DEBUG_AUDIO
89 abort ();
90#endif
91 return AUDIO_U8;
92 }
93}
94
84 return AUDIO_U16LSB;
85
86 default:
87 dolog ("Internal logic error: Bad audio format %d\n", fmt);
88#ifdef DEBUG_AUDIO
89 abort ();
90#endif
91 return AUDIO_U8;
92 }
93}
94
95static int sdl_to_audfmt(int sdlfmt, audfmt_e *fmt, int *endianness)
95static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, int *endianness)
96{
97 switch (sdlfmt) {
98 case AUDIO_S8:
99 *endianness = 0;
96{
97 switch (sdlfmt) {
98 case AUDIO_S8:
99 *endianness = 0;
100 *fmt = AUD_FMT_S8;
100 *fmt = AUDIO_FORMAT_S8;
101 break;
102
103 case AUDIO_U8:
104 *endianness = 0;
101 break;
102
103 case AUDIO_U8:
104 *endianness = 0;
105 *fmt = AUD_FMT_U8;
105 *fmt = AUDIO_FORMAT_U8;
106 break;
107
108 case AUDIO_S16LSB:
109 *endianness = 0;
106 break;
107
108 case AUDIO_S16LSB:
109 *endianness = 0;
110 *fmt = AUD_FMT_S16;
110 *fmt = AUDIO_FORMAT_S16;
111 break;
112
113 case AUDIO_U16LSB:
114 *endianness = 0;
111 break;
112
113 case AUDIO_U16LSB:
114 *endianness = 0;
115 *fmt = AUD_FMT_U16;
115 *fmt = AUDIO_FORMAT_U16;
116 break;
117
118 case AUDIO_S16MSB:
119 *endianness = 1;
116 break;
117
118 case AUDIO_S16MSB:
119 *endianness = 1;
120 *fmt = AUD_FMT_S16;
120 *fmt = AUDIO_FORMAT_S16;
121 break;
122
123 case AUDIO_U16MSB:
124 *endianness = 1;
121 break;
122
123 case AUDIO_U16MSB:
124 *endianness = 1;
125 *fmt = AUD_FMT_U16;
125 *fmt = AUDIO_FORMAT_U16;
126 break;
127
128 default:
129 dolog ("Unrecognized SDL audio format %d\n", sdlfmt);
130 return -1;
131 }
132
133 return 0;

--- 126 unchanged lines hidden (view full) ---

260static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,
261 void *drv_opaque)
262{
263 SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
264 SDLAudioState *s = &glob_sdl;
265 SDL_AudioSpec req, obt;
266 int endianness;
267 int err;
126 break;
127
128 default:
129 dolog ("Unrecognized SDL audio format %d\n", sdlfmt);
130 return -1;
131 }
132
133 return 0;

--- 126 unchanged lines hidden (view full) ---

260static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,
261 void *drv_opaque)
262{
263 SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
264 SDLAudioState *s = &glob_sdl;
265 SDL_AudioSpec req, obt;
266 int endianness;
267 int err;
268 audfmt_e effective_fmt;
268 AudioFormat effective_fmt;
269 struct audsettings obt_as;
270
271 req.freq = as->freq;
272 req.format = aud_to_sdlfmt (as->fmt);
273 req.channels = as->nchannels;
274 req.samples = conf.nb_samples;
275 req.callback = sdl_callback;
276 req.userdata = sdl;

--- 103 unchanged lines hidden ---
269 struct audsettings obt_as;
270
271 req.freq = as->freq;
272 req.format = aud_to_sdlfmt (as->fmt);
273 req.channels = as->nchannels;
274 req.samples = conf.nb_samples;
275 req.callback = sdl_callback;
276 req.userdata = sdl;

--- 103 unchanged lines hidden ---