aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-02-14 22:05:56 -0800
committerChris Robinson <[email protected]>2008-02-14 22:05:56 -0800
commit8c3188bc7dc2f47a27398fc61ed2dacd36397190 (patch)
tree5c46bd2fb13355a1bdb6f6118b86bee9452f2859
parent880196e5a811356c4a6b36798a81429b4a48eb40 (diff)
Remove FrameSize struct member
-rw-r--r--Alc/ALc.c8
-rw-r--r--Alc/alsa.c2
-rw-r--r--Alc/dsound.c11
-rw-r--r--Alc/oss.c15
-rw-r--r--Alc/winmm.c16
-rw-r--r--OpenAL32/Include/alMain.h1
6 files changed, 29 insertions, 24 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 7ce5c85b..2e3d2adf 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -451,8 +451,6 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
pDevice->Frequency = frequency;
pDevice->Format = format;
- pDevice->FrameSize = aluBytesFromFormat(format) *
- aluChannelsFromFormat(format);
for(i = 0;BackendList[i].Init;i++)
{
@@ -1169,13 +1167,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
device->Format = alGetEnumValue(fmt);
if(!aluChannelsFromFormat(device->Format))
- {
device->Format = AL_FORMAT_STEREO16;
- device->FrameSize = 4;
- }
- else
- device->FrameSize = aluBytesFromFormat(device->Format) *
- aluChannelsFromFormat(device->Format);
device->UpdateSize = GetConfigValueInt(NULL, "refresh", 8192);
if((ALint)device->UpdateSize <= 0)
diff --git a/Alc/alsa.c b/Alc/alsa.c
index 19682db7..09727ba9 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -647,7 +647,7 @@ static void alsa_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint l
}
Pointer = (char*)areas->addr + (offset * areas->step / 8);
- Count = size * pDevice->FrameSize;
+ Count = psnd_pcm_frames_to_bytes(data->pcmHandle, size);
memcpy(pBuffer, Pointer, Count);
pBuffer = (char*)pBuffer + Count;
diff --git a/Alc/dsound.c b/Alc/dsound.c
index 34f6d538..6dc87057 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -71,7 +71,9 @@ static ALuint DSoundProc(ALvoid *ptr)
DWORD avail;
HRESULT err;
- BufferSize = pDevice->UpdateSize*DS_FRAGS*pDevice->FrameSize;
+ BufferSize = pDevice->UpdateSize * DS_FRAGS *
+ aluBytesFromFormat(pDevice->Format) *
+ aluChannelsFromFormat(pDevice->Format);
while(!pData->killNow)
{
@@ -128,6 +130,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
DSBUFFERDESC DSBDescription;
DSoundData *pData = NULL;
WAVEFORMATEXTENSIBLE OutputType;
+ DWORD frameSize = 0;
LPGUID guid = NULL;
DWORD speakers;
HRESULT hr;
@@ -225,8 +228,8 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
SPEAKER_SIDE_LEFT |
SPEAKER_SIDE_RIGHT;
}
- device->FrameSize = aluBytesFromFormat(device->Format) *
- aluChannelsFromFormat(device->Format);
+ frameSize = aluBytesFromFormat(device->Format) *
+ aluChannelsFromFormat(device->Format);
OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
OutputType.Format.nChannels = aluChannelsFromFormat(device->Format);
@@ -264,7 +267,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
- DSBDescription.dwBufferBytes=device->UpdateSize * DS_FRAGS * device->FrameSize;
+ DSBDescription.dwBufferBytes=device->UpdateSize * DS_FRAGS * frameSize;
DSBDescription.lpwfxFormat=&OutputType.Format;
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
}
diff --git a/Alc/oss.c b/Alc/oss.c
index a1efc18a..ef1697d9 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -149,6 +149,7 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
int log2FragmentSize;
unsigned int periods;
audio_buf_info info;
+ ALuint frameSize;
char driver[64];
int numChannels;
oss_data *data;
@@ -196,8 +197,10 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
if((int)periods <= 0)
periods = 4;
numChannels = aluChannelsFromFormat(device->Format);
+ frameSize = numChannels * aluBytesFromFormat(device->Format);
+
ossSpeed = device->Frequency;
- log2FragmentSize = log2i(device->UpdateSize * device->FrameSize / periods);
+ log2FragmentSize = log2i(device->UpdateSize * frameSize / periods);
/* according to the OSS spec, 16 bytes are the minimum */
if (log2FragmentSize < 4)
@@ -237,9 +240,9 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
return ALC_FALSE;
}
- device->UpdateSize = info.fragsize / device->FrameSize;
+ device->UpdateSize = info.fragsize / frameSize;
- data->data_size = device->UpdateSize * device->FrameSize;
+ data->data_size = device->UpdateSize * frameSize;
data->mix_data = calloc(1, data->data_size);
device->ExtraData = data;
@@ -275,6 +278,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName,
int log2FragmentSize;
unsigned int periods;
audio_buf_info info;
+ ALuint frameSize;
int numChannels;
char driver[64];
oss_data *data;
@@ -320,8 +324,9 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName,
periods = 4;
numChannels = aluChannelsFromFormat(device->Format);
+ frameSize = numChannels * aluBytesFromFormat(device->Format);
ossSpeed = frequency;
- log2FragmentSize = log2i(SampleSize * device->FrameSize / periods);
+ log2FragmentSize = log2i(SampleSize * frameSize / periods);
/* according to the OSS spec, 16 bytes are the minimum */
if (log2FragmentSize < 4)
@@ -359,7 +364,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName,
return ALC_FALSE;
}
- data->ring = CreateRingBuffer(device->FrameSize, SampleSize);
+ data->ring = CreateRingBuffer(frameSize, SampleSize);
if(!data->ring)
{
AL_PRINT("ring buffer create failed\n");
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 118db589..4963597c 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -211,10 +211,11 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
wfexCaptureFormat.nChannels = aluChannelsFromFormat(pDevice->Format);
wfexCaptureFormat.wBitsPerSample = aluBytesFromFormat(pDevice->Format) * 8;
- wfexCaptureFormat.nBlockAlign = pDevice->FrameSize;
+ wfexCaptureFormat.nBlockAlign = wfexCaptureFormat.wBitsPerSample *
+ wfexCaptureFormat.nChannels / 8;
wfexCaptureFormat.nSamplesPerSec = frequency;
wfexCaptureFormat.nAvgBytesPerSec = wfexCaptureFormat.nSamplesPerSec *
- pDevice->FrameSize;
+ wfexCaptureFormat.nBlockAlign;
wfexCaptureFormat.cbSize = 0;
if (waveInOpen(&pData->hWaveInHandle, lDeviceID, &wfexCaptureFormat, (DWORD_PTR)&WaveInProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
@@ -361,16 +362,20 @@ static void WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lS
ALuint ulBytes, ulBytesToCopy;
ALuint ulCapturedSamples;
ALuint ulReadOffset;
+ ALuint frameSize = aluBytesFromFormat(pDevice->Format) *
+ aluChannelsFromFormat(pDevice->Format);
// Check that we have the requested numbers of Samples
- ulCapturedSamples = (pData->ulWriteCapturedDataPos - pData->ulReadCapturedDataPos) / pDevice->FrameSize;
+ ulCapturedSamples = (pData->ulWriteCapturedDataPos -
+ pData->ulReadCapturedDataPos) /
+ frameSize;
if(ulSamples > ulCapturedSamples)
{
SetALCError(ALC_INVALID_VALUE);
return;
}
- ulBytes = ulSamples * pDevice->FrameSize;
+ ulBytes = ulSamples * frameSize;
// Get Read Offset
ulReadOffset = (pData->ulReadCapturedDataPos % pData->ulCapturedDataSize);
@@ -399,7 +404,8 @@ static ALCuint WinMMAvailableSamples(ALCdevice *pDevice)
{
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
ALCuint lCapturedBytes = (pData->ulWriteCapturedDataPos - pData->ulReadCapturedDataPos);
- return lCapturedBytes / pDevice->FrameSize;
+ return lCapturedBytes / (aluBytesFromFormat(pDevice->Format) *
+ aluChannelsFromFormat(pDevice->Format));
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index a833be5e..0aafe1ad 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -140,7 +140,6 @@ struct ALCdevice_struct
ALuint Frequency;
ALuint UpdateSize;
- ALuint FrameSize;
ALenum Format;
ALCchar *szDeviceName;