Closed Rio6 closed 3 years ago
This is on ytdl branch btw
It looks like it happens only on videos where youtube-dl returns a "https://manifest.googlevideo.com/api/manifest/dash/..." as the video URL. Videos with "https://r7---sn-gvbxgn-tt1e.googlevideo.com/videoplayback" URL works. Passing --youtube-skip-dash-manifest
to youtube-dl it seems to fix the problem. I think we should add that as part of the invoke command.
Update: using bestaudio[protocol=https]/best
as format also works.
More update: directly playing youtube dash url with mpc add
plays it normally (I think it's using ffmpeg plugin), so I guess using ffmpeg instead of curl as backend is another option.
Although the code should still be fixed so it doesn't completely lock up MPD when something similiar happens.
I think it's caused by here:
size_t YtdlInputStream::Read(std::unique_lock<Mutex> &lock, void *ptr, size_t sz) {
if (input != nullptr) {
context = nullptr;
}
return ProxyInputStream::Read(lock, ptr, sz);
}
The line context = nullptr;
calls the destructor which runs things in the event loop and blocks. And something about that locks everything up. Removing that line actually allows the dash URLs to play (although they lag more compared to http streams, not sure if it's just me).
Maybe it needs to be moved elsewhere.
Hm, it might be fine to move it back into OnComplete, just try reverting b784c3b229451e5df79ff372fde9ec380aaa5154. I moved it because it seemed dangerous but it's technically valid as long as we're careful?
Making it to be the last thing to do in OnComplete (and OnError) looks fine for now. OnComplete is then the last thing being called in YtdlMonitor::OnSocketReady, which is the last thing in SocketEvent::Dispatch, which get's called at the end of its scope in EventLoop::Run.
Not sure if that's going to be guaranteed in the future though.
Not sure if that's going to be guaranteed in the future though.
It's probably going to be for SocketEvent::Dispatch
, since it's not unusual for the event to unregister itself as part of that dispatch handler. The rest is controlled by this plugin and is pretty reasonable to keep it that way so should be fine.
I noticed sometimes MPD deadlocks and become unresponsive (mpc commands failed with timeout, ctrl-c on MPD process does not terminate it). I haven't figured out what exactly causes that. Backtrace in gdb shows these two locations:
Update: they're probably waiting for the other two threads:
Not sure how they're realated to each other yet.