- renamed main_volume to speaker_volume and dac_volume to main_volume

(same for mute)
- added defines for headphone volume/mute
This commit is contained in:
cebix 1999-10-20 15:14:00 +00:00
parent 9818250a47
commit 00aabbe812
9 changed files with 84 additions and 58 deletions

View File

@ -279,12 +279,12 @@ uint32 audio_get_main_volume(void)
return 0x01000100; return 0x01000100;
} }
bool audio_get_dac_mute(void) bool audio_get_speaker_mute(void)
{ {
return false; return false;
} }
uint32 audio_get_dac_volume(void) uint32 audio_get_speaker_volume(void)
{ {
return 0x01000100; return 0x01000100;
} }
@ -297,10 +297,10 @@ void audio_set_main_volume(uint32 vol)
{ {
} }
void audio_set_dac_mute(bool mute) void audio_set_speaker_mute(bool mute)
{ {
} }
void audio_set_dac_volume(uint32 vol) void audio_set_speaker_volume(uint32 vol)
{ {
} }

View File

@ -306,12 +306,12 @@ uint32 audio_get_main_volume(void)
return 0x01000100; return 0x01000100;
} }
bool audio_get_dac_mute(void) bool audio_get_speaker_mute(void)
{ {
return false; return false;
} }
uint32 audio_get_dac_volume(void) uint32 audio_get_speaker_volume(void)
{ {
return 0x01000100; return 0x01000100;
} }
@ -329,10 +329,10 @@ void audio_set_main_volume(uint32 vol)
} }
} }
void audio_set_dac_mute(bool mute) void audio_set_speaker_mute(bool mute)
{ {
} }
void audio_set_dac_volume(uint32 vol) void audio_set_speaker_volume(uint32 vol)
{ {
} }

View File

@ -315,7 +315,7 @@ uint32 audio_get_main_volume(void)
{ {
if (mixer_fd >= 0) { if (mixer_fd >= 0) {
int vol; int vol;
if (ioctl(mixer_fd, SOUND_MIXER_READ_VOLUME, &vol) == 0) { if (ioctl(mixer_fd, SOUND_MIXER_READ_PCM, &vol) == 0) {
int left = vol >> 8; int left = vol >> 8;
int right = vol & 0xff; int right = vol & 0xff;
return ((left * 256 / 100) << 16) | (right * 256 / 100); return ((left * 256 / 100) << 16) | (right * 256 / 100);
@ -324,16 +324,16 @@ uint32 audio_get_main_volume(void)
return 0x01000100; return 0x01000100;
} }
bool audio_get_dac_mute(void) bool audio_get_speaker_mute(void)
{ {
return false; return false;
} }
uint32 audio_get_dac_volume(void) uint32 audio_get_speaker_volume(void)
{ {
if (mixer_fd >= 0) { if (mixer_fd >= 0) {
int vol; int vol;
if (ioctl(mixer_fd, SOUND_MIXER_READ_PCM, &vol) == 0) { if (ioctl(mixer_fd, SOUND_MIXER_READ_SPEAKER, &vol) == 0) {
int left = vol >> 8; int left = vol >> 8;
int right = vol & 0xff; int right = vol & 0xff;
return ((left * 256 / 100) << 16) | (right * 256 / 100); return ((left * 256 / 100) << 16) | (right * 256 / 100);
@ -352,20 +352,20 @@ void audio_set_main_volume(uint32 vol)
int left = vol >> 16; int left = vol >> 16;
int right = vol & 0xffff; int right = vol & 0xffff;
int p = ((left * 100 / 256) << 8) | (right * 100 / 256); int p = ((left * 100 / 256) << 8) | (right * 100 / 256);
ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &p); ioctl(mixer_fd, SOUND_MIXER_WRITE_PCM, &p);
} }
} }
void audio_set_dac_mute(bool mute) void audio_set_speaker_mute(bool mute)
{ {
} }
void audio_set_dac_volume(uint32 vol) void audio_set_speaker_volume(uint32 vol)
{ {
if (mixer_fd >= 0) { if (mixer_fd >= 0) {
int left = vol >> 16; int left = vol >> 16;
int right = vol & 0xffff; int right = vol & 0xffff;
int p = ((left * 100 / 256) << 8) | (right * 100 / 256); int p = ((left * 100 / 256) << 8) | (right * 100 / 256);
ioctl(mixer_fd, SOUND_MIXER_WRITE_PCM, &p); ioctl(mixer_fd, SOUND_MIXER_WRITE_SPEAKER, &p);
} }
} }

View File

@ -296,12 +296,12 @@ uint32 audio_get_main_volume(void)
return 0x01000100; return 0x01000100;
} }
bool audio_get_dac_mute(void) bool audio_get_speaker_mute(void)
{ {
return false; return false;
} }
uint32 audio_get_dac_volume(void) uint32 audio_get_speaker_volume(void)
{ {
return 0x01000100; return 0x01000100;
} }
@ -314,10 +314,10 @@ void audio_set_main_volume(uint32 vol)
{ {
} }
void audio_set_dac_mute(bool mute) void audio_set_speaker_mute(bool mute)
{ {
} }
void audio_set_dac_volume(uint32 vol) void audio_set_speaker_volume(uint32 vol)
{ {
} }

View File

@ -113,29 +113,41 @@ static int32 AudioGetInfo(uint32 infoPtr, uint32 selector, uint32 sourceID)
} }
case siSpeakerMute: case siSpeakerMute:
WriteMacInt16(infoPtr, audio_get_main_mute()); WriteMacInt16(infoPtr, audio_get_speaker_mute());
break; break;
case siSpeakerVolume: case siSpeakerVolume:
WriteMacInt32(infoPtr, audio_get_main_volume()); WriteMacInt32(infoPtr, audio_get_speaker_volume());
break;
case siHeadphoneMute:
WriteMacInt16(infoPtr, 0);
break;
case siHeadphoneVolume:
WriteMacInt32(infoPtr, 0x01000100);
break;
case siHeadphoneVolumeSteps:
WriteMacInt16(infoPtr, 13);
break; break;
case siHardwareMute: case siHardwareMute:
WriteMacInt16(infoPtr, audio_get_dac_mute()); WriteMacInt16(infoPtr, audio_get_main_mute());
break; break;
case siHardwareVolume: case siHardwareVolume:
WriteMacInt32(infoPtr, audio_get_dac_volume()); WriteMacInt32(infoPtr, audio_get_main_volume());
break;
case siHardwareVolumeSteps:
WriteMacInt16(infoPtr, 13);
break; break;
case siHardwareBusy: case siHardwareBusy:
WriteMacInt16(infoPtr, AudioStatus.num_sources != 0); WriteMacInt16(infoPtr, AudioStatus.num_sources != 0);
break; break;
case siHardwareVolumeSteps:
WriteMacInt16(infoPtr, 64);
break;
default: // Delegate to Apple Mixer default: // Delegate to Apple Mixer
if (AudioStatus.mixer == 0) if (AudioStatus.mixer == 0)
return badComponentSelector; return badComponentSelector;
@ -197,21 +209,25 @@ static int32 AudioSetInfo(uint32 infoPtr, uint32 selector, uint32 sourceID)
return badChannel; return badChannel;
case siSpeakerMute: case siSpeakerMute:
audio_set_main_mute((uint16)infoPtr); audio_set_speaker_mute((uint16)infoPtr);
break; break;
case siSpeakerVolume: case siSpeakerVolume:
D(bug(" set speaker volume %08lx\n", infoPtr)); D(bug(" set speaker volume %08lx\n", infoPtr));
audio_set_main_volume(infoPtr); audio_set_speaker_volume(infoPtr);
break;
case siHeadphoneMute:
case siHeadphoneVolume:
break; break;
case siHardwareMute: case siHardwareMute:
audio_set_dac_mute((uint16)infoPtr); audio_set_main_mute((uint16)infoPtr);
break; break;
case siHardwareVolume: case siHardwareVolume:
D(bug(" set hardware volume %08lx\n", infoPtr)); D(bug(" set hardware volume %08lx\n", infoPtr));
audio_set_dac_volume(infoPtr); audio_set_main_volume(infoPtr);
break; break;
default: // Delegate to Apple Mixer default: // Delegate to Apple Mixer
@ -351,7 +367,7 @@ adat_error: printf("FATAL: audio component data block initialization error\n");
return noErr; return noErr;
case kComponentVersionSelect: case kComponentVersionSelect:
return 0x00010002; return 0x00010003;
case kComponentCloseSelect: case kComponentCloseSelect:
open_count--; open_count--;

View File

@ -131,12 +131,12 @@ uint32 audio_get_main_volume(void)
return 0x01000100; return 0x01000100;
} }
bool audio_get_dac_mute(void) bool audio_get_speaker_mute(void)
{ {
return false; return false;
} }
uint32 audio_get_dac_volume(void) uint32 audio_get_speaker_volume(void)
{ {
return 0x01000100; return 0x01000100;
} }
@ -149,10 +149,10 @@ void audio_set_main_volume(uint32 vol)
{ {
} }
void audio_set_dac_mute(bool mute) void audio_set_speaker_mute(bool mute)
{ {
} }
void audio_set_dac_volume(uint32 vol) void audio_set_speaker_volume(uint32 vol)
{ {
} }

View File

@ -19,16 +19,19 @@
*/ */
/* /*
TODO: * SEE ALSO
LockRng * Guide to the File System Manager (from FSM 1.2 SDK)
UnlockRng *
(CatSearch) * TODO
(MakeFSSpec) * LockRng
(GetVolMountInfoSize) * UnlockRng
(GetVolMountInfo) * (CatSearch)
(GetForeignPrivs) * (MakeFSSpec)
(SetForeignPrivs) * (GetVolMountInfoSize)
*/ * (GetVolMountInfo)
* (GetForeignPrivs)
* (SetForeignPrivs)
*/
#include "sysdeps.h" #include "sysdeps.h"
@ -379,15 +382,19 @@ void InstallExtFS(void)
r.d[0] = gestaltFSAttr; r.d[0] = gestaltFSAttr;
Execute68kTrap(0xa1ad, &r); // Gestalt() Execute68kTrap(0xa1ad, &r); // Gestalt()
D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0])); D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0]));
if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) {
printf("WARNING: No FSM present, disabling ExtFS\n");
return; return;
}
// Yes, version >=1.2? // Yes, version >=1.2?
r.d[0] = gestaltFSMVersion; r.d[0] = gestaltFSMVersion;
Execute68kTrap(0xa1ad, &r); // Gestalt() Execute68kTrap(0xa1ad, &r); // Gestalt()
D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0])); D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0]));
if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) {
printf("WARNING: FSM <1.2 found, disabling ExtFS\n");
return; return;
}
D(bug("FSM present\n")); D(bug("FSM present\n"));

View File

@ -40,12 +40,12 @@ extern void audio_set_channels(int index);
extern bool audio_get_main_mute(void); extern bool audio_get_main_mute(void);
extern uint32 audio_get_main_volume(void); extern uint32 audio_get_main_volume(void);
extern bool audio_get_dac_mute(void); extern bool audio_get_speaker_mute(void);
extern uint32 audio_get_dac_volume(void); extern uint32 audio_get_speaker_volume(void);
extern void audio_set_main_mute(bool mute); extern void audio_set_main_mute(bool mute);
extern void audio_set_main_volume(uint32 vol); extern void audio_set_main_volume(uint32 vol);
extern void audio_set_dac_mute(bool mute); extern void audio_set_speaker_mute(bool mute);
extern void audio_set_dac_volume(uint32 vol); extern void audio_set_speaker_volume(uint32 vol);
// Current audio status // Current audio status
struct audio_status { struct audio_status {

View File

@ -60,18 +60,21 @@ enum {
// Sound information selectors // Sound information selectors
enum { enum {
siNumberChannels = 'chan', // current number of channels
siChannelAvailable = 'chav', // number of channels available
siSampleRate = 'srat', // current sample rate siSampleRate = 'srat', // current sample rate
siSampleRateAvailable = 'srav', // sample rates available siSampleRateAvailable = 'srav', // sample rates available
siSampleSize = 'ssiz', // current sample size siSampleSize = 'ssiz', // current sample size
siSampleSizeAvailable = 'ssav', // sample sizes available siSampleSizeAvailable = 'ssav', // sample sizes available
siNumberChannels = 'chan', // current number of channels
siChannelAvailable = 'chav', // number of channels available
siSpeakerMute = 'smut', // mute state of all built-in speaker
siSpeakerVolume = 'svol', // volume level of built-in speaker
siHardwareMute = 'hmut', // mute state of all hardware siHardwareMute = 'hmut', // mute state of all hardware
siHardwareVolume = 'hvol', // volume level of all hardware siHardwareVolume = 'hvol', // volume level of all hardware
siHardwareVolumeSteps = 'hstp', // number of volume steps for hardware siHardwareVolumeSteps = 'hstp', // number of volume steps for hardware
siHardwareBusy = 'hwbs' // sound hardware is in use siHardwareBusy = 'hwbs', // sound hardware is in use
siHeadphoneMute = 'pmut', // mute state of headphone
siHeadphoneVolume = 'pvol', // volume level of headphone
siHeadphoneVolumeSteps = 'hdst', // number of volume steps for headphone
siSpeakerMute = 'smut', // mute state of all built-in speakers
siSpeakerVolume = 'svol' // volume level of built-in speaker
}; };
enum { // ComponentResource struct enum { // ComponentResource struct