Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attaching a MediaRecorder instance to the Microphone breaks HDMI Output Audio #4

Open
scottmatheson opened this issue Aug 7, 2017 · 2 comments

Comments

@scottmatheson
Copy link

scottmatheson commented Aug 7, 2017

If a MediaRecorder instance attempts to attach to the HDMI Input via the MIC, the HDMI Output audio gets stuck repeating the same audio frame over and over from the moment the mMediaRecorder.start(); is executed. The full chipset release and start procedure must be performed to get HDMI Output working properly again.

Add/replace the code in RecordActivity for a demonstration:

    private boolean			isRecording			= false;
    private static final String TAG = "RecordActivity";
    private MediaRecorder mMediaRecorder = null;

    public boolean startRecorder(int format) {
		mMediaRecorder=new MediaRecorder();
		if (mMediaRecorder != null) {
			mMediaRecorder.setOnErrorListener(this);
			mMediaRecorder.setOnInfoListener(this);

			mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
			mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
			mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
			String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/recodedemo/" + System.currentTimeMillis() + (format == ZidooHdmiDisPlay.RECORD_FORMAT_TS ? ".ts" : ".mp4");
			//String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/out.mp4" ;
			mMediaRecorder.setOutputFile(p);
			try {
				mMediaRecorder.prepare();
				mMediaRecorder.start();
			}
			catch (Exception e) {
				Log.e(TAG, "Exception in preparing recorder", e);
				//Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
			}
		}
		isRecording = true;
		return true;
	}

	public void stopRecorder() {
		try {
			if (mMediaRecorder != null) {
				mMediaRecorder.stop();
				mMediaRecorder.reset();
				mMediaRecorder.release();
				mMediaRecorder=null;
			}
		}
		catch (Exception e) {
			Log.w(TAG, "Exception in stopping recorder", e);
			// can fail if start() failed for some reason
		}

		isRecording = false;
	}

	private void record() {
		if (isRecording) {
			stopRecorder();
			mRecordView.setText("Start recorde");
		} else {
			if (startRecorder(ZidooHdmiDisPlay.RECORD_FORMAT_MP4)) {
				mRecordView.setText("Stop recorde");
			}
		}
	}

	@Override
	public void onError(MediaRecorder mr, int what, int extra) {
		String msg = "Media Recorder Error";//getString(R.string.strange);
		switch (what) {
			case MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN:
				msg="Media Recorder Error Unknown";//getString(R.string.unknown_error);
				break;

			case MediaRecorder.MEDIA_ERROR_SERVER_DIED:
				msg="Media Recorder Server Died";//getString(R.string.server_died);
				break;
		}
		Log.w(TAG, msg);
	}

	@Override
	public void onInfo(MediaRecorder mr, int what, int extra) {
		// Is not usually called, supposedly
		String msg="Media Recorder Info";//getString(R.string.strange);
		switch (what) {
			case MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED:
				msg="Media Recorder Max Duration Reached";//getString(R.string.max_duration);
				break;

			case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
				msg="Media Recorder Max File Size Reached";//getString(R.string.max_size);
				break;
		}
		Log.d(TAG, msg);
	}
@scottmatheson
Copy link
Author

I have attached 2 files. The 1502144521520.mp4 file is the audio output captured by the MediaRecorder instance. The IMG_1527.m4v is a video recording of the interaction with the UI and the corresponding output. Ouch!

IMG_1527.m4v.zip
1502144521520.mp4.zip

@scottmatheson scottmatheson changed the title Attaching a MediaRecorder instance to copyrighted material breaks HDMI Output audio Attaching a MediaRecorder instance to the Microphone breaks HDMI Output Audio Aug 8, 2017
@scottmatheson
Copy link
Author

  1. Zidoo will not let you record copyrighted content using their interface/API.
  2. Zidoo will let you record non-copyrighted content using their interface/API.
  3. Attaching to the MIC while copyrighted content is playing causes the chipset to get stuck/repeat the same audio frame over and over. You must reset the chipset to recover.
  4. Attaching to the MIC while non-copyrighted content is playing causes the chipset to get stuck/repeat the same audio frame over and over. You must reset the chipset to recover.

The MIC is broken in all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant