1/* 2 * Copyright (c) 2002, 2007, 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 23 * questions. 24 */ 25 26#ifndef DIRECT_AUDIO_INCLUDED 27#define DIRECT_AUDIO_INCLUDED 28 29// includes for types 30#include "SoundDefs.h" 31 32// for memset 33#include <string.h> 34 35#include "Utilities.h" 36 37// the following defines should match the ones in AbstractMixer.java 38#define DAUDIO_PCM 0 39#define DAUDIO_ULAW 1 40#define DAUDIO_ALAW 2 41 42#define DAUDIO_STRING_LENGTH 200 43 44typedef struct tag_DirectAudioDeviceDescription { 45 // optional deviceID (complementary to deviceIndex) 46 INT32 deviceID; 47 INT32 maxSimulLines; 48 char name[DAUDIO_STRING_LENGTH+1]; 49 char vendor[DAUDIO_STRING_LENGTH+1]; 50 char description[DAUDIO_STRING_LENGTH+1]; 51 char version[DAUDIO_STRING_LENGTH+1]; 52} DirectAudioDeviceDescription; 53 54 55// method definitions 56 57#if (USE_DAUDIO == TRUE) 58 59// callback from GetFormats, implemented in DirectAudioDevice.c 60void DAUDIO_AddAudioFormat(void* creator, int significantBits, int frameSizeInBytes, 61 int channels, float sampleRate, 62 int encoding, int isSigned, 63 int bigEndian); 64 65 66// the following methods need to be implemented by the platform dependent code 67 68/* returns the number of mixer devices */ 69INT32 DAUDIO_GetDirectAudioDeviceCount(); 70 71/* returns TRUE on success, FALSE otherwise */ 72INT32 DAUDIO_GetDirectAudioDeviceDescription(INT32 mixerIndex, 73 DirectAudioDeviceDescription* description); 74 75// SourceDataLine and TargetDataLine 76 77void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* creator); 78 79void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource, 80 int encoding, float sampleRate, int sampleSizeInBits, 81 int frameSize, int channels, 82 int isSigned, int isBigEndian, int bufferSizeInBytes); 83int DAUDIO_Start(void* id, int isSource); 84int DAUDIO_Stop(void* id, int isSource); 85void DAUDIO_Close(void* id, int isSource); 86int DAUDIO_Write(void* id, char* data, int byteSize); // returns -1 on error 87int DAUDIO_Read(void* id, char* data, int byteSize); // returns -1 on error 88 89int DAUDIO_GetBufferSize(void* id, int isSource); 90int DAUDIO_StillDraining(void* id, int isSource); 91int DAUDIO_Flush(void* id, int isSource); 92/* in bytes */ 93int DAUDIO_GetAvailable(void* id, int isSource); 94INT64 DAUDIO_GetBytePosition(void* id, int isSource, INT64 javaBytePos); 95void DAUDIO_SetBytePosition(void* id, int isSource, INT64 javaBytePos); 96 97int DAUDIO_RequiresServicing(void* id, int isSource); 98void DAUDIO_Service(void* id, int isSource); 99 100#endif // USE_DAUDIO 101 102#endif // DIRECT_AUDIO_INCLUDED 103