BBC BASIC for Windows
« Wavemix32.dll issue »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:56pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Wavemix32.dll issue  (Read 239 times)
JFS
New Member
Image


member is offline

Avatar




PM


Posts: 11
xx Wavemix32.dll issue
« Thread started on: Sep 5th, 2014, 09:01am »

For ages now I have been using the wavemix32.dll to play simultaneous sounds and by and large, it works very well. However, it has one very frustrating issue: when I call WaveMixCloseSession it fails, returning an Invalid handle error. The consequence is that any subsequent attempt to reload and intiate the dll from my programme in the IDE fails. Thus, BB4W must be closed and restarted in order to run the programme a second time. After spending an age trying for find a fault in my code, I came to realise that there is no such fault - infact the simplest possible programme - just initiating then closing a session still returns the same error. A quick google revealed that users of Lbasic and Vbasic also suffer the same issue.

If my programme is compiled, the executable does not suffer the same issue and, as I mention, if I close the IDE, then my programme can be successfully re-run. Clearly therefore, BB4W is very kindly clearing up the mess when it closes.

Since I am currently doing some development work on my code, the issue has become a Right Royal Pain - hence my question - has anyone found a workaround for this, or is there anything I can add to my code which will perform the same "flushing" operation on this dll as BB4W performs when it is closed?

Many thanks and best wishes,

Howard

User IP Logged

Best Wishes,

Howard
rtr2
Guest
xx Re: Wavemix32.dll issue
« Reply #1 on: Sep 5th, 2014, 11:03am »

on Sep 5th, 2014, 09:01am, JFS wrote:
is there anything I can add to my code which will perform the same "flushing" operation on this dll as BB4W performs when it is closed?

It's not BB4W which is doing the cleanup, it's Windows. When your compiled EXE (or BB4W) closes, the process is terminated; Windows does a pretty thorough job of cleaning up when a process is terminated (it must, since even the address space into which the DLL was loaded is torn down).

I presume you are carefully following the recommended sequence of operations for closing down the DLL:
  1. Close all open channels using WaveMixCloseChannel()
  2. Free the memory for the waves using WaveMixFreeWave()
  3. End the session with WaveMixCloseSession()
  4. Free the DLL with FreeLibrary()
If you are doing that, but it still refuses to unload cleanly, it would suggest that the DLL itself is at fault.

With hindsight, BB4W should perhaps have worked the way LBB does. When you run a program from the LBB IDE it actually starts a separate process, so not only is the program guaranteed to close down cleanly, it's also impossible for a rogue BASIC program to crash the IDE (which as we all know is not unusual in BB4W).

Some while ago I had it in mind to initiate a user-led project to develop a replacement IDE for BB4W, based on the LBB IDE (itself written in BBC BASIC). This would provide an opportunity for new features to be added without my involvement. But the GUILIB fiasco made it very obvious that there is no appetite in the BB4W community for such a project (let's face it, there isn't really any BB4W community left at all).
User IP Logged

JFS
New Member
Image


member is offline

Avatar




PM


Posts: 11
xx Re: Wavemix32.dll issue
« Reply #2 on: Sep 5th, 2014, 2:24pm »

on Sep 5th, 2014, 11:03am, g4bau wrote:
I presume you are carefully following the recommended sequence of operations for closing down the DLL:
  1. Close all open channels using WaveMixCloseChannel()
  2. Free the memory for the waves using WaveMixFreeWave()
  3. End the session with WaveMixCloseSession()
  4. Free the DLL with FreeLibrary()
If you are doing that, but it still refuses to unload cleanly, it would suggest that the DLL itself is at fault.
...

... the GUILIB fiasco made it very obvious that there is no appetite in the BB4W community for such a project (let's face it, there isn't really any BB4W community left at all).


I am indeed doing all of that and spent an age checking a rechecking it all. Indded, as I say, the issue exists even, in code with only WaveMixInit() and WaveMixCloseSession() in it so I assume the dll is the issue - though I have only found reference to the issue in the context of LB VB (and in my case, BB4W) and I don't know if there is any significance in that.

Hindsight would be useful before the event! But I infer from your comment that closing the IDE is the only way to kill the process - so the answer to my question - is there a way of "cleaning up" from with my code - would appear to be "no"?

Incidentally, the Liberty Basic discussion did not seem to conclude with a positive solution to the issue.

I think you might be being a bit hard saying that there is no "community" - rather perhaps that there are too many people like me who use BB4W despite our incompetence to tackle anything as difficult as an IDE!!!

Many thanks,

Howard
User IP Logged

Best Wishes,

Howard
Edja
Developer

member is offline

Avatar




PM


Posts: 60
xx Re: Wavemix32.dll issue
« Reply #3 on: Sep 5th, 2014, 2:45pm »

Quote:
I think you might be being a bit hard saying that there is no "community" - rather perhaps that there are too many people like me who use BB4W despite our incompetence to tackle anything as difficult as an IDE!!!
Very true.The community would benefit if a few more "advanced users" would participate and share. I agree the vast majority are hobbyist/amateurs (including me). But that is not the same as saying there is no community at all.
User IP Logged

rtr2
Guest
xx Re: Wavemix32.dll issue
« Reply #4 on: Sep 5th, 2014, 3:02pm »

on Sep 5th, 2014, 2:24pm, JFS wrote:
I have only found reference to the issue in the context of LB VB (and in my case, BB4W) and I don't know if there is any significance in that.

The 'significance', I think, is that you are only likely to encounter the issue in languages which have an IDE from which you can 'run' a program, which on exit then 'returns' to the IDE without terminating the process.

In the majority of modern programming languages the only way to run a program is first to compile it (either to a stand-alone executable or to an intermediate code which is executed by a run-time engine) and then to run it as a separate process. In such a language you won't normally spot that a DLL is failing to unload properly, because Windows will clean up after it.

So only in languages like BB4W and LB4, in which you are likely to try to run a program two or more times without terminating the process in between, will the problem show up.

Quote:
is there a way of "cleaning up" from with my code - would appear to be "no"?

There is no way you can perform the cleanup that Windows performs when a process terminates, without actually terminating the process!

Quote:
Incidentally, the Liberty Basic discussion did not seem to conclude with a positive solution to the issue.

The 'solution', in the case of Liberty BASIC, is to use LBB rather than LB4! As I explained, although the LBB IDE behaves superficially exactly like the LB4 (and BB4W) IDEs do, behind the scenes it works entirely differently. When you run a BASIC program it is executed in a separate process - even when you are debugging it! Some rather complicated inter-process communication takes place to allow trace-highlighting, profiling and live variable-listing to happen!

There's just one way you can do something similar in BB4W - run your program from the profiler (Utilities... Profiler).

Quote:
I think you might be being a bit hard saying that there is no "community" - rather perhaps that there are too many people like me who use BB4W despite our incompetence to tackle anything as difficult as an IDE!!!

Part of the problem is indeed the lack of people with the necessary skills, the necessary time, the necessary inclination and a willingness to work cooperatively with others. Such people will always be a small proportion of the total user base, so in order for there to be enough of them you need a 'critical mass' of users. BB4W doesn't have that.

Also, the relatively few users who do (or did) fall into that category have, sadly, been disproportionately represented amongst those who have 'moved on' from BBC BASIC to other languages.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls