Added SDL_AUDIO_BYTESIZE

This commit is contained in:
Brick
2023-09-05 23:02:37 +01:00
committed by Sam Lantinga
parent 544351c98e
commit 53122593f8
12 changed files with 21 additions and 20 deletions

View File

@@ -513,7 +513,7 @@ static void StreamThing_ontick(Thing *thing, Uint64 now)
if (!available || (SDL_GetAudioStreamFormat(thing->data.stream.stream, NULL, &spec) < 0)) {
DestroyThingInPoof(thing);
} else {
const int ticksleft = (int) ((((Uint64) ((available / (SDL_AUDIO_BITSIZE(spec.format) / 8)) / spec.channels)) * 1000) / spec.freq);
const int ticksleft = (int) ((((Uint64) ((available / SDL_AUDIO_BYTESIZE(spec.format)) / spec.channels)) * 1000) / spec.freq);
const float pct = thing->data.stream.total_ticks ? (((float) (ticksleft)) / ((float) thing->data.stream.total_ticks)) : 0.0f;
thing->progress = 1.0f - pct;
}
@@ -553,7 +553,7 @@ static void StreamThing_ondrop(Thing *thing, int button, float x, float y)
SDL_UnbindAudioStream(thing->data.stream.stream); /* unbind from current device */
if (thing->line_connected_to->what == THING_LOGDEV_CAPTURE) {
SDL_FlushAudioStream(thing->data.stream.stream);
thing->data.stream.total_ticks = (int) (((((Uint64) (SDL_GetAudioStreamAvailable(thing->data.stream.stream) / (SDL_AUDIO_BITSIZE(spec->format) / 8))) / spec->channels) * 1000) / spec->freq);
thing->data.stream.total_ticks = (int) (((((Uint64) (SDL_GetAudioStreamAvailable(thing->data.stream.stream) / SDL_AUDIO_BYTESIZE(spec->format))) / spec->channels) * 1000) / spec->freq);
}
}
@@ -596,7 +596,7 @@ static Thing *CreateStreamThing(const SDL_AudioSpec *spec, const Uint8 *buf, con
if (buf && buflen) {
SDL_PutAudioStreamData(thing->data.stream.stream, buf, (int) buflen);
SDL_FlushAudioStream(thing->data.stream.stream);
thing->data.stream.total_ticks = (int) (((((Uint64) (SDL_GetAudioStreamAvailable(thing->data.stream.stream) / (SDL_AUDIO_BITSIZE(spec->format) / 8))) / spec->channels) * 1000) / spec->freq);
thing->data.stream.total_ticks = (int) (((((Uint64) (SDL_GetAudioStreamAvailable(thing->data.stream.stream) / SDL_AUDIO_BYTESIZE(spec->format))) / spec->channels) * 1000) / spec->freq);
}
thing->ontick = StreamThing_ontick;
thing->ondrag = StreamThing_ondrag;

View File

@@ -292,7 +292,7 @@ static void loop(void)
if (SDL_GetAudioStreamFormat(stream, &src_spec, &dst_spec) == 0) {
available_bytes = SDL_GetAudioStreamAvailable(stream);
available_seconds = (float)available_bytes / (float)(SDL_AUDIO_BITSIZE(dst_spec.format) / 8 * dst_spec.freq * dst_spec.channels);
available_seconds = (float)available_bytes / (float)(SDL_AUDIO_BYTESIZE(dst_spec.format) * dst_spec.freq * dst_spec.channels);
/* keep it looping. */
if (auto_loop && (available_seconds < 10.0f)) {

View File

@@ -712,8 +712,8 @@ static int audio_convertAudio(void *arg)
int src_samplesize, dst_samplesize;
int src_silence, dst_silence;
src_samplesize = (SDL_AUDIO_BITSIZE(spec1.format) / 8) * spec1.channels;
dst_samplesize = (SDL_AUDIO_BITSIZE(spec2.format) / 8) * spec2.channels;
src_samplesize = SDL_AUDIO_BYTESIZE(spec1.format) * spec1.channels;
dst_samplesize = SDL_AUDIO_BYTESIZE(spec2.format) * spec2.channels;
src_len = l * src_samplesize;
SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, src_len);