Thanks Wolfgang, this stuff really helps.

On Sat, Jun 27, 2009 at 4:32 PM, Wolfgang Lux <wolfgang....@gmail.com>wrote:

> I had a look at the code you posted yesterday and I've found two dubious
> points in NSSound_test.m:
>
> First, there is a retain/release error in NSSound's
> -initWithContentsOfFile:byRef: method. The NSData object returned from
> dataWithContentsOfMappedFile: is already autoreleased, but you release that
> object after calling -initWithData: (recall that you should only release
> objects that you own, which in general are only objects that you have
> allocated yourself either with alloc or copy).


I went ahead and made this change.  Is the reason I wasn't getting a seg
fault due to the TEST_RELEASE instead of a normal RELEASE?


> Second, I noticed that you call -performSelectorOnMainThread... with
> waitUntilDone = NO. I think you should use waitUntilDone = YES here. Note
> that if waitUntilDone = NO and you call -performSelectorOnMainThread... from
> the main thread the call is scheduled to be run at the next iteration of the
> run loop and not performed immediately. In addition, if you really use
> waitUntilDone = NO on purpose you should make sure that the sound object is
> retained until the scheduled method is actually run (i.e., you probably
> should retain self before calling performSelectorOnMainThread and
> autorelease self in _finished). Otherwise, there is a chance that the thread
> which calls the _stream method releases the sound object too early and the
> run loop invokes _finished for an already released object.


I tried setting waitUntilDone to YES, still no luck!  The -_finished method
still doesn't get called when calling -performSelectorOnMainThread:..., for
now I've just made that a -performSelector:withObject:, which works, but is
not what I want done.  I guess my next question here is: is
-performSelectorOnMainThread:withObject:waitUntilDone: working?  Maybe I
built -base incorrectly?

As for the check in -dealloc, it was inherited from the original
implementation, I'll go ahead and remove it.  This probably explains why I
used to get a crash whenever -dealloc was called.

On related news.... I've implemented the bundle/plug-in loading code, and so
far it works flawlessly.  There's still a lot that needs to be done, but I
think I might have this fully implemented by mid July.

I'm also having issues with -setCurrentTime:, I'm now using sf_seek() in
SndfileSource.m and the tool will crash either on that call or on
sf_read_short() in -_stream.  The best I've come up with is that sf_seek()
and sf_read_short() are trying to access the same data, at the same time
(sf_seek() is called from the main thread and sf_read_short() from the
stream thread) and blowing up.  I thought adding a lock in NSSound's
-setCurrentTime: would fix this problem but it did not.  Hopefully I'll get
some more stuff done today and will post the latest version of the test tool
for you guys to take a look.

Thanks
Stefan
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to