[openbeos] Re: Media Kit Query

  • From: John Hedditch <jhedditc@xxxxxxxxxxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sat, 21 Sep 2002 00:04:41 +0930

OK. Thanks for the tips - I'm about halfway through BMediaFormats now.

So far I have done

MakeFormatFor
GetFormatFor
Get<whatever>FormatFor
GetCodeFor
Lock()
Unlock()

I have a question to do with locking in this kit.

The idea of the Lock(), Unlock() calls seems to be to prevent the list of
supported formats/descriptions changing whilst you're looking at it, i.e to
prevent some sort of race condition between  RewindFormats/GetNextFormat and
the MakeFormatFor routine, plus the obvious one where 

Thread 1                Thread 2

while(!last_format)

GetNextFormat
                        RewindFormats
loop

My question is, if MakeFormatFor is called with BMediaFormats locked, should
it sleep and wait for the lock to be released, or should it return an 
error?

Furthermore, although the BeBook says that Lock()/Unlock() is only necessary
with the GetNextFormat/RewindFormats calls, the MakeFormatFor routine 
would seem to need to acquire it as well, for the same reason.

Any ideas?

John

Other related posts: