I don't feel really strongly, but given the choice between OSStatus
and int, I prefer OSStatus since it matches the API return type. It's
one less thing for future code readers to wonder about.
Chip, I think a search-and-replace script will fix this pretty easily.
This seems to work in vim:
:%s/%lx\(.*\), sc/%x\1, (int)sc/
Along with a careful manual review of each change and a check for any
OSStatus not named 'sc'.
Andrew
On Mon, Feb 22, 2016 at 01:00:14AM -0700, Charles Davis wrote:
> Signed-off-by: Charles Davis <cdavis5x(a)gmail.com>
> ---
> Try 2: Go back to casting for AudioDeviceIDs.
>
> The status prints are too numerous. I'm not changing them back to casts.
>
> dlls/winecoreaudio.drv/mmdevdrv.c | 84 +++++++++++++++++++--------------------
> 1 file changed, 42 insertions(+), 42 deletions(-)
>
> diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
> index 60ff3d9..e586c8f 100644
> --- a/dlls/winecoreaudio.drv/mmdevdrv.c
> +++ b/dlls/winecoreaudio.drv/mmdevdrv.c
> @@ -388,7 +388,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> AudioDeviceID *devices;
> AudioDeviceID default_id;
> AudioObjectPropertyAddress addr;
> - OSStatus sc;
> + int sc;
> int i, ndevices;
>
> TRACE("%d %p %p %p\n", flow, ids, num, def_index);
> @@ -406,7 +406,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> sc = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0,
> NULL, &size, &default_id);
> if(sc != noErr){
> - WARN("Getting _DefaultInputDevice property failed: %lx\n", sc);
> + WARN("Getting _DefaultInputDevice property failed: %x\n", sc);
> default_id = -1;
> }
>
> @@ -414,7 +414,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> sc = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr, 0,
> NULL, &devsize);
> if(sc != noErr){
> - WARN("Getting _Devices property size failed: %lx\n", sc);
> + WARN("Getting _Devices property size failed: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
>
> @@ -425,7 +425,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> sc = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL,
> &devsize, devices);
> if(sc != noErr){
> - WARN("Getting _Devices property failed: %lx\n", sc);
> + WARN("Getting _Devices property failed: %x\n", sc);
> HeapFree(GetProcessHeap(), 0, devices);
> return osstatus_to_hresult(sc);
> }
> @@ -462,7 +462,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> sc = AudioObjectGetPropertyDataSize(devices[i], &addr, 0, NULL, &size);
> if(sc != noErr){
> WARN("Unable to get _StreamConfiguration property size for "
> - "device %lu: %lx\n", devices[i], sc);
> + "device %u: %x\n", (unsigned int)devices[i], sc);
> continue;
> }
>
> @@ -480,7 +480,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> &size, buffers);
> if(sc != noErr){
> WARN("Unable to get _StreamConfiguration property for "
> - "device %lu: %lx\n", devices[i], sc);
> + "device %u: %x\n", (unsigned int)devices[i], sc);
> HeapFree(GetProcessHeap(), 0, buffers);
> continue;
> }
> @@ -502,8 +502,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> sc = AudioObjectGetPropertyData(devices[i], &addr, 0, NULL,
> &size, &name);
> if(sc != noErr){
> - WARN("Unable to get _Name property for device %lu: %lx\n",
> - devices[i], sc);
> + WARN("Unable to get _Name property for device %u: %x\n",
> + (unsigned int)devices[i], sc);
> continue;
> }
>
> @@ -528,7 +528,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
> *def_index = *num;
>
> TRACE("device %u: id %s key %u%s\n", *num, debugstr_w((*ids)[*num]),
> - (unsigned int)devices[i], (*def_index == *num) ? " (default)" : "");
> + devices[i], (*def_index == *num) ? " (default)" : "");
>
> (*num)++;
> }
> @@ -607,7 +607,7 @@ static AudioComponentInstance get_audiounit(EDataFlow dataflow, AudioDeviceID ad
> AudioComponentInstance unit;
> AudioComponent comp;
> AudioComponentDescription desc;
> - OSStatus sc;
> + int sc;
>
> memset(&desc, 0, sizeof(desc));
> desc.componentType = kAudioUnitType_Output;
> @@ -621,7 +621,7 @@ static AudioComponentInstance get_audiounit(EDataFlow dataflow, AudioDeviceID ad
>
> sc = AudioComponentInstanceNew(comp, &unit);
> if(sc != noErr){
> - WARN("AudioComponentInstanceNew failed: %lx\n", sc);
> + WARN("AudioComponentInstanceNew failed: %x\n", sc);
> return NULL;
> }
>
> @@ -632,7 +632,7 @@ static AudioComponentInstance get_audiounit(EDataFlow dataflow, AudioDeviceID ad
> sc = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_EnableIO,
> kAudioUnitScope_Input, 1, &enableio, sizeof(enableio));
> if(sc != noErr){
> - WARN("Couldn't enable I/O on input element: %lx\n", sc);
> + WARN("Couldn't enable I/O on input element: %x\n", sc);
> AudioComponentInstanceDispose(unit);
> return NULL;
> }
> @@ -641,7 +641,7 @@ static AudioComponentInstance get_audiounit(EDataFlow dataflow, AudioDeviceID ad
> sc = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_EnableIO,
> kAudioUnitScope_Output, 0, &enableio, sizeof(enableio));
> if(sc != noErr){
> - WARN("Couldn't disable I/O on output element: %lx\n", sc);
> + WARN("Couldn't disable I/O on output element: %x\n", sc);
> AudioComponentInstanceDispose(unit);
> return NULL;
> }
> @@ -1107,7 +1107,7 @@ static OSStatus feed_cb(AudioConverterRef converter, UInt32 *nframes, AudioBuffe
> static void capture_resample(ACImpl *This)
> {
> UINT32 resamp_period_frames = MulDiv(This->period_frames, This->dev_desc.mSampleRate, This->fmt->nSamplesPerSec);
> - OSStatus sc;
> + int sc;
>
> /* the resampling process often needs more source frames than we'd
> * guess from a straight conversion using the sample rate ratio. so
> @@ -1131,7 +1131,7 @@ static void capture_resample(ACImpl *This)
> sc = AudioConverterFillComplexBuffer(This->converter, feed_cb,
> This, &wanted_frames, &converted_list, NULL);
> if(sc != noErr){
> - WARN("AudioConverterFillComplexBuffer failed: %lx\n", sc);
> + WARN("AudioConverterFillComplexBuffer failed: %x\n", sc);
> break;
> }
>
> @@ -1215,18 +1215,18 @@ static OSStatus ca_capture_cb(void *user, AudioUnitRenderActionFlags *flags,
> static void dump_adesc(const char *aux, AudioStreamBasicDescription *desc)
> {
> TRACE("%s: mSampleRate: %f\n", aux, desc->mSampleRate);
> - TRACE("%s: mBytesPerPacket: %ld\n", aux, desc->mBytesPerPacket);
> - TRACE("%s: mFramesPerPacket: %ld\n", aux, desc->mFramesPerPacket);
> - TRACE("%s: mBytesPerFrame: %ld\n", aux, desc->mBytesPerFrame);
> - TRACE("%s: mChannelsPerFrame: %ld\n", aux, desc->mChannelsPerFrame);
> - TRACE("%s: mBitsPerChannel: %ld\n", aux, desc->mBitsPerChannel);
> + TRACE("%s: mBytesPerPacket: %u\n", aux, (unsigned int)desc->mBytesPerPacket);
> + TRACE("%s: mFramesPerPacket: %u\n", aux, (unsigned int)desc->mFramesPerPacket);
> + TRACE("%s: mBytesPerFrame: %u\n", aux, (unsigned int)desc->mBytesPerFrame);
> + TRACE("%s: mChannelsPerFrame: %u\n", aux, (unsigned int)desc->mChannelsPerFrame);
> + TRACE("%s: mBitsPerChannel: %u\n", aux, (unsigned int)desc->mBitsPerChannel);
> }
>
> static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance unit,
> const WAVEFORMATEX *fmt, AudioStreamBasicDescription *dev_desc,
> AudioConverterRef *converter)
> {
> - OSStatus sc;
> + int sc;
> HRESULT hr;
>
> if(dataflow == eCapture){
> @@ -1245,7 +1245,7 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
> sc = AudioUnitGetProperty(unit, kAudioUnitProperty_StreamFormat,
> kAudioUnitScope_Input, 1, dev_desc, &size);
> if(sc != noErr){
> - WARN("Couldn't get unit format: %lx\n", sc);
> + WARN("Couldn't get unit format: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
> dump_adesc("hardware", dev_desc);
> @@ -1258,13 +1258,13 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
> sc = AudioUnitSetProperty(unit, kAudioUnitProperty_StreamFormat,
> kAudioUnitScope_Output, 1, dev_desc, sizeof(*dev_desc));
> if(sc != noErr){
> - WARN("Couldn't set unit format: %lx\n", sc);
> + WARN("Couldn't set unit format: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
>
> sc = AudioConverterNew(dev_desc, &desc, converter);
> if(sc != noErr){
> - WARN("Couldn't create audio converter: %lx\n", sc);
> + WARN("Couldn't create audio converter: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
> }else{
> @@ -1276,7 +1276,7 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
> sc = AudioUnitSetProperty(unit, kAudioUnitProperty_StreamFormat,
> kAudioUnitScope_Input, 0, dev_desc, sizeof(*dev_desc));
> if(sc != noErr){
> - WARN("Couldn't set format: %lx\n", sc);
> + WARN("Couldn't set format: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
> }
> @@ -1291,7 +1291,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
> {
> ACImpl *This = impl_from_IAudioClient(iface);
> HRESULT hr;
> - OSStatus sc;
> + int sc;
> int i;
>
> TRACE("(%p)->(%x, %x, %s, %s, %p, %s)\n", This, mode, flags,
> @@ -1383,7 +1383,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
> sc = AudioUnitSetProperty(This->unit, kAudioOutputUnitProperty_SetInputCallback,
> kAudioUnitScope_Output, 1, &input, sizeof(input));
> if(sc != noErr){
> - WARN("Couldn't set callback: %lx\n", sc);
> + WARN("Couldn't set callback: %x\n", sc);
> AudioConverterDispose(This->converter);
> This->converter = NULL;
> CoTaskMemFree(This->fmt);
> @@ -1401,7 +1401,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
> sc = AudioUnitSetProperty(This->unit, kAudioUnitProperty_SetRenderCallback,
> kAudioUnitScope_Input, 0, &input, sizeof(input));
> if(sc != noErr){
> - WARN("Couldn't set callback: %lx\n", sc);
> + WARN("Couldn't set callback: %x\n", sc);
> CoTaskMemFree(This->fmt);
> This->fmt = NULL;
> OSSpinLockUnlock(&This->lock);
> @@ -1411,7 +1411,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
>
> sc = AudioUnitInitialize(This->unit);
> if(sc != noErr){
> - WARN("Couldn't initialize: %lx\n", sc);
> + WARN("Couldn't initialize: %x\n", sc);
> if(This->converter){
> AudioConverterDispose(This->converter);
> This->converter = NULL;
> @@ -1426,7 +1426,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
> * a while to return */
> sc = AudioOutputUnitStart(This->unit);
> if(sc != noErr){
> - WARN("Unit failed to start: %lx\n", sc);
> + WARN("Unit failed to start: %x\n", sc);
> if(This->converter){
> AudioConverterDispose(This->converter);
> This->converter = NULL;
> @@ -1515,7 +1515,7 @@ static HRESULT ca_get_max_stream_latency(ACImpl *This, UInt32 *max)
> AudioObjectPropertyAddress addr;
> AudioStreamID *ids;
> UInt32 size;
> - OSStatus sc;
> + int sc;
> int nstreams, i;
>
> addr.mScope = This->scope;
> @@ -1525,7 +1525,7 @@ static HRESULT ca_get_max_stream_latency(ACImpl *This, UInt32 *max)
> sc = AudioObjectGetPropertyDataSize(This->adevid, &addr, 0, NULL,
> &size);
> if(sc != noErr){
> - WARN("Unable to get size for _Streams property: %lx\n", sc);
> + WARN("Unable to get size for _Streams property: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
>
> @@ -1535,7 +1535,7 @@ static HRESULT ca_get_max_stream_latency(ACImpl *This, UInt32 *max)
>
> sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL, &size, ids);
> if(sc != noErr){
> - WARN("Unable to get _Streams property: %lx\n", sc);
> + WARN("Unable to get _Streams property: %x\n", sc);
> HeapFree(GetProcessHeap(), 0, ids);
> return osstatus_to_hresult(sc);
> }
> @@ -1551,7 +1551,7 @@ static HRESULT ca_get_max_stream_latency(ACImpl *This, UInt32 *max)
> sc = AudioObjectGetPropertyData(ids[i], &addr, 0, NULL,
> &size, &latency);
> if(sc != noErr){
> - WARN("Unable to get _Latency property: %lx\n", sc);
> + WARN("Unable to get _Latency property: %x\n", sc);
> continue;
> }
>
> @@ -1570,7 +1570,7 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient *iface,
> ACImpl *This = impl_from_IAudioClient(iface);
> UInt32 latency, stream_latency, size;
> AudioObjectPropertyAddress addr;
> - OSStatus sc;
> + int sc;
> HRESULT hr;
>
> TRACE("(%p)->(%p)\n", This, out);
> @@ -1593,7 +1593,7 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient *iface,
> sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL,
> &size, &latency);
> if(sc != noErr){
> - WARN("Couldn't get _Latency property: %lx\n", sc);
> + WARN("Couldn't get _Latency property: %x\n", sc);
> OSSpinLockUnlock(&This->lock);
> return osstatus_to_hresult(sc);
> }
> @@ -1730,7 +1730,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
> {
> ACImpl *This = impl_from_IAudioClient(iface);
> WAVEFORMATEXTENSIBLE *fmt;
> - OSStatus sc;
> + int sc;
> UInt32 size;
> Float64 rate;
> AudioBufferList *buffers;
> @@ -1756,7 +1756,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
> sc = AudioObjectGetPropertyDataSize(This->adevid, &addr, 0, NULL, &size);
> if(sc != noErr){
> CoTaskMemFree(fmt);
> - WARN("Unable to get size for _StreamConfiguration property: %lx\n", sc);
> + WARN("Unable to get size for _StreamConfiguration property: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
>
> @@ -1771,7 +1771,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
> if(sc != noErr){
> CoTaskMemFree(fmt);
> HeapFree(GetProcessHeap(), 0, buffers);
> - WARN("Unable to get _StreamConfiguration property: %lx\n", sc);
> + WARN("Unable to get _StreamConfiguration property: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
>
> @@ -1788,7 +1788,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
> sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL, &size, &rate);
> if(sc != noErr){
> CoTaskMemFree(fmt);
> - WARN("Unable to get _NominalSampleRate property: %lx\n", sc);
> + WARN("Unable to get _NominalSampleRate property: %x\n", sc);
> return osstatus_to_hresult(sc);
> }
> fmt->Format.nSamplesPerSec = rate;
> @@ -2820,7 +2820,7 @@ static const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl =
> static HRESULT ca_setvol(ACImpl *This, UINT32 index)
> {
> Float32 level;
> - OSStatus sc;
> + int sc;
>
> if(This->session->mute)
> level = 0.;
> @@ -2842,7 +2842,7 @@ static HRESULT ca_setvol(ACImpl *This, UINT32 index)
> sc = AudioUnitSetParameter(This->unit, kHALOutputParam_Volume,
> kAudioUnitScope_Global, 0, level, 0);
> if(sc != noErr)
> - WARN("Couldn't set volume: %lx\n", sc);
> + WARN("Couldn't set volume: %x\n", sc);
>
> return S_OK;
> }
> --
> 2.7.1
>
>
>