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

+ 1
- 1
CaseLights/Info.plist View File

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

Loading…
Cancel
Save