Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase and update stb_vorbis.h to SDL_sound's version : #395

Merged
merged 2 commits into from
May 21, 2022
Merged

Rebase and update stb_vorbis.h to SDL_sound's version : #395

merged 2 commits into from
May 21, 2022

Conversation

sezero
Copy link
Contributor

@sezero sezero commented May 21, 2022

- Keeps the original stb_vorbis as intact as possible so
  that future updates from mainstream would be painless.
- Reduces STB_VORBIS_MAX_CHANNELS from 16 to 6 (objections?)
- Adds several missing libm function overrides,
- SDL_mixer now requires SDL >= 2.0.9 because of SDL_exp()
- Fixes slow loads and leaks in start_decoder:
  nothings/stb#1174
- Fixes submap array out-of-bounds indexing bug:
  nothings/stb#1312
- Replace signed overflow clamps with unsigned overflow:
  nothings/stb#1168
- Replaces alloca() usage with setup_malloc() (from libxmp.)
- Fixes '-Wmaybe-uninitialized' warnings in get_seek_page_info:
  nothings/stb#1172
- A minor UBSan fix and suppression:
  nothings/stb#1168
- Fixes signature of dummy realloc() for STB_VORBIS_NO_CRT:
  nothings/stb#1198
- Renames BUFFER_SIZE macro to STB_BUFFER_SIZE:
  nothings/stb#1078
- Pulls in sample-accurate offset patch of Vitaly Novichkov:
  (stb_vorbis_get_playback_sample_offset, because it's used
  in OGG_Tell and OGG_GetSome):
  nothings/stb#1294
  nothings/stb#1295
- Fixes a few warnings here and there in some environments.
- Replaces two dummy '(void) 0' with 'do {} while(0)'
@sezero sezero requested a review from slouken May 21, 2022 12:40
@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

One noticeable difference is this changes stb_vorbis_get_sample_offset
back to original plain int, whereas @Wohlstand's version has it as an
Sint64. Also, stb_vorbis_get_playback_sample_offset and its internal
friends are now plain int (just like they are in his PR in mainstream)
instead of Sint64 again.

I don't know the reason Vitaly's Sint64 change: If there is a compelling
reason for it, I can do that change with proper documentation + SDL_mixer
ifdefs.

@Wohlstand
Copy link
Contributor

Wohlstand commented May 21, 2022

That was my new feature, it's VERY important as original call adds the bug at looping, it requires a sample accurate seek/tell.

I changed to Sint64 to match the 64bit off_t and value at original vorbis.

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

it's VERY important as original call adds the bug at looping,

I don't know what that means??

I changed to Sint64 to match the 64bit off_t and value at original vorbis.

Well, stb_vorbis mainstream doesn't follow that.

@slouken what do you think?

@slouken
Copy link
Collaborator

slouken commented May 21, 2022

I can't imagine having a music file that's larger than 2 billion samples. int should be fine for the range that we're working with. @Wohlstand, do you have a repro for the original bug you were fixing with that change?

Other than that outstanding question, I'm fine with merging this so our stb_vorbis.h is in line with SDL_sound.

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

Other than that outstanding question, I'm fine with merging this so our stb_vorbis.h is in line with SDL_sound.

OK, waiting for @Wohlstand's answer before merging.

@Wohlstand
Copy link
Contributor

Wohlstand commented May 21, 2022 via email

@Wohlstand
Copy link
Contributor

Wohlstand commented May 21, 2022

do you have a repro for the original bug you were fixing with that change?

One of my users sent me some OGG files that got a click on loop passing because of that bug I explained (that caused me to implement a new call for the sample-accurate seek).

@slouken
Copy link
Collaborator

slouken commented May 21, 2022

Do you still have the looping Ogg file for testing?
How large are the files of concert recordings from your friend?

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

One of my users sent me some OGG files that got a click on loop passing because of that bug I explained (that caused me to implement a new call).

Is that bug related to the Sint64 change, or is it only about implementing the new stb_vorbis_get_playback_sample_offset?

@Wohlstand
Copy link
Contributor

Do you still have the looping Ogg file for testing?
How large are the files of concert recordings from your friend?

  • Looped files:
    Lemme send some once I get my computer

  • concert recordings:
    I still have some at my archive (if I didn't removed them), lemme check them out...

@Wohlstand
Copy link
Contributor

One of my users sent me some OGG files that got a click on loop passing because of that bug I explained (that caused me to implement a new call).

Is that bug related to the Sint64 change, or is it only about implementing the new stb_vorbis_get_playback_sample_offset?

There are different and independent changes that fixing different cases:

  • Sint64 fixes playing of 3+ hours 198 KHz files
  • stb_vorbis_get_playback_sample_offset() fixed the tell accuracy requires for looping music.

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

One of my users sent me some OGG files that got a click on loop passing because of that bug I explained (that caused me to implement a new call).

Is that bug related to the Sint64 change, or is it only about implementing the new stb_vorbis_get_playback_sample_offset?

There are different and independent changes that fixing different cases:

* Sint64 fixes playing of 3+ hours 198 KHz files

* stb_vorbis_get_playback_sample_offset() fixed the tell accuracy requires for looping music.

I wasn't opposing to the new stb_vorbis_get_playback_sample_offset at all:
I included it already as you can see. (And as I understand it, the tell inaccuracy
was with using the original stb_vorbis_get_sample_offset, correct?)

As for Sint64 return: @slouken, what do you say?

@slouken
Copy link
Collaborator

slouken commented May 21, 2022

I'm not opposed to updating that to 64-bit. I think maybe make a PR with use case against upstream and see if the original author thinks it's a good idea?

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

Yes. Merging this now.

Vitaly: Can you create a bug entry here and get the idea of Sean Barrett about Sint64?

@sezero sezero merged commit 1be13e4 into libsdl-org:main May 21, 2022
@sezero sezero deleted the stbv-1 branch May 21, 2022 17:28
@Wohlstand
Copy link
Contributor

For the loop bug:
This file was sent to me by a user who reported the problem: Shipwreck_Shore_Underwater.ogg.zip
without my accurate "tell" call, it will always click on loop edge.

Vitaly: Can you create a bug entry here and get the idea of Sean Barrett about Sint64?

Sure, I still seek at my archive for mentioned concert recordings...

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

Ok, here are the ones changed from Sint64 to what it originally was,
for future reference:

  • stb_vorbis_get_sample_offset, stb_vorbis_get_playback_sample_offset:
    they return int instead of Sint64.

  • stb_vorbis_stream_length_in_samples: returns unsigned int instead
    of Sint64.

  • stb_vorbis_seek: takes unsigned int as sample_number parameter
    instead of Sint64.

  • struct stb_vorbis :: total_samples: uint instead of Sint64.

  • struct stb_vorbis :: current_playback_loc (from Vitaly's patch):
    int32 instead of Sint64. (Do note however, Vitaly didn't change
    the current_loc member and kept it as uint32.)

@Wohlstand
Copy link
Contributor

P.S. the huge problem is using C++ single-line comments at original stb_vorbis, which caused incompatibility with C90 compilers, that is why I replaced all comments with /* */.

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

P.S. the huge problem is using C++ single-line comments at original stb_vorbis, which caused incompatibility with C90 compilers, that is why I replaced all comments with /* */.

Maybe, but that causes difficulties when we want to apply mainstream changes.
Avoid using -ansi or similar.

@Wohlstand
Copy link
Contributor

P.P.S. About the length of these concert footages, they have 10 hours each.

@Wohlstand
Copy link
Contributor

Wohlstand commented May 21, 2022

Maybe, but that causes difficulties when we want to apply mainstream changes.

BTW, speaking in general, if use single-line comments in Pure-C, it's fine in the scope of project code, but speaking about public headers, they must follow the C90 standard to guarantee any project will be able to use it. Anyway, for this case, I'll post the issue on the mainstream side. (made nothings/stb#1328)

@Wohlstand
Copy link
Contributor

About the Sint64, I made the issue: nothings/stb#1329

@sezero
Copy link
Contributor Author

sezero commented May 21, 2022

About the Sint64, I made the issue: nothings/stb#1329

OK, I'll watching that ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants