// For Ptp sockets, data in read as a byte stream. Data is not organized in packets. // Read as much data as the provided buffer can contain. public virtual int recv(TPointer data, TPointer32 dataLengthAddr, int timeout, int nonblock) { int result = 0; try { SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread; if (pollRecv(data, dataLengthAddr, thread)) { // Recv completed immediately result = thread.cpuContext._v0; } else if (nonblock != 0) { // Recv cannot be completed in non-blocking mode result = SceKernelErrors.ERROR_NET_ADHOC_NO_DATA_AVAILABLE; } else { // Block current thread BlockedPdpAction blockedPdpAction = new BlockedPtpRecv(this, data, dataLengthAddr, timeout); blockedPdpAction.blockCurrentThread(); } } catch (IOException e) { result = SceKernelErrors.ERROR_NET_ADHOC_DISCONNECTED; Console.WriteLine("recv", e); } return(result); }
public virtual int accept(int peerMacAddr, int peerPortAddr, int timeout, int nonblock) { int result = 0; SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread; if (pollAccept(peerMacAddr, peerPortAddr, thread)) { // Accept completed immediately result = thread.cpuContext._v0; } else if (nonblock != 0) { // Accept cannot be completed in non-blocking mode result = SceKernelErrors.ERROR_NET_ADHOC_NO_DATA_AVAILABLE; } else { // Block current thread BlockedPtpAction blockedPtpAction = new BlockedPtpAccept(this, peerMacAddr, peerPortAddr, timeout); blockedPtpAction.blockCurrentThread(); } return(result); }
public virtual void hleAudioBlockingOutput(int threadId, SoundChannel channel, int addr, int leftVolume, int rightVolume) { //if (log.DebugEnabled) { Console.WriteLine(string.Format("hleAudioBlockingOutput {0}", channel.ToString())); } if (addr == 0) { // If another thread is also sending audio data on this channel, // do not wait for the channel to be drained, unblock the thread now. ThreadManForUser threadMan = Modules.ThreadManForUserModule; SceKernelThreadInfo thread = threadMan.getThreadById(threadId); if (thread != null) { thread.cpuContext._v0 = channel.SampleLength; threadMan.hleUnblockThread(threadId); } channel.Busy = false; } else if (!channel.OutputBlocking) { ThreadManForUser threadMan = Modules.ThreadManForUserModule; SceKernelThreadInfo thread = threadMan.getThreadById(threadId); if (thread != null) { changeChannelVolume(channel, leftVolume, rightVolume); int ret = doAudioOutput(channel, addr); thread.cpuContext._v0 = ret; threadMan.hleUnblockThread(threadId); } channel.Busy = false; } else { blockThreadOutput(threadId, channel, addr, leftVolume, rightVolume); } }
public virtual void execute() { SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread; Modules.ThreadManForUserModule.executeCallback(thread, callback, null, true, status, callbackArg, argument3); }
protected internal abstract bool pollConnect(SceKernelThreadInfo thread);
protected internal abstract bool pollAccept(int peerMacAddr, int peerPortAddr, SceKernelThreadInfo thread);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected bool pollRecv(pspsharp.HLE.TPointer data, pspsharp.HLE.TPointer32 dataLengthAddr, pspsharp.HLE.kernel.types.SceKernelThreadInfo thread) throws java.io.IOException protected internal virtual bool pollRecv(TPointer data, TPointer32 dataLengthAddr, SceKernelThreadInfo thread) { int Length = dataLengthAddr.getValue(); bool completed = false; if (Length > 0) { if (RcvdData <= 0 || receivedMessage != null) { update(); } if (RcvdData > 0) { if (Length > RcvdData) { Length = RcvdData; } // Copy the data already received dataLengthAddr.setValue(Length); Memory mem = Memory.Instance; mem.memcpy(data.Address, buffer.addr, Length); if (RcvdData > Length) { // Shift the remaining buffer data to the beginning of the buffer mem.memmove(buffer.addr, buffer.addr + Length, RcvdData - Length); } rcvdData -= Length; //if (log.DebugEnabled) { Console.WriteLine(string.Format("Returned received data: {0:D} bytes", Length)); if (log.TraceEnabled) { log.trace(string.Format("Returned data: {0}", Utilities.getMemoryDump(data.Address, Length))); } } setReturnValue(thread, 0); completed = true; } } return(completed); }
protected internal override bool pollAccept(int peerMacAddr, int peerPortAddr, SceKernelThreadInfo thread) { bool acceptCompleted = false; try { AdhocSocket acceptedSocket = socket.accept(); if (acceptedSocket != null) { sbyte[] destMacAddress = proOnline.getMacAddress(acceptedSocket.ReceivedAddress); if (destMacAddress != null) { // Return the accepted peer address and port pspNetMacAddress peerMacAddress = new pspNetMacAddress(destMacAddress); int peerPort = acceptedSocket.ReceivedPort; Memory mem = Memory.Instance; if (peerMacAddr != 0) { peerMacAddress.write(mem, peerMacAddr); } if (peerPortAddr != 0) { mem.write16(peerPortAddr, (short)peerPort); } // As a result of the "accept" call, create a new PTP Object PtpObject ptpObject = new ProOnlinePtpObject(this); // Add information about the accepted peer address and port ptpObject.DestMacAddress = peerMacAddress; ptpObject.DestPort = peerPort; ptpObject.Socket = acceptedSocket; // Add the received socket as a new Ptp Object Modules.sceNetAdhocModule.hleAddPtpObject(ptpObject); // Return the ID of the new PTP Object setReturnValue(thread, ptpObject.Id); //if (log.DebugEnabled) { Console.WriteLine(string.Format("accept completed, creating new Ptp object {0}", ptpObject)); } acceptCompleted = true; } } } catch (SocketTimeoutException) { // Ignore exception } catch (IOException e) { Console.WriteLine("pollAccept", e); } return(acceptCompleted); }
protected internal override bool pollConnect(SceKernelThreadInfo thread) { // A StreamSocket is always connected return(true); }