mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-22 04:03:19 +00:00
Stop using NSLog in internal functions because it seems to acquire a mutex that violates our locking order and causes deadlocks
This commit is contained in:
parent
dfe2addca2
commit
528b44f2f2
@ -25,7 +25,7 @@ static NSLock *controllerStreamLock;
|
|||||||
GCController *controller = [GCController controllers][i];
|
GCController *controller = [GCController controllers][i];
|
||||||
|
|
||||||
if (controller != NULL) {
|
if (controller != NULL) {
|
||||||
NSLog(@"Controller connected!");
|
printf("Controller connected!\n");
|
||||||
controller.controllerPausedHandler = ^(GCController *controller) {
|
controller.controllerPausedHandler = ^(GCController *controller) {
|
||||||
// We call LiSendControllerEvent while holding a lock to prevent
|
// We call LiSendControllerEvent while holding a lock to prevent
|
||||||
// multiple simultaneous calls since this function isn't thread safe.
|
// multiple simultaneous calls since this function isn't thread safe.
|
||||||
@ -117,7 +117,7 @@ static NSLock *controllerStreamLock;
|
|||||||
[ControllerSupport registerControllerCallbacks];
|
[ControllerSupport registerControllerCallbacks];
|
||||||
}];
|
}];
|
||||||
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||||
NSLog(@"Controller disconnected!");
|
printf("Controller disconnected!\n");
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[ControllerSupport registerControllerCallbacks];
|
[ControllerSupport registerControllerCallbacks];
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
touchLocation = [touch locationInView:self];
|
touchLocation = [touch locationInView:self];
|
||||||
touchMoved = false;
|
touchMoved = false;
|
||||||
|
|
||||||
NSLog(@"Touch down");
|
printf("Touch down\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
@ -38,10 +38,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
NSLog(@"Touch up");
|
printf("Touch up\n");
|
||||||
|
|
||||||
if (!touchMoved) {
|
if (!touchMoved) {
|
||||||
NSLog(@"Sending left mouse button press");
|
printf("Sending left mouse button press\n");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ void ArInit(void)
|
|||||||
status = AudioComponentInstanceNew(AudioComponentFindNext(NULL, &audioDesc), &audioUnit);
|
status = AudioComponentInstanceNew(AudioComponentFindNext(NULL, &audioDesc), &audioUnit);
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to instantiate new AudioComponent: %d", (int32_t)status);
|
printf("Unable to instantiate new AudioComponent: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioStreamBasicDescription audioFormat = {0};
|
AudioStreamBasicDescription audioFormat = {0};
|
||||||
@ -130,7 +130,7 @@ void ArInit(void)
|
|||||||
&audioFormat,
|
&audioFormat,
|
||||||
sizeof(audioFormat));
|
sizeof(audioFormat));
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to set audio unit to input: %d", (int32_t)status);
|
printf("Unable to set audio unit to input: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AURenderCallbackStruct callbackStruct = {0};
|
AURenderCallbackStruct callbackStruct = {0};
|
||||||
@ -144,12 +144,12 @@ void ArInit(void)
|
|||||||
&callbackStruct,
|
&callbackStruct,
|
||||||
sizeof(callbackStruct));
|
sizeof(callbackStruct));
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to set audio unit callback: %d", (int32_t)status);
|
printf("Unable to set audio unit callback: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = AudioUnitInitialize(audioUnit);
|
status = AudioUnitInitialize(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to initialize audioUnit: %d", (int32_t)status);
|
printf("Unable to initialize audioUnit: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ void ArRelease(void)
|
|||||||
|
|
||||||
OSStatus status = AudioUnitUninitialize(audioUnit);
|
OSStatus status = AudioUnitUninitialize(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to uninitialize audioUnit: %d", (int32_t)status);
|
printf("Unable to uninitialize audioUnit: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio session is now inactive
|
// Audio session is now inactive
|
||||||
@ -184,7 +184,7 @@ void ArStart(void)
|
|||||||
{
|
{
|
||||||
OSStatus status = AudioOutputUnitStart(audioUnit);
|
OSStatus status = AudioOutputUnitStart(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to start audioUnit: %d", (int32_t)status);
|
printf("Unable to start audioUnit: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ void ArStop(void)
|
|||||||
{
|
{
|
||||||
OSStatus status = AudioOutputUnitStop(audioUnit);
|
OSStatus status = AudioOutputUnitStop(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to stop audioUnit: %d", (int32_t)status);
|
printf("Unable to stop audioUnit: %d\n", (int32_t)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ void ArDecodeAndPlaySample(char* sampleData, int sampleLength)
|
|||||||
|
|
||||||
[audioLock lock];
|
[audioLock lock];
|
||||||
if (audioBufferQueueLength > MAX_QUEUE_ENTRIES) {
|
if (audioBufferQueueLength > MAX_QUEUE_ENTRIES) {
|
||||||
NSLog(@"Audio player too slow. Dropping all decoded samples!");
|
printf("Audio player too slow. Dropping all decoded samples!\n");
|
||||||
|
|
||||||
// Clear all values from the buffer queue
|
// Clear all values from the buffer queue
|
||||||
struct AUDIO_BUFFER_QUEUE_ENTRY *entry;
|
struct AUDIO_BUFFER_QUEUE_ENTRY *entry;
|
||||||
@ -251,29 +251,29 @@ void ClStageComplete(int stage)
|
|||||||
|
|
||||||
void ClStageFailed(int stage, long errorCode)
|
void ClStageFailed(int stage, long errorCode)
|
||||||
{
|
{
|
||||||
NSLog(@"Stage %d failed: %ld", stage, errorCode);
|
printf("Stage %d failed: %ld\n", stage, errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClConnectionStarted(void)
|
void ClConnectionStarted(void)
|
||||||
{
|
{
|
||||||
NSLog(@"Connection started");
|
printf("Connection started\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClConnectionTerminated(long errorCode)
|
void ClConnectionTerminated(long errorCode)
|
||||||
{
|
{
|
||||||
NSLog(@"ConnectionTerminated: %ld", errorCode);
|
printf("ConnectionTerminated: %ld\n", errorCode);
|
||||||
|
|
||||||
[_callback connectionTerminated];
|
[_callback connectionTerminated];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClDisplayMessage(char* message)
|
void ClDisplayMessage(char* message)
|
||||||
{
|
{
|
||||||
NSLog(@"DisplayMessage: %s", message);
|
printf("DisplayMessage: %s\n", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClDisplayTransientMessage(char* message)
|
void ClDisplayTransientMessage(char* message)
|
||||||
{
|
{
|
||||||
NSLog(@"DisplayTransientMessage: %s", message);
|
printf("DisplayTransientMessage: %s\n", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) terminate
|
-(void) terminate
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
NULL, 0, nalLength + 1, 0);
|
NULL, 0, nalLength + 1, 0);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
printf("CMBlockBufferReplaceDataBytes failed: %d\n", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@
|
|||||||
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
||||||
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
printf("CMBlockBufferReplaceDataBytes failed: %d\n", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@
|
|||||||
kCFAllocatorDefault, NULL, 0,
|
kCFAllocatorDefault, NULL, 0,
|
||||||
NAL_LENGTH_PREFIX_SIZE, 0);
|
NAL_LENGTH_PREFIX_SIZE, 0);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferAppendMemoryBlock failed: %d", (int)status);
|
printf("CMBlockBufferAppendMemoryBlock failed: %d\n", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@
|
|||||||
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
||||||
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
printf("CMBlockBufferReplaceDataBytes failed: %d\n", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@
|
|||||||
kCFAllocatorNull, // Don't deallocate data on free
|
kCFAllocatorNull, // Don't deallocate data on free
|
||||||
NULL, 0, dataLength, 0);
|
NULL, 0, dataLength, 0);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
printf("CMBlockBufferReplaceDataBytes failed: %d\n", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@
|
|||||||
|
|
||||||
if (formatDesc == NULL && (nalType == 0x7 || nalType == 0x8)) {
|
if (formatDesc == NULL && (nalType == 0x7 || nalType == 0x8)) {
|
||||||
if (waitingForSps && nalType == 0x7) {
|
if (waitingForSps && nalType == 0x7) {
|
||||||
NSLog(@"Got SPS");
|
printf("Got SPS\n");
|
||||||
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
waitingForSps = false;
|
waitingForSps = false;
|
||||||
}
|
}
|
||||||
@ -124,13 +124,13 @@
|
|||||||
else if ((waitingForPpsA || waitingForPpsB) && nalType == 0x8) {
|
else if ((waitingForPpsA || waitingForPpsB) && nalType == 0x8) {
|
||||||
// Read the NALU's PPS index to figure out which PPS this is
|
// Read the NALU's PPS index to figure out which PPS this is
|
||||||
if (waitingForPpsA) {
|
if (waitingForPpsA) {
|
||||||
NSLog(@"Got PPS 1");
|
printf("Got PPS 1\n");
|
||||||
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
waitingForPpsA = false;
|
waitingForPpsA = false;
|
||||||
ppsDataAFirstByte = data[FRAME_START_PREFIX_SIZE + 1];
|
ppsDataAFirstByte = data[FRAME_START_PREFIX_SIZE + 1];
|
||||||
}
|
}
|
||||||
else if (data[FRAME_START_PREFIX_SIZE + 1] != ppsDataAFirstByte) {
|
else if (data[FRAME_START_PREFIX_SIZE + 1] != ppsDataAFirstByte) {
|
||||||
NSLog(@"Got PPS 2");
|
printf("Got PPS 2\n");
|
||||||
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
waitingForPpsB = false;
|
waitingForPpsB = false;
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@
|
|||||||
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsDataA bytes], [ppsDataB bytes] };
|
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsDataA bytes], [ppsDataB bytes] };
|
||||||
const size_t parameterSetSizes[] = { [spsData length], [ppsDataA length], [ppsDataB length] };
|
const size_t parameterSetSizes[] = { [spsData length], [ppsDataA length], [ppsDataB length] };
|
||||||
|
|
||||||
NSLog(@"Constructing format description");
|
printf("Constructing format description\n");
|
||||||
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
||||||
2, /* count of parameter sets */
|
2, /* count of parameter sets */
|
||||||
parameterSetPointers,
|
parameterSetPointers,
|
||||||
@ -149,7 +149,7 @@
|
|||||||
NAL_LENGTH_PREFIX_SIZE,
|
NAL_LENGTH_PREFIX_SIZE,
|
||||||
&formatDesc);
|
&formatDesc);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"Failed to create format description: %d", (int)status);
|
printf("Failed to create format description: %d\n", (int)status);
|
||||||
formatDesc = NULL;
|
formatDesc = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@
|
|||||||
|
|
||||||
status = CMBlockBufferCreateEmpty(NULL, 0, 0, &blockBuffer);
|
status = CMBlockBufferCreateEmpty(NULL, 0, 0, &blockBuffer);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferCreateEmpty failed: %d", (int)status);
|
printf("CMBlockBufferCreateEmpty failed: %d\n", (int)status);
|
||||||
free(data);
|
free(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@
|
|||||||
NULL, 0, NULL,
|
NULL, 0, NULL,
|
||||||
&sampleBuffer);
|
&sampleBuffer);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMSampleBufferCreate failed: %d", (int)status);
|
printf("CMSampleBufferCreate failed: %d\n", (int)status);
|
||||||
CFRelease(blockBuffer);
|
CFRelease(blockBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user