< prev index next >

src/java.desktop/unix/native/libjsound/PLATFORM_API_LinuxOS_ALSA_CommonUtils.c

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  26 //#define USE_ERROR
  27 //#define USE_TRACE
  28 
  29 #include "PLATFORM_API_LinuxOS_ALSA_CommonUtils.h"
  30 
  31 static void alsaDebugOutput(const char *file, int line, const char *function, int err, const char *fmt, ...) {
  32 #ifdef USE_ERROR
  33     va_list args;
  34     va_start(args, fmt);
  35     printf("%s:%d function %s: error %d: %s\n", file, line, function, err, snd_strerror(err));
  36     if (strlen(fmt) > 0) {
  37         vprintf(fmt, args);
  38     }
  39     va_end(args);
  40 #endif
  41 }
  42 
  43 static int alsa_inited = 0;
  44 static int alsa_enumerate_pcm_subdevices = FALSE; // default: no
  45 static int alsa_enumerate_midi_subdevices = FALSE; // default: no





  46 
  47 void initAlsaSupport() {
  48     char* enumerate;
  49     if (!alsa_inited) {
  50         alsa_inited = TRUE;
  51         snd_lib_error_set_handler(&alsaDebugOutput);
  52 
  53         enumerate = getenv(ENV_ENUMERATE_PCM_SUBDEVICES);
  54         if (enumerate != NULL && strlen(enumerate) > 0
  55             && (enumerate[0] != 'f')   // false
  56             && (enumerate[0] != 'F')   // False
  57             && (enumerate[0] != 'n')   // no
  58             && (enumerate[0] != 'N')) { // NO
  59             alsa_enumerate_pcm_subdevices = TRUE;
  60         }
  61 #ifdef ALSA_MIDI_ENUMERATE_SUBDEVICES
  62         alsa_enumerate_midi_subdevices = TRUE;
  63 #endif
  64     }
  65 }


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  26 //#define USE_ERROR
  27 //#define USE_TRACE
  28 
  29 #include "PLATFORM_API_LinuxOS_ALSA_CommonUtils.h"
  30 
  31 static void alsaDebugOutput(const char *file, int line, const char *function, int err, const char *fmt, ...) {
  32 #ifdef USE_ERROR
  33     va_list args;
  34     va_start(args, fmt);
  35     printf("%s:%d function %s: error %d: %s\n", file, line, function, err, snd_strerror(err));
  36     if (strlen(fmt) > 0) {
  37         vprintf(fmt, args);
  38     }
  39     va_end(args);
  40 #endif
  41 }
  42 
  43 static int alsa_inited = 0;
  44 static int alsa_enumerate_pcm_subdevices = FALSE; // default: no
  45 static int alsa_enumerate_midi_subdevices = FALSE; // default: no
  46 
  47 /*
  48  * Declare library specific JNI_Onload entry if static build
  49  */
  50 DEF_STATIC_JNI_OnLoad
  51 
  52 void initAlsaSupport() {
  53     char* enumerate;
  54     if (!alsa_inited) {
  55         alsa_inited = TRUE;
  56         snd_lib_error_set_handler(&alsaDebugOutput);
  57 
  58         enumerate = getenv(ENV_ENUMERATE_PCM_SUBDEVICES);
  59         if (enumerate != NULL && strlen(enumerate) > 0
  60             && (enumerate[0] != 'f')   // false
  61             && (enumerate[0] != 'F')   // False
  62             && (enumerate[0] != 'n')   // no
  63             && (enumerate[0] != 'N')) { // NO
  64             alsa_enumerate_pcm_subdevices = TRUE;
  65         }
  66 #ifdef ALSA_MIDI_ENUMERATE_SUBDEVICES
  67         alsa_enumerate_midi_subdevices = TRUE;
  68 #endif
  69     }
  70 }


< prev index next >