Update of /cvsroot/foo/foo/libfoo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11202
Modified Files:
FOOSoundFile.m
Log Message:
added reopen method, comment support
Index: FOOSoundFile.m
===================================================================
RCS file: /cvsroot/foo/foo/libfoo/src/FOOSoundFile.m,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** FOOSoundFile.m 16 Aug 2004 04:48:27 -0000 1.5
--- FOOSoundFile.m 30 Aug 2004 14:35:04 -0000 1.6
***************
*** 63,66 ****
--- 63,67 ----
_file = NULL;
_fileName = nil;
+ _fileComment = nil;
_dynamics = NULL;
_cache.ptr = NULL;
***************
*** 77,80 ****
--- 78,82 ----
_file = NULL;
_fileName = nil;
+ _fileComment = nil;
_dynamics = NULL;
_cache.ptr = NULL;
***************
*** 109,113 ****
--- 111,121 ----
{
int mode;
+ const char *comment;
+ if ([self isOpen] == YES && [self close] == NO)
+ {
+ return NO;
+ }
+
switch (sndmode)
{
***************
*** 148,151 ****
--- 156,165 ----
// }
+ if (! (comment = sf_get_string(_file, SF_STR_COMMENT)))
+ {
+ comment = "";
+ }
+ _fileComment = [[NSString alloc] initWithCString: comment];
+
_fileMode = sndmode;
_fileFrames = _fileInfo.frames;
***************
*** 161,164 ****
--- 175,189 ----
+ - (BOOL) reopenWithMode: (int)sndmode
+ {
+ if (sndmode == _fileMode)
+ {
+ return YES;
+ }
+
+ return [self open: [NSString stringWithString: _fileName] mode: sndmode];
+ } // reopenWithMode:
+
+
- (BOOL) isOpen
{
***************
*** 206,209 ****
--- 231,239 ----
_fileName = nil;
}
+ if (_fileComment != nil)
+ {
+ RELEASE(_fileComment);
+ _fileComment = nil;
+ }
return YES;
***************
*** 497,500 ****
--- 527,564 ----
+ - (NSString *) getFileComment
+ {
+ return _fileComment;
+ } // getFileComment
+
+
+ - (int) setFileCommentFromString: (NSString *)fileComment
+ {
+ int result;
+
+ if ([self isOpen] == NO)
+ {
+ FOO_ERROR(YES, -98);
+ }
+ if (_fileMode == SND_READ)
+ {
+ FOO_ERROR(YES, -99);
+ }
+
+ result = sf_set_string(_file, SF_STR_COMMENT, [fileComment cString]);
+
+ if (! result)
+ { // succeeded, update _fileComment
+ if (_fileComment != nil)
+ {
+ RELEASE(_fileComment);
+ }
+ _fileComment = RETAIN(fileComment);
+ }
+
+ return result;
+ } // setFileCommentFromString
+
+
- validateDynamics
{
|