![]() |
#1 |
Forum King
|
Winamp Encoders
I learned a lot from trial-and-error and debug inspection about how Winamp interacts with the encoder plugins (enc_*.dll) while working on an Opus encoder plugin. The same problems I had interacting with WASABI objects I also had with AudioCoder objects, in that they also are MSVC classes. I thought it would be simple enough to define a new encoder object handler like I did for WASABI classes, which was close, but not all the way.
[SMALL_RANT] When Winamp is done with an encoder object it deletes it. Now for the layman this might not seem nefarious on it's own but to a third-party library developer it's actually not good (some would even say "bad form".) Deleting a class you did not create is dangerous, even when deleting a class from a DLL compiled with the same compiler, regardless if the destructor method is virtual. And since encoder plugins can (theoretically) be developed by any third-party developer, then submitted and reviewed there's no guarantee that it will be compiled with the same compiler. [/SMALL_RANT] Long story short, I had to add a special handling mechanism into my handling of my Winamp AudioCoder class, specifically, adding a method to the fake v-table pointer for handling calls to the AudioCoder's destructor. Notes for new encoder developers (these are just some notes from off the top of my head that I had to discover the hard way):
I am attaching my encoder handler source unit for Borland compilers. Enjoy. |
![]() |
![]() |
![]() |
#2 |
Ben Allison
Former Winamp Developer Join Date: Jan 2005
Location: Brooklyn, NY
Posts: 1,057
|
Definitely good info.
Don't get me started on the encoder API. It's a leftover from NSV development that got re-used. It's been haphazardly developed and in general, the "push data in, get data out" model leaves a lot to be desired. It was built for real-time encoding of streamable codecs like Layer 3 or ADTS AAC. The MP4/AAC encoder plugin just sends back dummy data, secretly writes to a temp file, and then swaps it over at the end (during FinishAudio). It's horribly inefficient (since winamp.exe is also writing to disk), but I don't think disk I/O is the bottleneck. The delete issue is a known issue. No guarantee that they were allocated from the same memory heap as winamp.exe I should just add a DeleteAudio and call it a day. Of course it'd only be compatible with newer versions of Winamp. I've been contemplating a new interface to replace it, but have been so busy with the Android app and the Cloud project for that. |
![]() |
![]() |
![]() |
#3 | |||
Forum King
|
Just now saw your reply.
Quote:
Quote:
Quote:
If it were me, I'd just interface it the same way the other plugins do it, a single exported function that returns a plugin struct that contains interface functions. But as I said before the current model is not THAT bad as I have been able to manage it, could just use a bit of tweaking. |
|||
![]() |
![]() |
![]() |
|
Tags |
audiocoder, encoder |
Thread Tools | Search this Thread |
Display Modes | |
|
|