Added int32 and float32 support (and some others!) to BeOS audio backend.
Untested: No BeOS system here for compiling! --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402044
This commit is contained in:
parent
5324cc6d9c
commit
558a5b6909
1 changed files with 66 additions and 25 deletions
|
@ -156,37 +156,78 @@ extern "C"
|
||||||
int BE_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
int BE_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||||
{
|
{
|
||||||
media_raw_audio_format format;
|
media_raw_audio_format format;
|
||||||
|
SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
|
||||||
|
int valid_datatype = 0;
|
||||||
|
|
||||||
|
/* Parse the audio format and fill the Be raw audio format */
|
||||||
|
memset(&format, '\0', sizeof (media_raw_audio_format));
|
||||||
|
format.byte_order = B_MEDIA_LITTLE_ENDIAN;
|
||||||
|
format.frame_rate = (float) spec->freq;
|
||||||
|
format.channel_count = spec->channels; /* !!! FIXME: support > 2? */
|
||||||
|
while ((!valid_datatype) && (test_format)) {
|
||||||
|
spec->format = test_format;
|
||||||
|
switch (test_format) {
|
||||||
|
case AUDIO_S8:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_CHAR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_U8:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_UCHAR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_S16LSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_SHORT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_S16MSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_SHORT;
|
||||||
|
format.byte_order = B_MEDIA_BIG_ENDIAN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_S32LSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_INT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_S32MSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_INT;
|
||||||
|
format.byte_order = B_MEDIA_BIG_ENDIAN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_F32LSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_F32MSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||||
|
format.byte_order = B_MEDIA_BIG_ENDIAN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
test_format = SDL_NextAudioFormat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
format.buffer_size = spec->samples;
|
||||||
|
|
||||||
|
if (!valid_datatype) { /* shouldn't happen, but just in case... */
|
||||||
|
SDL_SetError("Unsupported audio format");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the Be Application, if it's not already started */
|
/* Initialize the Be Application, if it's not already started */
|
||||||
if (SDL_InitBeApp() < 0) {
|
if (SDL_InitBeApp() < 0) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the audio format and fill the Be raw audio format */
|
|
||||||
format.frame_rate = (float) spec->freq;
|
|
||||||
format.channel_count = spec->channels;
|
|
||||||
switch (spec->format & ~0x1000) {
|
|
||||||
case AUDIO_S8:
|
|
||||||
/* Signed 8-bit audio unsupported, convert to U8 */
|
|
||||||
spec->format = AUDIO_U8;
|
|
||||||
case AUDIO_U8:
|
|
||||||
format.format = media_raw_audio_format::B_AUDIO_UCHAR;
|
|
||||||
format.byte_order = 0;
|
|
||||||
break;
|
|
||||||
case AUDIO_U16:
|
|
||||||
/* Unsigned 16-bit audio unsupported, convert to S16 */
|
|
||||||
spec->format ^= 0x8000;
|
|
||||||
case AUDIO_S16:
|
|
||||||
format.format = media_raw_audio_format::B_AUDIO_SHORT;
|
|
||||||
if (spec->format & 0x1000) {
|
|
||||||
format.byte_order = 1; /* Big endian */
|
|
||||||
} else {
|
|
||||||
format.byte_order = 2; /* Little endian */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
format.buffer_size = spec->samples;
|
|
||||||
|
|
||||||
/* Calculate the final parameters for this audio specification */
|
/* Calculate the final parameters for this audio specification */
|
||||||
SDL_CalculateAudioSpec(spec);
|
SDL_CalculateAudioSpec(spec);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue