aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-25 16:38:37 -0800
committerChris Robinson <[email protected]>2008-01-25 16:38:37 -0800
commit5f1c0450b328f77d637690e2221a9de21d909811 (patch)
treeab1a73f46ecb814b21359995c511b53acaff751f /Alc
parent04b62f77e37335be68d3e8c04c2cc7a354aef18c (diff)
Remove unnecessary Channels field
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c9
-rw-r--r--Alc/alsa.c4
-rw-r--r--Alc/dsound.c2
-rw-r--r--Alc/oss.c55
-rw-r--r--Alc/winmm.c4
5 files changed, 20 insertions, 54 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index bca519e2..b485ec2e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -430,9 +430,8 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
pDevice->Frequency = frequency;
pDevice->Format = format;
- pDevice->Channels = aluChannelsFromFormat(format);
pDevice->FrameSize = aluBytesFromFormat(format) *
- pDevice->Channels;
+ aluChannelsFromFormat(format);
for(i = 0;BackendList[i].Init;i++)
{
@@ -1141,16 +1140,14 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
if(fmt[0])
device->Format = alGetEnumValue(fmt);
- device->Channels = aluChannelsFromFormat(device->Format);
- if(!device->Channels)
+ if(!aluChannelsFromFormat(device->Format))
{
device->Format = AL_FORMAT_STEREO16;
- device->Channels = 2;
device->FrameSize = 4;
}
else
device->FrameSize = aluBytesFromFormat(device->Format) *
- device->Channels;
+ aluChannelsFromFormat(device->Format);
device->UpdateFreq = GetConfigValueInt(NULL, "refresh", 8192);
if((ALint)device->UpdateFreq <= 0)
diff --git a/Alc/alsa.c b/Alc/alsa.c
index d00902c4..1bd5c9b5 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -375,7 +375,7 @@ open_alsa:
/* set format (implicitly sets sample bits) */
ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, data->format), "set format") &&
/* set channels (implicitly sets frame bits) */
- ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, device->Channels), "set channels") &&
+ ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, aluChannelsFromFormat(device->Format)), "set channels") &&
/* set periods (implicitly constrains period/buffer parameters) */
(!periods || ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near")) &&
/* set rate (implicitly constrains period/buffer parameters) */
@@ -551,7 +551,7 @@ open_alsa:
/* set format (implicitly sets sample bits) */
ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, alsaFormat), "set format") &&
/* set channels (implicitly sets frame bits) */
- ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, pDevice->Channels), "set channels") &&
+ ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, aluChannelsFromFormat(pDevice->Format)), "set channels") &&
/* set rate (implicitly constrains period/buffer parameters) */
ok(psnd_pcm_hw_params_set_rate(data->pcmHandle, p, frequency, 0), "set rate") &&
/* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */
diff --git a/Alc/dsound.c b/Alc/dsound.c
index b5796fd9..a05c4034 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -199,7 +199,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
}
OutputType.wFormatTag = WAVE_FORMAT_PCM;
- OutputType.nChannels = device->Channels;
+ OutputType.nChannels = aluChannelsFromFormat(device->Format);
OutputType.wBitsPerSample = aluBytesFromFormat(device->Format) * 8;
OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8;
OutputType.nSamplesPerSec = device->Frequency;
diff --git a/Alc/oss.c b/Alc/oss.c
index f538d4b6..10591b79 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -195,7 +195,7 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
periods = GetConfigValueInt("oss", "periods", 4);
if((int)periods <= 0)
periods = 4;
- numChannels = device->Channels;
+ numChannels = aluChannelsFromFormat(device->Format);
ossSpeed = device->Frequency;
log2FragmentSize = log2i(device->UpdateFreq * device->FrameSize / periods);
@@ -220,9 +220,9 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
device->Frequency = ossSpeed;
- if((int)device->Channels != numChannels)
+ if((int)aluChannelsFromFormat(device->Format) != numChannels)
{
- AL_PRINT("Could not set %d channels, got %d instead\n", device->Channels, numChannels);
+ AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels);
close(data->fd);
free(data);
return ALC_FALSE;
@@ -319,7 +319,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName,
}
periods = 4;
- numChannels = device->Channels;
+ numChannels = aluChannelsFromFormat(device->Format);
ossSpeed = frequency;
log2FragmentSize = log2i(device->UpdateFreq * device->FrameSize / periods);
@@ -342,49 +342,18 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName,
}
#undef ok
- device->Channels = numChannels;
- device->Frequency = ossSpeed;
- device->Format = 0;
- if(ossFormat == AFMT_U8)
- {
- if(device->Channels == 1)
- {
- device->Format = AL_FORMAT_MONO8;
- device->FrameSize = 1;
- }
- else if(device->Channels == 2)
- {
- device->Format = AL_FORMAT_STEREO8;
- device->FrameSize = 2;
- }
- else if(device->Channels == 4)
- {
- device->Format = AL_FORMAT_QUAD8;
- device->FrameSize = 4;
- }
- }
- else if(ossFormat == AFMT_S16_NE)
+ if((int)aluChannelsFromFormat(device->Format) != numChannels)
{
- if(device->Channels == 1)
- {
- device->Format = AL_FORMAT_MONO16;
- device->FrameSize = 2;
- }
- else if(device->Channels == 2)
- {
- device->Format = AL_FORMAT_STEREO16;
- device->FrameSize = 4;
- }
- else if(device->Channels == 4)
- {
- device->Format = AL_FORMAT_QUAD16;
- device->FrameSize = 8;
- }
+ AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels);
+ close(data->fd);
+ free(data);
+ return ALC_FALSE;
}
- if(!device->Format)
+ if(!((ossFormat == AFMT_U8 && aluBytesFromFormat(device->Format) == 1) ||
+ (ossFormat == AFMT_S16_NE && aluBytesFromFormat(device->Format) == 2)))
{
- AL_PRINT("returned unknown format: %#x %d!\n", ossFormat, numChannels);
+ AL_PRINT("Could not set %d-bit input, got format %#x\n", aluBytesFromFormat(device->Format)*8, ossFormat);
close(data->fd);
free(data);
return ALC_FALSE;
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 17570efc..60f958cb 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -209,8 +209,8 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
memset(&wfexCaptureFormat, 0, sizeof(WAVEFORMATEX));
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
- wfexCaptureFormat.nChannels = pDevice->Channels;
- wfexCaptureFormat.wBitsPerSample = pDevice->FrameSize / pDevice->Channels * 8;
+ wfexCaptureFormat.nChannels = aluChannelsFromFormat(pDevice->Format);
+ wfexCaptureFormat.wBitsPerSample = aluBytesFromFormat(pDevice->Format) * 8;
wfexCaptureFormat.nBlockAlign = pDevice->FrameSize;
wfexCaptureFormat.nSamplesPerSec = frequency;
wfexCaptureFormat.nAvgBytesPerSec = wfexCaptureFormat.nSamplesPerSec *