Skip to content

Commit

Permalink
v2.0.0-beta03 (#392)
Browse files Browse the repository at this point in the history
* Fix #377 and update dependencies

* Fix #384

* Fix unbindFromSurface bug

* Bump version to v2.0.0-beta03

* Update build.gradle
  • Loading branch information
natario1 authored Feb 23, 2019
1 parent 7411614 commit d462b83
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CameraView is a well documented, high-level library that makes capturing picture
addressing most of the common issues and needs, and still leaving you with flexibility where needed.

```groovy
compile 'com.otaliastudios:cameraview:2.0.0-beta02'
compile 'com.otaliastudios:cameraview:2.0.0-beta03'
```

- Fast & reliable
Expand Down
2 changes: 1 addition & 1 deletion cameraview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

// Required by bintray
version = '2.0.0-beta02'
version = '2.0.0-beta03'
group = 'com.otaliastudios'

//region android dependencies
Expand Down
19 changes: 2 additions & 17 deletions cameraview/src/main/gles/com/otaliastudios/cameraview/EglCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public EglCore(EGLContext sharedContext, int flags) {
int[] values = new int[1];
EGL14.eglQueryContext(mEGLDisplay, mEGLContext, EGL14.EGL_CONTEXT_CLIENT_VERSION,
values, 0);
Log.d(TAG, "EGLContext created, client version " + values[0]);
// Log.d(TAG, "EGLContext created, client version " + values[0]);
}

/**
Expand Down Expand Up @@ -273,7 +273,7 @@ public EGLSurface createOffscreenSurface(int width, int height) {
public void makeCurrent(EGLSurface eglSurface) {
if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
// called makeCurrent() before create?
Log.d(TAG, "NOTE: makeCurrent w/o display");
// Log.d(TAG, "NOTE: makeCurrent w/o display");
}
if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) {
throw new RuntimeException("eglMakeCurrent failed");
Expand Down Expand Up @@ -351,21 +351,6 @@ public int getGlVersion() {
return mGlVersion;
}

/**
* Writes the current display, context, and surface to the log.
*/
public static void logCurrent(String msg) {
EGLDisplay display;
EGLContext context;
EGLSurface surface;

display = EGL14.eglGetCurrentDisplay();
context = EGL14.eglGetCurrentContext();
surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
", surface=" + surface);
}

/**
* Checks for EGL errors. Throws an exception if an error has been raised.
*/
Expand Down
29 changes: 21 additions & 8 deletions cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public void run() {
});
}

// Preview surface is now available. If camera is open, set up.
/**
* Preview surface is now available. If camera is open, set up.
* At this point we are sure that mPreview is not null.
*/
@Override
public void onSurfaceAvailable() {
LOG.i("onSurfaceAvailable:", "Size is", mPreview.getOutputSurfaceSize());
Expand All @@ -80,8 +83,11 @@ public void run() {
});
}

// Preview surface did change its size. Compute a new preview size.
// This requires stopping and restarting the preview.
/**
* Preview surface did change its size. Compute a new preview size.
* This requires stopping and restarting the preview.
* At this point we are sure that mPreview is not null.
*/
@Override
public void onSurfaceChanged() {
LOG.i("onSurfaceChanged, size is", mPreview.getOutputSurfaceSize());
Expand Down Expand Up @@ -119,8 +125,11 @@ private boolean shouldBindToSurface() {
return isCameraAvailable() && mPreview != null && mPreview.hasSurface() && !mIsBound;
}

// The act of binding an "open" camera to a "ready" preview.
// These can happen at different times but we want to end up here.
/**
* The act of binding an "open" camera to a "ready" preview.
* These can happen at different times but we want to end up here.
* At this point we are sure that mPreview is not null.
*/
@WorkerThread
private void bindToSurface() {
LOG.i("bindToSurface:", "Started");
Expand Down Expand Up @@ -275,7 +284,7 @@ void onStop() {
}
if (mCamera != null) {
stopPreview();
unbindFromSurface();
if (mIsBound) unbindFromSurface();
destroyCamera();
}
mCameraOptions = null;
Expand Down Expand Up @@ -440,8 +449,12 @@ private boolean applyPlaySounds(boolean oldPlaySound) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(mCameraId, info);
if (info.canDisableShutterSound) {
mCamera.enableShutterSound(mPlaySounds);
return true;
try {
// this method is documented to throw on some occasions. #377
return mCamera.enableShutterSound(mPlaySounds);
} catch (RuntimeException exception) {
return false;
}
}
}
if (mPlaySounds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ abstract class CameraController implements
mFrameManager = new FrameManager(2, this);
}

void setPreview(CameraPreview cameraPreview) {
void setPreview(@NonNull CameraPreview cameraPreview) {
mPreview = cameraPreview;
mPreview.setSurfaceCallback(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ public void setLifecycleOwner(@NonNull LifecycleOwner owner) {
public void open() {
if (!isEnabled()) return;
if (mCameraPreview != null) mCameraPreview.onResume();

if (checkPermissions(getAudio())) {
// Update display orientation for current CameraController
mOrientationHelper.enable(getContext());
Expand Down
4 changes: 2 additions & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ android {

dependencies {
implementation project(':cameraview')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'com.google.android.material:material:1.1.0-alpha03'
}
4 changes: 2 additions & 2 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<activity
android:name=".CameraActivity"
android:theme="@style/Theme.MainActivity"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenLayout|keyboardHidden"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:hardwareAccelerated="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
9 changes: 8 additions & 1 deletion docs/_posts/2018-12-20-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ order: 3

New versions are released through GitHub, so the reference page is the [GitHub Releases](https://github.com/natario1/CameraView/releases) page.

### v2.0.0-beta03

- Fixed a few bugs ([#392][392])
- Important fixes to video snapshot recording ([#374][374])

### v2.0.0-beta02

- Fixed important bugs ([#356][356])
Expand All @@ -19,4 +24,6 @@ New versions are released through GitHub, so the reference page is the [GitHub R
This is the first beta release. For changes with respect to v1, please take a look at the [migration guide](../extra/v1-migration-guide.html).

[356]: https://github.com/natario1/CameraView/pull/356
[360]: https://github.com/natario1/CameraView/pull/360
[360]: https://github.com/natario1/CameraView/pull/360
[374]: https://github.com/natario1/CameraView/pull/374
[392]: https://github.com/natario1/CameraView/pull/392
2 changes: 1 addition & 1 deletion docs/_posts/2018-12-20-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {
Then simply download the latest version:

```groovy
api 'com.otaliastudios:cameraview:2.0.0-beta02'
api 'com.otaliastudios:cameraview:2.0.0-beta03'
```

No other configuration steps are needed.

0 comments on commit d462b83

Please sign in to comment.