Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI for wifi remote disc streaming #8845

Merged
merged 19 commits into from
Jul 4, 2016
Merged

Conversation

unknownbrackets
Copy link
Collaborator

@unknownbrackets unknownbrackets commented Jul 4, 2016

This adds a screen under Tools where you can:

The sharing is based on your desktop's recent games list. The UI could probably use some polish but at least it's a basic start. Both devices must be connected to the same wifi network.

It selects a random port when sharing (via the OS), but for caching reasons, tries to reuse that port if possible next time.

-[Unknown]

@unknownbrackets unknownbrackets changed the title Add UI for wifi remote disc sharing Add UI for wifi remote disc streaming Jul 4, 2016
It's not great to delay loading when the server is down - we'll do a
proper check when we display the games.

This also fixes shutdown being slow.
@hrydgard
Copy link
Owner

hrydgard commented Jul 4, 2016

Very cool.

But, I could get it to hang very easily by first sharing, then stopping sharing, then clicking Browse games and then Cancel. Would be nice to have that fixed before merging :)

@unknownbrackets
Copy link
Collaborator Author

Oh, it's connecting to the socket that just closed... derp, forgot to close it properly.

-[Unknown]

Hopefully this will prevent a crash.  Currently http::Client uses blocking
reads so it will just hang.
@unknownbrackets
Copy link
Collaborator Author

Okay, now it tries to protect against that scenario. It is possible it may leak a hung thread waiting to download from a broken server - it'd be nice to change the http client to a non-blocking server. But anyway, it no longer hangs.

-[Unknown]

Before we were just relying on whatever timeout connect() wanted.
@unknownbrackets unknownbrackets deleted the http branch July 4, 2016 19:01
@Anuskuss
Copy link
Contributor

Can I use this to connect to my NAS (from my iPhone for example) or should I hard-code it in my recent list? Will this also work if I save the game to my RAM or will it fail because it actualy isn't fully downloading?

@unknownbrackets
Copy link
Collaborator Author

Well, if your NAS has an http:// server, you can use that directly by adding to your recent list.

The remote disc streaming simply uses standard HTTP 1.1 features, so it will typically work with most standards-compliant webservers. There could be bugs, though. I know for sure it works with Apache.

Alternatively, you could mount the NAS from your desktop, and use this sharing feature to broadcast it to your iPhone. However, it would be going from your phone to your desktop, and then to the NAS. Might add extra latency.

The "read entire ISO into RAM" setting on your desktop won't change anything with this feature currently. If used on your phone, it would likely reduce performance, so I don't recommend it.

It won't fully load the disc, but it does cache it on your device to reduce latency.

-[Unknown]

@Anuskuss
Copy link
Contributor

Anuskuss commented Aug 4, 2016

Are there any plans to support more protocols like FTP or SMB? Also I was asking if there could be a option which discovers all devices in the network like my NAS (e.g. HTTP, DLNA, Zeroconf).

@unknownbrackets
Copy link
Collaborator Author

unknownbrackets commented Aug 4, 2016

Well, I'm not personally planning to implement those things.

FTP would probably have worse latency than HTTP, but would be fairly easy to add. The HTTP client is really quite simple and a good reference for anyone looking to implement another protocol:

https://github.com/hrydgard/ppsspp/blob/master/Core/FileLoaders/HTTPFileLoader.cpp

I don't know much about SMB, but it's probably doable too. The important things it needs are:

  • Quick file size detection.
  • Random access (e.g. start reading a file from position X for Y bytes.)
  • Ideally, >2GB file support (some translations/hacks may be larger - but it is unusual.)

Some standard of multicast discovery could probably be implemented as well, but there can be complexities there. But nothing's really stopping anyone.

-[Unknown]

@Anuskuss
Copy link
Contributor

@unknownbrackets So I just installed a http server on my NAS and put the game in my recent list - and it works. But I would find it more convenient to discover my NAS rather than noting every game in ppsspp.ini.

Also I find out that when the server is not avalible or I have no internet connection, PPSSPP doesn't even load the covers of local games and when I click on a something, it hangs. Maybe you should include some sort of timeout?

@unknownbrackets
Copy link
Collaborator Author

It does have a timeout (which is why the covers don't load), but I haven't checked what happens when you try to actually click it. That can probably be improved - and the covers could probably more ideally show some sort of "timeout icon". I'd rather it didn't auto-remove them from Recent, though.

More discovery methods are welcome. Just open a pull request.

-[Unknown]

@Anuskuss
Copy link
Contributor

@unknownbrackets 😉 I know I want many things, so I hope I don't bother you that much.
I also have another idea: When you have the time and feel like improving sharing, how about (in the context of discovering servers) add an option to either stream or download the ROM? So I could play them on the fly or download them and play them on the go.

Also another (probably last) thing: You said that a file is being created when you stream a game (I think it was something like *.ppdc) for caching purposes. I deleted that file as I was comparing the loading times, and I'm maybe wrong on this one since I forgot where it is stored, but I haven't found a new file since and I think maybe this is a bug and a second file can't be created?

@unknownbrackets
Copy link
Collaborator Author

unknownbrackets commented Aug 21, 2016

I'm not being snarky - many other emulators have a varied number of contributors too. It's a fact that features are usually implemented by people who are interested in them.

PPSSPP has a vacuum in a few areas right now - no active contributor is interested in the iOS side of things, no active contributor is interested in network play, TAS, etc. That's why those features get the "short end of the stick." At the root, this probably either means the code looks bad to people who might otherwise be interested (even if only in those specific areas), or that people think that a person named "Someone A. Else" might do it.

If you're excited about something you've already got some of the qualifications needed - I'm not joking or being mean. A lot of open source contributors are not actually programmers - some are scientists, authors, graphic designers, musicians, students, teachers, or even middle management. Passion is really the only qualification.

As to the ppdc file - it definitely gets recreated. It's designed so the operating system can, at any time, clear these files. They are stored where Android asks for cache files to be stored. You can go to app info and hit "Clear cache". On Windows, they are stored in PSP/SYSTEM/CACHE. Feel free to delete at leisure.

-[Unknown]

@Anuskuss
Copy link
Contributor

@unknownbrackets Well, if I had the time I would already contributed to PPSSPP 😄

On the last question, where is the supposed file location on iOS?

@unknownbrackets
Copy link
Collaborator Author

Not sure. The part that tells PPSSPP where the OS wants cache files is probably not implemented on iOS, so it's probably also in PSP/SYSTEM/CACHE.

-[Unknown]

@Anuskuss
Copy link
Contributor

I can only see the .glshadercache files in there. Are you sure they will be recreated, do you have a way to test it?

@unknownbrackets
Copy link
Collaborator Author

unknownbrackets commented Aug 23, 2016

I delete them a lot, for testing. Any time it even generates a thumbnail for an HTTP URL, it will recreate them.

Note that it may not recreate a cache file if it cannot connect to the URL at all. The filename will look similar to the URL, but with more underscores. An easy way to test is on windows or linux/mac, just run PPSSPPWindows64 http://nas/my.cso (or similar on mac/linux.)

I don't really know how to validate things on iOS, but if your [Recent] list has an HTTP URL in it, and is being used, then it ought to work. Actually, this look promising.

On Android, you can run adb shell am start -n org.ppsspp.ppsspp/.PpssppActivity -e org.ppsspp.ppsspp.Shortcuts http://nas/my.cso. Long but it works fine.

-[Unknown]

@Anuskuss
Copy link
Contributor

One last note: PPSSPP crashes when the connection is lost (only tested on iOS). Can we have a more user-friendly way for that scenario, maybe a popup?

@unknownbrackets
Copy link
Collaborator Author

Well, PPSSPP would probably crash if you were playing off a USB disk and you unplugged the disk too.

Can probably handle that better, although the crash is likely due to the "fast memory" setting (note: in the "IR Interpreter" and "Interpreter", fast memory is ALWAYS on iirc.) We probably don't emulate it properly when this happens (like if you pulled the UMD out of a PSP while playing the game, which is the behavior we should probably emulate...)

-[Unknown]

@Anuskuss
Copy link
Contributor

IIRC if you push the eject button (on the old PSPs), it would shutdown the game and then show the XMB. Maybe we could use this function?

@unknownbrackets
Copy link
Collaborator Author

Well, I'm about as interested in mimicking the XMB UI as in mimicking Windows 3.11's UI, but when I eject a game on a PSP, it asks me if I want to quit the game. I can say no, and the game keeps playing.

In the game I tried, it just hung when I tried to do something that would require the disc. Putting the disc back in actually made it work, so it kinda seems like it just waits as long as it takes for the disc data to reappear. In that case, we could enable retry/disable timeouts when the game is reading data.

-[Unknown]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants