Skip to content

Commit b0ff9fb

Browse files
authored
Merge pull request #25738 from lorentey/CoreMedia-shims-5.1
[5.1][Shims] Add CoreMedia overlay shims
2 parents d0b40fb + 0c019cd commit b0ff9fb

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(sources
2020
UnicodeShims.h
2121
Visibility.h
2222

23+
CoreMediaOverlayShims.h
2324
DispatchOverlayShims.h
2425
NetworkOverlayShims.h
2526
OSOverlayShims.h
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//===--- CoreMediaOverlayShims.h ---===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file contains replacements for the initializers of some CoreMedia
14+
// objects that return the created instance as an out parameter and thus
15+
// cannot be used in Swift as-is.
16+
//
17+
//===----------------------------------------------------------------------===//
18+
19+
#ifndef SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H
20+
#define SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H
21+
22+
@import CoreMedia;
23+
@import CoreFoundation;
24+
25+
#if __has_feature(nullability)
26+
#pragma clang assume_nonnull begin
27+
#endif
28+
29+
// slurped from CoreAudio headers that are sometime private.
30+
typedef UInt32 AudioObjectID;
31+
typedef AudioObjectID AudioDeviceID;
32+
33+
// slurped from CoreMedia headers; see https://bugs.swift.org/browse/SR-2999
34+
typedef struct CM_BRIDGED_TYPE(id) OpaqueCMBlockBuffer *CMBlockBufferRef;
35+
typedef struct CM_BRIDGED_TYPE(id) opaqueCMBufferQueue *CMBufferQueueRef;
36+
typedef struct CM_BRIDGED_TYPE(id) OpaqueCMClock* CMClockRef;
37+
typedef const struct CM_BRIDGED_TYPE(id) opaqueCMFormatDescription *CMFormatDescriptionRef;
38+
typedef struct CM_BRIDGED_TYPE(id) opaqueCMSampleBuffer *CMSampleBufferRef;
39+
typedef struct CM_BRIDGED_TYPE(id) opaqueCMSimpleQueue *CMSimpleQueueRef;
40+
typedef struct CM_BRIDGED_TYPE(id) OpaqueCMTimebase* CMTimebaseRef;
41+
42+
#define INIT_REFERENCING(Type, availability) \
43+
CM_INLINE CM_RETURNS_RETAINED_PARAMETER Type##Ref CM_NONNULL \
44+
Type##Retain( \
45+
Type##Ref CM_NONNULL object) \
46+
CF_SWIFT_NAME(Type.init(referencing:)) \
47+
CF_REFINED_FOR_SWIFT \
48+
availability ;\
49+
CM_INLINE CM_RETURNS_RETAINED_PARAMETER Type##Ref CM_NONNULL \
50+
Type##Retain( \
51+
Type##Ref CM_NONNULL object) \
52+
{ \
53+
return (Type##Ref)CFRetain(object);\
54+
}
55+
56+
INIT_REFERENCING(CMClock, API_AVAILABLE(macosx(10.8)) API_UNAVAILABLE(ios, tvos, watchos))
57+
58+
INIT_REFERENCING(CMBlockBuffer, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))
59+
60+
INIT_REFERENCING(CMBufferQueue, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))
61+
62+
INIT_REFERENCING(CMFormatDescription, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))
63+
64+
INIT_REFERENCING(CMSampleBuffer, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))
65+
66+
INIT_REFERENCING(CMSimpleQueue, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))
67+
68+
INIT_REFERENCING(CMTimebase, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))
69+
70+
#if __has_feature(nullability)
71+
#pragma clang assume_nonnull end
72+
#endif
73+
74+
75+
#endif // SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H

stdlib/public/SwiftShims/module.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ module _SwiftNetworkOverlayShims {
7575
module _SwiftClockKitOverlayShims {
7676
header "ClockKitOverlayShims.h"
7777
}
78+
79+
module _SwiftCoreMediaOverlayShims {
80+
header "CoreMediaOverlayShims.h"
81+
}

0 commit comments

Comments
 (0)