Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

conventions: prefer calling `sizeof` on variable over type

  • Loading branch information...
commit d258bfd1e95cae2a8abc491308f3e533671fd97f 1 parent f5ca6dd
Patrick Ellis authored
Showing with 9 additions and 10 deletions.
  1. +9 −10 App/AppController.mm
19 App/AppController.mm
View
@@ -29,8 +29,7 @@ - (void)rebuildDeviceList{
UInt32 propsize;
AudioObjectPropertyAddress theAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &theAddress, 0, NULL,&propsize);
- int audioDeviceIDSize = sizeof(AudioDeviceID);
- int nDevices = propsize / audioDeviceIDSize;
+ int nDevices = propsize / sizeof(AudioDeviceID);
AudioDeviceID *devids = new AudioDeviceID[nDevices];
AudioObjectGetPropertyData(kAudioObjectSystemObject, &theAddress, 0, NULL, &propsize, devids);
for (int i = 0; i < nDevices; ++i) {
@@ -115,31 +114,31 @@ - (void)setToggleRecordHotKey:(NSString*)keyEquivalent {
- (void)initConnections {
Float32 maxVolume = 1.0;
- UInt32 size = sizeof(AudioDeviceID);
+ UInt32 size = sizeof(mStashedAudioDeviceID);
AudioObjectPropertyAddress devCurrDefAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
AudioObjectGetPropertyData(kAudioObjectSystemObject, &devCurrDefAddress, 0, NULL, &size, &mStashedAudioDeviceID);
mOutputDeviceID = mStashedAudioDeviceID;
AudioObjectPropertyAddress volCurrDef1Address = { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, 1 };
- size = sizeof(Float32);
+ size = sizeof(mStashedVolume);
AudioObjectGetPropertyData(mStashedAudioDeviceID, &volCurrDef1Address, 0, NULL, &size, &mStashedVolume);
AudioObjectPropertyAddress volCurrDef2Address = { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, 2 };
- size = sizeof(Float32);
+ size = sizeof(mStashedVolume2);
AudioObjectGetPropertyData(mStashedAudioDeviceID, &volCurrDef2Address, 0, NULL, &size, &mStashedVolume2);
mEngine = new AudioTee(mWavTapDeviceID, mOutputDeviceID);
AudioObjectPropertyAddress volSwapWav0Address = { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, 0 };
- AudioObjectSetPropertyData(mWavTapDeviceID, &volSwapWav0Address, 0, NULL, sizeof(Float32), &maxVolume);
+ AudioObjectSetPropertyData(mWavTapDeviceID, &volSwapWav0Address, 0, NULL, sizeof(maxVolume), &maxVolume);
AudioObjectPropertyAddress volSwapWav1Address = { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, 1 };
- AudioObjectSetPropertyData(mWavTapDeviceID, &volSwapWav1Address, 0, NULL, sizeof(Float32), &maxVolume);
+ AudioObjectSetPropertyData(mWavTapDeviceID, &volSwapWav1Address, 0, NULL, sizeof(maxVolume), &maxVolume);
AudioObjectPropertyAddress volSwapWav2Address = { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, 2 };
- AudioObjectSetPropertyData(mWavTapDeviceID, &volSwapWav2Address, 0, NULL, sizeof(Float32), &maxVolume);
+ AudioObjectSetPropertyData(mWavTapDeviceID, &volSwapWav2Address, 0, NULL, sizeof(maxVolume), &maxVolume);
mEngine->start();
- AudioObjectSetPropertyData(kAudioObjectSystemObject, &devCurrDefAddress, 0, NULL, sizeof(AudioDeviceID), &mWavTapDeviceID);
+ AudioObjectSetPropertyData(kAudioObjectSystemObject, &devCurrDefAddress, 0, NULL, sizeof(mWavTapDeviceID), &mWavTapDeviceID);
}
- (OSStatus)restoreSystemOutputDevice {
OSStatus err = noErr;
AudioObjectPropertyAddress devAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
- err = AudioObjectSetPropertyData(kAudioObjectSystemObject, &devAddress, 0, NULL, sizeof(AudioDeviceID), &mStashedAudioDeviceID);
+ err = AudioObjectSetPropertyData(kAudioObjectSystemObject, &devAddress, 0, NULL, sizeof(mStashedAudioDeviceID), &mStashedAudioDeviceID);
return err;
}
Please sign in to comment.
Something went wrong with that request. Please try again.