We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4896

Summary: timidity / music_timidity updates with new public functions
Product: SDL_mixer Reporter: Ozkan Sezer <sezeroz>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: admin
Version: unspecified   
Hardware: All   
OS: All   
Attachments: timidity updates patch
timidity updates patch

Description Ozkan Sezer 2019-12-13 19:12:40 UTC
Created attachment 4095 [details]
timidity updates patch

Please review the attached timidity / music_timidity patch.
It does the following:

* Timidity_init(): Library doesn't care about common timidity.cfg
system locations any more, callers are responsible for it. It now
takes a config_path argument as the full path of timidity.cfg.
If the config file argument contains a parent directory, that will
be added to timidity search path, provided that it is not the root
directory.  The config file is supposed to contain any other dirs
that needs to be added to the search path: therefore no need adding
several predefined directory paths to the search paths either: they
are now removed.

* configury: New --with-timidity-cfg=FILE option to set the default
config file of the library.

* music.c, New public apis Mix_SetTimidityCfg and Mix_GetTimidityCfg
Allows the mixer library user to set his own timidity config file.

* music_timidity.c, TIMIDITY_Open(): Calls Timidity_Init() with a
config file parameter now.  The config file parameter priority is
like the following:

- TIMIDITY_CFG environment var: highest priority. Try nothing else.
 (Should I try the other options in case of failure, instead?)

- Mix_GetTimidityCfg() result: second priority (set by user of the
  mixer library using Mix_SetTimidityCfg.) Nothing else is tried.
  (Should I try the other options in case of failure, instead?)

- If the above two are absent, a few OS-specific predefined config
  file paths are tried.  If that fails, NULL is sent to Timidity_init
  so that the library's default config file is tried.

Comments? OK to apply?
Comment 1 Ozkan Sezer 2019-12-13 22:55:04 UTC
(In reply to Ozkan Sezer from comment #0)
> If the config file argument contains a parent directory, that will
> be added to timidity search path, provided that it is not the root
> directory.  [...]

That is_rootdir() stuff might prove problematic across different OSs
so I think I'll be taking it out if the patch gets otherwise approved.
Comment 2 Ozkan Sezer 2019-12-14 04:35:55 UTC
Created attachment 4096 [details]
timidity updates patch

Patch without the is_rootdir checks.
Comment 3 Ozkan Sezer 2019-12-17 08:02:34 UTC
Vitaly: You said that this works. Have you merged this?
If yes, I will merge it here.
Comment 4 Vitaly Novichkov 2019-12-17 11:58:19 UTC
Yes, I have merged this with MixerX fork yesterday, so, it should be fine:
https://github.com/WohlSoft/SDL-Mixer-X/commit/27a32d4fbcf7af7cc4bca7ecd82a214475cf9715

I also did merge with AudioCodecs where I have replaced my crap with mainstream Mixer's copy: https://github.com/WohlSoft/AudioCodecs/commit/50a41484e183eff1d446504f50eeb1d7eb900a32

A bit later I'll make an issue and the patch that introduced a hot switch of config without restarting of a library. It is dependent on this patch.
Comment 5 Ozkan Sezer 2019-12-17 12:11:27 UTC
Patch merged: https://hg.libsdl.org/SDL_mixer/rev/89f446aae9b5