It is important for my usecase to have functions like Sleep and WaitForMultipleObjects w/timeout to have 1ms resolution on the timeout.
In normal Windows apps, it's possible to achieve this by calling timeBeginPeriod(1). Unfortunately, UWP does not seem to provide this function.
I can see the timer resolution increases affecting the UWP app - that is, if I run Chrome while the UWP app is running, the timer resolution in UWP app increases to 1ms; when I close Chrome it goes back to what looks like 15ms.
Is there a way to achieve the same from within a UWP app using some API other than timeBeginPeriod?
Related
I'm porting some audio playback code from iOS to wp8 (don't ask why), and I'm encountering some troubles with timers on my wp8 device. After some cursory research, I decided to go with QueryPerformanceCounter as a good-enough parallel to the MachAbsoluteTime stuff on iOS. However, since my device (Nokia Lumia 920) is dual core, QPC encounters problems, and my deltas often end up negative or ridiculously high. I need my playback loop to run every 10ms, but these spurious timer results are throwing my code off.
I looked into somehow giving my loop processor affinity, but I can't find a way to do so, since I can either use tasks or the threadpool instead of explicit thread creation on wp8. Any suggestions? Is there another timer I can use, or is there a way to give tasks or threadpool workitems proc affinity?
I am creating a screensharing application that would work in a similar manner like Google Hangout Screen Shares, and I'd like to know how the Google Talk plugin (used for Screen Shares) spawns child processes and uses a dynamic port range.
I am creating a background running application that user will have to install, and which talks with browser like how they describe here, http://www.codeproject.com/Articles/36517/Communicating-from-the-Browser-to-a-Desktop-Applic
But when I look at googleTalkPlugin, which is responsible for google hangout screen sharing, I saw that there are a lot of processes running, and whenever I open a new browser, a new talk plugin for that browser starts, as child service.
Here are some snapshots
and when I noticed the port used by googleTalkPlugin, I came to know its dynamic! If you saw the above link, the Browser Desktop communication is on static port.
I am very interested in knowing, how do I use dynamic port numbers? Also, should I create child process for every browser?
Or something better?
The reason there is a separate child process for each browser is that the Google Talk application is implemented as a browser plugin. Each browser has a Google Talk plugin installed and doesn't know about the other browsers, their plugins or their subprocesses. Each browser will launch the plugins that it has installed and, as Eduard mentioned in the comments, some plugins are started in a separate process. This isn't behavior that is special about Google Talk, it is behavior you will see with most plugins. If you implement your application as a browser plugin you will have the same behavior. If you don't want your application to run as a subprocess of a browser then you will need to write it as a standalone application, not a browser plugin.
If you want to learn more about spawning subprocesses read up on fork(). There are lots of other good resources around the internet on subprocesses.
Your other question is around dynamic port numbers. The easiest way to do this is to bind to port 0 and you will be assigned a random open port by the operating system. You can then use getsockname() to find out what port you ended up with. If you are working with a client/server situation you can have the client do this and then just tell the server which port it is using.
I'm using PortAudio as a front-end to a speech synthesis (Text to Speech) engine, and I want to provide a synchronous speak function that waits until playback has completed.
It seems like all of the PortAudio functions that deal with this only wait until the underlying API has finished consuming the audio data, not until playback has finished.
Is this possible with PortAudio? If not, are there any good cross-platform alternatives to PortAudio (has to include a C interface) that might support this?
I am not sure if the streamFinished callback, as documented here:
http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#aa11e7b06b2cde8621551f5d527965838
is what you want. It may suffer from the same issue, but I think it would work.
Two other possibilities are:
Use lower latency settings.
Use the hardware timing. This information is available from calls like GetStreamTime(). For example:
get the current time
push x seconds of audio to the hardware
wait for the hardware clock to show the start time plus x seconds
You might also be interested in this document:
http://www.rossbencina.com/static/writings/portaudio_sync_acmc2003.pdf
I'm afraid I don't know of another API with better support for this sort of thing.
I've been developing an audio app for Windows Phone 7 and up to this point have been using the WP7 emulator. The app uses a custom MediaStreamSource class to stream audio to a MediaElement.
On a real device, the custom MediaStreamSource completely fails. After calling MediaElement.Play(), the MediaStreamSource's GetSampleAsync method never gets called. It works just fine in the emulator.
I've started the app in the debugger (running on the device) and no exceptions get thrown anywhere.
I'm wondering if maybe my stream source is using a sample rate, bits per sample, or channel count that is not supported? I cannot find any documentation on what values are supported - however I find it hard to believe that my settings are not supported (44,100 Hz, 16 bits/sample, 2 channels).
Thoughts?
The answer is that the Zune software interferes with the phone's media capabilities. The app will work on the device if you disconnect the device from the computer, or by using the WPConnect tool: http://blogs.msdn.com/b/jaimer/archive/2010/11/03/tips-for-debugging-wp7-media-apps-with-wpconnect.aspx
I'm using Motorola device and developed it with J2ME . I'm searching for a functionality to detect incomming or outcomming calls when dropped .
I mean , when the call is dropped I need to recognize this event.
Thanks
There is no standard J2ME telephony API.
There could be a working proprietary java-based API on that particular handset but that's both unlikely and not obvious to verify.
You could use the life-cycle of the application to detect interrupts. Your device can detect when a phone-call comes in and ends, and trigger shownotify(), hidenotify(), startApp(), pauseApp(), then do something accordingly. See the canvas class. So if you have an application running, you can detect an incoming phone-call, wait for it to end then do something. This is of course very device/manufacturer specific and you are in a world of hurt when it comes to porting this for many devices. I'm not sure if you can do something like this for outgoing calls, since your app will be in the background and paused for most devices.
You could try checking the motorola developer webpage. Motorola has its own set of libraries for j2me, it may support the case you need.