Pulseaudio crash with A2DP, Bug #641

This is just a milemarker for those who may also be having an issue similar to what I experienced lately.  Hopefully the below summary is useful to somebody.

Problem #1: Bluetooth speakers connect to Ubuntu Linux just fine, but audio quality is crap.

Solution #1: Some BT speakers somehow get auto-identified as bluetooth headsets (aka for making phone calls) instead of speakers (primarily for music), and thus use a lower quality bluetooth profile.   Pulseaudio (On ubuntu in the sound settings -> hardware tab) allows you to easily toggle between profiles.

Problem #2: Switching between the standard profile and the A2DP higher quality profile causes pulseaudio to crash.  The crash output is something along the lines of:

E: sink.c: Assertion 'pa_frame_aligned(length, &s->sample_spec)' failed at
 pulsecore/sink.c:939, function pa_sink_render_full(). Aborting.

Semi-Solution #2: I don’t know of any proper solutions to the problem as of yet.  Googling gets you to to places like this,  http://comments.gmane.org/gmane.comp.audio.pulseaudio.bugs/2317 which only suggest a workaround of changing the default-sample-channel setting in daemon.conf to 2 instead of the default of 6.  This fix worked for me (I only have 2 BT speakers), but obviously may be problematic for more complicated setups.

I haven’t tried using a more modern build of Pulseaudio/Pulseaudio modules yet, totally plausible that its fixed in trunk.  It’s not exactly trivial to get a fully updated version of Pulse in a 12.04 Ubuntu LTS release, however.  For now, it’s working so I’ll save poking that bear for another time.

Life v2.0

My Story

When asked what I wanted to be when I grew up I would say a firefighter, and later, I’d say an accountant. It turns out I’m not very good with a firehose or with numbers, and so by the time I was in college I changed my mind and decided I wanted to be an entrepreneur and start my own company.

Given that, I was very excited when, In my junior year of college, I was invited to visit a local start up (little did I know ‘stop by for a visit’ means ‘come do some interviews’). I arrived and was shown into a small room with a table and a few chairs. As I was sitting there alone, awkwardly twiddling my thumbs wondering what I’d gotten myself into, in walked this tall, somewhat pale guy whose face I recognized but couldn’t quite figure out why. Halfway through the interview I realized it was a student in one of the classes I was teaching. After the interview he asked if I wouldn’t mind grading the latest homework assignment so he didn’t have to walk to campus to turn it in!

And so began my internship and eventually full time work with Invite Media while also in school. I’d schedule my classes to have Fridays off, so I’d spend evenings M-Th at work (5-11 or so) and all day Friday in the office. I remember Tuesday and Thursdays I would have a class that ended at 1PM, but I would run out at 12:59PM because there was a 1:02PM bus to the office that I could just make if I ran.

Somehow though, this never felt exhausting. I loved all of it. I never complained about working too much, or being tired, or hating my job or my boss, or that the work was too hard (and it was hard). It was an unforgettable and highly educational experience. Invite was acquired in May 2010 by Google where I stayed, first as a tech lead at Google/Invite and later as an APM in ads/cloud before finally jumping ship to start a new company, WiFast, in late 2011.

It had not taken all that long, but I was living my dream. Over the next 18 months we raised money from a group of incredible investors, hired 15 of the smartest people ever known from all over the USA and built technology that still makes my head spin. I had an amazing time working with incredible people and loved every minute of it.

And so we come to now. I left WiFast this summer and have had a lot of time to reflect upon having had my ‘dream jobs’. I’d worked for somebody else’s startup, a hugely successful and large tech company, and finally run my own start-up. I didn’t know what to do next, so instead I have basically lived the life of a retired 25 year old gear-head for a few months. I built a new engine from scratch for my 1985 sports car, helped some friends strip down and build a racing 1978 Volkswagen rabbit, raced outdoor go-karts, indoor go-karts, conquered every windy mountain road within 100 miles and spent countless hours just shooting the breeze with professional race car drivers and mechanics. All the while I’d been looking for what I wanted to do next with my life.


Purpose built VW Rabbit Race Car (left).
Me building a new engine for a 1985 Porsche 944 (right)

The future

And so now it comes time to explain why I’m not starting a company in 2014. Even though I had a blast all along the way in my career so far, there is still something missing. The following anecdote may help explain things:

In college I was privileged to be lectured to by Tom Cassel; he told a story that I will always remember of a company he ran and sold. He describes the feeling in the office the day after the sale was completed.

After years and years of dedication, of nearly going bankrupt, of having to sell everything and start over, to the highs of owning multiple properties and employing hundreds if not thousands of people, of having a change in regulations turn their business upside down overnight, he walked into the office and looked at the faces of all of the people that worked there. There were no balloons, no streamers, no loud music, barely any smiles. In fact, the office was quieter, almost to the point of somber.

What he realized is that it wasn’t the dream of selling the company that kept people going. It was enjoying the journey along the way.

“The journey is the reward.” — Tom Cassel

I feel as if starting another company now, after having just been with three american tech companies in various forms would simply be continuing an unconsciously guided journey; simply doing what feels natural. I want to be in control of my journey and spend what time I have enjoying and doing things in a deliberate way.

I have decided to accept an offer to work in China. The job is pretty cool, I’ll be an Entrepreneur in Residence at Tencent, one of China’s largest tech companies. Let’s be clear here though, Tencent is awesome, but the chance to live in China, literally the opposite side of the world from where I grew up both geographically and culturally, and to spend time exploring southeast Asia is REALLY awesome. I do not know exactly how long I’ll be there, but I do know my goal is to have different kinds of goals. To spend time exploring myself, exploring a new world around me, exploring how different cultures work and enjoying every moment of every day.

From Aerosmith’s “Amazing”:

Life’s a journey, not a destination
And I just can’t tell just what tomorrow brings

Epilogue

Since this is kind of my farewell-and-thanks-for-all-the-fish-USA letter for a while, I might as well take this time to thank some of the folks who have really made the difference in the past few years. My co-founders at WiFast: Alexey Komissarouk and Scott Kyle, as well as advisers, friends and family: Jack Abraham, Dr. Jonathan Rosenfeld, Omar Koukaz, Jessica (Jecca) Conard and Bruce Goldberg, and my immediate family, the Goldberg’s and Greenbergs.

Cheers,
-Zach

Consumer operating systems in 2013

<geek-rant> We’re halfway through 2013 and it just took me nearly 3 hours to get my brand new Lenovo laptop to dual boot Linux and win 8. (Story about needing win8 comes later). What the crap? Don’t worry, equal hate for both platforms in this rant.

1) For starters, win8 boots *awfully* slowly, even before I started messing with things (like, 3x longer than ubuntu on the same machine). Also, thoroughly not enjoying win8 in the half hour I’ve used it so far today (McAfee? Authorization dialogs that take over the entire screen? Every 10 seconds? And, goodness does it feel sluggish doing basic things)

2) Why does the ubuntu liveusb not have working graphics? I had to manually edit the kernel boot params to disable modesetting to even get to the installer!

3) And of course, once the installer was done it broke the ability to boot into windows (it actually wrote a grub config with an invalid command AND using the wrong partition AND using the wrong chainloader directive??!?).

4) Finally, it didn’t even install itself correctly! VESA was broken and it didn’t download FGLRX during install, so I had to setup the proprietary AMD drivers by hand, from VT1, with 80 columns of white-on black text.

Granted, the machine is running hardware that’s less than a year old, but that’s not an excuse anymore. If it were 2005 this would be alright, but it’s absolutely unacceptable in 2013.

Clearly something is systemically wrong here — but what, and how does the ecosystem need to change to fix this? Consumer operating systems are painfully simple compared to what’s running state of the art in the datacenter (I know this from first hand experience), we as a collective geekdom should be able to solve this.

</rant>

Broadcasting audio from ubuntu via HTTP (aka stream audio out to sonos on ubuntu)

This post is for all the folks who, like me, have tried (and failed out of frustration) 20 different times to stream local audio from an ubuntu machine to some other thing on the network via HTTP.  Today my goal was to get the Sonos in the office to stream from my machine — aka whatever was playing on my machine should come out of sonos.  I finally sat down and got it done with icecast and darkice today.  The basics for this article come from here.

OK, so without further ado, the basics:

sudo apt-get install icecast2 darkice
sudo nano /etc/default/icecast2

Change ENABLE=false to ENABLE=true.  The reason this is false by default is that icecast is actually a community radio streaming thing that is intended for multiple people to use.  Therefore it has some passwords in the default configuration file (/etc/icecast2/icecast.xml) that they want you to change before turning the thing on at first.  Since this is just us using icecast and we’re all on the local network, I chose to go with simplicity and defaults here.

Now, create a new config file someplace you like (perhaps ~/.darkice.cfg) which contains the following:

[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 1 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected
[input]
device = pulse
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # channels. 1 = mono, 2 = stereo
[icecast2-0]
bitrateMode = vbr # variable bit rate (cbr for constant)
quality = 1.0 # 1.0 is best quality
format = mp3
bitrate = 256 # bitrate
server = localhost # or IP
port = 8000 # port for IceCast2 
accesspassword = hackme # source password to the IceCast2 
servermountPoint = mystream.mp3 # mount point on the IceCast2 server or any name
name = mystream

Now bootup icecast

sudo /etc/init.d/icecast2 start

Now start darkice (the thing which actually reads pulse and sends it to icecast. Icecast then provides an HTTP URI you can use to give out to others)

darkice -c ~/.darkice.cfg

Now head on over to your consuming device and give it the url http://MY_IP:8000/mystream.mp3 (replacing MY_IP with your machines ip, aka 192.168.1.105).  In sonos you go to the “Radio” tab, hit “Add” then type in that url and a fancy-shamancy name.  Click the radio you created and shazam, good to go!

Note: there is a 3-4 second delay using icecast.  I’m not sure how much of that is icecast vs. sonos, but for just audio streaming its great.  That is, until I decide I really want to watch a youtube video with the audio coming out of sonos and I spend a few hours putting jack in the system…

Note: this was all done on Ubuntu 11.10 using standard repo versions of icecast, darkice, pulseaudio etc.

The problem isn’t piracy, it’s your product and publisher.

<provocative opening statement> A common saying you hear now a days in arguments about piracy is “I think people should get paid for their creative work”.    Yeah, well I don’t. </end troll-bait>

I think you should get paid for how well the free market likes you and decides to pay you.  It is your job to figure out how to be a businessmen and make money.

But I’m just an author and don’t understand business!

Then hire the person who is supposed to understand these things — a publisher!  It’s their responsibility, it is why you hire them, to make money in the marketplace with your creative work.  Historically they’ve been quite good at this.  Now that the market has been made more competitive (piracy is, after all, just a competitor to the work a publisher traditionally does) guess who are the ones complaining loudest?  That’s right, the folks who are supposed to be competing in the marketplace — the publishers.  Rather than compete against a competitor they are complaining for regulation to help keep their business afloat.

To paraphrase Gabe Newell’s Piracy is a service problem:  If you are being pirated, it means there’s something wrong with the service to begin with.  Somebody finds it more enjoyable or values more the experience of pirating your work than to get it via the channels you are offering.  Therefore you need to find a way to make your product more valuable than the pirated one.  Let me repeat that: It is your responsibility, as the person who wants to make money, to find a way to make your users happy enough that they want to pay you.

I don’t know of any other example of a business where I can launch my business, make money, have a competitor come in and then beg the government to make them go away.

Anybody who is complaining that piracy hurts their business is simply avoiding the problem that they aren’t providing a product that the marketplace likes enough to make money. Sure, piracy is incredible efficient so it makes your problem harder but that’s not the marketplace’s fault. Technology’s job is to make life more efficient and better for end users, I like to call it progress.

So rather than legislate to defend the old business models of a sector which was supposed to be market savvy to begin with, why don’t we let the market be efficient and have people innovate and let the businesses or technology that can provide the most end-user value win?

Discuss.

What are you doing, Boxee Box?

<rant>Its been almost a year since I started using my Boxee Box. Here are the new features I have noticed

  • Spotify Support
  • Grooveshark Support
  • Netflix Support

Things they made WORSE

  • Pandora — used to have an awesome visualizer and play for hours, now has a terrible visualizer and the darn thing freezes up after an hour or so due to (presumably) some kind of memory leak
  • The YouTube app inexplicably stopped working last week.

Things that are STILL broken

  • UPnP Support — Trying to find other UPnP devices simply does not work.
  • Random crashes — At random times it’ll reboot the UI or even the whole machine.
  • SDCard reading doesn’t work.  Insert an SD card into the boxee box, it says “SD Card inserted” but never shows up for me to browse as the documentation says it should.

Things they for there-must-be-some-reason but is INEXCUSABLE to have not done yet

  • Amazon Video on Demand!  Rokus had this for eons!
  • Better social integrations and sharing.  Why can’t I share immediately what im watching or listening to with somebody else?  I want to connect with other couch potatos using boxee and interact with them!  Maybe a chat app?  Video camera integration?
  • UI Speed and Polish — I shouldn’t be waiting 10 seconds everytime I start an app!  It also takes an INCREDIBLE number of button presses and clicks to get anything done.  From bootup to pandora playing I have to push at minimum 6 buttons.  That’s simply a user experience nightmare.
Overall though I don’t hate the Boxee Box.  It’s Pretty Good.  That said, they’ve had a year to go from Pretty Good to Excellent and have completely let me down in that respect.  </rant>

Track Racing on the East Coast

I finally made it to a track this weekend., and had an amazing time!  There are a bunch of things I learned in general about track racing through this experience, as far as logistics of how to actually do it.

General Info

  • Tracks rent out in time intervals, at the rate of thousands of dollars per hour.
  • “Groups” (aka BMW Club, Porsche Club, SSCA, EMRA) rent out the track for a few hours or a whole weekend.
  • Every group runs the day differently, and some are much more serious and competitive than others.
  • I went with EMRA, which is not super competitive and whose rules are a bit more relaxed.  They allow stock cars, stock seatbelts to race.  You need to tape up any glass (sunroofs, headlights), and have a proper racing helmet (snell rated), but that’s about it!
  • SSCA is much stricter about cars — everybody needs a rollcage etc.  Don’t expect to bring a stock M3 here generally.
  • No matter what you’ll pay several hundred $ for a track day.
  • HPDE — High performance Driver Education Event.
  • HPDE Insurance is a great idea — usually you can get this either at the track or buy it online ahead of time.  I paid about $115 for insurance for the day.
  • There are several tracks within 3-4 hours of NYC — to find a track day you can either pick a car club and look at their schedule, or pick a track and look at the track’s schedule.
    • Lime Rock Park
    • Watkin’s Glen
    • Pocinos Raceway
    • New Jersey Motorstate Park (NJMSP)
    • Summit Point Circuit
  • Unlike Autocross you usually get a LOT of time on the track at an event like this.  Anywhere from 1.5 -> 3 hours!
Bring to the track:
  • Your own Snell 2005 or 2010 rated FULL FACE helmet!  (Expect to pay $300+ for a good one)
  • Blue masking tape — the stuff that doesn’t leave residue
  • Zip Ties (to tie on a timing transponder)
  • A Razor / Sizzor (to cut the zip ties at the end of the day)
  • An EMPTY car — nothing in the trunk, etc.
  • Fresh break pads!  (You eat these guys up at the track!)

HID Kits, Xenon Bulbs and Halogen headlamps — The Story

So I’ve done a handful of research lately on halogen and Xenon lights.  Below is a basic summary of my findings when investigating (and eventually buying) replacements for my stock Halogen headlamps in my 2006 Mercedes C55 AMG.

Disclaimer: I pulled this together from bits and pieces here and there.  I do not claim to be an authority on lighting, but I think most of this is reasonably accurate.

Info about Xenons

  • HID = High-Intensity Discharge (for purposes of this doc, HID == Xenons)
  • HID Kit == Xenon Bulb (mine are size ‘D2S’ for low beam, H7 for high beam) + Ballast + Wiring.
  • If you already have headlamps with HIDs or are replacing the bulbs in an existing HID with a different color / temperature you do NOT need a whole new kit, just new bulbs.
  • Higher temperature == more color and less light
  • Stock color / temp is 4300Kelvin.  5000Kelvin is a brighter white, 6000K starts to look a bit blue and 8000K is getting fairly blue.  I went with 8000K 🙂
  • HID kits are generally a bit flaky, but are very cheap
  • Stock halogens are 35W, and to avoid complications its not a bad idea to stick with 35W if your upgrading to Xenon.  If the ECU notices a different power draw from the headlights it might throw errors.
  • Mercedes should be coded from Xenons (via STAR / ODBII computer systems) to avoid error codes.
Info about upgrading from Halogens to Xenons
  • If you have halogen lamps you can take out the halogens, buy an HID kit and be good to go, total cost of upgrade on the order of a couple hundred bucks (2-300) TOPS.
  • HOWEVER — You could also replace the whole headlamp assembly, which has several advantages:
    • Stock halogen headlamps do not use projector lenses.  Projector lenses look significantly better with Xenons than the traditional ones.
    • OEM Xenon headlamp kits come with their own ballast etc. which is generally more reliable than a HID Kit.
    • Mercedes OEM Xenon lamps have leveling motors etc, which is a nice to have but a bit gimmicky.
    •  I bought a used OEM Xenon assembly from a friend on mbworld.org — going to install them later this week.  Hoping for the best!

One way to do Django on AppEngine

Disclaimer: I work for Google.  Any and all opinions expressed or interpreted below are mine own and not that of my employer.

I’ve built dozens webapps in the past 10 years (thats right, i was writing web apps at 13) using all sorts of tools.  It started with raw HTML and spaghetti code perl.  Then it moved onto spaghetti code PHP.  Then it was PHP in a framework.  Then it was asp .NET and finally for the past 3 years or so I’ve used exclusively Django.

So naturally when a friend of mine approached me with an idea for a project using Google’s new prediction API I immediately thought to use Django.

But what’s the fun of doing a project the same way you’ve been doing it for 3 years?  Django + Apache + EC2 is boring.  I figured, I work for Google, perhaps I should be using a Google hosted solution.  It was time to use AppEngine.

Full stop.  Think for a minute.  Django, a highly relational tool built on databases like Mysql and Postgresql, seems fundamentally at odds with the philosophy of AppEngine — non relational, highly distributed.  Fudge!

OK, breathe.  There has to be a way to make this work.  From some research I discovered:

  • You *CAN* use Django + MySQL in AppEngine.  The most common technique I uncovered involves hosting MySQL outside of AppEngine and establishing a secure connection from AppEngine to the remote DB.  This seemed a bit excessive and wasteful — the whole point of this exercise is to use AppEngine!
  • Or, you could use Django-Nonrel

Django-Nonrel is a version of Django that modifies the Django query generator to work ontop of a non-relational database.  Beware though, this has some inherent drawbacks.  Complex joins and inheritance, for obvious reasons, no longer work.  Before continuing any further read through the entire django-nonrel page and all the limitations and make sure you can live with them.  I was able to, you probably (with a bit of work) can too.

That doesn’t solve all our problems though.  We still don’t have a connection between the Django application and the AppEngine datastore.  Thats where DjangoAppEngine comes in.  DAE provides the following, incredibly awesome, capabilities:

  • A connection between the django-nonrel query system and the AppEngine datastore.
  • Automagically sets up AppEngine logging for your Django App.
  • Automagically sets up the Django URL handling system within the AppEngine app — all you need to do is setup your urls.py!
  • Most importantly, provides new hooks within manage.py to allow you Django Shell access to your production AppEngine datastore!  While not critical once your app is deployed, for development and debugging this capability is invaluable!

So, brave adventurer, be off with you!  Explore the wonderful world of building applications with the ever popular python ORM Django ontop of the ever scalable AppEngine platform!   My experience was slow and painful, and involved a lot of head scratching and googling, but in the end all was working.   Read the documentation carefully and bliss shall be yours too!

Link to my app coming soon…

    Trying out the Nexus S

    I got a Nexus S today, and here are my initial thoughts, when comparing it to my Nokia N900.

    • No LED indicator light.  This is driving me nuts.  It’s rather jarring to not be able to look at my device and know whether or not it needs my attention.
    • It’s FAST!  Opening applications is instantaneous, scrolling is smooth, no slow downs whatsoever after the first day.
    • Android multitasking is rather annoying coming from Maemo.  I’m not in love with how it works, its kind’ve like “every app is always open” and to switch back to an application you just reopen it.  Thats nice, but it doesn’t lead to any nice workflows with great multitasking.
    • There is a lot more application support in the android ecosystem, which is nice coming from Maemo.
    • The lack of a physical keyboard is going to take some getting used to.  I’m not particularly thrilled about the on screen keyboard quiet yet.
    • Installing applications is quick and painless.  Much less frustrating than on Maemo.
    • I can actually use the email client!  It has good search features!  It doesn’t take 20 minutes to load!  Oh happy day!
    • There are… ads….?  In my applications?  This is weird.  I don’t like it.
    • SUPER integration with all Google services, which is sort’ve a big deal for me now a days.

    The Google services integration is actually the deal breaker for me, and is probably what will keep me on Android going forward.

    Update: So I’ve been using the phone for a couple of days now.   Here are some more thoughts:

    • Battery life is ‘meh’.  I felt like i had a lot more control over the battery usage on the N900 — changing from 2G/3G, disconnecting from the network etc. where all much simpler operations on the N900.
    • Using the phone, just for day to day stuff, is a pleasure.  By far the most ‘fun’ to use where it ‘just works’ a very large percentage of the time.
    • Voice commands are simply *phenominal*.  “Send text to daniel Hi dan, want to meet for drinks?” actually works about 90% of the time!  Or  “Goto engadget.com” or “navigate to pizza” all work rather well.  It’s what voice recognition should be like.
    • The navigation app is slow and almost unusable.  Nuts.