Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
17-11-2018, 12:01 (This post was last modified: 17-11-2018 12:07 by Uoppi.)
Post: #1
How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
I'm trying to toggle my PC power profiles (sleep after 5 min & never sleep) based on whether there's active streaming going on or not (between MinimServer and BubbleUPnP Server, which are on the same HTPC, reading from a NAS).The rationale for it being, normal sleeping tweaks and power on request overrides etc. don't work.

What I've got halfway working is to loop a query ('netstat -an') from a batch script, on a specific x.x.x.x.:9790 port. Is there any other method to check whether MinimServer is actively streaming? I'm thinking maybe mscript (which I'm unfamiliar with), or a batch script scanning the contents of some MinimServer log etc.? I'd really appreciate some help.

The x.x.x.x.:9790 port I mentioned is always opened when streaming starts but that also requires making the urlcache in BubbleUPnP Server read-only, so that BubbleUPnP Server always needs an active connection to MinimServer while streaming.

Everything seems to work fine up until streaming has stopped. Sometimes the x.x.x.x.:9790 disappears from the netstat active connection list after a few minutes but sometimes the connection appears to get stuck in established mode. What this means is that then my PC also remains in the never-sleep power profile Sad. I haven't been able to decipher the logic, the connection closing or not post-streaming seems hit-and-miss.
Find all posts by this user
Quote this message in a reply
17-11-2018, 20:38
Post: #2
RE: How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
OK, I figured it out. Here's what I did, in case someone else is looking for a similar hack:

1. Set MinimServer's ohnet.loglevel to none and loglevel to trace (to pause logging when streaming stops)
2. Make BubbleUPnP Server's urlcache.dat read-only (to force MinimServer to keep trace-level-logging the whole time that streaming is ongoing)
3. Make a script that compares minimserver.log file size changes once a minute
4. If file size changes, MinimServer has updated its log a.k.a. streaming may be going on -> initiate a never-sleeping power profile on PC
5. If minimserver.log file size stays the same, streaming has stopped -> switch to a sleep-after-5-minutes power profile
6. The script is always running in the background. It doesn't eat up any resources, but reliability can be an issue as it's just a dos script running in an invisible cmd (packed as exe).
Find all posts by this user
Quote this message in a reply
17-11-2018, 21:41
Post: #3
RE: How to detect on Windows if MinimServer is actively streaming?
I understand your reasons for doing this but I don't recommend having the logging level set to Trace as a permanent setting. This can produce extremely large amounts of log output in some circumstances.
Find all posts by this user
Quote this message in a reply
18-11-2018, 17:26 (This post was last modified: 18-11-2018 17:33 by Uoppi.)
Post: #4
RE: How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
(17-11-2018 21:41)simoncn Wrote:  I understand your reasons for doing this but I don't recommend having the logging level set to Trace as a permanent setting. This can produce extremely large amounts of log output in some circumstances.

Yeah, that's why I'm running a script via gpedit on shutdown to delete the minimserver.log (my HTPC is scheduled to restart every night).

The other issue that I've found is that by making BubbleUPnP Server's urlcache.dat read-only (i.e. rendering it permanently empty), after a restart it can become impossible to resume playback from BubbleUPnP's playlist on Android, i.e. BubbleUPnP doesn't know "where to look".

Just wondering: when BubbleUPnP Server's urlcache is thus disabled, is MinimServer keeping the urls in RAM or writing them as temp on disk locally - in which case they would disappear after each PC restart? The trace log reports regular reading-writing, which of course helps with my "stream-detection hack". If BubbleUPnP Server's urlcache is enabled, the MinimServer log simply stops after a while, as BubbleUPnP Server stores the url in its own cache and doesn't need MinimServer to "intervene".
Find all posts by this user
Quote this message in a reply
18-11-2018, 18:02
Post: #5
RE: How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
I don't know which URLs you are referring to. Can you post a few lines from the MinimServer log that show the "regular reading-writing"?
Find all posts by this user
Quote this message in a reply
18-11-2018, 19:18 (This post was last modified: 18-11-2018 19:20 by Uoppi.)
Post: #6
RE: How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
(18-11-2018 18:02)simoncn Wrote:  I don't know which URLs you are referring to. Can you post a few lines from the MinimServer log that show the "regular reading-writing"?

Doesn't MinimServer has its own url cache file (I believe it does anyway)? As does BubbleUPnP Server. In my scneario I'm streaming from a NAS into BubbleUPnP on my phone, with BubbleUPnP Server and MinimServer working together on the HTPC.

If BubbleUPnP Server's own urlcache.dat is used (as it is by default), MinimServer stops its own logging after a while (a few minutes into a song). And as my hack relies on the MinimServer log being written to at least once every few minutes, I have had to make the BubbleUPnP Server's urlcache read-only.

I'm not sure exactly why the logging stops - I assumed BubbleUPnP is "taking over" from MinimServer once it has cached the url into its own cache? In other words, BubbleUPnP only utilizes MinimServer when it has to. And by disabling the BubbleUPnP Server's urlcache, MinimServer is needed at least once every few minutes when streaming (at least so it appears based on the trace log). My apologies if I'm using incorrect and vague terminology, I'm really just a curious hobbyist. Smile
Find all posts by this user
Quote this message in a reply
18-11-2018, 22:09 (This post was last modified: 18-11-2018 22:31 by simoncn.)
Post: #7
RE: How to detect on Windows if MinimServer is actively streaming?
It is hard for me to say what is happening without seeing the trace log information that I requested in my previous post. My guess from what you have posted so far is that BubbleUPnP's urlcache.dat file might be a cache of streamed audio data. MinimServer does not use such a cache but streams data from the audio file "on demand" as requested by the renderer.
Find all posts by this user
Quote this message in a reply
20-11-2018, 21:38 (This post was last modified: 20-11-2018 21:40 by Uoppi.)
Post: #8
RE: How to detect on Windows if MinimServer (+BubbleUPnP Server) is actively streaming?
(18-11-2018 22:09)simoncn Wrote:  It is hard for me to say what is happening without seeing the trace log information that I requested in my previous post. My guess from what you have posted so far is that BubbleUPnP's urlcache.dat file might be a cache of streamed audio data. MinimServer does not use such a cache but streams data from the audio file "on demand" as requested by the renderer.

I'm not sure what I should screen capture to illustrate the idea. What I meant is that when BubbleUPnP Server caches data (it caches MinimServer-affixed urls), MinimServer's logging stops after a while because BubbleUPnP Server can then utilize its own cache.

Whereas what I need is to MinimServer to keep on logging to be able to detect streaming activity. But like I said it's a hack, which fortunately though seems to work more predictably for my needs than relying on Windows' own power management.

Just today, most likely because of a pretty recent Windows bug, I needed to move the minimserver.log from the default location to my Documents folder - closer to root. Reason being that Windows stopped refreshing the file metadata all of a sudden, which according to some reports may happen if the file path is very long. And as my script relies on detecting minimserver.log file size changing over time (in practical terms indicating streaming), my script temporarily failed. Let's see how it goes, so far so good.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)