Commit Graph

102 Commits

Author SHA1 Message Date
Rafael Kitover d7ff2afb80 add mac release builder script
Add `tools/osx/builder`, a POSIX sh script to build all dependant
libraries as static, targetted to OS X 10.7, and build the project with
them (also targetted to OS X 10.7.)

ffmpeg currently does not link, as recording functionality is currently
non-functional anyway, this will be fixed later.

MISC:

- set WORKING_DIRECTORY and ERROR_QUIET for all git commands, for the
  cases when the build directory is not under the git checkout

- #include <cerrno> in ConfigManager.cpp as it uses errno

- change `build*` in `.gitignore` to `build/*` so that files starting
  with "build" are not affected
2017-10-12 01:32:18 -07:00
Rafael Kitover e9a86c541d fix deadlock in SoundSDL::deinit() #139 #130
On SoundSDL destructor and `reset()`, there was a deadlock with Linux
pthreads, it happened sometimes that the reader thread would call
`SDL_SemWait(data_available)` while `deinit()` would destroy the
semaphore and the `SDL_SemWait()` would end up waiting forever on a null
semaphore.

Change the sequencing of deinit() to prevent this from happening, set
`initialized = false` at the beginning of the sequence to prevent
subsequent entries into the reader callback, and add an SDL_Delay(100)
between the final `SDL_SemPost()` and `SDL_UnlockMutex()`s and the
`SDL_DestroySemaphore()` and `SDL_DestroyMutex()`s to allow a running
reader to complete with a valid mutex and semaphores before they are
destroyed and the thread is joined.

Resetting the sound system also sometimes triggers a memory corruption
bug, but that's a separate issue.
2017-09-21 15:39:30 -07:00
Rafael Kitover e0f79f32a5 remove version.h in ConfigManager and AutoBuild.h
ConfigManager does not use any version info, but is part of libvbamcore,
so removing the `#include` makes rebuilds after git changes much much
faster.

Remove the AutoBuild.h includes from ConfigManager.cpp and SDL.cpp (the
SDL port) because the information in that file does not seem to be used
and it also includes version.h, forcing those files to rebuild
unnecessarily.
2017-08-27 13:32:13 -07:00
Rafael Kitover 2179215a8b fix rebuilds on git changes
Use cmake to generate the version.h from version.h.in which is a cleaned
up version of the old version.h with the git short sha into the build
directory, and include the version.h from there.

Continue to use the GetGitRevisionDescription plugin to make the cmake
configuration state depend on the current sha of HEAD, but throw away
the results (for the time being.)

This makes rebuilds after git changes such as a commit only recompile a
couple of files instead of the whole tree.
2017-08-27 13:20:17 -07:00
Rafael Kitover 1a8f2f9886 "no throttle" fixes/cleanups
`throttle == 0` is supposed to emulate at full speed and drop audio
data, this is different from `throttle == 100` which is emulation
throttled at normal speed, the default setting.

Fix the recently rewritten SoundSDL sound driver to make `throttle == 0`
work, and make some minor changes to clean up the relevant code in the
XAudio2 sound driver.
2017-08-27 07:21:27 -07:00
Rafael Kitover 1e3a85a34b cleanup SoundSDL #139 #130 #97 #67 #65 #46 #47
Rewrite SoundSDL (the SDL sound driver).

Clean up the code and eliminate all deadlocks/hangs/crashes (hopefully.)

Many of the deadlocks were caused by initialize() not de-initializing
properly and causing the audio callback thread to deadlock, fix this.

Also use better logic for the semaphore controls, which will also
hopefully increase audio quality.

Use better logic for the throttle control, with throttle == 0 being the
same as throttle == 100 and implement setThrottle().

Also increase the buffer size to 300ms and the number of samples to
2048, for hopefully less choppiness in audio overall.
2017-08-17 02:44:40 -07:00
Rafael Kitover f88faef1b2 SoundSDL: write silence when paused #139
The SDL API documentation for the audio callback specifies that the
callback *MUST* write to the buffer and not just return:

https://wiki.libsdl.org/SDL_AudioSpec#Remarks

write silence to the buffer (value taken from the AudioSpec returned
from OpenAudioDevice) when the emulator is paused.
2017-08-16 15:20:05 -07:00
Rafael Kitover 5e9c9093c0 SoundSDL: lock conditional code cleanup
Move the `bool lock` condition used to wait for sound data to be
exhausted from two places in the code into the `bool should_wait()`
member function.
2017-08-16 03:20:10 -07:00
Rafael Kitover 03a20820cb temp fix for deadlocks in SoundSDL on pause #139
SDL_PauseAudioDevice seems to be causing thread deadlocks in combination
with Wx threads (e.g. on menu activation or modal dialogs.)

Remove these calls from SoundSDL::pause() and SoundSDL::resume() for the
time being so that deadlocks do not happen.

This effectively allows pausing, but on resume there is no sound for 2-3
seconds until the buffer is filled again.

This will need a proper fix at a later time.
2017-08-15 15:30:27 -07:00
Rafael Kitover c99a58faee fix a memory leak due to wrong syntax
In C++ arrays are deleted with `delete[]` and not `delete`.
2017-08-03 16:29:37 -07:00
Zach Bacon e95c083466 this should fix the windows build 2017-05-11 22:13:11 -04:00
Zach Bacon dd34951d2f Windows doesn't have sterror_r 2017-05-11 21:34:18 -04:00
Rafael Kitover 01dd7cef45 fix portability issue with strerror_r()
If _GNU_SOURCE is defined on linux, then strerror_r() is an alternate,
non-POSIX version.

Undefine _GNU_SOURCE when including <string.h> in ConfigManager.cpp to
get the POSIX version of strerror_r(), and initialize the error string
buffer to "unknown error" so that the code does not crash whichever
version of the library function is being used, or strerror_r() fails for
some reason.
2017-04-27 13:16:16 -07:00
Rafael Kitover 02a1e38e6c SDL: improve error msg for unwritable config #105
Following up on 1ba2eef which fixed a crash caused by trying to write to
a NULL FILE* due to fopen() failure: write the error message to stderr
instead of trace.log and show the OS error using strerror_r().
2017-04-27 08:46:03 -07:00
Rafael Kitover cab6f0f026 delete memory in common/array.h on destruction
Hopefully fix a memory leak in common/array.h by adding a destructor
that does a delete on the underlying array if it was previously
allocated.
2017-04-27 08:35:25 -07:00
Jeremy Newton 1ba2eefebe Fix glibc crash: add log message on fopen failure
glibc's fclose implementation does not do a NULL check and will crash on "fclose(NULL)". A bunch of Fedora users have been sending in traces for this issue. I've added a log on failure case, likely if the user does not have permission to write to the file.
2017-04-17 12:04:07 -07:00
Rafael Kitover d1b4abc85a fix sound in SDL port/ConfigManager
Since we are using sound frequency to control game speed, not quality,
change ConfigManager to default to a frequency of 44100 instead of
22050.

This also fixes trace.log files showing up with "unknown sound quality"
warnings.
2017-03-06 04:26:33 -08:00
Rafael Kitover 7b85964eb6 full throttle support + snd driver improvements
Support throttle in all sound drivers: SDL, openal, dsound and xaudio.

Link OpenAL at compile time instead of runtime.

Minor improvement on 891f17d6, which added throttle support to SoundSDL
and made it actually work more often and crash less: check that throttle
is non-zero before scaling the frequency.

For dsound, add the CTRLFREQUENCY capability to buffers and call
SetFrequency on the secondary buffer in setThrottle().

For OpenAL, set AL_PITCH on the source to throttle / 100.0 in
setThrottle() and remove all dynamic library loading stuff.

For xaudio, 441e6c9e allows throttle to work, and is also necessary for
these changes to dsound and openal.
2017-03-05 08:43:25 -08:00
Mystro256 891f17d62f Fixes for SDL throttle
- Throttle should be set on init
- SDL auido device was not being correctly closed on throttle change
2017-03-05 05:32:34 -08:00
Zach Bacon f145d6ab0e Still working on libretro stuff, working on cheatsenabled compile issue now. 2017-02-25 00:55:29 -05:00
Zach Bacon a8a48919db Fixes build on the libretro side by wrapping an ifndef statement around rederedframes 2017-02-25 00:38:06 -05:00
n-a-c-h 931fda459a Fix case where buffer is filled to capacity and becoming empty. There always needs to be an extra entry as a separator between the write and the read. 2017-02-22 03:39:57 +02:00
n-a-c-h 3e0f5d89ba Rewrite of ringbuffer, and updated copyright file for Debian. 2017-02-22 02:03:21 +02:00
Mystro256 cc2fabbf0a Use fread return values for apply patch error checking
Silences gcc warnings
2017-02-12 04:26:21 -08:00
Su Yong 4e096c127c Some fixes for MSVC. 2017-02-11 10:57:35 +08:00
Rafael Kitover 34e408ccb7 fix Debian 8 Jessie and Ubuntu 14 Trusty compat
Fix some porting issues to make everything work on Debian 8 "Jessie"
and Ubuntu 14 "Trusty":

- set cmake minimum version to 2.8.12, this is the Ubuntu 14 version

- combine C and C++ flags and add all of them using
  ADD_COMPILE_OPTIONS() without using generator expressions, which is a
  cmake 3.2 or so feature

- add -fpermissive to force some non-const type casts to compile on
  older versions of gcc

- add -std=c++11 for gcc to enable support on older versions of gcc

- check that the compiler supports -fstack-protector-strong before
  adding it, older versions of gcc do not

- fix the debian section of ./installdeps to include libpng-dev instead
  of libpng16-dev and add gettext for msginit etc.

- fix compat checks in src/common/ffmpeg.cpp and src/wx/cmdevents.cpp to
  check for libavcodec >= 56 instead of > 56, the Debian Jessie version
  is exactly version 56 . With the one exception of
  AV_CODEC_FLAG_GLOBAL_HEADER which is defined in later versions.
2017-01-29 10:14:34 -08:00
Rafael Kitover 281e73eee0 correct fix for ddef88f0
Check that codec is not a NULL pointer right after it's first set, this
is done later after configuring the ctx anyway.
2016-12-31 04:07:12 -08:00
Mystro256 ddef88f0c5 Possible null dereference 2016-12-30 11:42:56 -05:00
Zach Bacon ea220b4822 one file was missed from the last PR, looking at you Mystro256 :P 2016-12-10 04:08:03 -05:00
Rafael Kitover 01200fadbd Mac OS X 10.7 (Lion) build and runtime support
Make a custom cstdint.h header file that includes <tr1/cstdint> if
<cstdint> is not available, because the clang 3.x used on Lion does not
have it. Change all references to <cstdint> to use it instead.

Add missing OpenGL header for older OS X in sdl/SDL.cpp .

When calling HiDPI methods, use respondsToSelector: to check if the
methods are available first.

Fix the bundling/linking script to support multiple copies of the same
dylib with different versions. Necessary to include both the Lion system
libpng and the brew libpng. Including the system libpng is necessary
because it is removed in later versions of OS X.
2016-11-03 10:49:13 -07:00
EoD 6612d34ddf Fix SDL.h includes
See comment in FindSDL2.cmake:
 Note that the header path has changed from SDL2/SDL.h to just SDL.h
 This needed to change because "proper" SDL convention
 is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
 reasons because not all systems place things in SDL2/ (see FreeBSD).
2016-07-31 00:11:21 +02:00
EoD 3cf6c2ca7b Fixes memgzio with zlib > 1.2.3.8 2016-07-30 23:55:00 +02:00
Dorian Wouters 31391e090c
Kill common/Types.h, replace its old typedefs w/ standard types
Fix includes in files using standard int types
Fix wxWidgets UI includes
Silence some unused variable warnings in GBA-arm.cpp macros
2016-07-29 11:07:11 +02:00
Dorian Wouters 37f0e75c45
Fix standard int types, prefix gb {C,H,N,Z}_FLAG with GB_ 2016-07-29 09:45:38 +02:00
MrJman006 9dd9fd5d26 Fixing U16 and U8 Parameter Types
It seems like most of the types are moving to fixed width integer types and this file wasn't fully converted.
2016-07-21 22:01:49 -04:00
Zach Bacon 59577d666f
Finished updating common, next up gb folder 2016-07-08 21:39:29 -04:00
Zach Bacon fa33b8eea4
More changes, things may break until it's done so be advised, git is a moving target 2016-07-08 20:57:21 -04:00
Zach Bacon 32a6d7b494
we are 2016, let's get with the times 2016-07-08 20:46:04 -04:00
Zach Bacon 5bf44d19be
updated standards to webkit standard 2016-07-08 19:59:29 -04:00
Markus Kitsinger (SwooshyCueb) 502de18456 Nonfunctional (but compiler-friendly) kludge for video recording with ffmpeg 3.0 2016-04-26 21:50:57 -05:00
Markus Kitsinger (SwooshyCueb) a3a07d2f56 Some encoders don't like s16 2016-04-26 21:45:52 -05:00
Markus Kitsinger (SwooshyCueb) 029a5fc14b Kludge for audio recording with ffmpeg 3.0 2016-04-26 21:41:30 -05:00
Markus Kitsinger (SwooshyCueb) 3f3c3859c1 Add some defines for ffmpeg 3.0 compatibility 2016-04-26 21:32:38 -05:00
Zach Bacon 7ed85a8c6f Finish committing the remaining gtk3 patch (wip) 2015-12-12 23:23:34 -05:00
Zach Bacon c8343267fc <wip> Migration to SDL2 made possible by galtgendo, gtk changes to follow. 2015-11-18 21:34:38 -05:00
Rafael Kitover 8b8f2f7a14 fix configuration directory on OSX
Write vbam.ini to ~/Library/Application Support/vbam on OSX.

Do not create ~/.vbam on OSX in common/ConfigManager.cpp .

Make get_config_path and wxvbamApp::GetConfigurationPath return
directories with a writable parent in reverse search order when no
writable directories in the current search order are available since the
directory is created in OnInit.

This prefers to create the user-local directory and write the vbam.ini
there.
2015-11-09 02:11:18 -05:00
n-a-c-h 3b850ac295 Rewrote our array class. 2015-06-16 01:59:41 +03:00
skidau 1dc399839c Added a "Check for updates" option to the Help menu. 2015-06-05 13:48:37 +00:00
skidau 6d964a523f FreeBSD build fix 2015-05-22 01:04:13 +00:00
skidau b02d948dc1 Made running the game at normal speed the default set-up. Patch by sergio-br2. 2015-05-19 23:17:57 +00:00