Re: NSSound Reimplementation

2009-06-13 Thread Stefan Bidigaray
OK, this is the architecture design I've come up with...

FYI: I deviated slightly from what I was originally thinking.  I'm going to
start a thread using NSThread's
-detachNewThreadWithSelector:toTarget:withObject: which will have a while
loop in it that streams the audio data.  I figured the playback methods
should just command the thread... -play starts the thread, -stop cancels it,
-pause blocks it, and -resume unblocks it (I'm still not sure how I'll
manage to do this).

So here's what I have, as far as interfaces go (i'm only presenting relevant
methods):

:
+ (BOOL)canInitWithSound: (NSSound *)aSound
Will verify this bundle can open the sound (be it raw, wav, ogg, mp3, etc)
- (id)initWithSound: (NSSound *)aSound
Will initialize the sound data for playback
- (NSUInteger)readBytes: (void *)bytes length: (NSUInteger)length
Reads the data
These next few match 1-to-1 with NSSound's methods and will be called by
NSSound...
- (NSTimeInterval)duration
- (void)setCurrentTime: (NSTimeInterval)
- (NSTimeInterval)currentTime
These are straight forward...
- (NSUInteger)bitsPerSample
- (NSUInteger)channelCount
- (NSUInteger)sampleRate
- (NSByteOrder)byteOrder

:
- (id) initWithBits: (NSUInteger)bitsPerSample
   channels: (NSUInteger)channelCount
 sampleRate: (NSUInteger)sampleRate
  byteOrder: (NSByteOrder)byteOrder
Initializes the device for playback with this info (see GSSoundInput's
methods)
- (BOOL)open
-initWithBits:... doesn't actually open the device, this does.
- (BOOL)close
Closes the device
- (NSUInteger)writeBytes: (void *)bytes length: (NSUInteger)length
Writes the data to the device (keep in mind the device can be anything that
accepts data, like a NSData object).
These next few match 1-to-1 with NSSound's methods and will be called by
NSSound...
- (void)setVolume: (float)volume
- (float)volume
- (NSString *)playbackDeviceIdentifier
- (void)setPlaybackDeviceIdentifier: (NSString *)playbackDeviceIdentifier
- (NSArray *)channelMapping
- (void)setChannelMapping: (NSArray *)channelMapping

NSSound:
- (id)initWithContentsOfFile:(NSString *)path byReference:(BOOL)byRef
Loads file in path using NSData's -initWithContentsOfMappedFile:
- (id)initWithData:(NSData *)data
Finds GSSoundInput and GSSoundOutput compatible bundles and initializes
them.
- (BOOL)pause
Blocks the thread.
- (BOOL)play
Makes sure there's no "stream" thread running for this NSSound and starts
one.
- (BOOL)resume
Unblocks/resume the thread.
- (BOOL)stop
Tell the thread to exit.
- (BOOL)isPlaying
If "stream" thread exists and is unblocked will return YES, otherwise NO.
- (void)_stream
This is where the stream loop actually occurs.

Is this a sensible design? I'm not sure this is the best way to go, but it's
the best I could come up with so far and I'd really like some feedback.
Like I mentioned before, I'm not really sure how to block and unblock the
thread, so I'll need some help there (the Apple docs are really confusing
with the whole thread thing, specially with the "this is how you do it...
you can also do it this way with 10.5 but we don't recommend it since it's
new").

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


NSCalendar and NSLocale support

2009-06-13 Thread Dave MacLachlan

Hey there...

I'm looking to add NSCalendar and NSLocale to Foundation. I'm happy to  
implement them, but I was hoping to do it on top of ICU (http://site.icu-project.org/ 
).


Are we willing to add a dependency on ICU to gnustep?

The ICU license is GNU GPL compatible...

http://userguide.icu-project.org/icufaq#TOC-How-is-the-ICU-licensed-

Or perhaps I should be looking somewhere else?

Cheers,
Dave


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


Re: Bad Undefines in NSKeyedArchiver and NSKeyedArchiver?

2009-06-13 Thread Dave MacLachlan


On Jun 13, 2009, at 01:19 , Richard Frith-Macdonald wrote:



On 13 Jun 2009, at 07:26, Dave MacLachlan wrote:

Excuse me if this is a silly question, but I just ran into problems  
compiling these two headers (Foundation/NSKeyedArchiver.h and  
Foundation/NSArchiver.h) and the fix looks obvious, but it's also  
obvious that these files have been this way for years.


Thanks ... I fixed that ... though it's clearly harmless normally,  
as the macro is defined to the same thing twice and the compiler  
doesn't even warn when a macro is being defined to the same value  
twice.  If you are encountering compiler warnings/errors then I  
guess you must be redefining GSIArray yourself, which you probably  
shouldn't be doing.  Maybe you want to look into using the new  
NSPointerArray class instead?
Obviously NSPointerArray is new, relatively untested code, but it's  
MacOS-X/Cocoa compatible.


Great thanks.

Cheers,
Dave


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


Re: Bad Undefines in NSKeyedArchiver and NSKeyedArchiver?

2009-06-13 Thread Richard Frith-Macdonald


On 13 Jun 2009, at 07:26, Dave MacLachlan wrote:

Excuse me if this is a silly question, but I just ran into problems  
compiling these two headers (Foundation/NSKeyedArchiver.h and  
Foundation/NSArchiver.h) and the fix looks obvious, but it's also  
obvious that these files have been this way for years.


Thanks ... I fixed that ... though it's clearly harmless normally, as  
the macro is defined to the same thing twice and the compiler doesn't  
even warn when a macro is being defined to the same value twice.  If  
you are encountering compiler warnings/errors then I guess you must be  
redefining GSIArray yourself, which you probably shouldn't be doing.   
Maybe you want to look into using the new NSPointerArray class instead?
Obviously NSPointerArray is new, relatively untested code, but it's  
MacOS-X/Cocoa compatible.



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