Skip to content

Commit

Permalink
removed leftover
Browse files Browse the repository at this point in the history
  • Loading branch information
tillt committed Sep 21, 2024
1 parent 4a097fd commit 0031f36
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 246 deletions.
245 changes: 0 additions & 245 deletions PlayEm/Audio/AudioController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -128,180 +128,6 @@ AudioObjectID defaultOutputDevice(void)

return deviceId;
}
/*
airplayOutputDeviceArray()
{
AudioObjectPropertyAddress addr;
UInt32 propsize;
// target all available audio devices
addr.mSelector = kAudioHardwarePropertyDevices;
addr.mScope = kAudioObjectPropertyScopeWildcard;
addr.mElement = kAudioObjectPropertyElementWildcard;
// get size of available data
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr, 0, NULL, &propsize);
int nDevices = propsize / sizeof(AudioDeviceID);
AudioDeviceID *devids = malloc(propsize);
// get actual device id array data
AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &propsize, devids);
// target device transport type property
addr.mSelector = kAudioDevicePropertyTransportType;
addr.mScope = kAudioObjectPropertyScopeGlobal;
addr.mElement = kAudioObjectPropertyElementMaster;
unsigned int transportType = 0;
propsize = sizeof(transportType);
for (int i=0; i<nDevices; i++) {
AudioObjectGetPropertyData(devids[i], &addr, 0, NULL, &propsize, &transportType);
if (kAudioDeviceTransportTypeAirPlay == transportType) {
// Found AirPlay audio device
}
}
free(devids);
return nil;
}*/

//NSArray* airplayOutputDevices()
//{
// CWWiFiClient *wifiClient = [CWWiFiClient sharedWiFiClient];
// CWInterface *interface = [wifiClient interface];
//
// NSError *error = nil;
// NSSet *availableNetworks = [interface scanForNetworksWithSSID:nil error:&error];
//
// if (error) {
// NSLog(@"Error scanning for networks: %@", [error localizedDescription]);
// } else {
// for (CWNetwork* network in availableNetworks) {
// NSLog(@"network %@", network);
//// if ([network isAirPlayCapable]) { // Assuming 'supportsAirPlay' is the equivalent method for 'isAirPlayCapable'
//// NSLog(@"AirPlay-capable device found: %@", [network ssid]);
//// }
// }
// }
// return nil;
//}

NSArray<NSNumber*>* outputDeviceArray()
{
AudioObjectPropertyAddress propertyAddress = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeWildcard,
kAudioObjectPropertyElementWildcard
};

UInt32 dataSize = 0;
OSStatus status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
&propertyAddress,
0,
NULL,
&dataSize);
if(kAudioHardwareNoError != status) {
fprintf(stderr, "AudioObjectGetPropertyDataSize (kAudioHardwarePropertyDevices) failed: %i\n", status);
return nil;
}

UInt32 deviceCount = static_cast<UInt32>(dataSize / sizeof(AudioDeviceID));

AudioDeviceID* audioDevices = static_cast<AudioDeviceID *>(malloc(dataSize));
if(NULL == audioDevices) {
fputs("Unable to allocate memory", stderr);
return nil;
}

status = AudioObjectGetPropertyData(kAudioObjectSystemObject,
&propertyAddress,
0,
NULL,
&dataSize,
audioDevices);
if(kAudioHardwareNoError != status) {
fprintf(stderr, "AudioObjectGetPropertyData (kAudioHardwarePropertyDevices) failed: %i\n", status);
free(audioDevices), audioDevices = NULL;
return nil;
}

NSMutableArray<NSNumber*>* deviceList = [NSMutableArray array];

CFMutableArrayRef outputDeviceArray = CFArrayCreateMutable(kCFAllocatorDefault,
deviceCount,
&kCFTypeArrayCallBacks);
if(NULL == outputDeviceArray) {
fputs("CFArrayCreateMutable failed", stderr);
free(audioDevices), audioDevices = NULL;
return nil;
}

propertyAddress.mSelector = kAudioDevicePropertyTransportType;
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
propertyAddress.mElement = kAudioObjectPropertyElementMaster;

unsigned int transportType = 0;
dataSize = sizeof(transportType);

for (int i = 0; i < deviceCount; i++) {
AudioObjectGetPropertyData(audioDevices[i],
&propertyAddress,
0,
NULL,
&dataSize,
&transportType);
NSLog(@"device ID %d", audioDevices[i]);

NSString* name = deviceName(audioDevices[i]);
NSLog(@"device name %@", name);

if (kAudioDeviceTransportTypeAirPlay == transportType) {
// Found AirPlay audio device
NSLog(@"airplay device!!!");
}
}


// Iterate through all the devices and determine which are output-capable

// NSLog(@"device UID %@", deviceUID);


// Determine if the device is an output device (it is an input device if it has input channels)
// dataSize = 0;
// propertyAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
// status = AudioObjectGetPropertyDataSize(audioDevices[i], &propertyAddress, 0, NULL, &dataSize);
// if(kAudioHardwareNoError != status) {
// fprintf(stderr, "AudioObjectGetPropertyDataSize (kAudioDevicePropertyStreamConfiguration) failed: %i\n", status);
// continue;
// }

// AudioBufferList *bufferList = static_cast<AudioBufferList *>(malloc(dataSize));
// if(NULL == bufferList) {
// fputs("Unable to allocate memory", stderr);
// break;
// }
//
// status = AudioObjectGetPropertyData(audioDevices[i], &propertyAddress, 0, NULL, &dataSize, bufferList);
// if(kAudioHardwareNoError != status || 0 == bufferList->mNumberBuffers) {
// if(kAudioHardwareNoError != status)
// fprintf(stderr, "AudioObjectGetPropertyData (kAudioDevicePropertyStreamConfiguration) failed: %i\n", status);
// free(bufferList), bufferList = NULL;
// continue;
// }

// free(bufferList), bufferList = NULL;
// }

free(audioDevices), audioDevices = NULL;

// Return a non-mutable copy of the array

//return copy;
return nil;
}

#ifdef support_audioqueueplayback
AVAudioFramePosition currentFrame(AudioQueueRef queue, AudioContext* context)
Expand Down Expand Up @@ -918,63 +744,6 @@ - (NSArray*)createBuffersWithFormat:(AVAudioFormat*)format
return buffers;
}

//- (BOOL)bufferCallback:(AVAudioPCMBuffer*)buffer
//{
// os_signpost_interval_begin(pointsOfInterest, POIAudioBufferCallback, "AudioBufferCallback");
//
// NSLog(@"buffer : %@", buffer);
// //dispatch_semaphore_wait(context->semaphore, DISPATCH_TIME_FOREVER);
// unsigned int frames = buffer.frameCapacity;
//
// float* output[2];
//
// output[0] = buffer.floatChannelData[0];
// output[1] = buffer.floatChannelData[1];
// unsigned long long fetched = [_context.sample rawSampleFromFrameOffset:_context.nextFrame
// frames:frames
// outputs:output];
// _context.nextFrame += fetched;
//
// if (fetched == 0) {
// NSLog(@"reached end of stream at %lld", _context.nextFrame);
// return NO;
// }
//
// [_player scheduleBuffer:buffer completionHandler:^{
// [self bufferCallback:buffer];
// }];
//
// os_signpost_interval_end(pointsOfInterest, POIAudioBufferCallback, "AudioBufferCallback");
// return YES;
//}

//- (BOOL)processBuffers
//{
// //dispatch_semaphore_wait(context->semaphore, DISPATCH_TIME_FOREVER);
// unsigned int frames = buffer.frameCapacity;
//
// float* output[2];
//
// output[0] = buffer.floatChannelData[0];
// output[1] = buffer.floatChannelData[1];
// unsigned long long fetched = [_context.sample rawSampleFromFrameOffset:_context.nextFrame
// frames:frames
// outputs:output];
// _context.nextFrame += fetched;
//
// if (fetched == 0) {
// NSLog(@"reached end of stream at %lld", _context.nextFrame);
// return NO;
// }
//
// [_player scheduleBuffer:buffer completionHandler:^{
// [self bufferCallback:buffer];
// }];
//
// os_signpost_interval_end(pointsOfInterest, POIAudioBufferCallback, "AudioBufferCallback");
// return YES;
//}

void LogBufferContents(const uint8_t *buffer, size_t length)
{
NSMutableString *bufferString = [NSMutableString stringWithCapacity:length * 3];
Expand Down Expand Up @@ -1174,16 +943,6 @@ - (void)setSample:(LazySample*)sample
return;
}

//- (void)checkRoute
//{
// Class MPAVRoutingController = NSClassFromString(@"MPAVRoutingController");
// Class MPAVRoute = NSClassFromString(@"MPAVRoute");
//
// id routingController = [[MPAVRoutingController alloc] init];
// NSArray* availableRoutes = [routingController performSelector:@selector(availableRoutes)];
//
//}

- (void)decodeAbortWithCallback:(void (^)(void))callback
{
if (_decodeOperation != NULL) {
Expand Down Expand Up @@ -1249,10 +1008,6 @@ - (BOOL)decode:(LazySample*)sample cancelTest:(BOOL (^)(void))cancelTest
to:engine.outputNode
format:sample.source.processingFormat];

// [engine connect:engine.mainMixerNode
// format:sample.source.processingFormat];


NSLog(@"starting engine...");
if (![engine startAndReturnError:&error]) {
NSLog(@"startAndReturnError failed: %@\n", error);
Expand Down
2 changes: 1 addition & 1 deletion PlayEm/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<key>CFBundleShortVersionString</key>
<string>1.5</string>
<key>CFBundleVersion</key>
<string>7902</string>
<string>7903</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit 0031f36

Please sign in to comment.