87 Commits

Author SHA1 Message Date
Daniel Collin
f1f3f62345 Check if inline is already defined 2014-09-14 10:28:31 +02:00
Erik Faye-Lund
739fc21cfd player: return interpolated value as double
The heavy lifting was already done in double precision, so just
return the full value to the user without truncating to float.
2012-10-19 17:10:57 +02:00
Erik Faye-Lund
7c43db7385 Merge branch 'work/io-callback' 2012-09-11 19:55:46 +02:00
Erik Faye-Lund
8f94efbc62 player: add suport for Win64 builds
To make sure it works, add support to the example while we're at
it. Also fix compilation warnings.
2012-03-01 14:27:55 +01:00
Erik Faye-Lund
217bed5131 player: implement io-callbacks for loading tracks
Some demos use datafiles; let's allow these to easily work by
adding a callback-interface for loading tracks.

The callbacks are only present in player-mode, because tracks
aren't loaded from disk in client-mode.
2011-04-25 23:48:49 +02:00
Erik Faye-Lund
b3825514b2 player: amiga-support
Proper Amiga-suport is supplied by using the AmiTCP stack when
USE_AMITCP is enabled. Add explicit OpenLibrary/CloseLibrary
calls, for those people who don't link against auto-opening
libs ala VBCC's auto.s.

Add a typedef for uint32_t (needed for network communication)
for Motorola 68k platforms.

Also add a SAS/C support for the 'inline' keyword.

Thanks to Aske Simon Christensen for help with the SAS/C support.
2011-03-21 22:13:30 +01:00
Erik Faye-Lund
dbe3cc7dcf player: reorganize compatibility checks
The current layout of the compatibility checks makes is a bit
tricky to reuse parts of a platforms quirk-arounds when adding
compiler-support.

Reorganize into three sections:
- inline support
- CRT features
- socket-stack
2011-03-17 00:54:32 +01:00
Erik Faye-Lund
4c8769c630 player: close socket on socket-error
While we're at it, make sure we always delete all the data before
trying to re-request. This we won't get out of sync on socket-error
at that particular location.
2011-01-26 22:23:45 +01:00
Erik Faye-Lund
94a88abab0 player: merge sync_connect and purge_and_rerequest
This function has only one call-site, and is trivial. Inline it
into it's caller instead.
2011-01-26 22:23:32 +01:00
Erik Faye-Lund
0c8cc404ff player: be consistent, return -1 on error
Previously some functions returned 1 and some returned -1 on
error. There were also two internal functions that returned 0
on error and 1 on 0 on success. Fix this, and make sure we
always return -1 on error and 0 on success.
2011-01-26 22:22:04 +01:00
Erik Faye-Lund
55f2508283 player: add some comments
The code is horribly undocumented as is. Try to improve this by
adding some comments in the most important parts.
2011-01-26 21:41:28 +01:00
Erik Faye-Lund
5efe69d845 player: catch malloc-failures
There were a couple of places where malloc-failures (out-of-memory,
really) weren't caught. This isn't a big deal on modern operating
systems, but is worth dealing with on low-end platforms.

Failures to add/delete keys should count as socket-errors, because
they cause the editor and client to become out of sync.
2011-01-26 21:20:38 +01:00
Erik Faye-Lund
8a49fd3c05 player: fix potential buffer overflow
Previously, sync_track_path could either overflow it's 'temp'
buffer by one byte, or (even worse) end up not zero-terminating
it.

Correct the code by explicitly zero-terminating the result of
strncpy, and reducing the lenght-parameter to strncat.
2011-01-25 23:39:06 +01:00
Erik Faye-Lund
1044584639 player: fixup some constness 2011-01-25 23:39:06 +01:00
Erik Faye-Lund
c570d58962 player: remove useless include 2011-01-25 23:39:05 +01:00
Erik Faye-Lund
9324a1180b player: unify loader-code a bit
Unify the interface for load_track_data() and request_track_data(),
as they essentially perform the same task, but for different
compile-time configurations.
2011-01-25 23:39:05 +01:00
Erik Faye-Lund
687df0876b protocol: make client-index implicit
This will enable us to unify the code in a later commit.

This is a protocol-breaking change, and means that matching editor
and player must be used.
2011-01-25 23:36:15 +01:00
Erik Faye-Lund
5bfd04f55b player: pass callback directly to sync_update
sync_update is the only code-path that can end up calling any of the
callbacks, so there's no need to store it in the device.

This is a breaking change, so all users needs to update their code
accordingly.
2011-01-25 04:10:39 +01:00
Erik Faye-Lund
e43c33a1ab player: add API to save tracks
This is a bit more convenient than having to remember to do
"remote export" from the editor all the time.
2010-12-27 20:32:55 +01:00
Erik Faye-Lund
7ea7cabd96 posix: include unistd.h for close
The close prototype is defined in unistd.h, according to
POSIX. Include it.
2010-09-13 00:03:11 +02:00
Erik Faye-Lund
ca123707b3 add NEED_STRDUP for C89 support
C89 does not define strdup(), so provide an implementation for
the systems that doesn't implement it. Enable it by adding
"CPPFLAG += -DNEED_STRDUP" to config.mak.
2010-09-04 14:32:26 +02:00
Erik Faye-Lund
ab243a6c1a add basic gcc support 2010-09-04 14:32:26 +02:00
Erik Faye-Lund
6aafb683cc select: send in socket + 1 2010-09-04 14:32:25 +02:00
Erik Faye-Lund
1d4e1bb795 gcc: fix compilation warnings 2010-09-04 14:32:24 +02:00
Erik Faye-Lund
d3dd8a78f0 player: fix typo hanle->handle 2010-08-31 19:33:52 +02:00
Erik Faye-Lund
6693c3f8f4 protocol: use network byte-order
The network code assumes that the client and server have the
same endianess. This isn't always the case, so let's change
it all to network byte-order.

This change is not backwards compatible, so old clients and
new editors (or vica verca) will not work together any more.
2010-08-29 23:43:10 +02:00
Erik Faye-Lund
9d4aea28fb player: do not assume 32-bit ints
The player can be compiled for other architectures than Windows,
where ints aren't 32-bit. 64-bit Mac/Linux are not-that-unlikely
examples.
2010-08-29 23:43:09 +02:00
Erik Faye-Lund
878d1534f1 player: increase warning level and fix a warning 2010-08-29 23:40:47 +02:00
Erik Faye-Lund
fbc958adeb player: make port unsigned short
TCP ports are unsigned 16 bit integer, so let's use a more natural
type for it.
2010-08-27 21:20:10 +02:00
Erik Faye-Lund
c600e2abbe player: wrap up send and recv
This leads to much simpler error checking.

Add casts so the inlined code can be called from the editor's
C++ code.
2010-08-25 23:38:24 +02:00
Erik Faye-Lund
078e344b24 player: require explicit connection-call
This makes it possible to change the host and port used
for connections between player and editor without
recompiling the library.
2010-08-25 23:21:51 +02:00
Erik Faye-Lund
bd9408fa85 player: make sync_update report error 2010-08-25 22:59:35 +02:00
Erik Faye-Lund
5c359b035d player: completely remove sync_update when not needed 2010-08-25 22:59:35 +02:00
Erik Faye-Lund
2a44eff473 player: pass row as integer to sync_update
There's no point in passing the row as a double to sync_update, which
only cares about the integer-part.
2010-08-25 22:59:34 +02:00
Erik Faye-Lund
e640a4ab6a editor: explicit C-declaration around sync/data.h
Trade an explicit extern "C" declaration for three
defined(__cplusplus) wrapped ones.
2010-07-06 23:03:37 +02:00
Erik Faye-Lund
12595c74f5 player: return const-pointer from sync_get_track()
There's no uses of sync_get_track() that can't do without a pointer to
a const object any more. Making sync_track const helps us 64k-proof
the code.
2010-07-06 21:09:37 +02:00
Erik Faye-Lund
a56dc45690 interpolation: smooth means smoothstep, not cosine
Smoothstep[1] is a nice smooth alternative to cosine that
doesn't require special math functons, and should thus be
suitable on more platforms. The cosine-curve and the
smoothstep are very similar, and this change introduces
only a very small error (always less than 1 per cent)
compared to the old result.

Change the smooth curve definition to match this.

[1]: http://en.wikipedia.org/wiki/Smoothstep
2010-03-25 00:13:02 +01:00
Erik Faye-Lund
9f6eeb0b5d editor: portability fixes
This is mostly just nit-pickery that allows most of the editor to
be compiled with MinGW. The nasty COM-stuff for the XML-loader in
syncdocument.cpp is still not compiling, though. There's also some
missing resource definitions, it seems.
2010-03-24 21:41:35 +01:00
Erik Faye-Lund
7934871684 client: make sync_track_path static 2010-03-24 17:58:20 +01:00
Erik Faye-Lund
88e9a4bf48 client: do not purge data when reconnetion failed 2010-03-20 16:18:21 +01:00
Erik Faye-Lund
0a362b42a4 client: allow reconnection to gather all data
A stray semicolon blocked purge_and_rerequest() to always
terminate after the first track, and report failure.
2010-03-20 16:15:12 +01:00
Erik Faye-Lund
fc9e038f3f client: unbreak SET_KEY and DELETE_KEY
In 70bcea3, I introduced incorrect handling of SET_KEY
and DELETE_KEY, leading to error on each connection.

Fix this by negating the condition.
2010-03-20 15:59:24 +01:00
Erik Faye-Lund
874c5b8ede rename LICENSE.TXT to COPYING 2010-03-19 17:41:37 +01:00
Erik Faye-Lund
6761a167e8 free device structure 2010-03-19 17:41:36 +01:00
Erik Faye-Lund
466c845593 define closesocket for posix systems 2010-03-19 17:41:36 +01:00
Erik Faye-Lund
14244a2d0d add sync_destroy_device() 2010-03-19 17:41:36 +01:00
Erik Faye-Lund
70bcea33ab clean up network code 2010-03-19 17:41:35 +01:00
Erik Faye-Lund
8c9f5db445 reconnect on disconnection 2010-03-19 17:41:35 +01:00
Erik Faye-Lund
decf843c04 player/client: port to C
Make sure that all code included in the player and client is
pure C. This helps on portability.
2010-03-19 17:41:34 +01:00
Erik Faye-Lund
7d62c05504 Whops, some code was left broken after some encapsulation-fixes. 2010-03-19 17:41:32 +01:00