[vorbis-dev] new DLL additions in core libs

Chris Wolf cwolf at starclass.com
Wed Sep 12 17:02:19 PDT 2001



>> 
>> On 9/12/2001 at 5:30 PM xiphmont at xiph.org wrote:
>> 
>> >On Wed, Sep 12, 2001 at 02:02:36PM -0700, Chris Wolf wrote:
>> >> In that case, I think I have an alternative workaround, so that we can
>> >lose the DLL
>> >> shared memory stuff...
>> >
>> >What's the idea?
>> >
>> >Monty
>> 
>> Well, I was going to try it first to make sure it worked... I was
>thinking
>> instead of using statically initialized arrays in registry.c, use
>dynamic allocation
>> something along the lines of _vi_psy_copy, which does not have this
>problem.
>
>OK.  So the basic problem is that static externs are unsharable?  

Pretty much -- any global definition in the data segment is not sharable, but function pointers are ok, 
because they are in the text segment.  In any case, I was able to get rid of the shared memory
scheme because that win32 function I added, table_map2mem(), returns a pointer to dynamically
allocated memory, with copies of all the function pointers.  I was able to successfully dynamically
link and execute oggdrop, without the shared memory code.  I should have thought of that before,
sorry.

Maybe if we replace the static arrays in registry.c with function calls, returning dynamically
allocated and initialized arrays, we can also eliminate the two files I added, shmmap.h and shmmap_c.h.

The only changes are to vorbisenc.c and getting rid of dllmain.c

Here's the patch to vorbisenc.c:

Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.15
diff -u -r1.15 vorbisenc.c
--- vorbisenc.c 2001/09/07 08:42:30     1.15
+++ vorbisenc.c 2001/09/12 22:54:53
@@ -37,6 +37,8 @@
 #if defined(_MSC_VER) && defined(STANDALONE_VORBISENC_DLL)
 # include "shmmap.h"

+  SHARED_MAP *g_shared_map;
+
 # define _time_P    g_shared_map->p_time_P
 # define _floor_P   g_shared_map->p_floor_P
 # define _residue_P g_shared_map->p_residue_P
@@ -48,6 +50,13 @@
 static void codec_setup_partialcopy(codec_setup_info *ci,
                                 codec_setup_info *cs){
   int i;
+
+#if defined(_MSC_VER) && defined(STANDALONE_VORBISENC_DLL)
+  int maplen;
+
+  if ((g_shared_map = table_map2mem(&maplen)) == (SHARED_MAP*)0)
+  ; /* some error handling for memory exhaustion */
+#endif

   memcpy(ci,cs,sizeof(codec_setup_info)); /* to get the flat numbers */

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list