$Id: TODO 3726 2011-12-02 21:34:15Z ensonic $

= general =
* rename public API in BuzzMachineLoader.h
  BuzzMachine -> BMLMachine
  BuzzMachineProperty -> BMLMachineProperty
  ...

* charsets, should we convert all strings to UTF-8 in here already?

= more tools =
== bmldump_src_skel ==
dump a source skelleton for rewriting a machine

== debugging ==
write a gdb script that enhances backtraces like:https://github.com/shinh/maloader/blob/master/gdb_maloader.py
https://github.com/shinh/maloader/blob/master/gdb_maloader.py

= testing =
modify tests/testmachine.sh
eventually improve scrolling:
  http://www.litotes.demon.co.uk/example_scripts/tableScroll.html
result should go to a given directory (use date-time when not provided)

= unemulated used libs =

grep -ho "Win32 LoadLibrary failed to load.*" testmachine/*.txt* | sort | uniq -c | sort -g

      3 wine/module: Win32 LoadLibrary failed to load: COMCTL32.dll
     28 wine/module: Win32 LoadLibrary failed to load: comdlg32.dll
      1 wine/module: Win32 LoadLibrary failed to load: DSOUND.dll
   2588 wine/module: Win32 LoadLibrary failed to load: GDI32.dll
  81803 wine/module: Win32 LoadLibrary failed to load: KERNEL32.dll
    147 wine/module: Win32 LoadLibrary failed to load: MSVCRT.dll
    254 wine/module: Win32 LoadLibrary failed to load: ole32.dll
     30 wine/module: Win32 LoadLibrary failed to load: OLEAUT32.dll
     20 wine/module: Win32 LoadLibrary failed to load: oledlg.dll
     18 wine/module: Win32 LoadLibrary failed to load: OLEPRO32.DLL
      2 wine/module: Win32 LoadLibrary failed to load: SHELL32.dll
      1 wine/module: Win32 LoadLibrary failed to load: SHLWAPI.dll
   4775 wine/module: Win32 LoadLibrary failed to load: USER32.dll
     44 wine/module: Win32 LoadLibrary failed to load: WINMM.dll
     63 wine/module: Win32 LoadLibrary failed to load: WINSPOOL.DRV

* ole stuff could be machines using auxbus
* DSOUND.dll
  Geonik's Dx Input.dll
* SHLWAPI.dll
  BuzzInAMovie.dll
* SHELL32.dll
  Rout VST Plugin Loader.dll
  mimo's miXo.dll

= missing window function entries =

unk_??0_Lockit@std@@QAE@XZ
unk_??1_Lockit@std@@QAE@XZ

unk_joyGetDevCapsA
unk_joyGetNumDevs
unk_joyGetPos

unk_waveInOpen

unk_midiOutGetNumDevs
unk_midiOutOpen

MFC42.DLL (check MFC42.DEF file)
  unk_MFC42.DLL:823 : ??2@YAPAXI@Z
  unk_MFC42.DLL:1176 : ?AfxGetThreadState@@YGPAV_AFX_THREAD_STATE@@XZ
  unk_MFC42.DLL:1243 : ?AfxSetModuleState@@YGPAVAFX_MODULE_STATE@@PAV1@@Z

user32.dll
  unk_CreateDialogParamA : http://msdn.microsoft.com/en-us/library/ms645445(VS.85).aspx
  unk_GetWindowTextA : http://msdn.microsoft.com/en-us/library/ms633520(VS.85).aspx
  unk_LoadIconA : http://msdn.microsoft.com/en-us/library/ms648072.aspx
  unk_SendMessageA : http://msdn.microsoft.com/en-us/library/ms644950.aspx
  unk_SetWindowPos : http://msdn.microsoft.com/en-us/library/ms633545.aspx
  unk_VkKeyScanA : http://msdn.microsoft.com/en-us/library/ms646329.aspx

Microsoft DirectShow 9.0
  unk_DMOEnum : http://msdn.microsoft.com/en-us/library/ms783373(VS.85).aspx

Kernel32.dll
  unk_FlsAlloc : http://msdn.microsoft.com/en-us/library/ms682664(VS.85).aspx
  unk_FlsFree
  unk_FlsSetValue
  unk_ResumeThread : http://msdn.microsoft.com/en-us/library/ms685086(VS.85).aspx

Gdi32.lib
  unk_GetStockObject : http://msdn.microsoft.com/en-us/library/ms533223.aspx

= list missing machine for songs =
for file in *.bmx; do ~/buzztard/bin/bt-cmd 2>/dev/null --command=info --input-file=$file | grep "  bml-"; done | sort | uniq -c | sort -n

= list songs that have no missing machines =
for file in *.bmx; do ~/buzztard/bin/bt-cmd 2>/dev/null --command=info --input-file=$file | grep -q "  bml-" || echo $file; done

= missing features =
* getting access to Patterns/Sequence

= getting better diagnostics on failure
http://www.eptacom.net/pubblicazioni/pub_eng/except.html
http://www.eptacom.net/pubblicazioni/pub_eng/assert.html
http://www.codeproject.com/KB/threads/StackWalker.aspx

== tools ==
use mingw-binutils to dump win32 binaries
/usr/local/i386-mingw32/bin/objdump -t MSVCRT.DLL
/usr/i586-mingw32msvc/bin/objdump ...


= x86_64 bit support for native plugins =
- we need to build a launcher+libbml with -m32
- in libbml's #ifdef HAVE_X86 section, we need to have alternative implementations
  for 64bit
  - the 32bit build would use the one we have there
  - the 64bit build would need to do IPC
  - the 32bit launcher would need to receive IPC and dispatch
- the front-env tests (bmltest_*) would remain as they are
- will we launch 1 helper per using process or 1 herlper per machine
  - 1 helper per process: 1 shm key
- creating the BuzzMachineHandle / BuzzMachine will create proxy structures with
  the ids for the launcher (index values to arrays on the launcher side)
- for the IPC we need to marshall (function, parameters, data)
  - we can just enumerate the API calls
  - the parameters will be hardcoded for each function

= test single plugins =
G_SLICE=always-malloc G_DEBUG=gc-friendly GLIBCPP_FORCE_NEW=1 GLIBCXX_FORCE_NEW=1 valgrind --tool=memcheck --leak-check=full --leak-resolution=high --trace-children=yes --num-callers=20 -v ../src/.libs/bmltest_info ~/buzztard/lib/Gear-real/Effects/Static\ Duafilt\ II.dll
../src/.libs/bmltest_info ~/buzztard/lib/Gear-real/Effects/Static\ Duafilt\ II.dll


= what windows dll to copy and which not =
== don't (we need to emulate) ==
kernel32.dll ntdll.dll
== seems safe ==
msvcp50.dll  msvcp60.dll MFC42.DLL MSVCRT.DLL


= buzz emulation =
== mdk machine ==
* we need to do ::AddInput() and ::DeleteInput to get input-mixing working
 (even though we would always just give one input).
* before we call WorkXXX() we need to call
  MachineInterfaceEx::Input(float *psamples, int numsamples, float amp)

other-sources/buzz-sources/__BUZZ1PLAYER__NOT_FOR_PUBLIC!/CMachine.cpp
* stereo output MIF_DOES_INPUT_MIXING machines will get stereo input
* bm->callbacks->mdkHelper->numChannels
== auxbus machines ==
* currently all auxbus using machines fail

= machine tests =
== hoshi ==
2008.02.22 : Of 532 machine(s) 448 worked and 84 failed to load.
2008.02.23 : Of 533 machine(s) 457 worked and 76 failed to load.
2008.11.19 : Of 533 machine(s) 458 worked and 75 failed to load.
2009.01.29 : Of 533 machine(s) 451 worked, 9 did not processed data and 73 failed to load.
2009.11.02 : Of 537 machine(s) 454 worked, 10 did not processed data and 73 failed to load
2010.02.03 : Of 517 machine(s) 433 worked, 9 did not processed data and 75 failed to load
2011.01.09 : Of 517 machine(s) 444 worked, 6 did not processed data and 67 failed to load.

== sterni/mautz ==
2008.10.14 : Of 853 machine(s) 759 worked and 94 failed to load.
2008.11.20 : Of 853 machine(s) 758 worked and 95 failed to load.
2011.01.11 : Of 857 machine(s) 760 worked, 7 did not processed data and 90 failed to load.

In gst-buzztard/src/bml/plugin.c I maintain a black list.

There seems to be several machines failing when calling GetInfo()
tail -n1 *.fail | grep -B1 "GetInfo"

== Generators ==
Geonik's PrimiFun.dll
  if we don't have MFC42.dll
    Called unk_MFC42.DLL:1176
    Called unk_MFC42.DLL:1243
    Called unk_MFC42.DLL:823
      - its library:ordinal
  if we have MFC42.DLL
    Called unk_GetConsoleMode
m4wii.dll
  if we don't have MFC42.dll
    Called unk_MFC42.DLL:1176
    Called unk_MFC42.DLL:1243
  if we have MFC42.DLL
    Called unk__CxxThrowException
    http://www.winehq.org/pipermail/wine-patches/2002-October/003917.html
    http://source.winehq.org/source/dlls/msvcrt/cppexcept.c
    http://source.winehq.org/source/dlls/msvcrt/cppexcept.h
    If we wrap this localy, the unk__ is gone (empty impl), but it segfaults.
    Maybe we need a full impl.
mimo's MidiGen.dll
  win32.c: TLS_COUNT is not enough
Jeskola Bass 2.dll
  buzzmachinecallbackspre12.cpp:105:BuzzMachineCallbacksPre12::MidiOut (dev=1,data=136987296)
Jeskola Tracker.dll
  if we don't have MFC42.dll
    Called unk_MFC42.DLL:823
  if we have MFC42.DLL
    Called unk__CxxThrowException
Ruff SPECCY II.dll
HD Percussive_FM.dll
  crash after ?

Aeguelles TB4004
  noisy distortion

== Effects ==
Arguelles TruePan
Jeskola XDelay (causes distortions)
Jeskola Raverb (causes distortions)
  BuzzMachineCallbacks::GetEnvSize (wave=-96185375,env=0)
  buzzmachinecallbackspre12.cpp:112:BuzzMachineCallbacksPre12::GetOscillatorTable (waveform=-128840458)
Jeskola Stereo Reverb (sometimes silences the whole song, NAN?)
Effects/Jeskola Wave Shaper.dll
  if we don't have MFC42.DLL
    Called unk_MFC42.DLL:1176
    Called unk_MFC42.DLL:1243
  if we have MFC42.DLL
    Entering DllMain(DLL_PROCESS_ATTACH) for /home/ensonic/buzztard/lib/win32/mfc42.dll
    Segmentation fault
Sonic Verb (seems to work now)
  buzzmachinecallbacks.cpp:199:BuzzMachineCallbacks::GetEnvPoint (wave=-1,env=-1,i=-1076278224,&x,&y,&flags)
  buzzmachinecallbacks.cpp:276:BuzzMachineCallbacks::SetSequenceData (row=-1217504548,ppat=B7A5B3C4)
Dolby Prologic Echo
  Param Direction : val [1 ... d=4096/n=0 ... 255], the def-val for an enum, can't be outside the range

Ynzn's Remote Compressor.dll
Ynzn's Remote Gate.dll
  both crash (problem with name? - no we have others with "'")
PSI Corp's LFO Filter.dll
Repeater.dll
RnZnAnFnCnR VST Effect Adapter.dll
Rnznanf Vst Effect Adapter.dll
Rout VST Plugin Loader.dll
Shaman Chorus.dll
WhiteNoise AuxReturn.dll
  crash

Zu*.dll
  #0  0xb7fce4e2 in exp_EH_prolog () from /home/ensonic/buzztard/lib/libbml.so.0
  #1  0xb7c9e38a in ?? ()
  #2  0x1001a898 in ?? ()
  #3  0xb7fafad4 in bmlw_open (bm_file_name=0xbfffeffe "/home/ensonic/buzztard/lib/Gear-real/Effects/Zu Parametric EQ.dll") at bml.c:207
  #4  0x080490cb in bmlw_test_info (libpath=0xbfffeffe "/home/ensonic/buzztard/lib/Gear-real/Effects/Zu Parametric EQ.dll") at bmltest_info.h:34
  #5  0x0804ab15 in main (argc=2, argv=0xbfffed64) at bmltest_info.c:96

