소스 검색

VLCAudio: add passthrough property (closes #17)

Felix Paul Kühne 8 년 전
부모
커밋
4877c42ead
3개의 변경된 파일30개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 0
      Headers/Public/VLCAudio.h
  2. 3 1
      NEWS
  3. 22 0
      Sources/VLCAudio.m

+ 5 - 0
Headers/Public/VLCAudio.h

@@ -47,6 +47,11 @@ extern NSString *const VLCMediaPlayerVolumeChanged;
 @property (assign) int volume;
 
 /**
+ * enable passthrough mode for the current audio device
+ * \note There is no warrenty that it succeeds as it depends on the capabilities of the hardware audio decoder / receiver attached by the user */
+@property (readwrite) BOOL passthrough;
+
+/**
  * Mute the current audio output.
  * \deprecated This selector will be removed in the next release */
 - (void)setMute:(BOOL)value __attribute__((deprecated));

+ 3 - 1
NEWS

@@ -44,7 +44,6 @@ New APIs:
       (int)currentTitleIndex
       (int)currentAudioTrackIndex
 
-
 - VLCMedia
   - added keys: VLCMetaInformationTrackTotal, VLCMetaInformationDirector,
                 VLCMetaInformationSeason, VLCMetaInformationEpisode,
@@ -68,6 +67,9 @@ New APIs:
   - added selectors: isEqual:
                      hash
 
+- VLCAudio
+  - added property: passthrough
+
 Deprecated APIs:
 - VLCAudio
   - setMute:

+ 22 - 0
Sources/VLCAudio.m

@@ -86,6 +86,28 @@ NSString *const VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
     return libvlc_audio_get_mute([self instance]);
 }
 
+- (void)setPassthrough:(BOOL)passthrough
+{
+    if (passthrough) {
+        libvlc_audio_output_device_set([self instance], NULL, "encoded");
+    } else {
+        libvlc_audio_output_device_set([self instance], NULL, "pcm");
+    }
+}
+
+- (BOOL)passthrough
+{
+    char *deviceIdentifier = libvlc_audio_output_device_get([self instance]);
+    if (deviceIdentifier != NULL) {
+        if (!strcmp(deviceIdentifier, "encoded")) {
+            return YES;
+        }
+        free(deviceIdentifier);
+    }
+
+    return NO;
+}
+
 - (void)setVolume:(int)value
 {
     if (value < VOLUME_MIN)