Browse Source

Fixed bug that caused microphone data to still be displayed after selecting another mode

Thomas Buck 9 years ago
parent
commit
05abf8cf30
2 changed files with 11 additions and 17 deletions
  1. 10
    16
      CaseLights/AppDelegate.m
  2. 1
    1
      CaseLights/Info.plist

+ 10
- 16
CaseLights/AppDelegate.m View File

373
     
373
     
374
     // Stop previous audio data retrieval
374
     // Stop previous audio data retrieval
375
     if (microphone != nil) {
375
     if (microphone != nil) {
376
-        [microphone stopFetchingAudio];
376
+        [microphone setMicrophoneOn:NO];
377
     }
377
     }
378
     
378
     
379
     // Remove display callback
379
     // Remove display callback
433
     
433
     
434
     // Stop previous audio data retrieval
434
     // Stop previous audio data retrieval
435
     if (microphone != nil) {
435
     if (microphone != nil) {
436
-        [microphone stopFetchingAudio];
436
+        [microphone setMicrophoneOn:NO];
437
     }
437
     }
438
     
438
     
439
     // Turn off all other LED menu items
439
     // Turn off all other LED menu items
591
         
591
         
592
         // Stop previous audio data retrieval
592
         // Stop previous audio data retrieval
593
         if (microphone != nil) {
593
         if (microphone != nil) {
594
-            [microphone stopFetchingAudio];
594
+            [microphone setMicrophoneOn:NO];
595
         }
595
         }
596
 
596
 
597
         // Turn off all other LED menu items
597
         // Turn off all other LED menu items
680
     
680
     
681
     // Stop previous audio data retrieval
681
     // Stop previous audio data retrieval
682
     if (microphone != nil) {
682
     if (microphone != nil) {
683
-        [microphone stopFetchingAudio];
683
+        [microphone setMicrophoneOn:NO];
684
     }
684
     }
685
     
685
     
686
     // Schedule next invocation for this animation...
686
     // Schedule next invocation for this animation...
724
     
724
     
725
     // Stop previous audio data retrieval
725
     // Stop previous audio data retrieval
726
     if (microphone != nil) {
726
     if (microphone != nil) {
727
-        [microphone stopFetchingAudio];
727
+        [microphone setMicrophoneOn:NO];
728
     }
728
     }
729
     
729
     
730
     // Schedule next invocation for this animation...
730
     // Schedule next invocation for this animation...
785
                 // Found device
785
                 // Found device
786
                 foundDev = YES;
786
                 foundDev = YES;
787
                 if (microphone != nil) {
787
                 if (microphone != nil) {
788
-                    [microphone stopFetchingAudio];
788
+                    [microphone setMicrophoneOn:NO];
789
                 } else {
789
                 } else {
790
                     microphone = [EZMicrophone microphoneWithDelegate:self];
790
                     microphone = [EZMicrophone microphoneWithDelegate:self];
791
                 }
791
                 }
792
                 [microphone setDevice:dev];
792
                 [microphone setDevice:dev];
793
-                [microphone startFetchingAudio];
793
+                [microphone setMicrophoneOn:YES];
794
                 break;
794
                 break;
795
             }
795
             }
796
         }
796
         }
821
                 
821
                 
822
                 // Stop previous audio data retrieval
822
                 // Stop previous audio data retrieval
823
                 if (microphone != nil) {
823
                 if (microphone != nil) {
824
-                    [microphone stopFetchingAudio];
824
+                    [microphone setMicrophoneOn:NO];
825
                 }
825
                 }
826
                 
826
                 
827
                 NSColor *color = [staticColors valueForKey:key];
827
                 NSColor *color = [staticColors valueForKey:key];
933
 - (void)microphone:(EZMicrophone *)microphone hasAudioReceived:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels {
933
 - (void)microphone:(EZMicrophone *)microphone hasAudioReceived:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels {
934
     __weak typeof (self) weakSelf = self;
934
     __weak typeof (self) weakSelf = self;
935
     
935
     
936
-    if (weakSelf.microphone == nil) {
937
-        return;
938
-    }
939
-    
940
     // Getting audio data as an array of float buffer arrays that can be fed into the
936
     // Getting audio data as an array of float buffer arrays that can be fed into the
941
     // EZAudioPlot, EZAudioPlotGL, or whatever visualization you would like to do with
937
     // EZAudioPlot, EZAudioPlotGL, or whatever visualization you would like to do with
942
     // the microphone data.
938
     // the microphone data.
943
     dispatch_async(dispatch_get_main_queue(),^{
939
     dispatch_async(dispatch_get_main_queue(),^{
944
-        if (weakSelf.microphone == nil) {
940
+        if (weakSelf.microphone.microphoneOn == NO) {
945
             return;
941
             return;
946
         }
942
         }
947
-        
943
+            
948
         // buffer[0] = left channel, buffer[1] = right channel
944
         // buffer[0] = left channel, buffer[1] = right channel
949
         [AudioVisualizer updateBuffer:buffer[0] withBufferSize:bufferSize];
945
         [AudioVisualizer updateBuffer:buffer[0] withBufferSize:bufferSize];
950
     });
946
     });
951
 }
947
 }
952
 
948
 
953
 - (void)microphone:(EZMicrophone *)microphone changedDevice:(EZAudioDevice *)device {
949
 - (void)microphone:(EZMicrophone *)microphone changedDevice:(EZAudioDevice *)device {
954
-    // This is not always guaranteed to occur on the main thread so make sure you
955
-    // wrap it in a GCD block
956
     dispatch_async(dispatch_get_main_queue(), ^{
950
     dispatch_async(dispatch_get_main_queue(), ^{
957
         NSLog(@"Changed audio input device: %@", [device name]);
951
         NSLog(@"Changed audio input device: %@", [device name]);
958
     });
952
     });

+ 1
- 1
CaseLights/Info.plist View File

21
 	<key>CFBundleSignature</key>
21
 	<key>CFBundleSignature</key>
22
 	<string>????</string>
22
 	<string>????</string>
23
 	<key>CFBundleVersion</key>
23
 	<key>CFBundleVersion</key>
24
-	<string>402</string>
24
+	<string>404</string>
25
 	<key>LSApplicationCategoryType</key>
25
 	<key>LSApplicationCategoryType</key>
26
 	<string>public.app-category.utilities</string>
26
 	<string>public.app-category.utilities</string>
27
 	<key>LSMinimumSystemVersion</key>
27
 	<key>LSMinimumSystemVersion</key>

Loading…
Cancel
Save