VirtualBox

Changeset 5050 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Sep 26, 2007 2:55:04 PM (17 years ago)
Author:
vboxsync
Message:

Moved the ALSA code into a separate shared object loaded at runtime

Location:
trunk/src/VBox/Devices/Audio
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/alsaaudio.c

    r3784 r5050  
    3333
    3434#include "Builtins.h"
    35 #include "../../vl_vbox.h"
     35#include "vl_vbox.h"
    3636#include "audio.h"
    3737#include <iprt/alloc.h>
     
    10891089};
    10901090
     1091extern DECLEXPORT(struct audio_driver) alsa_audio_driver;
    10911092struct audio_driver alsa_audio_driver = {
    10921093    INIT_FIELD (name           = ) "alsa",
  • trunk/src/VBox/Devices/Audio/audio.c

    r4521 r5050  
    3333#include <iprt/alloc.h>
    3434
     35#if defined(RT_OS_LINUX) && defined(VBOX_WITH_ALSA)
     36# include <iprt/ldr.h>
     37# define VBOX_LIB_ALSA "VBoxAlsa"
     38#endif
     39
    3540#include "Builtins.h"
    3641#include "../../vl_vbox.h"
     
    6267} DRVAUDIO, *PDRVAUDIO;
    6368
     69#if !(defined(RT_OS_LINUX) && defined(VBOX_WITH_ALSA))
    6470static struct audio_driver *drvtab[] = {
    65 #ifdef RT_OS_LINUX
     71# ifdef RT_OS_LINUX
    6672    &oss_audio_driver,
    67 #ifdef VBOX_WITH_ALSA
    68     &alsa_audio_driver,
    69 #endif
    70 #endif
    71 #ifdef RT_OS_DARWIN
     73# endif
     74# ifdef RT_OS_DARWIN
    7275    &coreaudio_audio_driver,
    73 #endif
    74 #ifdef RT_OS_WINDOWS
     76# endif
     77# ifdef RT_OS_WINDOWS
    7578    &dsound_audio_driver,
    76 #endif
    77 #ifdef RT_OS_L4
     79# endif
     80# ifdef RT_OS_L4
    7881    &oss_audio_driver,
    79 #endif
     82# endif
    8083    &no_audio_driver
    8184};
     85#else
     86static struct audio_driver *drvtab[] = {
     87    &oss_audio_driver,
     88    NULL, /* alsa_audio_driver is now in a shared object */
     89    &no_audio_driver
     90};
     91#endif
    8292
    8393struct fixed_settings {
     
    15451555
    15461556        for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
    1547             if (!strcmp (drvname, drvtab[i]->name)) {
    1548                 done = !audio_driver_init (s, drvtab[i]);
    1549                 found = 1;
    1550                 break;
     1557            /* The ALSA entry can be null if we couldn't load the library */
     1558            if (drvtab[i] != NULL)
     1559            {
     1560                if (!strcmp (drvname, drvtab[i]->name)) {
     1561                    done = !audio_driver_init (s, drvtab[i]);
     1562                    found = 1;
     1563                    break;
     1564                }
    15511565            }
    15521566        }
     
    18591873    PDRVAUDIO pData = PDMINS2DATA(pDrvIns, PDRVAUDIO);
    18601874    char *drvname;
     1875#if defined(RT_OS_LINUX) && defined(VBOX_WITH_ALSA)
     1876    RTLDRMOD hLibVBoxAlsa;
     1877#endif
    18611878
    18621879    LogFlow(("drvAUDIOConstruct:\n"));
     1880    /*
     1881     * Load the ALSA driver if needed
     1882     */
     1883#if defined(RT_OS_LINUX) && defined(VBOX_WITH_ALSA)
     1884    Log2(("Loading ALSA library %s\n", VBOX_LIB_ALSA));
     1885    rc = (RTLdrLoad(VBOX_LIB_ALSA, &hLibVBoxAlsa));
     1886    if (RT_FAILURE(rc))
     1887    {
     1888        Log(("Failed to load ALSA library %s.  Reason: %Rrc\n", VBOX_LIB_ALSA, rc));
     1889    }
     1890    else
     1891    {
     1892        rc = RTLdrGetSymbol(hLibVBoxAlsa, "alsa_audio_driver", (void **) &drvtab[1]);
     1893        if (RT_FAILURE(rc))
     1894        {
     1895            Log(("Failed to get symbol \"alsa_audio_driver\" from library %s.  Reason: %Rrc\n",
     1896                 VBOX_LIB_ALSA, rc));
     1897            drvtab[1] = NULL;
     1898        }
     1899    }
     1900#endif
    18631901    /*
    18641902     * Validate the config.
  • trunk/src/VBox/Devices/Audio/audio.h

    r3214 r5050  
    2525#define QEMU_AUDIO_H
    2626
     27#ifdef VBOX
     28# include <iprt/types.h>
     29#endif
     30
    2731#include "sys-queue.h"
    2832
     
    105109} QEMUAudioTimeStamp;
    106110
     111#ifdef VBOX
     112extern DECLEXPORT(void) AUD_vlog (const char *cap, const char *fmt, va_list ap);
     113extern DECLEXPORT(void) AUD_log (const char *cap, const char *fmt, ...)
     114#else
    107115void AUD_vlog (const char *cap, const char *fmt, va_list ap);
    108116void AUD_log (const char *cap, const char *fmt, ...)
     117#endif
    109118#if defined (__GNUC__) && !defined (VBOX) /* VBox: oh, please, shut up. */
    110119    __attribute__ ((__format__ (__printf__, 2, 3)))
  • trunk/src/VBox/Devices/Audio/audio_int.h

    r1636 r5050  
    3434#endif
    3535
     36#ifdef VBOX
     37#include <iprt/types.h>
     38#endif
     39
    3640#include <limits.h>
    3741#include "mixeng.h"
     
    215219extern struct audio_driver coreaudio_audio_driver;
    216220extern struct audio_driver dsound_audio_driver;
    217 extern volume_t nominal_volume;
    218221#ifdef VBOX
     222extern DECLEXPORT(volume_t) nominal_volume;
    219223extern volume_t pcm_out_volume;
    220224extern volume_t pcm_in_volume;
     225#else
     226extern volume_t nominal_volume;
    221227#endif
    222228
     
    224230uint64_t audio_get_ticks_per_sec (void);
    225231
     232#ifdef VBOX
     233extern DECLEXPORT(void) audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
     234void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
     235
     236extern DECLEXPORT(int)  audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len);
     237extern DECLEXPORT(int)  audio_pcm_hw_get_live_in (HWVoiceIn *hw);
     238
     239extern DECLEXPORT(int)  audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len);
     240extern DECLEXPORT(int)  audio_pcm_hw_get_live_out (HWVoiceOut *hw);
     241int  audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live);
     242
     243int audio_bug (const char *funcname, int cond);
     244extern DECLEXPORT(void *)audio_calloc (const char *funcname, int nmemb, size_t size);
     245#else
    226246void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
    227247void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
     
    236256int audio_bug (const char *funcname, int cond);
    237257void *audio_calloc (const char *funcname, int nmemb, size_t size);
     258#endif
    238259
    239260#define VOICE_ENABLE 1
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette