mozilla-esd.patch
branchmozilla-1.9.2
changeset 112 22a2c93a47ee
equal deleted inserted replaced
109:2bfb3c461caf 112:22a2c93a47ee
       
     1 # HG changeset patch
       
     2 # User Wolfgang Rosenauer <wr@rosenauer.org>
       
     3 # Parent a93100d87cc9841c6e3e4b29a47bb7b91f23415f
       
     4 Bug 579877 - sound output via libesd broken if no esound daemon running. r=karlt
       
     5 
       
     6 diff --git a/widget/src/gtk2/nsSound.cpp b/widget/src/gtk2/nsSound.cpp
       
     7 --- a/widget/src/gtk2/nsSound.cpp
       
     8 +++ b/widget/src/gtk2/nsSound.cpp
       
     9 @@ -52,36 +52,31 @@
       
    10  #include "nsCOMPtr.h"
       
    11  #include "nsAutoPtr.h"
       
    12  #include "nsString.h"
       
    13  
       
    14  #include <stdio.h>
       
    15  #include <unistd.h>
       
    16  
       
    17  #include <gtk/gtk.h>
       
    18 -/* used with esd_open_sound */
       
    19 -static int esdref = -1;
       
    20  static PRLibrary *elib = nsnull;
       
    21  static PRLibrary *libcanberra = nsnull;
       
    22  static PRLibrary* libasound = nsnull;
       
    23  
       
    24  // the following from esd.h
       
    25  
       
    26  #define ESD_BITS8  (0x0000)
       
    27  #define ESD_BITS16 (0x0001) 
       
    28  #define ESD_MONO (0x0010)
       
    29  #define ESD_STEREO (0x0020) 
       
    30  #define ESD_STREAM (0x0000)
       
    31  #define ESD_PLAY (0x1000)
       
    32  
       
    33  #define WAV_MIN_LENGTH 44
       
    34  
       
    35 -typedef int (*EsdOpenSoundType)(const char *host);
       
    36 -typedef int (*EsdCloseType)(int);
       
    37 -
       
    38  /* used to play the sounds from the find symbol call */
       
    39  typedef int  (*EsdPlayStreamType) (int, int, const char *, const char *);
       
    40  typedef int  (*EsdAudioOpenType)  (void);
       
    41  typedef int  (*EsdAudioWriteType) (const void *, int);
       
    42  typedef void (*EsdAudioCloseType) (void);
       
    43  
       
    44  /* used to find and play common system event sounds.
       
    45     this interfaces with libcanberra.
       
    46 @@ -126,50 +121,30 @@ NS_IMPL_ISUPPORTS2(nsSound, nsISound, ns
       
    47  ////////////////////////////////////////////////////////////////////////
       
    48  nsSound::nsSound()
       
    49  {
       
    50      mInited = PR_FALSE;
       
    51  }
       
    52  
       
    53  nsSound::~nsSound()
       
    54  {
       
    55 -    if (esdref >= 0) {
       
    56 -        EsdCloseType EsdClose = (EsdCloseType) PR_FindFunctionSymbol(elib, "esd_close");
       
    57 -        if (EsdClose)
       
    58 -            (*EsdClose)(esdref);
       
    59 -        esdref = -1;
       
    60 -    }
       
    61  }
       
    62  
       
    63  NS_IMETHODIMP
       
    64  nsSound::Init()
       
    65  {
       
    66      // This function is designed so that no library is compulsory, and
       
    67      // one library missing doesn't cause the other(s) to not be used.
       
    68      if (mInited) 
       
    69          return NS_OK;
       
    70  
       
    71      mInited = PR_TRUE;
       
    72  
       
    73      if (!elib) {
       
    74          elib = PR_LoadLibrary("libesd.so.0");
       
    75 -        if (elib) {
       
    76 -            EsdOpenSoundType EsdOpenSound =
       
    77 -                (EsdOpenSoundType) PR_FindFunctionSymbol(elib, "esd_open_sound");
       
    78 -            if (!EsdOpenSound) {
       
    79 -                PR_UnloadLibrary(elib);
       
    80 -                elib = nsnull;
       
    81 -            } else {
       
    82 -                esdref = (*EsdOpenSound)("localhost");
       
    83 -                if (esdref < 0) {
       
    84 -                    PR_UnloadLibrary(elib);
       
    85 -                    elib = nsnull;
       
    86 -                }
       
    87 -            }
       
    88 -        }
       
    89      }
       
    90  
       
    91      if (!libasound) {
       
    92          PRFuncPtr func = PR_FindFunctionSymbolAndLibrary("snd_lib_error_set_handler",
       
    93                                                           &libasound);
       
    94          if (libasound) {
       
    95              snd_lib_error_set_handler_fn snd_lib_error_set_handler =
       
    96                   (snd_lib_error_set_handler_fn) func;