loarabia

New MediaStreamSource documentation

Happy Days and Jubilation. This link is to new MSDN library documentation describing how to implement MediaStreamSources for many different formats. Very handy.

Getting Organized

A few months ago, I heard of and then read David Allen’s Getting Things Done or more correctly, I checked the book out of the library twice each time reading about the first half. It is a great book that I would summarize in two points (roughly):

  1. Stress comes from worrying about what you’ve forgotten you need to do
  2. Know what the next physical action is to progress any task forward

To satisfy the 1st point, David Allen recommends collecting all of your projects and their corresponding tasks together in a single workstation (he advocates a physical workstation in the book). As a Software Engineer, most of my work resides in the proverbial “Cloud” and I didn’t feel super keen on printing everything off that I was doing to organize things.

Looking around at the tools available I could code something up or reuse existing tools. My natural itch was to write lots of code however, Microsoft has a pretty nifty product, OneNote that works on Windows Phone and iPhone for when I’m on the go and it works on both a Mac and Windows desktop either via a native application or a web application. So I set about collecting and organizing my data in this system.

The Technique

What follows will make more sense if you’ve read the first 4 or 5 chapters of the book and hopefully it will be useful to you if you’re trying to get ahead of a never-ending stream of tasks. This is my ideal notebook setup.

Also, I’m sure this rough method would work well with Google Docs and Android but I haven’t tried that out.

The Notebook

When I connected my Windows Live account to my Windows Phone, it automatically synced with a precreated private notebook on my account “Personal (Web)”. If you don’t already have a notebook created though, you’ll want to creat one.

Note: In my case, I’m actually using 2 notebooks. My first notebook on Live for Home stuff is the “Personal (Web)” notebook above and I use a second notebook on an internal work Sharepoint since I don’t think they’d like me taking data outside corporate walls.) Strictly speaking, if I was working for myself, I’d have them both in a single notebook and the rest of the post assumes that.

The Sections

I set up 4 Sections, each with a specific purpose.

  1. Home
  2. Home Ref
  3. Work
  4. Work Ref

The Home Ref and Work Ref Sections

Home Ref and Work Ref are simply alphabatized pages of reference materials, meetings notes, intresting website snippets, email snippets, and whatever else I happen to need or find interesting.

The Home and Work Sections

The Home and Work sections are both set up with 4 pages.

  1. In
  2. In Progress
  3. Out
  4. Someday Maybe

In

A bulleted list of thoughts, tasks, and projects. Each is a sentence sometimes with sub-bullets if I already roughly know what I want to do but generally not. Everything is collected and lands here and this section gets reviewed weekly. You might see something like the below

  1. Sell old cell phone
  2. Read The Grapes of Wrath
  3. Get a better grasp on the useful aspects of statistics etc.

In Progress

Anything in the In list is fair game for being Cut and Pasted to the In Progress list. Normally this has 10 items or less and I tend to prepend when I think I can start this item or when I do start this item as a date at the front of the item. Items here are projects and tasks only. A project may have sub projects but the root one is bold. You might see something like

  1. (1/1/2011) Sci-fi novel
    • Write high level story ark
    • Define characters
      • (1/3/2011) What is the Bad Guy’s name? (1/5/2011 - bad guy is Vort)
      • What is the Good Guy’s name?
    • Write first chapter

The above to some degree is still too high level for what would actually show up in the In Progress page but it shows off the structure.

There may be completed items in this list. Normally I would just suffix the item like the Bad Guy with the date and a little note or pointer to the end result. Sometimes I also use strikethrough to show they are done.

Out

Once you have enough items from In Progress completed that you actually find them cluttering up your In Progress list or once you have all of the items for a project done, just Cut and Paste them over to the Out page and suffix the overall project with a completed date.

Someday Maybe

This is a list with exactly the same level of detail as the In list but tend to contain items that are even longer term. For the most part I’m considering not using this section anymore and just leaving everything in In but for those of you that are sticklers for the exact method described in the book you might find that to be heresy.

Wrapping Up

This is my technique using OneNote. Some of the things I like about it.

  • Keeps me on track towards my goal
  • Simple (you could even do this in notepad if you wanted)
  • I can see where I started and where I am now
  • When it comes review time at work, I have data to show managers

Also, worth noting, this is basically a simplistic manual bug-tracking / task management system that could be found in many software development shops.

RunLoopRun!

I had a Forrest Gump moment this morning.

I was trying to register a main thread from a daemon to get notifications from OS X. I got a RunLoop from the main thread, registered my handlers, and started the notification mechanism, but my main thread continued to exit on me. What gives?

As it turns out, I was missing a call to CFRunLoopRun (or [NSRunLoop run] — same effect). Oy!

In my defense, most of the Apple documentation (and samples) appear to be built around NSApplication’s RunLoop which is already running. Furthermore, the RunLoop object doesn’t have methods to return state like running / not running / waiting or anything like that.

So if you’re writing and running a console application using Apple’s various OS notification mechanisms, don’t forget to call RunLoopRun before you’re done with initialization!

"Colorful Language" in Apple’s documentation

This description was amusing:

Fortunately, at least in the near term, this is unlikely to occur in practice, as 64 bits allows enough room for about one event per eraser-sized region on the Earth’s surface (including water) and would require about 2000 exabytes (2 million million gigabytes) of storage to hold them all. However, you should still check for this flag and take appropriate action if you receive it.

A note on ReadDirectoryChangesW

Outside of using the Journaling APIs, Window’s ReadDirectoryChangesW is the most versatile API to use to watch for FileSystemChanges. I’ve noticed though that it appears to return multiple times for the same item. In some cases, this is completely expected. For instance, getting a response with FILE_ACTION_RENAMED_OLD_NAME followed by FILE_ACTION_RENAMED_NEW_NAME.

However, in the rename scenario it also seems to respond with a FILE_ACTION_MODIFIED response right after the FILE_ACTION_RENAMED_NEW_NAME response (at least in my testing).

Sample Gist

Updated ManagedMediaHelpers

An update to the ManagedMediaHelpers project was posted a while ago but I forgot to update here. You can get it from:

There are both big and small open issues for anyone who wants to contribute. Just fork the code on github and send me a pull request.

The code in both places is identical right now but GitHub is where active development will be taking place.

The current code update included the following changes:

  • Added Windows Phone 7 Sample
  • Updated Mp3MediaStreamSource to run on Windows Phone 7
  • Updated Mp3MediaStreamSource to not require reading the entire file into memory
  • Updated to support Duration
  • Updated to support streaming content

Windows Phone 7 + MediaStreamSource question

  • Earlier today had this question via Tumblr's ask feature. Rather than reply and expose the full name and email address of the asker, I've trimmed the post down to this. I'll update as the dialog progresses.
  • pcosway: Have been trying to use MediaStreamSource on WP7, following your code. Everything is fine ... except no sound output on device or emulator. Even Tim Heuer's Mp3StoreandPlayback code has the problem. Any pointers to a solution or a relevant person to contact? (http://storage2.timheuer.com/Mp3StoreandPlayback.zip)
  • loarabia: Have you checked that the emulator volume and MediaElement volume are both set to 100%? I believe one of them defaults to 50% which is very hard to hear.
  • pcosway: Some debugging
  • loarabia: and suggestions
  • pcosway: back
  • loarabia: and forth
  • pcosway: over email
  • loarabia: It looks like WP7 and the emulator require audio timestamps to be populated and appropriately updated. My original Mp3MediaStreamSource sample didn't update the timestamps when it passed in each audio sample. I'll update it soon and rerelease the ManagedMediaHelpers project.
  • pcosway: [paraphrasing] That seemed to be it.