1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-12 15:45:13 +00:00
Commit graph

1050 commits

Author SHA1 Message Date
Samuel Gomes d48df65282 Delete copy and move constructors and assignments operators for BufferMap class 2023-01-09 06:02:29 +05:30
Samuel Gomes 8c0590acee Add workaround for _SNDCOPY for sound created using _SNDOPEN(buffer, "memory") 2023-01-09 05:33:39 +05:30
Samuel Gomes 2e176ebf98 Set AUDIO_DEBUG to 0 2023-01-08 00:34:58 +05:30
Samuel Gomes 2957c41061 Workaround for _SNDCOPY for _SNDNEW sounds. Another one to follow for _SNDOPEN(buffer, "memory") 2023-01-08 00:14:59 +05:30
Samuel Gomes 5a893b8ffc Update comments and some beautification 2023-01-06 20:32:03 +05:30
Samuel Gomes eacee1f609 Add PushMonoSampleFrames 2023-01-06 12:21:17 +05:30
Samuel Gomes f7690aea17 Update comments 2023-01-02 16:24:08 +05:30
Samuel Gomes ecfe4fb1be Format code 2023-01-01 23:17:56 +05:30
Samuel Gomes 6c72deafc1 Improve _SNDOPEN test and supress printfs in Hively replayer code 2023-01-01 23:14:05 +05:30
Samuel Gomes e4273c0a68 Add Amiga AHX & HVL decoder 2023-01-01 22:56:02 +05:30
Samuel Gomes 061bf6af3d Rename _NEWSOUND to _SNDNEW to align with _SND* APIs 2022-12-31 12:00:38 +05:30
Samuel Gomes da9d9e871c Fix for template argument deduction/substitution failed 2022-12-31 05:18:22 +05:30
Samuel Gomes 4c80f6bcea Implement feature request #28 2022-12-31 01:49:23 +05:30
Samuel Gomes eebb56afd5 Implement load sound from memory #232 2022-12-22 20:42:27 +05:30
Samuel Gomes a72f80258f Address #186 2022-12-22 15:11:20 +05:30
Samuel Gomes bc65076feb Reduce mutex locks by using 2 vectors for _SNDRAW 2022-12-21 11:47:41 +05:30
Samuel Gomes b187102668
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-12-21 04:22:23 +05:30
github-actions[bot] 55b168db6c Automatic update of ./internal/source 2022-12-20 13:31:46 +00:00
github-actions[bot] 0c28341eb9 Automatic update of ./internal/source 2022-12-19 15:39:35 +00:00
Samuel Gomes 1357f53041 Add NO_PITCH, NO_SPATIALIZATION flags for raw ma_sound 2022-12-16 12:28:22 +05:30
Samuel Gomes bcc7105641 Avoid getting queue size inside loop 2022-12-16 03:50:32 +05:30
Samuel Gomes bd82b24ac7 Improve SOUND timing - #167 2022-12-15 10:47:27 +05:30
Samuel Gomes df9b739e23 Address #166 - _SNDRAW using miniaudio data source 2022-12-15 09:16:42 +05:30
Samuel Gomes cf16cb0c00 Replace custom queue code with C++ STL queue 2022-12-13 09:12:52 +05:30
Samuel Gomes 7f2ab7e83a
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-12-04 01:32:39 +05:30
github-actions[bot] 6aea9b3a65 Automatic update of ./internal/source 2022-12-03 17:00:49 +00:00
Matthew Kilgore 7ac2eefcb8 Fix slowdown of _ScreenX and _ScreenY
The commands _ScreenX and _ScreenY got significantly slower due to the
need to wait for the GLUT thread to wake up and execute the glutGet()
command for them. We've already seen a few programs (including the IDE)
where this behavior completely grinds the program to a halt, so we
definitely can't keep it.

The simple solution here is to not call glutGet() on every _ScreenX/Y
command. Instead every time the idle/timer function runs we get the
current values for the relevant glutGet() variables and store them.
libqb_glut_get() then checks if the value being read is one of the ones
we read in the idle/timer functionand if so just returns the last read
value. By doing it this way the commands no longer has to wait on the
GLUT thread for the result.
2022-11-30 17:33:17 -05:00
Matthew Kilgore f7fabda198 Fix random seg faults on exit
Fairly straightfowrad, programs were randomly seg faulting on exit. This
was happening due to GLUT registering a cleanup function via atexit(),
which then gets called when exit() is called.

The issue happens when exit() is called on a thread other than the GLUT
thread, which leads to the exit() call then attempting to cleanup GLUT
while the other thread is still using it, which randomly leads to seg
faults.

Fixing this is slightly annoying. We cannot stop the GLUT thread, as
the basic GLUT API (which is used on Mac OS) simply does not offer a way
to exit the glutMainLoop() call. Thus the simplest solution is to simply
make sure we call exit() on the GLUT thread, which we can fairly easily
due via the message queue.

That being the case, a new libqb_exit() API was added, which simply
regsiters the GLUT exit message and then waits for the program to end.
The atexit() handler then runs on the GLUT thread and everything works
out fine.

In the future we probably should redo the exit logic a bit so that all
the threads are actually stopped/joined to ensure the exit process is
consistent, however this is good enough for now. Also, there's plenty of
error states which call exit() which I did not address.
2022-11-29 20:04:54 -05:00
Matthew Kilgore 6c288ecb6f Don't compile libqb.cpp as Objective-C on Mac OS
With the recent changes to libqb.cpp to pull out some of the GLUT logic,
the only actual Objective-C in libqb.cpp was pulled out. That being the
case, it's no longer necessary to have libqb.mm for compiling libqb.cpp,
so we're removing it to simplify the compliation logic a bit.
2022-11-29 20:04:54 -05:00
Matthew Kilgore 72193e34e5 Add GLUT command queue, processed on GLUT thread
This fixes all the code so that all the calls to glut functions
happen on the same thread that is running GLUT.

We achieve this by creating a queue of GLUT commands to execute.
Commands can be added to the queue anywhere in the code, and then the
queue is processed on the GLUT thread via it's idle func or timer func.
The command is run and if necessary the result is provided in the
message queue object. Each object contains a completion which can be
waited on to block until the GLUT thread has processed the command.

Fixes: #66
2022-11-29 20:04:54 -05:00
Matthew Kilgore d678be717c Move GLUT initialization logic into separate .cpp file 2022-11-29 20:04:53 -05:00
Samuel Gomes 0e19bcc03c
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-28 08:29:33 +05:30
github-actions[bot] e12b13eebf Automatic update of ./internal/source 2022-11-27 21:41:39 +00:00
Samuel Gomes d13bf35822
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-28 01:05:07 +05:30
github-actions[bot] 6547bed5e0 Automatic update of ./internal/source 2022-11-27 19:32:17 +00:00
Samuel Gomes 93bf793c19
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-27 10:58:57 +05:30
github-actions[bot] dbd18aeae1 Automatic update of ./internal/source 2022-11-27 04:55:10 +00:00
Matt Kilgore 8185234792
Merge branch 'main' into fix-glut-init-logic 2022-11-26 22:42:46 -05:00
github-actions[bot] 715bfd3682 Automatic update of ./internal/source 2022-11-27 03:36:50 +00:00
github-actions[bot] a8cc180307 Automatic update of ./internal/source 2022-11-27 02:24:41 +00:00
github-actions[bot] 3cba0d4265 Automatic update of ./internal/source 2022-11-27 00:30:08 +00:00
Roland Heyder ec6e648007 Simplify #include
Solving #119
2022-11-27 00:11:04 +01:00
github-actions[bot] 28dc80b551 Automatic update of ./internal/source 2022-11-26 09:13:26 +00:00
Matthew Kilgore d2aa572a94 Fix GLUT initialization logic
The current GLUT initialization logic is flawed because it allows the
QB64 code portion of the program to start on a separate thread at the
same time that the GLUT code is starting. This results in a race where
some commands won't work for a brief period at the beginning of the
program (with "won't work" being very inconsistent, some return invalid
values, some have a chance at seg faulting).

The same issue also leads to us adding many `while (!window_exists)`
checks in an attempt to solve this race for some of the commands.
Unfortunately this solution is very inconsistently applied leading to
some deadlock situations, and really it's a silly solution when this
race is entirely our creation anyway.

To fix this, the logic was changed such that we perform all of the GLUT
initialization besides calling `glutMainLoop()` before we ever start the
thread that runs the actual QB64 code. By doing it this way we ensure
that the GLUT initialization has already taken place before the code
runs and thus the race is gone.

Things get a bit more interesting with $SCREENHIDE, because that simply
delays the execution of the GLUT initialization indefinitely until
_ScreenShow is done. This was previously very buggy since some commands
rely on FreeGLUT being up and will simply hang the entire program if
run. Other commands have logic to catch this and simply return zero.

The above issue is solved with the `NEEDS_GLUT()` and `OPTIONAL_GLUT()`
macros. Both of them simply check if the GLUT initialization has taken
place and exit the current function if it has not. The difference
between the two is that `NEEDS_GLUT()` throws an 'illegal function call'
error while `OPTIONAL_GLUT()` simply exits with no error. The choice of
behavior of each function was based upon its previous behavior - if it
checked `screen_hide` and exited with no error previously, then
`OPTIONAL_GLUT()` was used. If it deadlocked or similar then
`NEEDS_GLUT()` was used (so instead of deadlocking, it now produces an
error). In this way, programs can now never get stuck due to the use of
`$SCREENHIDE` and all the commands have consistent behavior that can be
relied upon.

Fixes: #234
2022-11-26 01:33:32 -05:00
Samuel Gomes b29eaed459
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-26 07:59:30 +05:30
Samuel Gomes fe65031433
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-25 11:24:02 +05:30
SteveMcNeill ca7d6ee289 fix comment
Whoops!  Not enough coffee, I guess.  ;)
2022-11-25 00:52:29 -05:00
SteveMcNeill 0d76a7bbed Simplify multi-line logic to single line. 2022-11-24 15:00:54 -05:00
SteveMcNeill 6d055e5df1 Bugfix to _FONT
Fonts 9, 15, and 17 can *only* be used in SCREEN 0.  Attempting to use them in graphic screens results in a seg fault and an instant program crash on Windows.  This is definitely the most undesirable of behaviors for a program, and can easily be caught and dealt with just by tossing a simple "Illegal Function Call" error for the issue.
2022-11-24 08:34:31 -05:00
github-actions[bot] 9d3ca747d0 Automatic update of ./internal/source 2022-11-24 12:38:54 +00:00