source: trunk/src/winmm/waveoutbase.cpp@ 21358

Last change on this file since 21358 was 21358, checked in by rlwalsh, 16 years ago

add FlashWaveOut class to winmm - see Ticket #2

File size: 5.8 KB
Line 
1/* $Id: waveoutbase.cpp,v 1.4 2001-10-24 22:47:42 sandervl Exp $ */
2
3/*
4 * Wave playback class (DART)
5 *
6 * Copyright 1998-2001 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 * Note:
12 * 2000/11/24 PH MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector!
13 *
14 */
15
16/******************************************************************************/
17// Includes
18/******************************************************************************/
19
20#define INCL_BASE
21#define INCL_OS2MM
22#include <os2wrap.h> //Odin32 OS/2 api wrappers
23#include <os2mewrap.h> //Odin32 OS/2 MMPM/2 api wrappers
24#include <stdlib.h>
25#include <string.h>
26#define OS2_ONLY
27#include <win32api.h>
28#include <wprocess.h>
29
30#include "misc.h"
31#include "waveoutbase.h"
32#include "initwinmm.h"
33
34#define DBG_LOCALLOG DBG_waveoutbase
35#include "dbglocal.h"
36
37/******************************************************************************/
38/******************************************************************************/
39
40ULONG WaveOut::defvolume = 0xFFFFFFFF;
41
42/******************************************************************************/
43/******************************************************************************/
44WaveOut::WaveOut(LPWAVEFORMATEX pwfx, ULONG fdwOpen, ULONG nCallback, ULONG dwInstance)
45 : WaveInOut(pwfx, fdwOpen, nCallback, dwInstance)
46{
47 volume = defvolume;
48
49 dprintf(("waveOutOpen: samplerate %d, numChan %d bps %d (%d), format %x", SampleRate, nChannels, BitsPerSample, pwfx->nBlockAlign, pwfx->wFormatTag));
50}
51/******************************************************************************/
52/******************************************************************************/
53WaveOut::~WaveOut()
54{
55}
56/******************************************************************************/
57/******************************************************************************/
58int WaveOut::getNumDevices()
59{
60 MCI_AMP_OPEN_PARMS AmpOpenParms;
61 MCI_GENERIC_PARMS GenericParms = {0};
62 APIRET rc;
63
64 // Try to open the device to see if it's there
65 memset(&AmpOpenParms, 0, sizeof(AmpOpenParms));
66 AmpOpenParms.usDeviceID = 0;
67 AmpOpenParms.pszDeviceType = (PSZ)MCI_DEVTYPE_AUDIO_AMPMIX;
68
69 rc = mymciSendCommand(0, MCI_OPEN,
70 MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE,
71 (PVOID) &AmpOpenParms, 0);
72
73 if (LOUSHORT(rc) != MCIERR_SUCCESS)
74 return 0;
75
76 // Close the device
77 mymciSendCommand(AmpOpenParms.usDeviceID, MCI_CLOSE,
78 MCI_WAIT,
79 (PVOID)&GenericParms, 0);
80
81 return 1;
82}
83/******************************************************************************/
84/******************************************************************************/
85BOOL WaveOut::queryFormat(ULONG formatTag, ULONG nChannels,
86 ULONG nSamplesPerSec, ULONG wBitsPerSample)
87{
88 APIRET rc;
89 BOOL winrc = TRUE;
90 MCI_OPEN_PARMS OpenParms;
91 MCI_WAVE_GETDEVCAPS_PARMS DevCapsParms;
92 MCI_GENERIC_PARMS GenericParms = {0};
93#ifdef DEBUG
94 char szError[64] = "";
95#endif
96
97 dprintf(("WINMM: WaveOut::queryFormat %x srate=%d, nchan=%d, bps=%d", formatTag, nSamplesPerSec, nChannels, wBitsPerSample));
98
99 // Open the device.
100 memset(&OpenParms, 0, sizeof(OpenParms));
101 OpenParms.pszDeviceType = (PSZ)MCI_DEVTYPE_WAVEFORM_AUDIO;
102
103 rc = mymciSendCommand(0, MCI_OPEN,
104 MCI_WAIT | MCI_OPEN_TYPE_ID,
105 (PVOID)&OpenParms, 0);
106 if (LOUSHORT(rc) != MCIERR_SUCCESS) {
107 #ifdef DEBUG
108 mymciGetErrorString(rc, szError, sizeof(szError));
109 dprintf(("WINMM: WaveOut::queryFormat: %s\n", szError));
110 #endif
111 return FALSE;
112 }
113
114 // See if the device can handle the specified format.
115 memset(&DevCapsParms, 0, sizeof(MCI_WAVE_GETDEVCAPS_PARMS));
116 DevCapsParms.ulBitsPerSample = wBitsPerSample;
117 DevCapsParms.ulFormatTag = DATATYPE_WAVEFORM;
118 DevCapsParms.ulSamplesPerSec = nSamplesPerSec;
119 DevCapsParms.ulChannels = nChannels;
120 DevCapsParms.ulFormatMode = MCI_PLAY;
121 DevCapsParms.ulItem = MCI_GETDEVCAPS_WAVE_FORMAT;
122
123 rc = mymciSendCommand(OpenParms.usDeviceID, MCI_GETDEVCAPS,
124 MCI_WAIT | MCI_GETDEVCAPS_EXTENDED | MCI_GETDEVCAPS_ITEM,
125 (PVOID)&DevCapsParms, 0);
126 if (LOUSHORT(rc) != MCIERR_SUCCESS) {
127 #ifdef DEBUG
128 mymciGetErrorString(rc, szError, sizeof(szError));
129 dprintf(("WINMM: WaveOut::queryFormat: %s\n", szError));
130 #endif
131 winrc = FALSE;
132 }
133
134 // Close the device
135 rc = mymciSendCommand(OpenParms.usDeviceID, MCI_CLOSE,
136 MCI_WAIT, (PVOID)&GenericParms, 0);
137 if (LOUSHORT(rc) != MCIERR_SUCCESS) {
138 #ifdef DEBUG
139 mymciGetErrorString(rc, szError, sizeof(szError));
140 dprintf(("WINMM: WaveOut::queryFormat: %s\n", szError));
141 #endif
142 winrc = FALSE;
143 }
144
145 return winrc;
146}
147/******************************************************************************/
148// Called if waveOutSetVolume is called by the application with waveout handle NULL
149// Sets the default volume of each waveout stream (until it's volume is changed
150// with an appropriate waveOutSetVolume call)
151/******************************************************************************/
152void WaveOut::setDefaultVolume(ULONG volume)
153{
154 dprintf(("WaveOut::setDefaultVolume %x", volume));
155 defvolume = volume;
156}
157/******************************************************************************/
158/******************************************************************************/
159DWORD WaveOut::getDefaultVolume()
160{
161 return defvolume;
162}
163/******************************************************************************/
164/******************************************************************************/
165
Note: See TracBrowser for help on using the repository browser.