Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c97418e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "ndk data source: add close API"

parents 33727211 45b88d22
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct AMediaDataSource {
    void *userdata;
    AMediaDataSourceReadAt readAt;
    AMediaDataSourceGetSize getSize;
    AMediaDataSourceClose close;
};

NdkDataSource::NdkDataSource(AMediaDataSource *dataSource)
@@ -77,6 +78,12 @@ String8 NdkDataSource::getMIMEType() const {
    return String8("application/octet-stream");
}

void NdkDataSource::close() {
    if (mDataSource->close != NULL && mDataSource->userdata != NULL) {
        mDataSource->close(mDataSource->userdata);
    }
}

extern "C" {

EXPORT
@@ -85,6 +92,7 @@ AMediaDataSource* AMediaDataSource_new() {
    mSource->userdata = NULL;
    mSource->readAt = NULL;
    mSource->getSize = NULL;
    mSource->close = NULL;
    return mSource;
}

@@ -111,5 +119,10 @@ void AMediaDataSource_setGetSize(AMediaDataSource *mSource, AMediaDataSourceGetS
    mSource->getSize = getSize;
}

EXPORT
void AMediaDataSource_setClose(AMediaDataSource *mSource, AMediaDataSourceClose close) {
    mSource->close = close;
}

} // extern "C"
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ struct NdkDataSource : public DataSource {
    virtual status_t getSize(off64_t *);
    virtual String8 toString();
    virtual String8 getMIMEType() const;
    virtual void close();

private:

+18 −0
Original line number Diff line number Diff line
@@ -73,6 +73,13 @@ typedef ssize_t (*AMediaDataSourceReadAt)(
 */
typedef ssize_t (*AMediaDataSourceGetSize)(void *userdata);

/**
 * Called to close the data source and release associated resources.
 * The NDK media framework guarantees that after |close| is called
 * no future callbacks will be invoked on the data source.
 */
typedef void (*AMediaDataSourceClose)(void *userdata);

/**
 * Create new media data source. Returns NULL if memory allocation
 * for the new data source object fails.
@@ -117,6 +124,17 @@ void AMediaDataSource_setGetSize(
        AMediaDataSource*,
        AMediaDataSourceGetSize);

/**
 * Set a custom callback to receive signal from the NDK media framework
 * when the data source is closed.
 *
 * Please refer to the definition of AMediaDataSourceClose for
 * additional details.
 */
void AMediaDataSource_setClose(
        AMediaDataSource*,
        AMediaDataSourceClose);

#endif  /*__ANDROID_API__ >= 28 */

__END_DECLS
+1 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ LIBMEDIANDK {
    AMediaCrypto_requiresSecureDecoderComponent;
    AMediaDataSource_delete;      # introduced=28
    AMediaDataSource_new;         # introduced=28
    AMediaDataSource_setClose;    # introduced=28
    AMediaDataSource_setGetSize;  # introduced=28
    AMediaDataSource_setReadAt;   # introduced=28
    AMediaDataSource_setUserdata; # introduced=28