libxmp / xmp-cli

Command-line mod player using libxmp
GNU General Public License v2.0
75 stars 22 forks source link

replacing posix libc dependencies #57

Closed sezero closed 1 year ago

sezero commented 1 year ago

This is rather a draft for now: main goal is to replace unnecessary posix libc dependencies with ansi or os-specific code.

The first attempt, i.e. the first patch here replaces posix file io in wav, aiff, and raw output modules with ansi stdio: please review carefully.

The next attempt would be removing / conditionalizing sys/types.h and unistd.h includes, replacing posix usleep / gettimeofday in the amiga code, etc.

AliceLR commented 1 year ago

Everything looks good so far. I don't see any issue with the lseekfseek replacement but I've also never really used lseek.

sezero commented 1 year ago

This should be ready for full review, and merge if OK.

@raziel-: Can you please review especially https://github.com/libxmp/xmp-cli/pull/57/commits/3b936f92bd0a7e9b2366efbe24d2162b2c7c1d74 for amigaos4 correctness?

sezero commented 1 year ago

Also noticed that: although we technically support dos, we do not have proper dos paths in read_config.c. We should probably look for xmp.cfg and modules.cfg (.conf being renamed to .cfg: for dos file naming) under C:\ or \ (i.e. root of current drive.)

raziel- commented 1 year ago

@sezero

I can't check before the end of next week, sorry

sezero commented 1 year ago

I can't check before the end of next week, sorry

@raziel-: No rush. And thanks!

sezero commented 1 year ago

Tentatively approving, assuming someone else can review that before merge.

I run-tested the amiga part using a linux-hosted version of Aros. AmigaOS4 is the part where I'm worried about (that one has multiple api changes compared to the classic versions), so I can really wait until @raziel- gets back to us.

raziel- commented 1 year ago

@sezero

Sorry :-(

Would it help to merge and fix potential AmigaOS4 issue in-tree later? Every other platform destination seems to be fine, don't they.

sezero commented 1 year ago

Would it help to merge and fix potential AmigaOS4 issue in-tree later? Every other platform destination seems to be fine, don't they.

OK then, merging. I'd really appreciate it if you can find time to review / test the os4 code, though. Thanks!

raziel- commented 1 year ago

Will do asap

raziel- commented 1 year ago

@sezero

I'm sorry, but...do i miss ""configure"...i can' t seem to find it anywhere

sezero commented 1 year ago

You should generate it by running the included autogen.sh script. Or, I can generate a ready-to-be-configured package for you: shall I?

raziel- commented 1 year ago

That would be nice, thank you

Automake is something that doesn't run well in my SDK

sezero commented 1 year ago

OK, here you go: xmp, and also its dependency libxmp from git, ready to be configured. xmp-4.2.0.tar.gz libxmp-4.5.1.tar.gz

raziel- commented 1 year ago

Thank you

The lib builds fine, but now i'm struggling as to where to install it in the toolchain.

xmp tells me it can't find the lib, i have it placed into local/newlib/lib, but it doesn't seem to get picked up

sorry for being a noob

sezero commented 1 year ago

I suggest that you place the generated libxmp.pc file under local/newlib/lib/pkgconfig and if necessary set the environment variable PKG_CONFIG_PATH=local/newlib/lib/pkgconfig (I hope I copied your path correctly.) Make sure that the contents of libxmp.pc reflects the reality, i.e. the includedir and libdir entries are correct.

Ask again if you hit any issues.

raziel- commented 1 year ago

Thank you very much again.

I can see at least two errors that I made from your answer. I'll rectify them and report back tomorrow.

sezero commented 1 year ago

Thanks.

To make your life easier, here is an alternative, simple makefile solution for xmp client: os4-makefile.zip

  1. cd into xmp-4.2.0/src directory
  2. put xmp.h from libxmp in there
  3. put the newly built libxmp.a in there
  4. put this Makefile.amigaos4 in there, edit it if necessary.
  5. and run: make -f Makefile.amigaos4
  6. finally: test the newly built xmp binary.
raziel- commented 1 year ago

@sezero

Thank you again...i don't get that pkg stuff to work

with your makefile i can compile a working binary, test .xm file plays fine, so your changes work :-)

Are you interested in compilation warnings? Should i send it to you personally or can i post them here?

Also the copyright notice is outdated (see below)

Extended Module Player 4.2.0 Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr Using Amiga AHI audio Mixer set to 44100 Hz, 16bit, cubic spline interpolated stereo Press 'h' for help

Loading /girl_from_mars.xm (1 of 1) Module name : Girl From Mars Module type : MilkyTracker XM 1.04 Module length: 27 patterns Patterns : 30 Instruments : 7 Samples : 7 Channels : 14 [ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 ] Duration : 1min52s Speed[17] BPM[20] Pos[1A/1A] Pat[1B/1D] Row[3F/3F] Chn[0E/0E] 0:01:49.9

sezero commented 1 year ago

with your makefile i can compile a working binary, test .xm file plays fine, so your changes work :-)

Great! Thanks for testing.

Are you interested in compilation warnings? Should i send it to you personally or can i post them here?

If you have patches, I'd like to have them yes: Here or personally both work for me.

Also the copyright notice is outdated (see below)

Extended Module Player 4.2.0 Copyright (C) 1996-2016

Will update before release.

raziel- commented 1 year ago

I also finally fixed my toolchain...working now and still producing a running binary :-)

i unfortunately wouldn't know where to start fixing those warnings, i just collect them :-)

Here they are, if you can give me any pointers as to where and what to change to make them go away, i`m listening and trying them locally aswell

gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o commands.o -c commands.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o delay.o -c delay.c delay.c: In function 'amiga_atexit': delay.c:71:17: warning: 'DeleteIORequest' is deprecated [-Wdeprecated-declarations] 71 DeleteIORequest((struct IORequest *) timerio); ^~~~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:148:35: note: declared here 148 DEPRECATED void APICALL (DeleteIORequest)(struct ExecIFace Self, struct IORequest * ioRequest); ^~~~~~~ delay.c:72:17: warning: 'DeleteMsgPort' is deprecated [-Wdeprecated-declarations] 72 DeleteMsgPort(timerport); ^~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:98:35: note: declared here 98 DEPRECATED void APICALL (DeleteMsgPort)(struct ExecIFace Self, struct MsgPort * port); ^~~~~ delay.c: In function 'amiga_inittimer': delay.c:79:9: warning: 'CreateMsgPort' is deprecated [-Wdeprecated-declarations] 79 timerport = CreateMsgPort(); ^~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:96:47: note: declared here 96 DEPRECATED struct MsgPort APICALL (CreateMsgPort)(struct ExecIFace *Self); ^~~~~ delay.c:82:35: warning: 'CreateIORequest' is deprecated [-Wdeprecated-declarations] 82 timerio = (struct TimeRequest *) CreateIORequest(timerport, sizeof(struct TimeRequest)); ^~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:147:49: note: declared here 147 DEPRECATED struct IORequest APICALL (CreateIORequest)(struct ExecIFace Self, const struct MsgPort ioReplyPort, ULONG size); ^~~~~~~ delay.c:90:50: warning: passing argument 2 of 'IExec->GetInterface' from incompatible pointer type [-Wincompatible-pointer-types] 90 ITimer = (struct TimerIFace *) GetInterface(TimerBase, "main", 1, NULL); ^~~~~~
struct Device *

delay.c:90:50: note: expected 'struct Library ' but argument is of type 'struct Device ' delay.c:97:33: warning: 'DeleteIORequest' is deprecated [-Wdeprecated-declarations] 97 | DeleteIORequest((struct IORequest )timerio); | ^~~~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:148:35: note: declared here 148 | DEPRECATED void APICALL (DeleteIORequest)(struct ExecIFace Self, struct IORequest ioRequest); | ^~~~~~~ delay.c:98:33: warning: 'DeleteMsgPort' is deprecated [-Wdeprecated-declarations] 98 | DeleteMsgPort(timerport); | ^~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:98:35: note: declared here 98 | DEPRECATED void APICALL (DeleteMsgPort)(struct ExecIFace Self, struct MsgPort port); | ^~~~~ delay.c:101:25: warning: 'DeleteMsgPort' is deprecated [-Wdeprecated-declarations] 101 | DeleteMsgPort(timerport); | ^~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from delay.c:38: /SDK/include/include_h/interfaces/exec.h:98:35: note: declared here 98 | DEPRECATED void APICALL (DeleteMsgPort)(struct ExecIFace Self, struct MsgPort port); | ^~~~~ gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o getopt_long.o -c getopt_long.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o info.o -c info.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o main.o -c main.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o options.o -c options.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o read_config.o -c read_config.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o sound.o -c sound.c gcc -O2 -Wall -I. -DSOUND_AHI -DWORDS_BIGENDIAN -o sound_ahi.o -c sound_ahi.c sound_ahi.c: In function 'closeLibs': sound_ahi.c:51:9: warning: 'DeleteIORequest' is deprecated [-Wdeprecated-declarations] 51 | DeleteIORequest((struct IORequest ) AHIReq[0]); | ^~~~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:148:35: note: declared here 148 | DEPRECATED void APICALL (DeleteIORequest)(struct ExecIFace Self, struct IORequest ioRequest); | ^~~~~~~ sound_ahi.c:55:9: warning: 'DeleteMsgPort' is deprecated [-Wdeprecated-declarations] 55 | DeleteMsgPort(AHImp); | ^~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:98:35: note: declared here 98 | DEPRECATED void APICALL (DeleteMsgPort)(struct ExecIFace Self, struct MsgPort port); | ^~~~~ sound_ahi.c: In function 'init': sound_ahi.c:69:5: warning: 'CreateMsgPort' is deprecated [-Wdeprecated-declarations] 69 | AHImp = CreateMsgPort(); | ^~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:96:47: note: declared here 96 | DEPRECATED struct MsgPort APICALL (CreateMsgPort)(struct ExecIFace Self); | ^~~~~ sound_ahi.c:71:29: warning: 'CreateIORequest' is deprecated [-Wdeprecated-declarations] 71 | AHIReq[0] = (struct AHIRequest )CreateIORequest(AHImp, sizeof(struct AHIRequest)); | ^~~~~~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:147:49: note: declared here 147 | DEPRECATED struct IORequest APICALL (CreateIORequest)(struct ExecIFace Self, const struct MsgPort ioReplyPort, ULONG size); | ^~~~~~~ sound_ahi.c:74:13: warning: 'AllocVec' is deprecated [-Wdeprecated-declarations] 74 | AHIReq[1] = AllocVec(sizeof(struct AHIRequest), SHAREDMEMFLAG); | ^~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:47:35: note: declared here 47 | DEPRECATED APTR APICALL (AllocVec)(struct ExecIFace Self, ULONG byteSize, ULONG attributes); | ^~~~ sound_ahi.c:89:21: warning: 'AllocVec' is deprecated [-Wdeprecated-declarations] 89 | AHIBuf[0] = AllocVec(BUFFERSIZE, SHAREDMEMFLAG | MEMF_CLEAR); | ^~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:47:35: note: declared here 47 | DEPRECATED APTR APICALL (AllocVec)(struct ExecIFace Self, ULONG byteSize, ULONG attributes); | ^~~~ sound_ahi.c:91:25: warning: 'AllocVec' is deprecated [-Wdeprecated-declarations] 91 | AHIBuf[1] = AllocVec(BUFFERSIZE, SHAREDMEMFLAG | MEMF_CLEAR); | ^~ In file included from /SDK/include/include_h/proto/exec.h:30, from sound_ahi.c:21: /SDK/include/include_h/interfaces/exec.h:47:35: note: declared here 47 | DEPRECATED APTR APICALL (AllocVec)(struct ExecIFace *Self, ULONG byteSize, ULONG attributes); | ^~~~

sezero commented 1 year ago

i unfortunately wouldn't know where to start fixing those warnings, i just collect them :-)

Well, if you don't have patches ready and if the result works fine then let's keep things as they are.

Thanks!

raziel- commented 1 year ago

Gladly and thank you very much for all the help again