jack.c 4.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/*
 * Wine Driver for jack Sound Server
 *   http://jackit.sourceforge.net
 *
 * Copyright 2002 Chris Morgan
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 22 23 24
 */

#include "config.h"
#include "wine/port.h"
25

26
#include <stdarg.h>
27
#include <stdio.h>
28 29 30 31 32 33 34

#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmddk.h"
#include "jack.h"
35 36 37 38
#include "wine/library.h"
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(jack);
39 40 41

#ifdef HAVE_JACK_JACK_H

42 43
#ifndef SONAME_LIBJACK
#define SONAME_LIBJACK "libjack.so"
44 45 46 47 48 49 50
#endif

void *jackhandle = NULL;

/**************************************************************************
 * 				JACK_drvLoad			[internal]	
 */
51
static LRESULT JACK_drvLoad(void)
52
{
53
  TRACE("()\n");
54 55 56 57

  /* dynamically load the jack library if not already loaded */
  if(!jackhandle)
  {
58
    jackhandle = wine_dlopen(SONAME_LIBJACK, RTLD_NOW, NULL, 0);
59 60
    TRACE("SONAME_LIBJACK == %s\n", SONAME_LIBJACK);
    TRACE("jackhandle == %p\n", jackhandle);
61 62
    if(!jackhandle)
    {
63
      FIXME("error loading the jack library %s, please install this library to use jack\n", SONAME_LIBJACK);
64 65 66 67 68
      jackhandle = (void*)-1;
      return 0;
    }
  }

69
  return JACK_WaveInit();
70 71 72 73 74 75
}

/**************************************************************************
 * 				JACK_drvFree			[internal]	
 */
/* unload the jack library on driver free */
76
static LRESULT JACK_drvFree(void)
77
{
78
  TRACE("()\n");
79 80 81

  if(jackhandle && (jackhandle != (void*)-1))
  {
82 83
    JACK_WaveRelease();

84
    TRACE("calling wine_dlclose() on jackhandle\n");
85 86 87 88 89 90 91 92 93 94
    wine_dlclose(jackhandle, NULL, 0);
    jackhandle = NULL;
  }

  return 1;
}

/**************************************************************************
 * 				JACK_drvOpen			[internal]	
 */
95
static LRESULT JACK_drvOpen(LPSTR str)
96
{
97
  TRACE("(%s)\n", str);
98 99 100 101
  /* if we were unable to load the jack library then fail the */
  /* driver open */
  if(!jackhandle)
  {
102
    FIXME("unable to open the jack library, returning 0\n");
103 104 105 106 107 108 109 110 111
    return 0;
  }

  return 1;
}

/**************************************************************************
 * 				JACK_drvClose			[internal]	
 */
112
static LRESULT JACK_drvClose(DWORD_PTR dwDevID)
113
{
114 115
  TRACE("(%08lx)\n", dwDevID);
  return 1;
116 117 118 119 120 121 122
}
#endif /* #ifdef HAVE_JACK_JACK_H */


/**************************************************************************
 * 				DriverProc (WINEJACK.1)
 */
123 124
LRESULT CALLBACK JACK_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, 
                                 LPARAM dwParam1, LPARAM dwParam2)
125
{
126 127 128 129 130 131 132 133 134 135 136 137
     TRACE("(%08lX, %p, %s (%08X), %08lX, %08lX)\n",
           dwDevID, hDriv, wMsg == DRV_LOAD ? "DRV_LOAD" :
           wMsg == DRV_FREE ? "DRV_FREE" :
           wMsg == DRV_OPEN ? "DRV_OPEN" :
           wMsg == DRV_CLOSE ? "DRV_CLOSE" :
           wMsg == DRV_ENABLE ? "DRV_ENABLE" :
           wMsg == DRV_DISABLE ? "DRV_DISABLE" :
           wMsg == DRV_QUERYCONFIGURE ? "DRV_QUERYCONFIGURE" :
           wMsg == DRV_CONFIGURE ? "DRV_CONFIGURE" :
           wMsg == DRV_INSTALL ? "DRV_INSTALL" :
           wMsg == DRV_REMOVE ? "DRV_REMOVE" : "UNKNOWN", 
           wMsg, dwParam1, dwParam2);
138 139 140
    
    switch(wMsg) {
#ifdef HAVE_JACK_JACK_H
141 142 143 144 145 146
    case DRV_LOAD:		return JACK_drvLoad();
    case DRV_FREE:		return JACK_drvFree();
    case DRV_OPEN:		return JACK_drvOpen((LPSTR)dwParam1);
    case DRV_CLOSE:		return JACK_drvClose(dwDevID);
    case DRV_ENABLE:		return 1;
    case DRV_DISABLE:		return 1;
147 148
    case DRV_QUERYCONFIGURE:	return 1;
    case DRV_CONFIGURE:		MessageBoxA(0, "jack audio driver!", "jack driver", MB_OK);	return 1;
149 150
    case DRV_INSTALL:		return DRVCNF_RESTART;
    case DRV_REMOVE:		return DRVCNF_RESTART;
151 152 153 154 155
#endif
    default:
	return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
    }
}