Merge "MediaSync: clean up configureAudioTrack and configureSurface." into mnc-dev
This commit is contained in:
@@ -312,13 +312,13 @@ final public class MediaSync {
|
||||
* @throws IllegalArgumentException if the surface has been released, is invalid,
|
||||
* or can not be connected.
|
||||
* @throws IllegalStateException if setting the surface is not supported, e.g.
|
||||
* not in the Initialized state, or another surface has already been configured.
|
||||
* not in the Initialized state, or another surface has already been set.
|
||||
*/
|
||||
public void setSurface(@Nullable Surface surface) {
|
||||
native_configureSurface(surface);
|
||||
native_setSurface(surface);
|
||||
}
|
||||
|
||||
private native final void native_configureSurface(@Nullable Surface surface);
|
||||
private native final void native_setSurface(@Nullable Surface surface);
|
||||
|
||||
/**
|
||||
* Sets the audio track for MediaSync.
|
||||
@@ -328,21 +328,17 @@ final public class MediaSync {
|
||||
* @param audioTrack Specify an AudioTrack through which to render the audio data.
|
||||
* @throws IllegalArgumentException if the audioTrack has been released, or is invalid.
|
||||
* @throws IllegalStateException if setting the audio track is not supported, e.g.
|
||||
* not in the Initialized state, or another audio track has already been configured.
|
||||
* not in the Initialized state, or another audio track has already been set.
|
||||
*/
|
||||
public void setAudioTrack(@Nullable AudioTrack audioTrack) {
|
||||
// AudioTrack has sanity check for configured sample rate.
|
||||
int nativeSampleRateInHz = (audioTrack == null ? 0 : audioTrack.getSampleRate());
|
||||
|
||||
native_configureAudioTrack(audioTrack, nativeSampleRateInHz);
|
||||
native_setAudioTrack(audioTrack);
|
||||
mAudioTrack = audioTrack;
|
||||
if (audioTrack != null && mAudioThread == null) {
|
||||
createAudioThread();
|
||||
}
|
||||
}
|
||||
|
||||
private native final void native_configureAudioTrack(
|
||||
@Nullable AudioTrack audioTrack, int nativeSampleRateInHz);
|
||||
private native final void native_setAudioTrack(@Nullable AudioTrack audioTrack);
|
||||
|
||||
/**
|
||||
* Requests a Surface to use as the input. This may only be called after
|
||||
@@ -350,7 +346,7 @@ final public class MediaSync {
|
||||
* <p>
|
||||
* The application is responsible for calling release() on the Surface when
|
||||
* done.
|
||||
* @throws IllegalStateException if not configured, or another input surface has
|
||||
* @throws IllegalStateException if not set, or another input surface has
|
||||
* already been created.
|
||||
*/
|
||||
@NonNull
|
||||
@@ -574,7 +570,7 @@ final public class MediaSync {
|
||||
* @param sizeInBytes number of bytes to queue.
|
||||
* @param presentationTimeUs the presentation timestamp in microseconds for the first frame
|
||||
* in the buffer.
|
||||
* @throws IllegalStateException if audio track is not configured or internal configureation
|
||||
* @throws IllegalStateException if audio track is not set or internal configureation
|
||||
* has not been done correctly.
|
||||
*/
|
||||
public void queueAudio(
|
||||
@@ -582,7 +578,7 @@ final public class MediaSync {
|
||||
long presentationTimeUs) {
|
||||
if (mAudioTrack == null || mAudioThread == null) {
|
||||
throw new IllegalStateException(
|
||||
"AudioTrack is NOT configured or audio thread is not created");
|
||||
"AudioTrack is NOT set or audio thread is not created");
|
||||
}
|
||||
|
||||
synchronized(mAudioLock) {
|
||||
|
||||
@@ -61,12 +61,12 @@ JMediaSync::JMediaSync() {
|
||||
JMediaSync::~JMediaSync() {
|
||||
}
|
||||
|
||||
status_t JMediaSync::configureSurface(const sp<IGraphicBufferProducer> &bufferProducer) {
|
||||
return mSync->configureSurface(bufferProducer);
|
||||
status_t JMediaSync::setSurface(const sp<IGraphicBufferProducer> &bufferProducer) {
|
||||
return mSync->setSurface(bufferProducer);
|
||||
}
|
||||
|
||||
status_t JMediaSync::configureAudioTrack(const sp<AudioTrack> &audioTrack) {
|
||||
return mSync->configureAudioTrack(audioTrack);
|
||||
status_t JMediaSync::setAudioTrack(const sp<AudioTrack> &audioTrack) {
|
||||
return mSync->setAudioTrack(audioTrack);
|
||||
}
|
||||
|
||||
status_t JMediaSync::createInputSurface(
|
||||
@@ -163,9 +163,9 @@ static void throwExceptionAsNecessary(
|
||||
}
|
||||
}
|
||||
|
||||
static void android_media_MediaSync_native_configureSurface(
|
||||
static void android_media_MediaSync_native_setSurface(
|
||||
JNIEnv *env, jobject thiz, jobject jsurface) {
|
||||
ALOGV("android_media_MediaSync_configureSurface");
|
||||
ALOGV("android_media_MediaSync_setSurface");
|
||||
|
||||
sp<JMediaSync> sync = getMediaSync(env, thiz);
|
||||
if (sync == NULL) {
|
||||
@@ -184,7 +184,7 @@ static void android_media_MediaSync_native_configureSurface(
|
||||
}
|
||||
}
|
||||
|
||||
status_t err = sync->configureSurface(bufferProducer);
|
||||
status_t err = sync->setSurface(bufferProducer);
|
||||
|
||||
if (err == INVALID_OPERATION) {
|
||||
throwExceptionAsNecessary(
|
||||
@@ -196,9 +196,9 @@ static void android_media_MediaSync_native_configureSurface(
|
||||
}
|
||||
}
|
||||
|
||||
static void android_media_MediaSync_native_configureAudioTrack(
|
||||
static void android_media_MediaSync_native_setAudioTrack(
|
||||
JNIEnv *env, jobject thiz, jobject jaudioTrack) {
|
||||
ALOGV("android_media_MediaSync_configureAudioTrack");
|
||||
ALOGV("android_media_MediaSync_setAudioTrack");
|
||||
|
||||
sp<JMediaSync> sync = getMediaSync(env, thiz);
|
||||
if (sync == NULL) {
|
||||
@@ -215,7 +215,7 @@ static void android_media_MediaSync_native_configureAudioTrack(
|
||||
}
|
||||
}
|
||||
|
||||
status_t err = sync->configureAudioTrack(audioTrack);
|
||||
status_t err = sync->setAudioTrack(audioTrack);
|
||||
|
||||
if (err == INVALID_OPERATION) {
|
||||
throwExceptionAsNecessary(
|
||||
@@ -501,13 +501,13 @@ static void android_media_MediaSync_native_finalize(JNIEnv *env, jobject thiz) {
|
||||
}
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
{ "native_configureSurface",
|
||||
{ "native_setSurface",
|
||||
"(Landroid/view/Surface;)V",
|
||||
(void *)android_media_MediaSync_native_configureSurface },
|
||||
(void *)android_media_MediaSync_native_setSurface },
|
||||
|
||||
{ "native_configureAudioTrack",
|
||||
"(Landroid/media/AudioTrack;I)V",
|
||||
(void *)android_media_MediaSync_native_configureAudioTrack },
|
||||
{ "native_setAudioTrack",
|
||||
"(Landroid/media/AudioTrack;)V",
|
||||
(void *)android_media_MediaSync_native_setAudioTrack },
|
||||
|
||||
{ "createInputSurface", "()Landroid/view/Surface;",
|
||||
(void *)android_media_MediaSync_createInputSurface },
|
||||
|
||||
@@ -33,8 +33,8 @@ class MediaSync;
|
||||
struct JMediaSync : public RefBase {
|
||||
JMediaSync();
|
||||
|
||||
status_t configureSurface(const sp<IGraphicBufferProducer> &bufferProducer);
|
||||
status_t configureAudioTrack(const sp<AudioTrack> &audioTrack);
|
||||
status_t setSurface(const sp<IGraphicBufferProducer> &bufferProducer);
|
||||
status_t setAudioTrack(const sp<AudioTrack> &audioTrack);
|
||||
|
||||
status_t createInputSurface(sp<IGraphicBufferProducer>* bufferProducer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user