[Scopeapp-cvs]scopeapp/src PortAudioSampler.h,1.1,1.2 PortAudioSampler.m,1.1,1.2
Status: Alpha
Brought to you by:
narge
|
From: <sco...@li...> - 2003-04-25 07:27:35
|
Update of /cvsroot/scopeapp/scopeapp/src
In directory sc8-pr-cvs1:/tmp/cvs-serv17938/src
Modified Files:
PortAudioSampler.h PortAudioSampler.m
Log Message:
Use the new InputErrorHandler protocol in PortAudioSampler; display sensible
error messages when an error occurs (rather than just using NSLog).
Index: PortAudioSampler.h
===================================================================
RCS file: /cvsroot/scopeapp/scopeapp/src/PortAudioSampler.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PortAudioSampler.h 5 Dec 2002 15:03:37 -0000 1.1
--- PortAudioSampler.h 25 Apr 2003 07:27:31 -0000 1.2
***************
*** 33,36 ****
--- 33,37 ----
// InputSampler data
id <InputHandler, NSObject> myOwner;
+ id <InputErrorHandler, NSObject> myErrorHandler;
int myBlockSize;
float mySampleRate;
***************
*** 42,49 ****
}
- -(id) init;
-
// init a sampler with a given owner object
! -(id) initWithOwner: (id <InputHandler>) owner;
-(void) dealloc;
--- 43,49 ----
}
// init a sampler with a given owner object
! -(id) initWithOwner: (id <InputHandler>) owner
! withErrorHandler: (id <InputErrorHandler, NSObject>) errorHandler;
-(void) dealloc;
Index: PortAudioSampler.m
===================================================================
RCS file: /cvsroot/scopeapp/scopeapp/src/PortAudioSampler.m,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PortAudioSampler.m 5 Dec 2002 15:03:38 -0000 1.1
--- PortAudioSampler.m 25 Apr 2003 07:27:32 -0000 1.2
***************
*** 26,29 ****
--- 26,30 ----
#import "PortAudioSampler.h"
+ #import "ScopeAppGlobals.h"
#import <AppKit/AppKit.h>
***************
*** 48,58 ****
@implementation PortAudioSampler
- -(id) init
- {
- return [self initWithOwner: nil];
- }
-
// init a sampler with a given owner object
-(id) initWithOwner: (id <InputHandler, NSObject>) owner
{
if(gPASamplerExists) return nil;
--- 49,55 ----
@implementation PortAudioSampler
// init a sampler with a given owner object
-(id) initWithOwner: (id <InputHandler, NSObject>) owner
+ withErrorHandler: (id <InputErrorHandler, NSObject>) errorHandler
{
if(gPASamplerExists) return nil;
***************
*** 65,68 ****
--- 62,68 ----
if(myOwner) { [myOwner retain]; }
+ myErrorHandler = errorHandler;
+ if(myErrorHandler) { [myErrorHandler retain]; }
+
mySamplerRunning = NO;
***************
*** 88,91 ****
--- 88,92 ----
if(myOwner != nil) { [myOwner release]; }
+ if(myErrorHandler != nil) { [myErrorHandler release]; }
[super dealloc];
***************
*** 120,126 ****
--- 121,138 ----
status = Pa_StartStream(myStream);
+
if (status) {
NSLog(@"Pa_StartStream: returned %d (%s)", status,
Pa_GetErrorText(status));
+
+ [myErrorHandler displayError: _(@"Couldn't start recording sound.")
+ withExtraText: [NSString stringWithFormat:
+ _(@"PortAudio returned error: %s"),
+ Pa_GetErrorText(status)]
+ withDefaultButton: _(@"OK")
+ withCancelButton: nil isFatal: YES];
+
+ mySamplerRunning = NO;
+
return nil;
}
***************
*** 140,143 ****
--- 152,165 ----
NSLog(@"Pa_StopStream: returned %d (%s)", status,
Pa_GetErrorText(status));
+
+ [myErrorHandler displayError: _(@"Couldn't stop recording sound.")
+ withExtraText: [NSString stringWithFormat:
+ _(@"PortAudio returned error: %s"),
+ Pa_GetErrorText(status)]
+ withDefaultButton: _(@"OK")
+ withCancelButton: nil isFatal: NO];
+
+ mySamplerRunning = YES;
+
return nil;
}
***************
*** 215,220 ****
status = Pa_Initialize();
if (status) {
! NSLog(@"Pa_StartStream: returned %d (%s)", status,
Pa_GetErrorText(status));
return nil;
}
--- 237,250 ----
status = Pa_Initialize();
if (status) {
! NSLog(@"Pa_Initialize: returned %d (%s)", status,
Pa_GetErrorText(status));
+
+ [myErrorHandler displayError: _(@"Couldn't open sound input device.")
+ withExtraText: [NSString stringWithFormat:
+ _(@"PortAudio returned error: %s"),
+ Pa_GetErrorText(status)]
+ withDefaultButton: _(@"OK")
+ withCancelButton: nil isFatal: YES];
+
return nil;
}
***************
*** 224,227 ****
--- 254,265 ----
if(inputDevice == paNoDevice) {
NSLog(@"Pa_GetDefaultInputDeviceID: returned paNoDevice");
+ [myErrorHandler displayError: _(@"Couldn't find sound input device.")
+ #if __APPLE__
+ withExtraText: _(@"Select a sound input device in the Sound panel of System Preferences.")
+ #else
+ withExtraText: _(@"Make sure your sound card is configured correctly.")
+ #endif
+ withDefaultButton: _(@"OK")
+ withCancelButton: nil isFatal: YES];
Pa_Terminate();
return nil;
***************
*** 263,266 ****
--- 301,312 ----
NSLog(@"Pa_OpenStream: returned %d (%s)", status,
Pa_GetErrorText(status));
+
+ [myErrorHandler displayError: _(@"Couldn't open sound input device.")
+ withExtraText: [NSString stringWithFormat:
+ _(@"PortAudio returned error: %s"),
+ Pa_GetErrorText(status)]
+ withDefaultButton: _(@"OK")
+ withCancelButton: nil isFatal: YES];
+
Pa_Terminate();
return nil;
|