diff options
Diffstat (limited to 'media')
31 files changed, 2225 insertions, 575 deletions
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 3346bed..4d1535f 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -88,7 +88,7 @@ public class AudioRecord private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT = -16; private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -17; private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT = -18; - private static final int AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE = -19; + private static final int AUDIORECORD_ERROR_SETUP_INVALIDSOURCE = -19; private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED = -20; // Events: @@ -113,13 +113,7 @@ public class AudioRecord */ @SuppressWarnings("unused") private int mNativeRecorderInJavaObj; - /** - * Accessed by native methods: provides access to record source constants - */ - @SuppressWarnings("unused") - private final static int SOURCE_DEFAULT = MediaRecorder.AudioSource.DEFAULT; - @SuppressWarnings("unused") - private final static int SOURCE_MIC = MediaRecorder.AudioSource.MIC; + /** * Accessed by native methods: provides access to the callback data. */ @@ -252,8 +246,8 @@ public class AudioRecord //-------------- // audio source - if ( (audioSource != MediaRecorder.AudioSource.DEFAULT) - && (audioSource != MediaRecorder.AudioSource.MIC) ) { + if ( (audioSource < MediaRecorder.AudioSource.DEFAULT) || + (audioSource > MediaRecorder.getAudioSourceMax()) ) { throw (new IllegalArgumentException("Invalid audio source.")); } else { mRecordSource = audioSource; diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 881de4d..937baad 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -163,6 +163,9 @@ public class AudioService extends IAudioService.Stub { */ private int mRingerMode; + /** @see System#MODE_RINGER_STREAMS_AFFECTED */ + private int mRingerModeAffectedStreams; + /** @see System#MUTE_STREAMS_AFFECTED */ private int mMuteAffectedStreams; @@ -286,6 +289,10 @@ public class AudioService extends IAudioService.Stub { mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0); + mRingerModeAffectedStreams = Settings.System.getInt(cr, + Settings.System.MODE_RINGER_STREAMS_AFFECTED, + ((1 << AudioManager.STREAM_RING)|(1 << AudioManager.STREAM_NOTIFICATION)|(1 << AudioManager.STREAM_SYSTEM))); + mMuteAffectedStreams = System.getInt(cr, System.MUTE_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM))); @@ -399,7 +406,7 @@ public class AudioService extends IAudioService.Stub { ensureValidStreamType(streamType); syncRingerAndNotificationStreamVolume(streamType, index, false); - setStreamVolumeInt(streamType, index, false); + setStreamVolumeInt(streamType, index, false, true); // UI, etc. mVolumePanel.postVolumeChanged(streamType, flags); @@ -437,7 +444,7 @@ public class AudioService extends IAudioService.Stub { } if (streamType == AudioManager.STREAM_RING) { // One-off to sync notification volume to ringer volume - setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION, index, force); + setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION, index, force, true); } } } @@ -451,10 +458,11 @@ public class AudioService extends IAudioService.Stub { * @param index Desired volume index of the stream * @param force If true, set the volume even if the desired volume is same * as the current volume. + * @param lastAudible If true, stores new index as last audible one */ - private void setStreamVolumeInt(int streamType, int index, boolean force) { + private void setStreamVolumeInt(int streamType, int index, boolean force, boolean lastAudible) { VolumeStreamState streamState = mStreamStates[streamType]; - if (streamState.setIndex(index) || force) { + if (streamState.setIndex(index, lastAudible) || force) { // Post message to set system volume (it in turn will post a message // to persist). Do not change volume if stream is muted. if (streamState.muteCount() == 0) { @@ -517,13 +525,20 @@ public class AudioService extends IAudioService.Stub { if (!isStreamAffectedByRingerMode(streamType)) continue; // Bring back last audible volume setStreamVolumeInt(streamType, mStreamStates[streamType].mLastAudibleIndex, - false); + false, false); } } else { for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) { - if (!isStreamAffectedByRingerMode(streamType)) continue; - // Either silent or vibrate, either way volume is 0 - setStreamVolumeInt(streamType, 0, false); + if (isStreamAffectedByRingerMode(streamType)) { + // Either silent or vibrate, either way volume is 0 + setStreamVolumeInt(streamType, 0, false, false); + } else { + // restore stream volume in the case the stream changed from affected + // to non affected by ringer mode. Does not arm to do it for streams that + // are not affected as well. + setStreamVolumeInt(streamType, mStreamStates[streamType].mLastAudibleIndex, + false, false); + } } } @@ -621,7 +636,7 @@ public class AudioService extends IAudioService.Stub { int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE); int index = mStreamStates[streamType].mIndex; syncRingerAndNotificationStreamVolume(streamType, index, true); - setStreamVolumeInt(streamType, index, true); + setStreamVolumeInt(streamType, index, true, true); } } @@ -653,7 +668,7 @@ public class AudioService extends IAudioService.Stub { mSpeakerIsOn = true; mRoutes[AudioSystem.MODE_IN_CALL] = AudioSystem.ROUTE_SPEAKER; incallMask = AudioSystem.ROUTE_ALL; - } else if (mSpeakerIsOn) { + } else if (routes == 0 && mSpeakerIsOn) { mSpeakerIsOn = false; if (mBluetoothScoIsConnected) { mRoutes[AudioSystem.MODE_IN_CALL] = AudioSystem.ROUTE_BLUETOOTH_SCO; @@ -680,7 +695,7 @@ public class AudioService extends IAudioService.Stub { // should not affect A2DP routing ringtoneMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; normalMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; - } else if (mBluetoothScoIsConnected) { + } else if (routes == 0 && mBluetoothScoIsConnected) { mBluetoothScoIsConnected = false; if (mHeadsetIsConnected) { mRoutes[AudioSystem.MODE_IN_CALL] = AudioSystem.ROUTE_HEADSET; @@ -724,7 +739,7 @@ public class AudioService extends IAudioService.Stub { ringtoneMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; normalMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; } - } else if (mHeadsetIsConnected) { + } else if (routes == 0 && mHeadsetIsConnected) { mHeadsetIsConnected = false; // do not act upon headset disconnection if bluetooth SCO is connected to match phone app behavior if (!mBluetoothScoIsConnected) { @@ -757,7 +772,7 @@ public class AudioService extends IAudioService.Stub { // so there is no need to disable other routes. ringtoneMask = AudioSystem.ROUTE_BLUETOOTH_A2DP; normalMask = AudioSystem.ROUTE_BLUETOOTH_A2DP; - } else if (mBluetoothA2dpIsConnected) { + } else if (routes == 0 && mBluetoothA2dpIsConnected) { mBluetoothA2dpIsConnected = false; mRoutes[AudioSystem.MODE_RINGTONE] &= ~AudioSystem.ROUTE_BLUETOOTH_A2DP; mRoutes[AudioSystem.MODE_NORMAL] &= ~AudioSystem.ROUTE_BLUETOOTH_A2DP; @@ -791,7 +806,7 @@ public class AudioService extends IAudioService.Stub { int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE); int index = mStreamStates[streamType].mIndex; syncRingerAndNotificationStreamVolume(streamType, index, true); - setStreamVolumeInt(streamType, index, true); + setStreamVolumeInt(streamType, index, true, true); } } } @@ -941,9 +956,7 @@ public class AudioService extends IAudioService.Stub { } public boolean isStreamAffectedByRingerMode(int streamType) { - int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver, - Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); - return (ringerModeAffectedStreams & (1 << streamType)) != 0; + return (mRingerModeAffectedStreams & (1 << streamType)) != 0; } public boolean isStreamAffectedByMute(int streamType) { @@ -1095,15 +1108,15 @@ public class AudioService extends IAudioService.Stub { } public boolean adjustIndex(int deltaIndex) { - return setIndex(mIndex + deltaIndex); + return setIndex(mIndex + deltaIndex, true); } - public boolean setIndex(int index) { + public boolean setIndex(int index, boolean lastAudible) { int oldIndex = mIndex; mIndex = getValidIndex(index); if (oldIndex != mIndex) { - if (mIndex > 0) { + if (lastAudible) { mLastAudibleIndex = mIndex; } return true; @@ -1153,7 +1166,7 @@ public class AudioService extends IAudioService.Stub { mDeathHandlers.add(this); // If the stream is not yet muted by any client, set lvel to 0 if (muteCount() == 0) { - setIndex(0); + setIndex(0, false); sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, mStreamType, SENDMSG_NOOP, 0, 0, VolumeStreamState.this, 0); } @@ -1180,7 +1193,7 @@ public class AudioService extends IAudioService.Stub { // If the stream is not mut any more, restore it's volume if // ringer mode allows it if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) { - setIndex(mLastAudibleIndex); + setIndex(mLastAudibleIndex, false); sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, mStreamType, SENDMSG_NOOP, 0, 0, VolumeStreamState.this, 0); } @@ -1405,6 +1418,10 @@ public class AudioService extends IAudioService.Stub { public void onChange(boolean selfChange) { super.onChange(selfChange); + mRingerModeAffectedStreams = Settings.System.getInt(mContentResolver, + Settings.System.MODE_RINGER_STREAMS_AFFECTED, + 0); + /* * Ensure all stream types that should be affected by ringer mode * are in the proper state. diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 3cd841d..5f1be9d 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -425,8 +425,7 @@ public class AudioTrack } /** - * Returns the current playback rate in Hz. Note that this rate may differ from the one set - * with {@link #setPlaybackRate(int)} as the value effectively used is implementation-dependent. + * Returns the current playback rate in Hz. */ public int getPlaybackRate() { return native_get_playback_rate(); @@ -651,18 +650,13 @@ public class AudioTrack * Sets the playback sample rate for this track. This sets the sampling rate at which * the audio data will be consumed and played back, not the original sampling rate of the * content. Setting it to half the sample rate of the content will cause the playback to - * last twice as long, but will also result result in a negative pitch shift. - * The current implementation supports a maximum sample rate of 64kHz. - * Use {@link #getSampleRate()} to check the rate actually used in hardware after - * potential clamping. + * last twice as long, but will also result in a negative pitch shift. + * The valid sample rate range if from 1Hz to twice the value returned by + * {@link #getNativeOutputSampleRate(int)}. * @param sampleRateInHz the sample rate expressed in Hz * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE}, * {@link #ERROR_INVALID_OPERATION} */ - // FIXME: the implementation should support twice the hardware output sample rate - // (see {@link #getNativeOutputSampleRate(int)}), but currently - // due to the representation of the sample rate in the native layer, the sample rate - // is limited to 65535Hz public int setPlaybackRate(int sampleRateInHz) { if (mState != STATE_INITIALIZED) { return ERROR_INVALID_OPERATION; @@ -670,8 +664,7 @@ public class AudioTrack if (sampleRateInHz <= 0) { return ERROR_BAD_VALUE; } - native_set_playback_rate(sampleRateInHz); - return SUCCESS; + return native_set_playback_rate(sampleRateInHz); } @@ -1031,8 +1024,8 @@ public class AudioTrack private native final void native_setVolume(float leftVolume, float rightVolume); - private native final void native_set_playback_rate(int sampleRateInHz); - private native final int native_get_playback_rate(); + private native final int native_set_playback_rate(int sampleRateInHz); + private native final int native_get_playback_rate(); private native final int native_set_marker_pos(int marker); private native final int native_get_marker_pos(); diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 19ab0ad..3b46d69 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -58,7 +58,7 @@ import java.lang.ref.WeakReference; * MediaPlayer object driven by the supported playback control operations. * The ovals represent the states a MediaPlayer object may reside * in. The arcs represent the playback control operations that drive the object - * state transition. There are two types of arcs. The arcs with a single arrow + * state transition. There are two types of arcs. The arcs with a single arrow * head represent synchronous method calls, while those with * a double arrow head represent asynchronous method calls.</p> * @@ -69,42 +69,42 @@ import java.lang.ref.WeakReference; * <p>From this state diagram, one can see that a MediaPlayer object has the * following states:</p> * <ul> - * <li>When a MediaPlayer object is just created using <code>new</code> or - * after {@link #reset()} is called, it is in the <em>Idle</em> state; and after - * {@link #release()} is called, it is in the <em>End</em> state. Between these - * two states is the life cycle of the MediaPlayer object. + * <li>When a MediaPlayer object is just created using <code>new</code> or + * after {@link #reset()} is called, it is in the <em>Idle</em> state; and after + * {@link #release()} is called, it is in the <em>End</em> state. Between these + * two states is the life cycle of the MediaPlayer object. * <ul> - * <li>There is a subtle but important difference between a newly constructed - * MediaPlayer object and the MediaPlayer object after {@link #reset()} - * is called. It is a programming error to invoke methods such - * as {@link #getCurrentPosition()}, - * {@link #getDuration()}, {@link #getVideoHeight()}, + * <li>There is a subtle but important difference between a newly constructed + * MediaPlayer object and the MediaPlayer object after {@link #reset()} + * is called. It is a programming error to invoke methods such + * as {@link #getCurrentPosition()}, + * {@link #getDuration()}, {@link #getVideoHeight()}, * {@link #getVideoWidth()}, {@link #setAudioStreamType(int)}, * {@link #setLooping(boolean)}, - * {@link #setVolume(float, float)}, {@link #pause()}, {@link #start()}, - * {@link #stop()}, {@link #seekTo(int)}, {@link #prepare()} or - * {@link #prepareAsync()} in the <em>Idle</em> state for both cases. If any of these - * methods is called right after a MediaPlayer object is constructed, - * the user supplied callback method OnErrorListener.onError() won't be + * {@link #setVolume(float, float)}, {@link #pause()}, {@link #start()}, + * {@link #stop()}, {@link #seekTo(int)}, {@link #prepare()} or + * {@link #prepareAsync()} in the <em>Idle</em> state for both cases. If any of these + * methods is called right after a MediaPlayer object is constructed, + * the user supplied callback method OnErrorListener.onError() won't be * called by the internal player engine and the object state remains - * unchanged; but if these methods are called right after {@link #reset()}, + * unchanged; but if these methods are called right after {@link #reset()}, * the user supplied callback method OnErrorListener.onError() will be - * invoked by the internal player engine and the object will be + * invoked by the internal player engine and the object will be * transfered to the <em>Error</em> state. </li> - * <li>It is also recommended that once - * a MediaPlayer object is no longer being used, call {@link #release()} immediately - * so that resources used by the internal player engine associated with the + * <li>It is also recommended that once + * a MediaPlayer object is no longer being used, call {@link #release()} immediately + * so that resources used by the internal player engine associated with the * MediaPlayer object can be released immediately. Resource may include - * singleton resources such as hardware acceleration components and + * singleton resources such as hardware acceleration components and * failure to call {@link #release()} may cause subsequent instances of * MediaPlayer objects to fallback to software implementations or fail * altogether. Once the MediaPlayer - * object is in the <em>End</em> state, it can no longer be used and + * object is in the <em>End</em> state, it can no longer be used and * there is no way to bring it back to any other state. </li> - * <li>Furthermore, - * the MediaPlayer objects created using <code>new</code> is in the - * <em>Idle</em> state, while those created with one - * of the overloaded convenient <code>create</code> methods are <em>NOT</em> + * <li>Furthermore, + * the MediaPlayer objects created using <code>new</code> is in the + * <em>Idle</em> state, while those created with one + * of the overloaded convenient <code>create</code> methods are <em>NOT</em> * in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> * state if the creation using <code>create</code> method is successful. * </li> @@ -114,23 +114,23 @@ import java.lang.ref.WeakReference; * reasons, such as unsupported audio/video format, poorly interleaved * audio/video, resolution too high, streaming timeout, and the like. * Thus, error reporting and recovery is an important concern under - * these circumstances. Sometimes, due to programming errors, invoking a playback + * these circumstances. Sometimes, due to programming errors, invoking a playback * control operation in an invalid state may also occur. Under all these * error conditions, the internal player engine invokes a user supplied * OnErrorListener.onError() method if an OnErrorListener has been * registered beforehand via * {@link #setOnErrorListener(android.media.MediaPlayer.OnErrorListener)}. * <ul> - * <li>It is important to note that once an error occurs, the - * MediaPlayer object enters the <em>Error</em> state (except as noted + * <li>It is important to note that once an error occurs, the + * MediaPlayer object enters the <em>Error</em> state (except as noted * above), even if an error listener has not been registered by the application.</li> * <li>In order to reuse a MediaPlayer object that is in the <em> - * Error</em> state and recover from the error, + * Error</em> state and recover from the error, * {@link #reset()} can be called to restore the object to its <em>Idle</em> * state.</li> - * <li>It is good programming practice to have your application - * register a OnErrorListener to look out for error notifications from - * the internal player engine.</li> + * <li>It is good programming practice to have your application + * register a OnErrorListener to look out for error notifications from + * the internal player engine.</li> * <li>IlleglStateException is * thrown to prevent programming errors such as calling {@link #prepare()}, * {@link #prepareAsync()}, or one of the overloaded <code>setDataSource @@ -141,28 +141,28 @@ import java.lang.ref.WeakReference; * {@link #setDataSource(FileDescriptor)}, or * {@link #setDataSource(String)}, or * {@link #setDataSource(Context, Uri)}, or - * {@link #setDataSource(FileDescriptor, long, long)} transfers a + * {@link #setDataSource(FileDescriptor, long, long)} transfers a * MediaPlayer object in the <em>Idle</em> state to the * <em>Initialized</em> state. * <ul> - * <li>An IllegalStateException is thrown if + * <li>An IllegalStateException is thrown if * setDataSource() is called in any other state.</li> - * <li>It is good programming - * practice to always look out for <code>IllegalArgumentException</code> + * <li>It is good programming + * practice to always look out for <code>IllegalArgumentException</code> * and <code>IOException</code> that may be thrown from the overloaded * <code>setDataSource</code> methods.</li> * </ul> * </li> * <li>A MediaPlayer object must first enter the <em>Prepared</em> state - * before playback can be started. + * before playback can be started. * <ul> * <li>There are two ways (synchronous vs. * asynchronous) that the <em>Prepared</em> state can be reached: * either a call to {@link #prepare()} (synchronous) which * transfers the object to the <em>Prepared</em> state once the method call * returns, or a call to {@link #prepareAsync()} (asynchronous) which - * first transfers the object to the <em>Preparing</em> state after the - * call returns (which occurs almost right way) while the internal + * first transfers the object to the <em>Preparing</em> state after the + * call returns (which occurs almost right way) while the internal * player engine continues working on the rest of preparation work * until the preparation work completes. When the preparation completes or when {@link #prepare()} call returns, * the internal player engine then calls a user supplied callback method, @@ -173,22 +173,22 @@ import java.lang.ref.WeakReference; * the <em>Preparing</em> state is a transient state, and the behavior * of calling any method with side effect while a MediaPlayer object is * in the <em>Preparing</em> state is undefined.</li> - * <li>An IllegalStateException is - * thrown if {@link #prepare()} or {@link #prepareAsync()} is called in - * any other state.</li> - * <li>While in the <em>Prepared</em> state, properties - * such as audio/sound volume, screenOnWhilePlaying, looping can be + * <li>An IllegalStateException is + * thrown if {@link #prepare()} or {@link #prepareAsync()} is called in + * any other state.</li> + * <li>While in the <em>Prepared</em> state, properties + * such as audio/sound volume, screenOnWhilePlaying, looping can be * adjusted by invoking the corresponding set methods.</li> * </ul> * </li> - * <li>To start the playback, {@link #start()} must be called. After + * <li>To start the playback, {@link #start()} must be called. After * {@link #start()} returns successfully, the MediaPlayer object is in the - * <em>Started</em> state. {@link #isPlaying()} can be called to test + * <em>Started</em> state. {@link #isPlaying()} can be called to test * whether the MediaPlayer object is in the <em>Started</em> state. * <ul> * <li>While in the <em>Started</em> state, the internal player engine calls * a user supplied OnBufferingUpdateListener.onBufferingUpdate() callback - * method if a OnBufferingUpdateListener has been registered beforehand + * method if a OnBufferingUpdateListener has been registered beforehand * via {@link #setOnBufferingUpdateListener(OnBufferingUpdateListener)}. * This callback allows applications to keep track of the buffering status * while streaming audio/video.</li> @@ -197,44 +197,44 @@ import java.lang.ref.WeakReference; * </ul> * </li> * <li>Playback can be paused and stopped, and the current playback position - * can be adjusted. Playback can be paused via {@link #pause()}. When the call to + * can be adjusted. Playback can be paused via {@link #pause()}. When the call to * {@link #pause()} returns, the MediaPlayer object enters the - * <em>Paused</em> state. Note that the transition from the <em>Started</em> - * state to the <em>Paused</em> state and vice versa happens - * asynchronously in the player engine. It may take some time before - * the state is updated in calls to {@link #isPlaying()}, and it can be + * <em>Paused</em> state. Note that the transition from the <em>Started</em> + * state to the <em>Paused</em> state and vice versa happens + * asynchronously in the player engine. It may take some time before + * the state is updated in calls to {@link #isPlaying()}, and it can be * a number of seconds in the case of streamed content. * <ul> - * <li>Calling {@link #start()} to resume playback for a paused + * <li>Calling {@link #start()} to resume playback for a paused * MediaPlayer object, and the resumed playback - * position is the same as where it was paused. When the call to + * position is the same as where it was paused. When the call to * {@link #start()} returns, the paused MediaPlayer object goes back to * the <em>Started</em> state.</li> * <li>Calling {@link #pause()} has no effect on * a MediaPlayer object that is already in the <em>Paused</em> state.</li> * </ul> * </li> - * <li>Calling {@link #stop()} stops playback and causes a + * <li>Calling {@link #stop()} stops playback and causes a * MediaPlayer in the <em>Started</em>, <em>Paused</em>, <em>Prepared - * </em> or <em>PlaybackCompleted</em> state to enter the + * </em> or <em>PlaybackCompleted</em> state to enter the * <em>Stopped</em> state. * <ul> - * <li>Once in the <em>Stopped</em> state, playback cannot be started + * <li>Once in the <em>Stopped</em> state, playback cannot be started * until {@link #prepare()} or {@link #prepareAsync()} are called to set * the MediaPlayer object to the <em>Prepared</em> state again.</li> - * <li>Calling {@link #stop()} has no effect on a MediaPlayer + * <li>Calling {@link #stop()} has no effect on a MediaPlayer * object that is already in the <em>Stopped</em> state.</li> * </ul> * </li> - * <li>The playback position can be adjusted with a call to - * {@link #seekTo(int)}. + * <li>The playback position can be adjusted with a call to + * {@link #seekTo(int)}. * <ul> * <li>Although the asynchronuous {@link #seekTo(int)} * call returns right way, the actual seek operation may take a while to - * finish, especially for audio/video being streamed. When the actual - * seek operation completes, the internal player engine calls a user + * finish, especially for audio/video being streamed. When the actual + * seek operation completes, the internal player engine calls a user * supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener - * has been registered beforehand via + * has been registered beforehand via * {@link #setOnSeekCompleteListener(OnSeekCompleteListener)}.</li> * <li>Please * note that {@link #seekTo(int)} can also be called in the other states, @@ -242,7 +242,7 @@ import java.lang.ref.WeakReference; * </em> state.</li> * <li>Furthermore, the actual current playback position * can be retrieved with a call to {@link #getCurrentPosition()}, which - * is helpful for applications such as a Music player that need to keep + * is helpful for applications such as a Music player that need to keep * track of the playback progress.</li> * </ul> * </li> @@ -272,7 +272,7 @@ import java.lang.ref.WeakReference; * <td>Invalid States </p></td> * <td>Comments </p></td></tr> * <tr><td>getCurrentPosition </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted} </p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method in a valid state does not change the @@ -282,45 +282,45 @@ import java.lang.ref.WeakReference; * <td>{Prepared, Started, Paused, Stopped, PlaybackCompleted} </p></td> * <td>{Idle, Initialized, Error} </p></td> * <td>Successful invoke of this method in a valid state does not change the - * state. Calling this method in an invalid state transfers the object + * state. Calling this method in an invalid state transfers the object * to the <em>Error</em> state. </p></td></tr> * <tr><td>getVideoHeight </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method in a valid state does not change the - * state. Calling this method in an invalid state transfers the object + * state. Calling this method in an invalid state transfers the object * to the <em>Error</em> state. </p></td></tr> * <tr><td>getVideoWidth </p></td> * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> - * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an invalid state transfers the + * <td>Successful invoke of this method in a valid state does not change + * the state. Calling this method in an invalid state transfers the * object to the <em>Error</em> state. </p></td></tr> * <tr><td>isPlaying </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an invalid state transfers the + * the state. Calling this method in an invalid state transfers the * object to the <em>Error</em> state. </p></td></tr> * <tr><td>pause </p></td> * <td>{Started, Paused}</p></td> * <td>{Idle, Initialized, Prepared, Stopped, PlaybackCompleted, Error}</p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Paused</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Paused</em> state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * <tr><td>prepare </p></td> * <td>{Initialized, Stopped} </p></td> * <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error} </p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Prepared</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Prepared</em> state. Calling this method in an * invalid state throws an IllegalStateException.</p></td></tr> * <tr><td>prepareAsync </p></td> * <td>{Initialized, Stopped} </p></td> * <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error} </p></td> - * <td>Successful invoke of this method in a valid state transfers the + * <td>Successful invoke of this method in a valid state transfers the * object to the <em>Preparing</em> state. Calling this method in an * invalid state throws an IllegalStateException.</p></td></tr> * <tr><td>release </p></td> @@ -328,18 +328,18 @@ import java.lang.ref.WeakReference; * <td>{} </p></td> * <td>After {@link #release()}, the object is no longer available. </p></td></tr> * <tr><td>reset </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted, Error}</p></td> * <td>{}</p></td> * <td>After {@link #reset()}, the object is like being just created.</p></td></tr> * <tr><td>seekTo </p></td> * <td>{Prepared, Started, Paused, PlaybackCompleted} </p></td> * <td>{Idle, Initialized, Stopped, Error}</p></td> - * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an invalid state transfers the + * <td>Successful invoke of this method in a valid state does not change + * the state. Calling this method in an invalid state transfers the * object to the <em>Error</em> state. </p></td></tr> * <tr><td>setAudioStreamType </p></td> - * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, + * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method does not change the state.</p></td></tr> @@ -347,8 +347,8 @@ import java.lang.ref.WeakReference; * <td>{Idle} </p></td> * <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, * Error} </p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Initialized</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Initialized</em> state. Calling this method in an * invalid state throws an IllegalStateException.</p></td></tr> * <tr><td>setDisplay </p></td> * <td>any </p></td> @@ -356,11 +356,11 @@ import java.lang.ref.WeakReference; * <td>This method can be called in any state and calling it does not change * the object state. </p></td></tr> * <tr><td>setLooping </p></td> - * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, + * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> - * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an + * <td>Successful invoke of this method in a valid state does not change + * the state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * <tr><td>isLooping </p></td> * <td>any </p></td> @@ -398,7 +398,7 @@ import java.lang.ref.WeakReference; * <td>This method can be called in any state and calling it does not change * the object state. </p></td></tr> * <tr><td>setVolume </p></td> - * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, + * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method does not change the state. @@ -410,14 +410,14 @@ import java.lang.ref.WeakReference; * <tr><td>start </p></td> * <td>{Prepared, Started, Paused, PlaybackCompleted}</p></td> * <td>{Idle, Initialized, Stopped, Error}</p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Started</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Started</em> state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * <tr><td>stop </p></td> * <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> * <td>{Idle, Initialized, Error}</p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Stopped</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Stopped</em> state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * </table> * @@ -429,13 +429,13 @@ import java.lang.ref.WeakReference; * */ public class MediaPlayer -{ +{ static { System.loadLibrary("media_jni"); } - + private final static String TAG = "MediaPlayer"; - + private int mNativeContext; // accessed by native methods private int mListenerContext; // accessed by native methods private Surface mSurface; // accessed by native methods @@ -444,16 +444,16 @@ public class MediaPlayer private PowerManager.WakeLock mWakeLock = null; private boolean mScreenOnWhilePlaying; private boolean mStayAwake; - + /** - * Default constructor. Consider using one of the create() methods for + * Default constructor. Consider using one of the create() methods for * synchronously instantiating a MediaPlayer from a Uri or resource. * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances may * result in an exception.</p> */ public MediaPlayer() { - + Looper looper; if ((looper = Looper.myLooper()) != null) { mEventHandler = new EventHandler(this, looper); @@ -468,17 +468,27 @@ public class MediaPlayer */ native_setup(new WeakReference<MediaPlayer>(this)); } - + + /* + * Update the MediaPlayer ISurface. Call after updating mSurface. + */ + private native void _setVideoSurface(); + /** * Sets the SurfaceHolder to use for displaying the video portion of the media. * This call is optional. Not calling it when playing back a video will * result in only the audio track being played. - * + * * @param sh the SurfaceHolder to use for video display */ public void setDisplay(SurfaceHolder sh) { mSurfaceHolder = sh; - mSurface = sh.getSurface(); + if (sh != null) { + mSurface = sh.getSurface(); + } else { + mSurface = null; + } + _setVideoSurface(); updateSurfaceScreenOn(); } @@ -488,29 +498,29 @@ public class MediaPlayer * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> - * - * @param context the Context to use + * + * @param context the Context to use * @param uri the Uri from which to get the datasource * @return a MediaPlayer object, or null if creation failed */ public static MediaPlayer create(Context context, Uri uri) { return create (context, uri, null); } - + /** * Convenience method to create a MediaPlayer for a given Uri. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> - * - * @param context the Context to use + * + * @param context the Context to use * @param uri the Uri from which to get the datasource * @param holder the SurfaceHolder to use for displaying the video * @return a MediaPlayer object, or null if creation failed */ public static MediaPlayer create(Context context, Uri uri, SurfaceHolder holder) { - + try { MediaPlayer mp = new MediaPlayer(); mp.setDataSource(context, uri); @@ -539,9 +549,9 @@ public class MediaPlayer * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> - * - * @param context the Context to use - * @param resid the raw resource id (<var>R.raw.<something></var>) for + * + * @param context the Context to use + * @param resid the raw resource id (<var>R.raw.<something></var>) for * the resource to use as the datasource * @return a MediaPlayer object, or null if creation failed */ @@ -567,17 +577,17 @@ public class MediaPlayer } return null; } - + /** * Sets the data source as a content Uri. - * + * * @param context the Context to use when resolving the Uri * @param uri the Content URI of the data you want to play * @throws IllegalStateException if it is called in an invalid state */ public void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException { - + String scheme = uri.getScheme(); if(scheme == null || scheme.equals("file")) { setDataSource(uri.getPath()); @@ -607,13 +617,14 @@ public class MediaPlayer fd.close(); } } + Log.d(TAG, "Couldn't open file on client side, trying server side"); setDataSource(uri.toString()); return; } /** * Sets the data source (file-path or http/rtsp URL) to use. - * + * * @param path the path of the file, or the http/rtsp URL of the stream you want to play * @throws IllegalStateException if it is called in an invalid state */ @@ -622,57 +633,57 @@ public class MediaPlayer /** * Sets the data source (FileDescriptor) to use. It is the caller's responsibility * to close the file descriptor. It is safe to do so as soon as this call returns. - * + * * @param fd the FileDescriptor for the file you want to play * @throws IllegalStateException if it is called in an invalid state */ - public void setDataSource(FileDescriptor fd) + public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException { // intentionally less than LONG_MAX setDataSource(fd, 0, 0x7ffffffffffffffL); } - + /** * Sets the data source (FileDescriptor) to use. It is the caller's responsibility * to close the file descriptor. It is safe to do so as soon as this call returns. - * + * * @param fd the FileDescriptor for the file you want to play * @param offset the offset into the file where the data to be played starts, in bytes * @param length the length in bytes of the data to be played * @throws IllegalStateException if it is called in an invalid state */ - public native void setDataSource(FileDescriptor fd, long offset, long length) + public native void setDataSource(FileDescriptor fd, long offset, long length) throws IOException, IllegalArgumentException, IllegalStateException; /** * Prepares the player for playback, synchronously. - * + * * After setting the datasource and the display surface, you need to either * call prepare() or prepareAsync(). For files, it is OK to call prepare(), * which blocks until MediaPlayer is ready for playback. - * + * * @throws IllegalStateException if it is called in an invalid state */ public native void prepare() throws IOException, IllegalStateException; - + /** * Prepares the player for playback, asynchronously. - * + * * After setting the datasource and the display surface, you need to either * call prepare() or prepareAsync(). For streams, you should call prepareAsync(), * which returns immediately, rather than blocking until enough data has been * buffered. - * + * * @throws IllegalStateException if it is called in an invalid state */ public native void prepareAsync() throws IllegalStateException; - + /** * Starts or resumes playback. If playback had previously been paused, * playback will continue from where it was paused. If playback had * been stopped, or never started before, playback will start at the * beginning. - * + * * @throws IllegalStateException if it is called in an invalid state */ public void start() throws IllegalStateException { @@ -681,10 +692,10 @@ public class MediaPlayer } private native void _start() throws IllegalStateException; - + /** - * Stops playback after playback has been stopped or paused. - * + * Stops playback after playback has been stopped or paused. + * * @throws IllegalStateException if the internal player engine has not been * initialized. */ @@ -694,10 +705,10 @@ public class MediaPlayer } private native void _stop() throws IllegalStateException; - + /** * Pauses playback. Call start() to resume. - * + * * @throws IllegalStateException if the internal player engine has not been * initialized. */ @@ -707,20 +718,20 @@ public class MediaPlayer } private native void _pause() throws IllegalStateException; - + /** * Set the low-level power management behavior for this MediaPlayer. This * can be used when the MediaPlayer is not playing through a SurfaceHolder * set with {@link #setDisplay(SurfaceHolder)} and thus can use the * high-level {@link #setScreenOnWhilePlaying(boolean)} feature. - * + * * <p>This function has the MediaPlayer access the low-level power manager * service to control the device's power usage while playing is occurring. * The parameter is a combination of {@link android.os.PowerManager} wake flags. * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} * permission. * By default, no attempt is made to keep the device awake during playback. - * + * * @param context the Context to use * @param mode the power/wake mode to set * @see android.os.PowerManager @@ -742,14 +753,14 @@ public class MediaPlayer mWakeLock.acquire(); } } - + /** * Control whether we should use the attached SurfaceHolder to keep the * screen on while video playback is occurring. This is the preferred * method over {@link #setWakeMode} where possible, since it doesn't * require that the application have permission for low-level wake lock * access. - * + * * @param screenOn Supply true to keep the screen on, false to allow it * to turn off. */ @@ -759,7 +770,7 @@ public class MediaPlayer updateSurfaceScreenOn(); } } - + private void stayAwake(boolean awake) { if (mWakeLock != null) { if (awake && !mWakeLock.isHeld()) { @@ -771,61 +782,61 @@ public class MediaPlayer mStayAwake = awake; updateSurfaceScreenOn(); } - + private void updateSurfaceScreenOn() { if (mSurfaceHolder != null) { mSurfaceHolder.setKeepScreenOn(mScreenOnWhilePlaying && mStayAwake); } } - + /** * Returns the width of the video. - * + * * @return the width of the video, or 0 if there is no video, * no display surface was set, or prepare()/prepareAsync() * have not completed yet */ public native int getVideoWidth(); - + /** * Returns the height of the video. - * + * * @return the height of the video, or 0 if there is no video, * no display surface was set, or prepare()/prepareAsync() * have not completed yet */ public native int getVideoHeight(); - + /** * Checks whether the MediaPlayer is playing. - * + * * @return true if currently playing, false otherwise */ public native boolean isPlaying(); - + /** * Seeks to specified time position. - * + * * @param msec the offset in milliseconds from the start to seek to * @throws IllegalStateException if the internal player engine has not been * initialized */ public native void seekTo(int msec) throws IllegalStateException; - + /** * Gets the current playback position. - * + * * @return the current position in milliseconds */ public native int getCurrentPosition(); - + /** * Gets the duration of the file. - * + * * @return the duration in milliseconds */ public native int getDuration(); - + /** * Releases resources associated with this MediaPlayer object. * It is considered good practice to call this method when you're @@ -845,7 +856,7 @@ public class MediaPlayer } private native void _release(); - + /** * Resets the MediaPlayer to its uninitialized state. After calling * this method, you will have to initialize it again by setting the @@ -857,13 +868,13 @@ public class MediaPlayer // make sure none of the listeners get called anymore mEventHandler.removeCallbacksAndMessages(null); } - + private native void _reset(); - + /** * Sets the audio stream type for this MediaPlayer. See {@link AudioManager} * for a list of stream types. - * + * * @param streamtype the audio stream type * @see android.media.AudioManager */ @@ -871,20 +882,20 @@ public class MediaPlayer /** * Sets the player to be looping or non-looping. - * + * * @param looping whether to loop or not */ public native void setLooping(boolean looping); /** * Checks whether the MediaPlayer is looping or non-looping. - * + * * @return true if the MediaPlayer is currently looping, false otherwise */ public native boolean isLooping(); /** - * Sets the volume on this player. + * Sets the volume on this player. * This API is recommended for balancing the output of audio streams * within an application. Unless you are writing an application to * control user settings, this API should be used in preference to @@ -903,7 +914,7 @@ public class MediaPlayer * @hide */ public native Bitmap getFrameAt(int msec) throws IllegalStateException; - + private native final void native_setup(Object mediaplayer_this); private native final void native_finalize(); @Override @@ -1026,7 +1037,7 @@ public class MediaPlayer { /** * Called when the media file is ready for playback. - * + * * @param mp the MediaPlayer that is ready for playback */ void onPrepared(MediaPlayer mp); @@ -1053,7 +1064,7 @@ public class MediaPlayer { /** * Called when the end of a media source is reached during playback. - * + * * @param mp the MediaPlayer that reached the end of the file */ void onCompletion(MediaPlayer mp); @@ -1080,14 +1091,14 @@ public class MediaPlayer { /** * Called to update status in buffering a media stream. - * + * * @param mp the MediaPlayer the update pertains to * @param percent the percentage (0-100) of the buffer * that has been filled thus far */ void onBufferingUpdate(MediaPlayer mp, int percent); } - + /** * Register a callback to be invoked when the status of a network * stream's buffer has changed. @@ -1100,7 +1111,7 @@ public class MediaPlayer } private OnBufferingUpdateListener mOnBufferingUpdateListener; - + /** * Interface definition of a callback to be invoked indicating * the completion of a seek operation. @@ -1109,23 +1120,23 @@ public class MediaPlayer { /** * Called to indicate the completion of a seek operation. - * + * * @param mp the MediaPlayer that issued the seek operation */ public void onSeekComplete(MediaPlayer mp); } - + /** * Register a callback to be invoked when a seek operation has been * completed. - * + * * @param listener the callback that will be run */ public void setOnSeekCompleteListener(OnSeekCompleteListener listener) { mOnSeekCompleteListener = listener; } - + private OnSeekCompleteListener mOnSeekCompleteListener; /** @@ -1136,25 +1147,25 @@ public class MediaPlayer { /** * Called to indicate the video size - * + * * @param mp the MediaPlayer associated with this callback * @param width the width of the video * @param height the height of the video */ public void onVideoSizeChanged(MediaPlayer mp, int width, int height); } - + /** * Register a callback to be invoked when the video size is * known or updated. - * + * * @param listener the callback that will be run */ public void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener) { mOnVideoSizeChangedListener = listener; } - + private OnVideoSizeChangedListener mOnVideoSizeChangedListener; /* Do not change these values without updating their counterparts @@ -1166,11 +1177,11 @@ public class MediaPlayer public static final int MEDIA_ERROR_UNKNOWN = 1; /** Media server died. In this case, the application must release the - * MediaPlayer object and instantiate a new one. + * MediaPlayer object and instantiate a new one. * @see android.media.MediaPlayer.OnErrorListener */ public static final int MEDIA_ERROR_SERVER_DIED = 100; - + /** The video is streamed and its container is not valid for progressive * playback i.e the video's index (e.g moov atom) is not at the start of the * file. @@ -1187,7 +1198,7 @@ public class MediaPlayer { /** * Called to indicate an error. - * + * * @param mp the MediaPlayer the error pertains to * @param what the type of error that has occurred: * <ul> @@ -1202,11 +1213,11 @@ public class MediaPlayer */ boolean onError(MediaPlayer mp, int what, int extra); } - + /** * Register a callback to be invoked when an error has happened * during an asynchronous operation. - * + * * @param listener the callback that will be run */ public void setOnErrorListener(OnErrorListener listener) @@ -1251,7 +1262,7 @@ public class MediaPlayer { /** * Called to indicate an info or a warning. - * + * * @param mp the MediaPlayer the info pertains to. * @param what the type of info or warning. * <ul> @@ -1271,7 +1282,7 @@ public class MediaPlayer /** * Register a callback to be invoked when an info/warning is available. - * + * * @param listener the callback that will be run */ public void setOnInfoListener(OnInfoListener listener) diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 5d90e62..be4b489 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -125,6 +125,15 @@ public class MediaRecorder public static final int DEFAULT = 0; /** Microphone audio source */ public static final int MIC = 1; + + /** Voice call uplink (Tx) audio source */ + public static final int VOICE_UPLINK = 2; + + /** Voice call downlink (Rx) audio source */ + public static final int VOICE_DOWNLINK = 3; + + /** Voice call uplink + downlink audio source */ + public static final int VOICE_CALL = 4; } /** @@ -155,8 +164,19 @@ public class MediaRecorder public static final int THREE_GPP = 1; /** MPEG4 media file format*/ public static final int MPEG_4 = 2; - /** Raw AMR file format */ + + /** The following formats are audio only .aac or .amr formats **/ + /** @deprecated Deprecated in favor of AMR_NB */ + /** @todo change link when AMR_NB is exposed. Deprecated in favor of {@link MediaRecorder.OutputFormat#AMR_NB} */ public static final int RAW_AMR = 3; + /** @hide AMR NB file format */ + public static final int AMR_NB = 3; + /** @hide AMR WB file format */ + public static final int AMR_WB = 4; + /** @hide AAC ADIF file format */ + public static final int AAC_ADIF = 5; + /** @hide AAC ADTS file format */ + public static final int AAC_ADTS = 6; }; /** @@ -171,7 +191,14 @@ public class MediaRecorder public static final int DEFAULT = 0; /** AMR (Narrowband) audio codec */ public static final int AMR_NB = 1; - //public static final AAC = 2; currently unsupported + /** @hide AMR (Wideband) audio codec */ + public static final int AMR_WB = 2; + /** @hide AAC audio codec */ + public static final int AAC = 3; + /** @hide enhanced AAC audio codec */ + public static final int AAC_PLUS = 4; + /** @hide enhanced AAC plus audio codec */ + public static final int EAAC_PLUS = 5; } /** @@ -189,6 +216,46 @@ public class MediaRecorder public static final int MPEG_4_SP = 3; } + + /** + * @hide Defines the audio sampling rate. This must be set before + * setAudioEncoder() or it will be ignored. + * This parameter is used with + * {@link MediaRecorder#setParameters(String)}. + */ + public final class AudioParamSamplingRate { + /* Do not change these values without updating their counterparts + * in include/media/mediarecorder.h! + */ + private AudioParamSamplingRate() {} + public static final String AUDIO_PARAM_SAMPLING_RATE_KEY = "audio-param-sampling-rate="; + } + + /** + * @hide Defines the audio number of channels. This must be set before + * setAudioEncoder() or it will be ignored. + * This parameter is used with + * {@link MediaRecorder#setParameters(String)}. + */ + public final class AudioParamChannels { + /* Do not change these values without updating their counterparts + * in include/media/mediarecorder.h! + */ + private AudioParamChannels() {} + public static final String AUDIO_PARAM_NUMBER_OF_CHANNELS = "audio-param-number-of-channels="; + } + + /** + * @hide Defines the audio encoding bitrate. This must be set before + * setAudioEncoder() or it will be ignored. + * This parameter is used with + * {@link MediaRecorder#setParameters(String)}. + */ + public final class AudioParamEncodingBitrate{ + private AudioParamEncodingBitrate() {} + public static final String AUDIO_PARAM_ENCODING_BITRATE = "audio-param-encoding-bitrate="; + } + /** * Sets the audio source to be used for recording. If this method is not * called, the output file will not contain an audio track. The source needs @@ -203,6 +270,12 @@ public class MediaRecorder throws IllegalStateException; /** + * Gets the maximum value for audio sources. + * @see android.media.MediaRecorder.AudioSource + */ + public static final int getAudioSourceMax() { return AudioSource.VOICE_CALL; } + + /** * Sets the video source to be used for recording. If this method is not * called, the output file will not contain an video track. The source needs * to be specified before setting recording-parameters or encoders. Call @@ -317,6 +390,16 @@ public class MediaRecorder throws IllegalStateException; /** + * @hide Sets a parameter in the author engine. + * + * @param params the parameter to set. + * @see android.media.MediaRecorder.AudioParamSamplingRate + * @see android.media.MediaRecorder.AudioParamChannels + * @see android.media.MediaRecorder.AudioParamEncodingBitrate + */ + public native void setParameters(String params); + + /** * Pass in the file descriptor of the file to be written. Call this after * setOutputFormat() but before prepare(). * @@ -433,7 +516,7 @@ public class MediaRecorder { /** * Called when an error occurs while recording. - * + * * @param mr the MediaRecorder that encountered the error * @param what the type of error that has occurred: * <ul> @@ -479,7 +562,7 @@ public class MediaRecorder { /** * Called when an error occurs while recording. - * + * * @param mr the MediaRecorder that encountered the error * @param what the type of error that has occurred: * <ul> diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index ae3e181..cccc0fc 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -53,7 +53,45 @@ import java.util.HashSet; import java.util.Iterator; /** - * Internal service that no-one should use directly. + * Internal service helper that no-one should use directly. + * + * The way the scan currently works is: + * - The Java MediaScannerService creates a MediaScanner (this class), and calls + * MediaScanner.scanDirectories on it. + * - scanDirectories() calls the native processDirectory() for each of the specified directories. + * - the processDirectory() JNI method wraps the provided mediascanner client in a native + * 'MyMediaScannerClient' class, then calls processDirectory() on the native MediaScanner + * object (which got created when the Java MediaScanner was created). + * - native MediaScanner.processDirectory() (currently part of opencore) calls + * doProcessDirectory(), which recurses over the folder, and calls + * native MyMediaScannerClient.scanFile() for every file whose extension matches. + * - native MyMediaScannerClient.scanFile() calls back on Java MediaScannerClient.scanFile, + * which calls doScanFile, which after some setup calls back down to native code, calling + * MediaScanner.processFile(). + * - MediaScanner.processFile() calls one of several methods, depending on the type of the + * file: parseMP3, parseMP4, parseMidi, parseOgg or parseWMA. + * - each of these methods gets metadata key/value pairs from the file, and repeatedly + * calls native MyMediaScannerClient.handleStringTag, which calls back up to its Java + * counterparts in this file. + * - Java handleStringTag() gathers the key/value pairs that it's interested in. + * - once processFile returns and we're back in Java code in doScanFile(), it calls + * Java MyMediaScannerClient.endFile(), which takes all the data that's been + * gathered and inserts an entry in to the database. + * + * In summary: + * Java MediaScannerService calls + * Java MediaScanner scanDirectories, which calls + * Java MediaScanner processDirectory (native method), which calls + * native MediaScanner processDirectory, which calls + * native MyMediaScannerClient scanFile, which calls + * Java MyMediaScannerClient scanFile, which calls + * Java MediaScannerClient doScanFile, which calls + * Java MediaScanner processFile (native method), which calls + * native MediaScanner processFile, which calls + * native parseMP3, parseMP4, parseMidi, parseOgg or parseWMA, which calls + * native MyMediaScanner handleStringTag, which calls + * Java MyMediaScanner handleStringTag. + * Once MediaScanner processFile returns, an entry is inserted in to the database. * * {@hide} */ @@ -506,7 +544,10 @@ public class MediaScanner public void handleStringTag(String name, String value) { if (name.equalsIgnoreCase("title") || name.startsWith("title;")) { - mTitle = value.trim(); + // Don't trim() here, to preserve the special \001 character + // used to force sorting. The media provider will trim() before + // inserting the title in to the database. + mTitle = value; } else if (name.equalsIgnoreCase("artist") || name.startsWith("artist;")) { mArtist = value.trim(); } else if (name.equalsIgnoreCase("albumartist") || name.startsWith("albumartist;")) { diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java index 8f05cec..42edae6 100644 --- a/media/java/android/media/RingtoneManager.java +++ b/media/java/android/media/RingtoneManager.java @@ -176,17 +176,20 @@ public class RingtoneManager { private static final String[] INTERNAL_COLUMNS = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, - "\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "\"" + "\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "\"", + MediaStore.Audio.Media.TITLE_KEY }; private static final String[] DRM_COLUMNS = new String[] { DrmStore.Audio._ID, DrmStore.Audio.TITLE, - "\"" + DrmStore.Audio.CONTENT_URI + "\"" + "\"" + DrmStore.Audio.CONTENT_URI + "\"", + DrmStore.Audio.TITLE + " AS " + MediaStore.Audio.Media.TITLE_KEY }; private static final String[] MEDIA_COLUMNS = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, - "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"" + "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"", + MediaStore.Audio.Media.TITLE_KEY }; /** @@ -361,7 +364,7 @@ public class RingtoneManager { final Cursor mediaCursor = getMediaRingtones(); return mCursor = new SortCursor(new Cursor[] { internalCursor, drmCursor, mediaCursor }, - MediaStore.MediaColumns.TITLE); + MediaStore.Audio.Media.DEFAULT_SORT_ORDER); } /** diff --git a/media/java/android/media/ToneGenerator.java b/media/java/android/media/ToneGenerator.java index 4b53756..e5ee9a3 100644 --- a/media/java/android/media/ToneGenerator.java +++ b/media/java/android/media/ToneGenerator.java @@ -19,11 +19,11 @@ package android.media; /** - * This class provides methods to play DTMF tones (ITU-T Recommendation Q.23), - * call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111). + * This class provides methods to play DTMF tones (ITU-T Recommendation Q.23), + * call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111). * Depending on call state and routing options, tones are mixed to the downlink audio - * or output to the speaker phone or headset. - * This API is not for generating tones over the uplink audio path. + * or output to the speaker phone or headset. + * This API is not for generating tones over the uplink audio path. */ public class ToneGenerator { @@ -33,99 +33,99 @@ public class ToneGenerator * List of all available tones: These constants must be kept consistant with * the enum in ToneGenerator C++ class. */ - /** + /** * DTMF tone for key 0: 1336Hz, 941Hz, continuous</p> - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_0 = 0; /** * DTMF tone for key 1: 1209Hz, 697Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_1 = 1; /** * DTMF tone for key 2: 1336Hz, 697Hz, continuous - * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_DTMF_2 = 2; + /** + * DTMF tone for key 3: 1477Hz, 697Hz, continuous + * * @see #ToneGenerator(int, int) */ - public static final int TONE_DTMF_2 = 2; - /** - * DTMF tone for key 3: 1477Hz, 697Hz, continuous - * - * @see #ToneGenerator(int, int) - */ public static final int TONE_DTMF_3 = 3; /** * DTMF tone for key 4: 1209Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_4 = 4; /** * DTMF tone for key 5: 1336Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_5 = 5; /** * DTMF tone for key 6: 1477Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_6 = 6; /** * DTMF tone for key 7: 1209Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_7 = 7; /** * DTMF tone for key 8: 1336Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_8 = 8; /** * DTMF tone for key 9: 1477Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_9 = 9; /** * DTMF tone for key *: 1209Hz, 941Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_S = 10; /** * DTMF tone for key #: 1477Hz, 941Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_P = 11; /** * DTMF tone for key A: 1633Hz, 697Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_A = 12; /** * DTMF tone for key B: 1633Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_B = 13; /** * DTMF tone for key C: 1633Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_C = 14; /** * DTMF tone for key D: 1633Hz, 941Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_D = 15; @@ -151,7 +151,7 @@ public class ToneGenerator * Call supervisory tone, Congestion: * CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF... * ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_CONGESTION = 18; @@ -159,27 +159,28 @@ public class ToneGenerator * Call supervisory tone, Radio path acknowlegment : * CEPT, ANSI: 425Hz, 200ms ON * JAPAN: 400Hz, 1s ON, 2s OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_RADIO_ACK = 19; /** * Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_RADIO_NOTAVAIL = 20; /** * Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_ERROR = 21; /** * Call supervisory tone, Call Waiting: * CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF... - * ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) - * + * ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, + * (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_CALL_WAITING = 22; @@ -187,42 +188,43 @@ public class ToneGenerator * Call supervisory tone, Ring Tone: * CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... * ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_RINGTONE = 23; /** * Proprietary tone, general beep: 400Hz+1200Hz, 35ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_BEEP = 24; /** * Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_ACK = 25; /** * Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_NACK = 26; /** * Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_PROMPT = 27; /** * Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_BEEP2 = 28; /** - * Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms + * Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, + * each on for 250 ms * * @see #ToneGenerator(int, int) */ @@ -240,7 +242,8 @@ public class ToneGenerator */ public static final int TONE_SUP_CONGESTION_ABBREV = 31; /** - * Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle + * Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone + * repeated 3 times in a 100 ms on, 100 ms off cycle * * @see #ToneGenerator(int, int) */ @@ -251,7 +254,474 @@ public class ToneGenerator * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_PIP = 33; - + /** + * CDMA Dial tone : 425Hz continuous + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_DIAL_TONE_LITE = 34; + /** + * CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_USA_RINGBACK = 35; + /** + * CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_INTERCEPT = 36; + /** + * CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ABBR_INTERCEPT = 37; + /** + * CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_REORDER = 38; + /** + * + * CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ABBR_REORDER = 39; + /** + * CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_BUSY = 40; + /** + * CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CONFIRM = 41; + /** + * + * CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ANSWER = 42; + /** + * + * CDMA Network Callwaiting tone: 440Hz 300ms ON + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_CALLWAITING = 43; + /** + * CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_PIP = 44; + /** + * ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, + * 2091 32ms ON, 2556 48ms ON, 4s OFF + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL = 45; + /** + * ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, + * 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} times, + * 2091Hz 32ms ON, 4s OFF. + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP = 46; + /** + * ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times + * 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, + * 2091Hz 16ms ON, 200ms OFF + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI = 47; + /** + * ISDN Call sign PAT3 tone: silent tone + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT3 = 48; + /** + * ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times + * 2091Hz 20ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING = 49; + /** + * + * ISDN Pat5 tone: silent tone + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT5 = 50; + /** + * + * ISDN Pat6 tone: silent tone + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT6 = 51; + /** + * ISDN Pat7 tone: silent tone + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT7 = 52; + /** + * TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times + * 4000ms OFF, Repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_L = 53; + /** + * TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times + * 4000ms OFF, Repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_L = 54; + /** + * TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, + * 4000ms OFF, Repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_L = 55; + /** + * CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, + * 400ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SS = 56; + /** + * CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, + * 400ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SS = 57; + /** + * CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, + * 400ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SS = 58; + /** + * CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, + * 4000ms OFF, repeat ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SSL = 59; + /** + * CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, + * 4000ms OFF, repeat ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SSL = 60; + /** + * CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, + * 4000ms OFF, repeat ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SSL = 61; + /** + * CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, + * 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, + * 3000ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SS_2 = 62; + /** + * CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, + * 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, + * 3000ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SS_2 = 63; + /** + * CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, + * 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, + * 3000ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SS_2 = 64; + /** + * CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, + * 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SLS = 65; + /** + * CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, + * 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT + * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SLS = 66; + /** + * CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, + * 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, + * {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SLS = 67; + /** + * CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, + * 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_S_X4 = 68; + /** + * CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, + * 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_S_X4 = 69; + /** + * CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, + * 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... + * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_S_X4 = 70; + /** + * CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_L = 71; + /** + * CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_L = 72; + /** + * CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_L = 73; + /** + * CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times + * 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_SS = 74; + /** + * CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times + * 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_SS = 75; + /** + * CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times + * 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_SS = 76; + /** + * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_SSL = 77; + /** + * CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_SSL = 78; + /** + * CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, + * {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT.... + * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_SSL = 79; + /** + * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_SLS = 80; + /** + * CDMA HIGH PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_SLS = 81; + /** + * CDMA HIGH PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, + * {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_SLS = 82; + /** + * CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, + * 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, + * {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, + * {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_S_X4 = 83; + /** + * CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, + * 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, + * {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, + * {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_S_X4 = 84; + /** + * CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, + * 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, + * {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, + * {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_S_X4 = 85; + /** + * CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON + * 622Hz 62ms ON, 1109Hz 62ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_NETWORK_LITE = 86; + /** + * CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, + * 1245 62ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_AUTOREDIAL_LITE = 87; + /** + * CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ONE_MIN_BEEP = 88; + /** + * + * CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_KEYPAD_VOLUME_KEY_LITE = 89; + /** + * CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_PRESSHOLDKEY_LITE = 90; + /** + * CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, + * 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_INCALL_LITE = 91; + /** + * CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times + * 4990ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_EMERGENCY_RINGBACK = 92; + /** + * CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_CALL_GUARD = 93; + /** + * CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_SOFT_ERROR_LITE = 94; + /** + * CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALLDROP_LITE = 95; + /** + * CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_BUSY_ONE_SHOT = 96; + /** + * CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ABBR_ALERT = 97; + /** + * CDMA_SIGNAL_OFF - silent tone + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_SIGNAL_OFF = 98; /** Maximum volume, for use with {@link #ToneGenerator(int,int)} */ public static final int MAX_VOLUME = AudioSystem.MAX_VOLUME; @@ -261,10 +731,10 @@ public class ToneGenerator /** * ToneGenerator class contructor specifying output stream type and volume. - * + * * @param streamType The streame type used for tone playback (e.g. STREAM_MUSIC). * @param volume The volume of the tone, given in percentage of maximum volume (from 0-100). - * + * */ public ToneGenerator(int streamType, int volume) { native_setup(streamType, volume); @@ -272,7 +742,7 @@ public class ToneGenerator /** * This method starts the playback of a tone of the specified type. - * only one tone can play at a time: if a tone is playing while this method is called, + * only one tone can play at a time: if a tone is playing while this method is called, * this tone is stopped and replaced by the one requested. * @param toneType The type of tone generate chosen from the following list: * <ul> @@ -308,6 +778,71 @@ public class ToneGenerator * <li>{@link #TONE_SUP_CONGESTION_ABBREV} * <li>{@link #TONE_SUP_CONFIRM} * <li>{@link #TONE_SUP_PIP} + * <li>{@link #TONE_CDMA_DIAL_TONE_LITE} + * <li>{@link #TONE_CDMA_NETWORK_USA_RINGBACK} + * <li>{@link #TONE_CDMA_INTERCEPT} + * <li>{@link #TONE_CDMA_ABBR_INTERCEPT} + * <li>{@link #TONE_CDMA_REORDER} + * <li>{@link #TONE_CDMA_ABBR_REORDER} + * <li>{@link #TONE_CDMA_NETWORK_BUSY} + * <li>{@link #TONE_CDMA_CONFIRM} + * <li>{@link #TONE_CDMA_ANSWER} + * <li>{@link #TONE_CDMA_NETWORK_CALLWAITING} + * <li>{@link #TONE_CDMA_PIP} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT3} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT5} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT6} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT7} + * <li>{@link #TONE_CDMA_HIGH_L} + * <li>{@link #TONE_CDMA_MED_L} + * <li>{@link #TONE_CDMA_LOW_L} + * <li>{@link #TONE_CDMA_HIGH_SS} + * <li>{@link #TONE_CDMA_MED_SS} + * <li>{@link #TONE_CDMA_LOW_SS} + * <li>{@link #TONE_CDMA_HIGH_SSL} + * <li>{@link #TONE_CDMA_MED_SSL} + * <li>{@link #TONE_CDMA_LOW_SSL} + * <li>{@link #TONE_CDMA_HIGH_SS_2} + * <li>{@link #TONE_CDMA_MED_SS_2} + * <li>{@link #TONE_CDMA_LOW_SS_2} + * <li>{@link #TONE_CDMA_HIGH_SLS} + * <li>{@link #TONE_CDMA_MED_SLS} + * <li>{@link #TONE_CDMA_LOW_SLS} + * <li>{@link #TONE_CDMA_HIGH_S_X4} + * <li>{@link #TONE_CDMA_MED_S_X4} + * <li>{@link #TONE_CDMA_LOW_S_X4} + * <li>{@link #TONE_CDMA_HIGH_PBX_L} + * <li>{@link #TONE_CDMA_MED_PBX_L} + * <li>{@link #TONE_CDMA_LOW_PBX_L} + * <li>{@link #TONE_CDMA_HIGH_PBX_SS} + * <li>{@link #TONE_CDMA_MED_PBX_SS} + * <li>{@link #TONE_CDMA_LOW_PBX_SS} + * <li>{@link #TONE_CDMA_HIGH_PBX_SSL} + * <li>{@link #TONE_CDMA_MED_PBX_SSL} + * <li>{@link #TONE_CDMA_LOW_PBX_SSL} + * <li>{@link #TONE_CDMA_HIGH_PBX_SLS} + * <li>{@link #TONE_CDMA_MED_PBX_SLS} + * <li>{@link #TONE_CDMA_LOW_PBX_SLS} + * <li>{@link #TONE_CDMA_HIGH_PBX_S_X4} + * <li>{@link #TONE_CDMA_MED_PBX_S_X4} + * <li>{@link #TONE_CDMA_LOW_PBX_S_X4} + * <li>{@link #TONE_CDMA_ALERT_NETWORK_LITE} + * <li>{@link #TONE_CDMA_ALERT_AUTOREDIAL_LITE} + * <li>{@link #TONE_CDMA_ONE_MIN_BEEP} + * <li>{@link #TONE_CDMA_KEYPAD_VOLUME_KEY_LITE} + * <li>{@link #TONE_CDMA_PRESSHOLDKEY_LITE} + * <li>{@link #TONE_CDMA_ALERT_INCALL_LITE} + * <li>{@link #TONE_CDMA_EMERGENCY_RINGBACK} + * <li>{@link #TONE_CDMA_ALERT_CALL_GUARD} + * <li>{@link #TONE_CDMA_SOFT_ERROR_LITE} + * <li>{@link #TONE_CDMA_CALLDROP_LITE} + * <li>{@link #TONE_CDMA_NETWORK_BUSY_ONE_SHOT} + * <li>{@link #TONE_CDMA_ABBR_ALERT} + * <li>{@link #TONE_CDMA_SIGNAL_OFF} * </ul> * @see #ToneGenerator(int, int) */ @@ -328,9 +863,10 @@ public class ToneGenerator private native final void native_setup(int streamType, int volume); private native final void native_finalize(); + + @Override protected void finalize() { native_finalize(); } + @SuppressWarnings("unused") private int mNativeContext; // accessed by native methods - - } diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 707db02..6317fe2 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -125,8 +125,8 @@ static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaP return old; } -// If exception is NULL and opStatus is not OK, this method sends an error -// event to the client application; otherwise, if exception is not NULL and +// If exception is NULL and opStatus is not OK, this method sends an error +// event to the client application; otherwise, if exception is not NULL and // opStatus is not OK, this method throws the given exception to the client // application. static void process_media_player_call(JNIEnv *env, jobject thiz, status_t opStatus, const char* exception, const char *message) @@ -198,22 +198,37 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." ); } +static void setVideoSurface(const sp<MediaPlayer>& mp, JNIEnv *env, jobject thiz) +{ + jobject surface = env->GetObjectField(thiz, fields.surface); + if (surface != NULL) { + const sp<Surface>& native_surface = get_surface(env, surface); + LOGV("prepare: surface=%p (id=%d)", + native_surface.get(), native_surface->ID()); + mp->setVideoSurface(native_surface); + } +} static void -android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz) +android_media_MediaPlayer_setVideoSurface(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } - jobject surface = env->GetObjectField(thiz, fields.surface); - if (surface != NULL) { - const sp<Surface>& native_surface = get_surface(env, surface); - LOGV("prepare: surface=%p (id=%d)", - native_surface.get(), native_surface->ID()); - mp->setVideoSurface(native_surface); + setVideoSurface(mp, env, thiz); +} + +static void +android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz) +{ + sp<MediaPlayer> mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return; } + setVideoSurface(mp, env, thiz); process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." ); } @@ -228,7 +243,7 @@ android_media_MediaPlayer_prepareAsync(JNIEnv *env, jobject thiz) jobject surface = env->GetObjectField(thiz, fields.surface); if (surface != NULL) { const sp<Surface>& native_surface = get_surface(env, surface); - LOGV("prepareAsync: surface=%p (id=%d)", + LOGV("prepareAsync: surface=%p (id=%d)", native_surface.get(), native_surface->ID()); mp->setVideoSurface(native_surface); } @@ -256,7 +271,7 @@ android_media_MediaPlayer_stop(JNIEnv *env, jobject thiz) jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } - process_media_player_call( env, thiz, mp->stop(), NULL, NULL ); + process_media_player_call( env, thiz, mp->stop(), NULL, NULL ); } static void @@ -469,6 +484,7 @@ android_media_MediaPlayer_native_finalize(JNIEnv *env, jobject thiz) static JNINativeMethod gMethods[] = { {"setDataSource", "(Ljava/lang/String;)V", (void *)android_media_MediaPlayer_setDataSource}, {"setDataSource", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaPlayer_setDataSourceFD}, + {"_setVideoSurface", "()V", (void *)android_media_MediaPlayer_setVideoSurface}, {"prepare", "()V", (void *)android_media_MediaPlayer_prepare}, {"prepareAsync", "()V", (void *)android_media_MediaPlayer_prepareAsync}, {"_start", "()V", (void *)android_media_MediaPlayer_start}, diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index cac65d6..0273a5a 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -41,7 +41,7 @@ using namespace android; // ---------------------------------------------------------------------------- // helper function to extract a native Camera object from a Camera Java object -extern sp<Camera> get_native_camera(JNIEnv *env, jobject thiz, struct camera_context_t** context); +extern sp<Camera> get_native_camera(JNIEnv *env, jobject thiz, struct JNICameraContext** context); struct fields_t { jfieldID context; @@ -165,7 +165,7 @@ static void android_media_MediaRecorder_setVideoSource(JNIEnv *env, jobject thiz, jint vs) { LOGV("setVideoSource(%d)", vs); - if (vs < VIDEO_SOURCE_DEFAULT || vs > VIDEO_SOURCE_CAMERA) { + if (vs < VIDEO_SOURCE_DEFAULT || vs >= VIDEO_SOURCE_LIST_END) { jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid video source"); return; } @@ -177,10 +177,11 @@ static void android_media_MediaRecorder_setAudioSource(JNIEnv *env, jobject thiz, jint as) { LOGV("setAudioSource(%d)", as); - if (as < AUDIO_SOURCE_DEFAULT || as > AUDIO_SOURCE_MIC) { + if (as < AUDIO_SOURCE_DEFAULT || as >= AUDIO_SOURCE_LIST_END) { jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio source"); return; } + sp<MediaRecorder> mr = getMediaRecorder(env, thiz); process_media_recorder_call(env, mr->setAudioSource(as), "java/lang/RuntimeException", "setAudioSource failed."); } @@ -201,7 +202,7 @@ static void android_media_MediaRecorder_setVideoEncoder(JNIEnv *env, jobject thiz, jint ve) { LOGV("setVideoEncoder(%d)", ve); - if (ve < VIDEO_ENCODER_DEFAULT || ve > VIDEO_ENCODER_MPEG_4_SP) { + if (ve < VIDEO_ENCODER_DEFAULT || ve >= VIDEO_ENCODER_LIST_END) { jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid video encoder"); return; } @@ -213,7 +214,7 @@ static void android_media_MediaRecorder_setAudioEncoder(JNIEnv *env, jobject thiz, jint ae) { LOGV("setAudioEncoder(%d)", ae); - if (ae < AUDIO_ENCODER_DEFAULT || ae > AUDIO_ENCODER_AMR_NB) { + if (ae < AUDIO_ENCODER_DEFAULT || ae >= AUDIO_ENCODER_LIST_END) { jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio encoder"); return; } @@ -222,6 +223,29 @@ android_media_MediaRecorder_setAudioEncoder(JNIEnv *env, jobject thiz, jint ae) } static void +android_media_MediaRecorder_setParameters(JNIEnv *env, jobject thiz, jstring params) +{ + LOGV("setParameters()"); + if (params == NULL) + { + LOGE("Invalid or empty params string. This parameter will be ignored."); + return; + } + + sp<MediaRecorder> mr = getMediaRecorder(env, thiz); + + const char* params8 = env->GetStringUTFChars(params, NULL); + if (params8 == NULL) + { + LOGE("Failed to covert jstring to String8. This parameter will be ignored."); + return; + } + + process_media_recorder_call(env, mr->setParameters(String8(params8)), "java/lang/RuntimeException", "setParameter failed."); + env->ReleaseStringUTFChars(params,params8); +} + +static void android_media_MediaRecorder_setOutputFileFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length) { LOGV("setOutputFile"); @@ -384,6 +408,7 @@ static JNINativeMethod gMethods[] = { {"setOutputFormat", "(I)V", (void *)android_media_MediaRecorder_setOutputFormat}, {"setVideoEncoder", "(I)V", (void *)android_media_MediaRecorder_setVideoEncoder}, {"setAudioEncoder", "(I)V", (void *)android_media_MediaRecorder_setAudioEncoder}, + {"setParameters", "(Ljava/lang/String;)V", (void *)android_media_MediaRecorder_setParameters}, {"_setOutputFile", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaRecorder_setOutputFileFD}, {"setVideoSize", "(II)V", (void *)android_media_MediaRecorder_setVideoSize}, {"setVideoFrameRate", "(I)V", (void *)android_media_MediaRecorder_setVideoFrameRate}, diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp index 0812650..ce80f92 100644 --- a/media/jni/soundpool/SoundPool.cpp +++ b/media/jni/soundpool/SoundPool.cpp @@ -44,23 +44,27 @@ SoundPool::SoundPool(jobject soundPoolRef, int maxChannels, int streamType, int LOGV("SoundPool constructor: maxChannels=%d, streamType=%d, srcQuality=%d", maxChannels, streamType, srcQuality); - if (maxChannels > 32) { - LOGW("App requested %d channels, capped at 32", maxChannels); - maxChannels = 32; + // check limits + mMaxChannels = maxChannels; + if (mMaxChannels < 1) { + mMaxChannels = 1; + } + else if (mMaxChannels > 32) { + mMaxChannels = 32; } + LOGW_IF(maxChannels != mMaxChannels, "App requested %d channels", maxChannels); mQuit = false; mSoundPoolRef = soundPoolRef; mDecodeThread = 0; - mMaxChannels = maxChannels; mStreamType = streamType; mSrcQuality = srcQuality; mAllocated = 0; mNextSampleID = 0; mNextChannelID = 0; - mChannelPool = new SoundChannel[maxChannels]; - for (int i = 0; i < maxChannels; ++i) { + mChannelPool = new SoundChannel[mMaxChannels]; + for (int i = 0; i < mMaxChannels; ++i) { mChannelPool[i].init(this); mChannels.push_back(&mChannelPool[i]); } diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 1720af0..e56efbb 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -50,7 +50,7 @@ AudioRecord::AudioRecord() } AudioRecord::AudioRecord( - int streamType, + int inputSource, uint32_t sampleRate, int format, int channelCount, @@ -61,7 +61,7 @@ AudioRecord::AudioRecord( int notificationFrames) : mStatus(NO_INIT) { - mStatus = set(streamType, sampleRate, format, channelCount, + mStatus = set(inputSource, sampleRate, format, channelCount, frameCount, flags, cbf, user, notificationFrames); } @@ -82,7 +82,7 @@ AudioRecord::~AudioRecord() } status_t AudioRecord::set( - int streamType, + int inputSource, uint32_t sampleRate, int format, int channelCount, @@ -104,8 +104,8 @@ status_t AudioRecord::set( return NO_INIT; } - if (streamType == DEFAULT_INPUT) { - streamType = MIC_INPUT; + if (inputSource == DEFAULT_INPUT) { + inputSource = MIC_INPUT; } if (sampleRate == 0) { @@ -157,7 +157,7 @@ status_t AudioRecord::set( // open record channel status_t status; - sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), streamType, + sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), inputSource, sampleRate, format, channelCount, frameCount, @@ -185,7 +185,6 @@ status_t AudioRecord::set( mCblk = static_cast<audio_track_cblk_t*>(cblk->pointer()); mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t); mCblk->out = 0; - mSampleRate = sampleRate; mFormat = format; // Update buffer size in case it has been limited by AudioFlinger during track creation mFrameCount = mCblk->frameCount; @@ -196,11 +195,12 @@ status_t AudioRecord::set( mRemainingFrames = notificationFrames; mUserData = user; // TODO: add audio hardware input latency here - mLatency = (1000*mFrameCount) / mSampleRate; + mLatency = (1000*mFrameCount) / sampleRate; mMarkerPosition = 0; mMarkerReached = false; mNewPosition = 0; mUpdatePeriod = 0; + mInputSource = (uint8_t)inputSource; return NO_ERROR; } @@ -217,11 +217,6 @@ uint32_t AudioRecord::latency() const return mLatency; } -uint32_t AudioRecord::sampleRate() const -{ - return mSampleRate; -} - int AudioRecord::format() const { return mFormat; @@ -242,6 +237,11 @@ int AudioRecord::frameSize() const return channelCount()*((format() == AudioSystem::PCM_8_BIT) ? sizeof(uint8_t) : sizeof(int16_t)); } +int AudioRecord::inputSource() const +{ + return (int)mInputSource; +} + // ------------------------------------------------------------------------- status_t AudioRecord::start() @@ -315,6 +315,11 @@ bool AudioRecord::stopped() const return !mActive; } +uint32_t AudioRecord::getSampleRate() +{ + return mCblk->sampleRate; +} + status_t AudioRecord::setMarkerPosition(uint32_t marker) { if (mCbf == 0) return INVALID_OPERATION; diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 289bd75..b2c067b 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -243,7 +243,6 @@ status_t AudioTrack::set( mCblk->volume[0] = mCblk->volume[1] = 0x1000; mVolume[LEFT] = 1.0f; mVolume[RIGHT] = 1.0f; - mSampleRate = sampleRate; mStreamType = streamType; mFormat = format; mChannelCount = channelCount; @@ -254,7 +253,7 @@ status_t AudioTrack::set( mNotificationFrames = notificationFrames; mRemainingFrames = notificationFrames; mUserData = user; - mLatency = afLatency + (1000*mFrameCount) / mSampleRate; + mLatency = afLatency + (1000*mFrameCount) / sampleRate; mLoopCount = 0; mMarkerPosition = 0; mMarkerReached = false; @@ -281,11 +280,6 @@ int AudioTrack::streamType() const return mStreamType; } -uint32_t AudioTrack::sampleRate() const -{ - return mSampleRate; -} - int AudioTrack::format() const { return mFormat; @@ -438,24 +432,23 @@ void AudioTrack::getVolume(float* left, float* right) *right = mVolume[RIGHT]; } -void AudioTrack::setSampleRate(int rate) +status_t AudioTrack::setSampleRate(int rate) { int afSamplingRate; if (AudioSystem::getOutputSamplingRate(&afSamplingRate, mStreamType) != NO_ERROR) { - return; + return NO_INIT; } // Resampler implementation limits input sampling rate to 2 x output sampling rate. - if (rate <= 0) rate = 1; - if (rate > afSamplingRate*2) rate = afSamplingRate*2; - if (rate > MAX_SAMPLE_RATE) rate = MAX_SAMPLE_RATE; + if (rate <= 0 || rate > afSamplingRate*2 ) return BAD_VALUE; - mCblk->sampleRate = (uint16_t)rate; + mCblk->sampleRate = rate; + return NO_ERROR; } uint32_t AudioTrack::getSampleRate() { - return uint32_t(mCblk->sampleRate); + return mCblk->sampleRate; } status_t AudioTrack::setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount) @@ -866,7 +859,7 @@ status_t AudioTrack::dump(int fd, const Vector<String16>& args) const result.append(buffer); snprintf(buffer, 255, " format(%d), channel count(%d), frame count(%d)\n", mFormat, mChannelCount, mFrameCount); result.append(buffer); - snprintf(buffer, 255, " sample rate(%d), status(%d), muted(%d)\n", mSampleRate, mStatus, mMuted); + snprintf(buffer, 255, " sample rate(%d), status(%d), muted(%d)\n", (mCblk == 0) ? 0 : mCblk->sampleRate, mStatus, mMuted); result.append(buffer); snprintf(buffer, 255, " active(%d), latency (%d)\n", mActive, mLatency); result.append(buffer); diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp index 52bd7d4..eeaa54f 100644 --- a/media/libmedia/IAudioFlinger.cpp +++ b/media/libmedia/IAudioFlinger.cpp @@ -99,7 +99,7 @@ public: virtual sp<IAudioRecord> openRecord( pid_t pid, - int streamType, + int inputSource, uint32_t sampleRate, int format, int channelCount, @@ -110,7 +110,7 @@ public: Parcel data, reply; data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); data.writeInt32(pid); - data.writeInt32(streamType); + data.writeInt32(inputSource); data.writeInt32(sampleRate); data.writeInt32(format); data.writeInt32(channelCount); @@ -384,14 +384,14 @@ status_t BnAudioFlinger::onTransact( case OPEN_RECORD: { CHECK_INTERFACE(IAudioFlinger, data, reply); pid_t pid = data.readInt32(); - int streamType = data.readInt32(); + int inputSource = data.readInt32(); uint32_t sampleRate = data.readInt32(); int format = data.readInt32(); int channelCount = data.readInt32(); size_t bufferCount = data.readInt32(); uint32_t flags = data.readInt32(); status_t status; - sp<IAudioRecord> record = openRecord(pid, streamType, + sp<IAudioRecord> record = openRecord(pid, inputSource, sampleRate, format, channelCount, bufferCount, flags, &status); reply->writeInt32(status); reply->writeStrongBinder(record->asBinder()); diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp index f37519f..f18765a 100644 --- a/media/libmedia/IMediaPlayer.cpp +++ b/media/libmedia/IMediaPlayer.cpp @@ -164,6 +164,7 @@ public: status_t setVolume(float leftVolume, float rightVolume) { Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); data.writeFloat(leftVolume); data.writeFloat(rightVolume); remote()->transact(SET_VOLUME, data, &reply); @@ -261,6 +262,7 @@ status_t BnMediaPlayer::onTransact( return NO_ERROR; } break; case SET_VOLUME: { + CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setVolume(data.readFloat(), data.readFloat())); return NO_ERROR; } break; diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp index 370e3fb..01cdb6c 100644 --- a/media/libmedia/IMediaPlayerService.cpp +++ b/media/libmedia/IMediaPlayerService.cpp @@ -195,4 +195,3 @@ status_t BnMediaPlayerService::onTransact( // ---------------------------------------------------------------------------- }; // namespace android - diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp index 81ee92c..c22cd53 100644 --- a/media/libmedia/ToneGenerator.cpp +++ b/media/libmedia/ToneGenerator.cpp @@ -33,199 +33,720 @@ namespace android { // Descriptors for all available tones (See ToneGenerator::ToneDescriptor class declaration for details) const ToneGenerator::ToneDescriptor ToneGenerator::sToneDescriptors[] = { - { segments: {{ duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 941, 0 }}, - { duration: 0 , waveFreq: { 0 }}}, + { segments: {{ duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 941, 0 }, 0, 0}, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_0 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 697, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 697, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_1 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 697, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 697, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_2 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 697, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 697, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_3 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 770, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 770, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_4 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 770, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 770, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_5 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 770, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 770, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_6 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 852, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 852, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_7 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 852, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 852, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_8 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 852, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 852, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_9 - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 941, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 941, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_S - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 941, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 941, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_P - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 697, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 697, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_A - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 770, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 770, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_B - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 852, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 852, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_C - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 941, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 941, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_DTMF_D - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 425, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_DIAL - { segments: { { duration: 500 , waveFreq: { 425, 0 }}, - { duration: 500, waveFreq: { 0 }}, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 500 , waveFreq: { 425, 0 }, 0, 0}, + { duration: 500, waveFreq: { 0 }, 0, 0}, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_BUSY - { segments: { { duration: 200, waveFreq: { 425, 0 } }, - { duration: 200, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_CONGESTION - { segments: { { duration: 200, waveFreq: { 425, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 0, repeatSegment: 0 }, // TONE_SUP_RADIO_ACK - { segments: { { duration: 200, waveFreq: { 425, 0 }}, - { duration: 200, waveFreq: { 0 }}, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0}, + { duration: 200, waveFreq: { 0 }, 0, 0}, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 2, repeatSegment: 0 }, // TONE_SUP_RADIO_NOTAVAIL - { segments: { { duration: 330, waveFreq: { 950, 1400, 1800, 0 }}, - { duration: 1000, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 330, waveFreq: { 950, 1400, 1800, 0 }, 0, 0}, + { duration: 1000, waveFreq: { 0 }, 0, 0}, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_ERROR - { segments: { { duration: 200, waveFreq: { 425, 0 } }, - { duration: 600, waveFreq: { 0 } }, - { duration: 200, waveFreq: { 425, 0 } }, - { duration: 3000, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 600, waveFreq: { 0 }, 0, 0 }, + { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_CALL_WAITING - { segments: { { duration: 1000, waveFreq: { 425, 0 } }, - { duration: 4000, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 1000, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_RINGTONE - { segments: { { duration: 40, waveFreq: { 400, 1200, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 40, waveFreq: { 400, 1200, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 0, repeatSegment: 0 }, // TONE_PROP_BEEP - { segments: { { duration: 100, waveFreq: { 1200, 0 } }, - { duration: 100, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 100, waveFreq: { 1200, 0 }, 0, 0 }, + { duration: 100, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 1, repeatSegment: 0 }, // TONE_PROP_ACK - { segments: { { duration: 400, waveFreq: { 300, 400, 500, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 400, waveFreq: { 300, 400, 500, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 0, repeatSegment: 0 }, // TONE_PROP_NACK - { segments: { { duration: 200, waveFreq: { 400, 1200, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 200, waveFreq: { 400, 1200, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 0, repeatSegment: 0 }, // TONE_PROP_PROMPT - { segments: { { duration: 40, waveFreq: { 400, 1200, 0 } }, - { duration: 200, waveFreq: { 0 } }, - { duration: 40, waveFreq: { 400, 1200, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 40, waveFreq: { 400, 1200, 0 }, 0, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 40, waveFreq: { 400, 1200, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 0, repeatSegment: 0 }, // TONE_PROP_BEEP2 - { segments: { { duration: 250, waveFreq: { 440, 0 } }, - { duration: 250, waveFreq: { 620, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0 }}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_SUP_INTERCEPT - { segments: { { duration: 250, waveFreq: { 440, 0 } }, - { duration: 250, waveFreq: { 620, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 7, repeatSegment: 0 }, // TONE_SUP_INTERCEPT_ABBREV - { segments: { { duration: 250, waveFreq: { 480, 620, 0 } }, - { duration: 250, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 7, repeatSegment: 0 }, // TONE_SUP_CONGESTION_ABBREV - { segments: { { duration: 100, waveFreq: { 350, 440, 0 } }, - { duration: 100, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 100, waveFreq: { 350, 440, 0 }, 0, 0 }, + { duration: 100, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 2, repeatSegment: 0 }, // TONE_SUP_CONFIRM - { segments: { { duration: 100, waveFreq: { 480, 0 } }, - { duration: 100, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 100, waveFreq: { 480, 0 }, 0, 0 }, + { duration: 100, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: 3, repeatSegment: 0 }, // TONE_SUP_PIP - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 350, 440, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: {{ duration: ToneGenerator::TONEGEN_INF, waveFreq: { 425, 0 }, 0, 0}, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_DIAL_TONE_LITE + { segments: { { duration: 2000, waveFreq: { 440, 480, 0 }, 0, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_NETWORK_USA_RINGBACK + { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_INTERCEPT + { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ABBR_INTERCEPT + { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_REORDER + { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: 7, + repeatSegment: 0 }, // TONE_CDMA_ABBR_REORDER + { segments: { { duration: 500, waveFreq: { 480, 620, 0 }, 0, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_NETWORK_BUSY + { segments: { { duration: 100, waveFreq: { 350, 440, 0 }, 0, 0 }, + { duration: 100, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: 2, + repeatSegment: 0 }, // TONE_CDMA_CONFIRM + { segments: { { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ANSWER + { segments: { { duration: 300, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_NETWORK_CALLWAITING + { segments: { { duration: 100, waveFreq: { 480, 0 }, 0, 0 }, + { duration: 100, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, + repeatCnt: 3, + repeatSegment: 0 }, // TONE_CDMA_PIP + + { segments: { { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 64, waveFreq: { 2556, 0}, 19, 0}, + { duration: 32, waveFreq: { 2091, 0}, 0, 0}, + { duration: 48, waveFreq: { 2556, 0}, 0, 0}, + { duration: 4000, waveFreq: { 0 }, 0, 0}, + { duration: 0, waveFreq: { 0 }, 0, 0}}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL + { segments: { { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 64, waveFreq: { 2556, 0}, 7, 0 }, + { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 400, waveFreq: { 0 }, 0, 0 }, + { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 64, waveFreq: { 2556, 0}, 7, 4 }, + { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP + { segments: { { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 64, waveFreq: { 2556, 0}, 3, 0 }, + { duration: 16, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 64, waveFreq: { 2556, 0}, 3, 4 }, + { duration: 16, waveFreq: { 2091, 0}, 0, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI + { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT3 + { segments: { { duration: 32, waveFreq: { 2091, 0 }, 0, 0 }, + { duration: 64, waveFreq: { 2556, 0 }, 4, 0 }, + { duration: 20, waveFreq: { 2091, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 } , 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING + { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT5 + { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT6 + { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT7 + + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 39, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_L + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 39, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_L + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 39, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_L + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 15, 0 }, + { duration: 400, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_SS + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 15, 0 }, + { duration: 400, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_SS + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 15, 0 }, + { duration: 400, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_SS + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 15, 6 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_SSL + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 15, 6 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_SSL + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 15, 6 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_SSL + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 19, 0 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 19, 3 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_SS_2 + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 19, 0 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 19, 3 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_SS_2 + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 19, 0 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 19, 3 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_SS_2 + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 9, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 19, 3 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 9, 6 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_SLS + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 9, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 19, 3 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 9, 6 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_SLS + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 9, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 19, 3 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 9, 6 }, + { duration: 3000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_SLS + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 9, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 9, 3 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 9, 6 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 9, 9 }, + { duration: 2500, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_S_X4 + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 9, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 9, 3 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 9, 6 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 9, 9 }, + { duration: 2500, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_S_X4 + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 9, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 9, 3 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 9, 6 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 9, 9 }, + { duration: 2500, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_S_X4 + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 19, 0 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_L + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 19, 0 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_PBX_L + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 19, 0 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_L + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_SS + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_PBX_SS + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_SS + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 15, 6 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_SSL + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 15, 6 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_PBX_SSL + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 15, 6 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_SSL + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 15, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 6 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_SLS + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 15, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 6 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_PBX_SLS + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 15, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 6 }, + { duration: 1000, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_SLS + { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 6 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 4000, 0 }, 7, 9 }, + { duration: 800, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_S_X4 + { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 6 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 2900, 0 }, 7, 9 }, + { duration: 800, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_MED_PBX_S_X4 + { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 6 }, + { duration: 200, waveFreq: { 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, + { duration: 25, waveFreq: { 1450, 0 }, 7, 9 }, + { duration: 800, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_S_X4 + + { segments: { { duration: 62, waveFreq: { 1109, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 740, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 622, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 1109, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ALERT_NETWORK_LITE + { segments: { { duration: 62, waveFreq: { 1245, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 659, 0 }, 2, 0 }, + { duration: 62, waveFreq: { 1245, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ALERT_AUTOREDIAL_LITE + { segments: { { duration: 400, waveFreq: { 1150, 770, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ONE_MIN_BEEP + { segments: { { duration: 120, waveFreq: { 941, 1477, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_KEYPAD_VOLUME_KEY_LITE + { segments: { { duration: 375, waveFreq: { 587, 0 }, 0, 0 }, + { duration: 125, waveFreq: { 1175, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_PRESSHOLDKEY_LITE + { segments: { { duration: 62, waveFreq: { 587, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 831, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 1109, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 831, 0 }, 0, 0 }, + { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ALERT_INCALL_LITE + { segments: { { duration: 125, waveFreq: { 941, 0 }, 0, 0 }, + { duration: 10, waveFreq: { 0 }, 2, 0 }, + { duration: 4990, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: ToneGenerator::TONEGEN_INF, + repeatSegment: 0 }, // TONE_CDMA_EMERGENCY_RINGBACK + { segments: { { duration: 125, waveFreq: { 1319, 0 }, 0, 0 }, + { duration: 125, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 2, + repeatSegment: 0 }, // TONE_CDMA_ALERT_CALL_GUARD + { segments: { { duration: 125, waveFreq: { 1047, 0 }, 0, 0 }, + { duration: 125, waveFreq: { 370, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_SOFT_ERROR_LITE + { segments: { { duration: 125, waveFreq: { 1480, 0 }, 0, 0 }, + { duration: 125, waveFreq: { 1397, 0 }, 0, 0 }, + { duration: 125, waveFreq: { 784, 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 } }, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_CALLDROP_LITE + + { segments: { { duration: 500, waveFreq: { 425, 0 }, 0, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_NETWORK_BUSY_ONE_SHOT + { segments: { { duration: 400, waveFreq: { 1150, 770 }, 0, 0 }, + { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_ABBR_ALERT + { segments: { { duration: 0, waveFreq: { 0 }, 0, 0 }}, + repeatCnt: 0, + repeatSegment: 0 }, // TONE_CDMA_SIGNAL_OFF + + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 350, 440, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_ANSI_DIAL - { segments: { { duration: 500, waveFreq: { 480, 620, 0 } }, - { duration: 500, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 500, waveFreq: { 480, 620, 0 }, 0, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_ANSI_BUSY - { segments: { { duration: 250, waveFreq: { 480, 620, 0 } }, - { duration: 250, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, + { duration: 250, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_ANSI_CONGESTION - { segments: { { duration: 300, waveFreq: { 440, 0 } }, - { duration: 9700, waveFreq: { 0 } }, - { duration: 100, waveFreq: { 440, 0 } }, - { duration: 100, waveFreq: { 0 } }, - { duration: 100, waveFreq: { 440, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 300, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 9700, waveFreq: { 0 }, 0, 0 }, + { duration: 100, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 100, waveFreq: { 0 }, 0, 0 }, + { duration: 100, waveFreq: { 440, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 1 }, // TONE_ANSI_CALL_WAITING - { segments: { { duration: 2000, waveFreq: { 440, 480, 0 } }, - { duration: 4000, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 2000, waveFreq: { 440, 480, 0 }, 0, 0 }, + { duration: 4000, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_ANSI_RINGTONE - { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 400, 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 400, 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_JAPAN_DIAL - { segments: { { duration: 500, waveFreq: { 400, 0 } }, - { duration: 500, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 500, waveFreq: { 400, 0 }, 0, 0 }, + { duration: 500, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_JAPAN_BUSY - { segments: { { duration: 1000, waveFreq: { 400, 0 } }, - { duration: 2000, waveFreq: { 0 } }, - { duration: 0 , waveFreq: { 0 }}}, + { segments: { { duration: 1000, waveFreq: { 400, 0 }, 0, 0 }, + { duration: 2000, waveFreq: { 0 }, 0, 0 }, + { duration: 0 , waveFreq: { 0 }, 0, 0}}, repeatCnt: ToneGenerator::TONEGEN_INF, repeatSegment: 0 }, // TONE_JAPAN_RADIO_ACK + + + }; // Used by ToneGenerator::getToneForRegion() to convert user specified supervisory tone type @@ -529,9 +1050,9 @@ initAudioTrack_exit: // //////////////////////////////////////////////////////////////////////////////// void ToneGenerator::audioCallback(int event, void* user, void *info) { - + if (event != AudioTrack::EVENT_MORE_DATA) return; - + const AudioTrack::Buffer *buffer = static_cast<const AudioTrack::Buffer *>(info); ToneGenerator *lpToneGen = static_cast<ToneGenerator *>(user); short *lpOut = buffer->i16; @@ -549,12 +1070,12 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) { unsigned int lGenSmp; unsigned int lWaveCmd = WaveGenerator::WAVEGEN_CONT; bool lSignal = false; - + lpToneGen->mLock.lock(); // Update pcm frame count and end time (current time at the end of this process) lpToneGen->mTotalSmp += lReqSmp; - + // Update tone gen state machine and select wave gen command switch (lpToneGen->mState) { case TONE_PLAYING: @@ -562,13 +1083,13 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) { break; case TONE_STARTING: LOGV("Starting Cbk"); - + lWaveCmd = WaveGenerator::WAVEGEN_START; break; case TONE_STOPPING: case TONE_RESTARTING: LOGV("Stop/restart Cbk"); - + lWaveCmd = WaveGenerator::WAVEGEN_STOP; lpToneGen->mNextSegSmp = TONEGEN_INF; // forced to skip state machine management below break; @@ -578,21 +1099,21 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) { lNumSmp = 0; goto audioCallback_EndLoop; } - - + + // Exit if tone sequence is over if (lpToneDesc->segments[lpToneGen->mCurSegment].duration == 0) { if (lpToneGen->mState == TONE_PLAYING) { - lpToneGen->mState = TONE_STOPPING; + lpToneGen->mState = TONE_STOPPING; } goto audioCallback_EndLoop; } - + if (lpToneGen->mTotalSmp > lpToneGen->mNextSegSmp) { // Time to go to next sequence segment - + LOGV("End Segment, time: %d\n", (unsigned int)(systemTime()/1000000)); - + lGenSmp = lReqSmp; // If segment, ON -> OFF transition : ramp volume down @@ -609,25 +1130,49 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) { LOGV("ON->OFF, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp); } - // Go to next segment - lpToneGen->mCurSegment++; + // check if we need to loop and loop for the reqd times + if (lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt) { + if (lpToneGen->mLoopCounter < lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt) { + LOGV ("in if loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n", + lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt, + lpToneGen->mLoopCounter, + lpToneGen->mCurSegment); + lpToneGen->mCurSegment = lpToneDesc->segments[lpToneGen->mCurSegment].loopIndx; + ++lpToneGen->mLoopCounter; + } else { + // completed loop. go to next segment + lpToneGen->mLoopCounter = 0; + lpToneGen->mCurSegment++; + LOGV ("in else loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n", + lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt, + lpToneGen->mLoopCounter, + lpToneGen->mCurSegment); + } + } else { + lpToneGen->mCurSegment++; + LOGV ("Goto next seg loopCnt(%d) loopctr(%d), CurSeg(%d) \n", + lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt, + lpToneGen->mLoopCounter, + lpToneGen->mCurSegment); + + } // Handle loop if last segment reached if (lpToneDesc->segments[lpToneGen->mCurSegment].duration == 0) { LOGV("Last Seg: %d\n", lpToneGen->mCurSegment); - + // Pre increment loop count and restart if total count not reached. Stop sequence otherwise if (++lpToneGen->mCurCount <= lpToneDesc->repeatCnt) { LOGV("Repeating Count: %d\n", lpToneGen->mCurCount); - + lpToneGen->mCurSegment = lpToneDesc->repeatSegment; if (lpToneDesc->segments[lpToneDesc->repeatSegment].waveFreq[0] != 0) { lWaveCmd = WaveGenerator::WAVEGEN_START; } - + LOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment, (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate); - + } else { lGenSmp = 0; LOGV("End repeat, time: %d\n", (unsigned int)(systemTime()/1000000)); @@ -644,11 +1189,11 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) { lGenSmp = 0; } } - + // Update next segment transition position. No harm to do it also for last segment as lpToneGen->mNextSegSmp won't be used any more lpToneGen->mNextSegSmp += (lpToneDesc->segments[lpToneGen->mCurSegment].duration * lpToneGen->mSamplingRate) / 1000; - + } else { // Inside a segment keep tone ON or OFF if (lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[0] == 0) { @@ -657,24 +1202,24 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) { lGenSmp = lReqSmp; // If event segment, tone is currently ON } } - + if (lGenSmp) { // If samples must be generated, call all active wave generators and acumulate waves in lpOut unsigned int lFreqIdx = 0; unsigned short lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[lFreqIdx]; - + while (lFrequency != 0) { WaveGenerator *lpWaveGen = lpToneGen->mWaveGens.valueFor(lFrequency); lpWaveGen->getSamples(lpOut, lGenSmp, lWaveCmd); lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[++lFreqIdx]; } } - + lNumSmp -= lReqSmp; lpOut += lReqSmp; - + audioCallback_EndLoop: - + switch (lpToneGen->mState) { case TONE_RESTARTING: LOGV("Cbk restarting track\n"); @@ -694,7 +1239,7 @@ audioCallback_EndLoop: LOGV("Cbk Stopping track\n"); lSignal = true; lpToneGen->mpAudioTrack->stop(); - + // Force loop exit lNumSmp = 0; break; @@ -765,6 +1310,7 @@ bool ToneGenerator::prepareWave() { mTotalSmp = 0; mCurSegment = 0; mCurCount = 0; + mLoopCounter = 0; if (mpToneDesc->segments[0].duration == TONEGEN_INF) { mNextSegSmp = TONEGEN_INF; } else{ diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp index 809316a..24e3e6f 100644 --- a/media/libmedia/mediaplayer.cpp +++ b/media/libmedia/mediaplayer.cpp @@ -503,7 +503,7 @@ void MediaPlayer::notify(int msg, int ext1, int ext2) // TODO: In the future, we might be on the same thread if the app is // running in the same process as the media server. In that case, // this will deadlock. - // + // // The threadId hack below works around this for the care of prepare // and seekTo within the same process. // FIXME: Remember, this is a hack, it's not even a hack that is applied @@ -511,7 +511,7 @@ void MediaPlayer::notify(int msg, int ext1, int ext2) if (mLockThreadId != getThreadId()) { mLock.lock(); locked = true; - } + } if (mPlayer == 0) { LOGV("notify(%d, %d, %d) callback on disconnected mediaplayer", msg, ext1, ext2); diff --git a/media/libmedia/mediarecorder.cpp b/media/libmedia/mediarecorder.cpp index 6b26faf..5093f0e 100644 --- a/media/libmedia/mediarecorder.cpp +++ b/media/libmedia/mediarecorder.cpp @@ -180,7 +180,7 @@ status_t MediaRecorder::setOutputFormat(int of) LOGE("setOutputFormat called in an invalid state: %d", mCurrentState); return INVALID_OPERATION; } - if (mIsVideoSourceSet && of >= OUTPUT_FORMAT_RAW_AMR) { + if (mIsVideoSourceSet && of >= OUTPUT_FORMAT_AUDIO_ONLY_START) { //first non-video output format LOGE("output format (%d) is meant for audio recording only and incompatible with video recording", of); return INVALID_OPERATION; } @@ -345,7 +345,7 @@ status_t MediaRecorder::setVideoFrameRate(int frames_per_second) } if (!mIsVideoSourceSet) { LOGE("try to set video frame rate without setting video source first"); - return INVALID_OPERATION; + return INVALID_OPERATION; } status_t ret = mMediaRecorder->setVideoFrameRate(frames_per_second); @@ -475,7 +475,7 @@ status_t MediaRecorder::stop() mCurrentState = MEDIA_RECORDER_ERROR; return ret; } - + // FIXME: // stop and reset are semantically different. // We treat them the same for now, and will change this in the future. @@ -492,7 +492,7 @@ status_t MediaRecorder::reset() LOGE("media recorder is not initialized yet"); return INVALID_OPERATION; } - + doCleanUp(); status_t ret = UNKNOWN_ERROR; switch(mCurrentState) { diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp index e0d2947..8bc410c 100644 --- a/media/libmediaplayerservice/MediaRecorderClient.cpp +++ b/media/libmediaplayerservice/MediaRecorderClient.cpp @@ -37,6 +37,7 @@ namespace android { const char* cameraPermission = "android.permission.CAMERA"; +const char* recordAudioPermission = "android.permission.RECORD_AUDIO"; static bool checkPermission(const char* permissionString) { #ifndef HAVE_ANDROID_OS @@ -86,6 +87,9 @@ status_t MediaRecorderClient::setVideoSource(int vs) status_t MediaRecorderClient::setAudioSource(int as) { LOGV("setAudioSource(%d)", as); + if (!checkPermission(recordAudioPermission)) { + return PERMISSION_DENIED; + } Mutex::Autolock lock(mLock); if (mRecorder == NULL) { LOGE("recorder is not initialized"); diff --git a/media/libmediaplayerservice/VorbisPlayer.cpp b/media/libmediaplayerservice/VorbisPlayer.cpp index 14fd6ce..7f0ef21 100644 --- a/media/libmediaplayerservice/VorbisPlayer.cpp +++ b/media/libmediaplayerservice/VorbisPlayer.cpp @@ -345,9 +345,6 @@ status_t VorbisPlayer::reset() { LOGV("reset\n"); Mutex::Autolock l(mMutex); - if (mState != STATE_OPEN) { - return NO_ERROR; - } return reset_nosync(); } @@ -355,10 +352,13 @@ status_t VorbisPlayer::reset() status_t VorbisPlayer::reset_nosync() { // close file - ov_clear(&mVorbisFile); // this also closes the FILE if (mFile != NULL) { - LOGV("OOPS! Vorbis didn't close the file"); - fclose(mFile); + ov_clear(&mVorbisFile); // this also closes the FILE + if (mFile != NULL) { + LOGV("OOPS! Vorbis didn't close the file"); + fclose(mFile); + mFile = NULL; + } } mState = STATE_ERROR; diff --git a/media/tests/MediaFrameworkTest/AndroidManifest.xml b/media/tests/MediaFrameworkTest/AndroidManifest.xml index d0ff9ce..6908220 100644 --- a/media/tests/MediaFrameworkTest/AndroidManifest.xml +++ b/media/tests/MediaFrameworkTest/AndroidManifest.xml @@ -19,6 +19,7 @@ <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.CAMERA" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application> <uses-library android:name="android.test.runner" /> <activity android:label="@string/app_name" diff --git a/media/tests/MediaFrameworkTest/res/raw/testmidi.mid b/media/tests/MediaFrameworkTest/res/raw/testmidi.mid Binary files differindex df84e20..d4ead53 100644 --- a/media/tests/MediaFrameworkTest/res/raw/testmidi.mid +++ b/media/tests/MediaFrameworkTest/res/raw/testmidi.mid diff --git a/media/tests/MediaFrameworkTest/res/raw/testmp3.mp3 b/media/tests/MediaFrameworkTest/res/raw/testmp3.mp3 Binary files differindex 89c44b0..b7d69f8 100644 --- a/media/tests/MediaFrameworkTest/res/raw/testmp3.mp3 +++ b/media/tests/MediaFrameworkTest/res/raw/testmp3.mp3 diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java index 760b6b5..e76967d 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java @@ -23,27 +23,27 @@ package com.android.mediaframeworktest; * */ public class MediaNames { - + //A directory to hold all kinds of media files + public static final String MEDIA_SAMPLE_POOL = "/sdcard/media_api/samples/"; //Audio files - public static final String MP3CBR = "/sdcard/media_api/music/MP3CBR.mp3"; - public static final String MP3VBR = "/sdcard/media_api/music/MP3VBR.mp3"; + public static final String MP3CBR = "/sdcard/media_api/music/MP3_256kbps_2ch.mp3"; + public static final String MP3VBR = "/sdcard/media_api/music/MP3_256kbps_2ch_VBR.mp3"; public static final String SHORTMP3 = "/sdcard/media_api/music/SHORTMP3.mp3"; - public static final String MIDI = "/sdcard/media_api/music/MIDI.mid"; + public static final String MIDI = "/sdcard/media_api/music/ants.mid"; public static final String WMA9 = "/sdcard/media_api/music/WMA9.wma"; public static final String WMA10 = "/sdcard/media_api/music/WMA10.wma"; - public static final String WAV = "/sdcard/media_api/music/complicated_wav.wav"; - public static final String AMR = "/sdcard/media_api/music/AMRNB.amr"; - public static final String OGG = "/sdcard/media_api/music/Mists_of_Time-4T.ogg"; - public static final String OGGSHORT = "/sdcard/media_api/music/Skippy.ogg"; + public static final String WAV = "/sdcard/media_api/music/rings_2ch.wav"; + public static final String AMR = "/sdcard/media_api/music/test_amr_ietf.amr"; + public static final String OGG = "/sdcard/media_api/music/Revelation.ogg"; - public static final int MP3CBR_LENGTH = 231116; - public static final int MP3VBR_LENGTH = 126407; + public static final int MP3CBR_LENGTH = 71000; + public static final int MP3VBR_LENGTH = 71000; public static final int SHORTMP3_LENGTH = 286; - public static final int MIDI_LENGTH = 210528; + public static final int MIDI_LENGTH = 17000; public static final int WMA9_LENGTH = 126559; public static final int WMA10_LENGTH = 126559; - public static final int AMR_LENGTH = 126540; - public static final int OGG_LENGTH = 40000; + public static final int AMR_LENGTH = 37000; + public static final int OGG_LENGTH = 4000; public static final int SEEK_TIME = 10000; public static final long PAUSE_WAIT_TIME = 3000; @@ -60,29 +60,21 @@ public class MediaNames { //public static final String VIDEO_RTSP3GP = "rtsp://193.159.241.21/sp/alizee05.3gp"; //local video - public static final String VIDEO_MP4 = "/sdcard/media_api/video/gingerkids.MP4"; + public static final String VIDEO_MP4 = "/sdcard/media_api/video/MPEG4_320_AAC_64.mp4"; public static final String VIDEO_LONG_3GP = "/sdcard/media_api/video/radiohead.3gp"; public static final String VIDEO_SHORT_3GP = "/sdcard/media_api/video/short.3gp"; public static final String VIDEO_LARGE_SIZE_3GP = "/sdcard/media_api/video/border_large.3gp"; - public static final String VIDEO_H263_AAC = "/sdcard/media_api/video/H263_AAC.3gp"; - public static final String VIDEO_H263_AMR = "/sdcard/media_api/video/H263_AMR.3gp"; - public static final String VIDEO_H264_AAC = "/sdcard/media_api/video/H264_AAC.3gp"; - public static final String VIDEO_H264_AMR = "/sdcard/media_api/video/H264_AMR.3gp"; + public static final String VIDEO_H263_AAC = "/sdcard/media_api/video/H263_56_AAC_24.3gp"; + public static final String VIDEO_H263_AMR = "/sdcard/media_api/video/H263_56_AMRNB_6.3gp"; + public static final String VIDEO_H264_AAC = "/sdcard/media_api/video/H264_320_AAC_64.3gp"; + public static final String VIDEO_H264_AMR = "/sdcard/media_api/video/H264_320_AMRNB_6.3gp"; public static final String VIDEO_WMV = "/sdcard/media_api/video/bugs.wmv"; - public static final String VIDEO_HIGHRES_H263 = "/sdcard/media_api/video/h263_qcif_30fps.3gp"; - public static final String VIDEO_HIGHRES_MP4 = "/sdcard/media_api/video/mpeg4_qvga_24fps.3gp"; + public static final String VIDEO_HIGHRES_H263 = "/sdcard/media_api/video/H263_500_AMRNB_12.3gp"; + public static final String VIDEO_HIGHRES_MP4 = "/sdcard/media_api/video/H264_500_AAC_128.3gp"; //ringtone public static final String ringtone = "/sdcard/media_api/ringtones/F1_NewVoicemail.mp3"; - - //streaming mp3 - public static final String STREAM_LARGE_MP3 = - "http://wms.pv.com:7070/MediaDownloadContent/mp3/BuenaVista_04_Pueblo_Nuevo.mp3"; - public static final String STREAM_SMALL_MP3 = - "http://wms.pv.com:7070/MediaDownloadContent/mp3/ID3V2_TestFile.mp3"; - public static final String STREAM_REGULAR_MP3 = - "http://wms.pv.com:7070/MediaDownloadContent/mp3/ElectricCosmo.mp3"; - + //streaming mp3 public static final String STREAM_MP3_1 = "http://wms.pv.com:7070/MediaDownloadContent/mp3/chadthi_jawani_128kbps.mp3"; @@ -509,4 +501,6 @@ public class MediaNames { "http://sridharg.googlejunta.com/yslau/stress_media/mp3_regular.mp3"; public static final String STREAM_MPEG4_QVGA_128k = "http://sridharg.googlejunta.com/yslau/stress_media/mpeg4_qvga_24fps.3gp"; + public static final int STREAM_H264_480_360_1411k_DURATION = 46000; + public static final int VIDEO_H263_AAC_DURATION = 501000; } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java index 12eacd3..ae9e102 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java @@ -19,6 +19,7 @@ package com.android.mediaframeworktest; import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestSuite; import com.android.mediaframeworktest.stress.MediaRecorderStressTest; +import com.android.mediaframeworktest.stress.MediaPlayerStressTest; import junit.framework.TestSuite; @@ -28,6 +29,7 @@ public class MediaRecorderStressTestRunner extends InstrumentationTestRunner { public TestSuite getAllTests() { TestSuite suite = new InstrumentationTestSuite(this); suite.addTestSuite(MediaRecorderStressTest.class); + suite.addTestSuite(MediaPlayerStressTest.class); return suite; } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java index d9e17ea..0c0974c 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java @@ -32,8 +32,14 @@ import android.os.Looper; import android.os.SystemClock; import android.util.Log; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; +import java.io.Writer; +import java.io.FileOutputStream; +import java.util.Random; /** * Junit / Instrumentation test case for the media player api @@ -50,8 +56,9 @@ public class CodecTest { private static final Object lock = new Object(); private static final Object prepareDone = new Object(); private static final Object videoSizeChanged = new Object(); + private static final Object onCompletion = new Object(); private static boolean onPrepareSuccess = false; - + private static boolean onCompleteSuccess = false; public static String printCpuInfo(){ String cm = "dumpsys cpuinfo"; @@ -78,7 +85,9 @@ public class CodecTest { try{ mp.setDataSource(filePath); mp.prepare(); - }catch (Exception e){} + }catch (Exception e){ + Log.v(TAG, e.toString()); + } int duration = mp.getDuration(); Log.v(TAG, "Duration " + duration); mp.release(); @@ -527,7 +536,6 @@ public class CodecTest { //Verify the thumbnail Bitmap goldenBitmap = mBitmapFactory.decodeFile(goldenPath); - outputWidth = outThumbnail.getWidth(); outputHeight = outThumbnail.getHeight(); goldenHeight = goldenBitmap.getHeight(); @@ -537,15 +545,18 @@ public class CodecTest { if ((outputWidth != goldenWidth) || (outputHeight != goldenHeight)) return false; - //Check one line of pixel - int x = goldenHeight/2; - for (int j=0; j<goldenWidth; j++){ - if (goldenBitmap.getPixel(x, j) != outThumbnail.getPixel(x, j)){ + // Check half line of pixel + int x = goldenHeight / 2; + for (int j = 1; j < goldenWidth / 2; j++) { + if (goldenBitmap.getPixel(x, j) != outThumbnail.getPixel(x, j)) { Log.v(TAG, "pixel = " + goldenBitmap.getPixel(x, j)); - return false; + return false; } - } - }catch (Exception e){} + } + }catch (Exception e){ + Log.v(TAG, e.toString()); + return false; + } return true; } @@ -725,8 +736,75 @@ public class CodecTest { } return onPrepareSuccess; } - - - -} + static MediaPlayer.OnCompletionListener mCompletionListener = new MediaPlayer.OnCompletionListener() { + public void onCompletion(MediaPlayer mp) { + synchronized (onCompletion) { + Log.v(TAG, "notify the completion callback"); + onCompletion.notify(); + onCompleteSuccess = true; + } + } + }; + + // For each media file, forward twice and backward once, then play to the end + public static boolean playMediaSamples(String filePath) throws Exception { + int duration = 0; + int curPosition = 0; + int nextPosition = 0; + int waittime = 0; + Random r = new Random(); + initializeMessageLooper(); + synchronized (lock) { + try { + lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE); + } catch(Exception e) { + Log.v(TAG, "looper was interrupted."); + return false; + } + } + try { + mMediaPlayer.setOnCompletionListener(mCompletionListener); + Log.v(TAG, "playMediaSamples: sample file name " + filePath); + mMediaPlayer.setDataSource(filePath); + mMediaPlayer.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder()); + mMediaPlayer.prepare(); + duration = mMediaPlayer.getDuration(); + Log.v(TAG, "playMediaSamples: duration = " + duration); + // start to play + mMediaPlayer.start(); + // randomly play for time within (0, duration/3) + Thread.sleep(r.nextInt(duration/3)); + mMediaPlayer.pause(); + Log.v(TAG, "playMediaSamples: current position after pause: " + + mMediaPlayer.getCurrentPosition()); + // seek to position (0, 2/3*duration) + nextPosition = mMediaPlayer.getCurrentPosition() + r.nextInt(duration/3); + mMediaPlayer.seekTo(nextPosition); + Log.v(TAG, "playMediaSamples: current position after the first seek:" + + mMediaPlayer.getCurrentPosition()); + // play for another short time + mMediaPlayer.start(); + Thread.sleep(r.nextInt(duration/6)); + Log.v(TAG, "playMediaSamples: position after the second play:" + + mMediaPlayer.getCurrentPosition()); + // seek to a random position (0, duration) + mMediaPlayer.seekTo(r.nextInt(duration)); + Log.v(TAG, "playMediaSamples: current position after the second seek:" + + mMediaPlayer.getCurrentPosition()); + waittime = duration - mMediaPlayer.getCurrentPosition(); + synchronized(onCompletion){ + try { + onCompletion.wait(waittime + 30000); + }catch (Exception e) { + Log.v(TAG, "playMediaSamples are interrupted"); + return false; + } + } + terminateMessageLooper(); + }catch (Exception e) { + Log.v(TAG, "playMediaSamples:" + e.getMessage()); + } + return onCompleteSuccess; + } +} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java index 8be7058..ea42f53 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java @@ -26,6 +26,8 @@ import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.Suppress; +import java.io.File; + /** * Junit / Instrumentation test case for the media player api @@ -78,7 +80,6 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra assertTrue("MIDI getDuration", duratoinWithinTolerence); } - @Suppress @MediumTest public void testWMA9GetDuration() throws Exception { int duration = CodecTest.getDuration(MediaNames.WMA9); @@ -120,7 +121,6 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra assertTrue("MIDI GetCurrentPosition", currentPosition); } - @Suppress @LargeTest public void testWMA9GetCurrentPosition() throws Exception { boolean currentPosition = CodecTest.getCurrentPosition(MediaNames.WMA9); @@ -158,7 +158,6 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra assertTrue("MIDI Pause", isPaused); } - @Suppress @LargeTest public void testWMA9Pause() throws Exception { boolean isPaused = CodecTest.pause(MediaNames.WMA9); @@ -230,7 +229,6 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra assertTrue("MIDI setLooping", isLoop); } - @Suppress @LargeTest public void testWMA9SetLooping() throws Exception { boolean isLoop = CodecTest.setLooping(MediaNames.WMA9); @@ -269,7 +267,6 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra assertTrue("MIDI seekTo", isLoop); } - @Suppress @LargeTest public void testWMA9SeekTo() throws Exception { boolean isLoop = CodecTest.seekTo(MediaNames.WMA9); @@ -308,7 +305,7 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra boolean isEnd = CodecTest.seekToEnd(MediaNames.MIDI); assertTrue("MIDI seekToEnd", isEnd); } - + @Suppress @LargeTest public void testWMA9SeekToEnd() throws Exception { @@ -386,7 +383,6 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra assertTrue("H264AMR SeekTo", isSeek); } - @Suppress @LargeTest public void testVideoWMVSeekTo() throws Exception { boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_WMV); @@ -408,7 +404,7 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra //Play a mid file which the duration is around 210 seconds @LargeTest public void testMidiResources() throws Exception { - boolean midiResources = CodecTest.resourcesPlayback(MediaFrameworkTest.midiafd,180000); + boolean midiResources = CodecTest.resourcesPlayback(MediaFrameworkTest.midiafd,16000); assertTrue("Play midi from resources", midiResources); } @@ -420,7 +416,7 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra @MediumTest public void testPrepareAsyncReset() throws Exception { - boolean isReset = CodecTest.prepareAsyncReset(MediaNames.STREAM_LARGE_MP3); + boolean isReset = CodecTest.prepareAsyncReset(MediaNames.STREAM_MP3); assertTrue("PrepareAsync Reset", isReset); } @@ -456,4 +452,29 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra CodecTest.prepareAsyncCallback(MediaNames.STREAM_H264_480_360_1411k, true); assertTrue("StreamH264PrepareAsyncCallback", onPrepareSuccess); } + + //Provide a tool to play all kinds of media files in a directory + @Suppress + @LargeTest + public void testMediaSamples() throws Exception { + // load directory files + boolean onCompleteSuccess = false; + File dir = new File(MediaNames.MEDIA_SAMPLE_POOL); + String[] children = dir.list(); + if (children == null) { + Log.v("MediaPlayerApiTest:testMediaSamples", "dir is empty"); + return; + } else { + for (int i = 0; i < children.length; i++) { + //Get filename of directory + String filename = children[i]; + Log.v("MediaPlayerApiTest", + "testMediaSamples: file to be played: " + + dir + "/" + filename); + onCompleteSuccess = + CodecTest.playMediaSamples(dir + "/" + filename); + assertTrue("testMediaSamples", onCompleteSuccess); + } + } + } } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java index 2f0173d..84058f5 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java @@ -54,20 +54,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<Medi private static final int NUM_STRESS_LOOP = 10; private static final int NUM_PLAYBACk_IN_EACH_LOOP = 20; private static final long MEDIA_STRESS_WAIT_TIME = 5000; //5 seconds - private static final String H263_VIDEO_PLAYBACK_MEMOUT = - "/sdcard/h263VideoPlaybackMemOut.txt"; - private static final String H264_VIDEO_PLAYBACK_MEMOUT = - "/sdcard/h264VideoPlaybackMemOut.txt"; - private static final String WMV_VIDEO_PLAYBACK_MEMOUT = - "/sdcard/WmvVideoPlaybackMemOut.txt"; - private static final String H263_VIDEO_ONLY_RECORD_MEMOUT = - "/sdcard/recordH263VideoOnlyMemOut.txt"; - private static final String MP4_VIDEO_ONLY_RECORD_MEMOUT = - "/sdcard/recordMPEG4VideoOnlyMemOut.txt"; - private static final String H263_VIDEO_AUDIO_RECORD_MEMOUT = - "/sdcard/recordVideoH263AudioMemOut.txt"; - private static final String AUDIO_ONLY_RECORD_MEMOUT = - "/sdcard/recordAudioOnlyMemOut.txt"; + private static final String MEDIA_MEMORY_OUTPUT = + "/sdcard/mediaMemOutput.txt"; + + //the tolerant memory leak + private static final int MAX_ACCEPTED_MEMORY_LEAK_KB = 150; + + private static int mStartMemory = 0; + private static int mEndMemory = 0; + private static int mStartPid = 0; + private static int mEndPid = 0; public MediaPlayerPerformance() { @@ -253,8 +249,21 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<Medi //Write the ps output to the file public void getMemoryWriteToLog(Writer output) { + String memusage = null; + memusage = captureMediaserverInfo(); + Log.v(TAG, memusage); + try { + //Write to file output + output.write(memusage); + } catch (Exception e) { + e.toString(); + } + } + + public String captureMediaserverInfo() { String cm = "ps mediaserver"; String memoryUsage = null; + int ch; try { Process p = Runtime.getRuntime().exec(cm); @@ -267,18 +276,48 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<Medi } catch (IOException e) { Log.v(TAG, e.toString()); } - String[] poList = memoryUsage.split("\r|\n|\r\n"); String memusage = poList[1].concat("\n"); - Log.v(TAG, memusage); - try { - //Write to file output - output.write(memusage); - } catch (Exception e) { - e.toString(); - } + return memusage; } + public int getMediaserverPid(){ + String memoryUsage = null; + int pidvalue = 0; + memoryUsage = captureMediaserverInfo(); + String[] poList2 = memoryUsage.split("\t|\\s+"); + String pid = poList2[1]; + pidvalue = Integer.parseInt(pid); + Log.v(TAG, "PID = " + pidvalue); + return pidvalue; + } + + public int getMediaserverVsize(){ + String memoryUsage = captureMediaserverInfo(); + String[] poList2 = memoryUsage.split("\t|\\s+"); + String vsize = poList2[3]; + int vsizevalue = Integer.parseInt(vsize); + Log.v(TAG, "VSIZE = " + vsizevalue); + return vsizevalue; + } + + public boolean validateMemoryResult (int startPid, int startMemory, Writer output) throws Exception { + mEndPid = getMediaserverPid(); + mEndMemory = getMediaserverVsize(); + + //Write the total memory different into the output file + output.write("The total diff = " + (mEndMemory - startMemory)); + output.write("\n\n"); + //mediaserver crash + if (startPid != mEndPid){ + output.write("mediaserver died. Test failed\n"); + return false; + } + //memory leak greter than the tolerant + if ((mEndMemory - startMemory) > MAX_ACCEPTED_MEMORY_LEAK_KB ) + return false; + return true; + } @Suppress public void testWmaParseTime() throws Exception { @@ -290,87 +329,151 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<Medi // Test case 1: Capture the memory usage after every 20 h263 playback @LargeTest public void testH263VideoPlaybackMemoryUsage() throws Exception { - File h263MemoryOut = new File(H263_VIDEO_PLAYBACK_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(h263MemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File h263MemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(h263MemoryOut, true)); + output.write("H263 Video Playback Only\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { mediaStressPlayback(MediaNames.VIDEO_HIGHRES_H263); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("H263 playback memory test", memoryResult); } // Test case 2: Capture the memory usage after every 20 h264 playback @LargeTest public void testH264VideoPlaybackMemoryUsage() throws Exception { - File h264MemoryOut = new File(H264_VIDEO_PLAYBACK_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(h264MemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File h264MemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(h264MemoryOut, true)); + output.write("H264 Video Playback only\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { mediaStressPlayback(MediaNames.VIDEO_H264_AMR); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("H264 playback memory test", memoryResult); } // Test case 3: Capture the memory usage after each 20 WMV playback @LargeTest public void testWMVVideoPlaybackMemoryUsage() throws Exception { - File wmvMemoryOut = new File(WMV_VIDEO_PLAYBACK_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(wmvMemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File wmvMemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(wmvMemoryOut, true)); + output.write("WMV video playback only\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { mediaStressPlayback(MediaNames.VIDEO_WMV); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("wmv playback memory test", memoryResult); } // Test case 4: Capture the memory usage after every 20 video only recorded @LargeTest public void testH263RecordVideoOnlyMemoryUsage() throws Exception { - File videoH263RecordOnlyMemoryOut = new File(H263_VIDEO_ONLY_RECORD_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(videoH263RecordOnlyMemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File videoH263RecordOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(videoH263RecordOnlyMemoryOut, true)); + output.write("H263 video record only\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { stressVideoRecord(20, 352, 288, MediaRecorder.VideoEncoder.H263, MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("H263 record only memory test", memoryResult); } // Test case 5: Capture the memory usage after every 20 video only recorded @LargeTest public void testMpeg4RecordVideoOnlyMemoryUsage() throws Exception { - File videoMp4RecordOnlyMemoryOut = new File(MP4_VIDEO_ONLY_RECORD_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(videoMp4RecordOnlyMemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File videoMp4RecordOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(videoMp4RecordOnlyMemoryOut, true)); + output.write("MPEG4 video record only\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { stressVideoRecord(20, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP, MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("mpeg4 record only memory test", memoryResult); } - // Test case 6: Capture the memory usage after every 20 video and audio recorded + // Test case 6: Capture the memory usage after every 20 video and audio + // recorded @LargeTest public void testRecordVidedAudioMemoryUsage() throws Exception { - File videoRecordAudioMemoryOut = new File(H263_VIDEO_AUDIO_RECORD_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(videoRecordAudioMemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File videoRecordAudioMemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(videoRecordAudioMemoryOut, true)); + output.write("Audio and h263 video record\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { stressVideoRecord(20, 352, 288, MediaRecorder.VideoEncoder.H263, MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, false); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("H263 audio video record memory test", memoryResult); } // Test case 7: Capture the memory usage after every 20 audio only recorded @LargeTest public void testRecordAudioOnlyMemoryUsage() throws Exception { - File audioOnlyMemoryOut = new File(AUDIO_ONLY_RECORD_MEMOUT); - Writer output = new BufferedWriter(new FileWriter(audioOnlyMemoryOut)); + boolean memoryResult = false; + mStartPid = getMediaserverPid(); + mStartMemory = getMediaserverVsize(); + + File audioOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(audioOnlyMemoryOut, true)); + output.write("Audio record only\n"); + getMemoryWriteToLog(output); for (int i = 0; i < NUM_STRESS_LOOP; i++) { stressAudioRecord(MediaNames.RECORDER_OUTPUT); getMemoryWriteToLog(output); } + output.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, output); output.close(); + assertTrue("audio record only memory test", memoryResult); } } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java new file mode 100644 index 0000000..5e213d7 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mediaframeworktest.stress; + +import com.android.mediaframeworktest.MediaFrameworkTest; + +import android.hardware.Camera; +import android.media.MediaPlayer; +import android.media.MediaRecorder; +import android.test.ActivityInstrumentationTestCase2; +import android.test.suitebuilder.annotation.LargeTest; +import android.util.Log; +import android.view.SurfaceHolder; + +import com.android.mediaframeworktest.MediaNames; + +import java.util.Random; + +/** + * Junit / Instrumentation test case for the media player + */ +public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> { + private String TAG = "MediaPlayerStressTest"; + private MediaRecorder mRecorder; + private Camera mCamera; + + private static final int NUMBER_OF_RANDOM_REPOSITION_AND_PLAY = 10; + private static final int NUMBER_OF_RANDOM_REPOSITION_AND_PLAY_SHORT = 5; + private static final int NUMBER_OF_STRESS_LOOPS = 1000; + private static final int PLAYBACK_END_TOLERANCE = 5000; + private static final int WAIT_UNTIL_PLAYBACK_FINISH = 515000 ; + + public MediaPlayerStressTest() { + super("com.android.mediaframeworktest", MediaFrameworkTest.class); + } + + protected void setUp() throws Exception { + getActivity(); + super.setUp(); + } + + @LargeTest + public void testStressHWDecoderRelease() throws Exception { + SurfaceHolder mSurfaceHolder; + long randomseed = System.currentTimeMillis(); + Random generator = new Random(randomseed); + Log.v(TAG, "Random seed: " + randomseed); + int video_duration = MediaNames.STREAM_H264_480_360_1411k_DURATION; + int random_play_time; + + mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); + try { + for (int i = 0; i < NUMBER_OF_STRESS_LOOPS; i++) { + MediaPlayer mp = new MediaPlayer(); + mp.setDataSource(MediaNames.STREAM_H264_480_360_1411k); + mp.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder()); + mp.prepare(); + mp.start(); + // seek and play + for (int j = 0; j < generator.nextInt(10); j++) { + random_play_time = + generator.nextInt(MediaNames.STREAM_H264_480_360_1411k_DURATION / 2); + Log.v(TAG, "Play time = " + random_play_time); + Thread.sleep(random_play_time); + int seek_time = MediaNames.STREAM_H264_480_360_1411k_DURATION / 2; + Log.v(TAG, "Seek time = " + seek_time); + mp.seekTo(seek_time); + } + mp.release(); + } + + } catch (Exception e) { + Log.v(TAG, e.toString()); + } + } + + @LargeTest + public void testStressGetCurrentPosition() throws Exception { + SurfaceHolder mSurfaceHolder; + long randomseed = System.currentTimeMillis(); + Random generator = new Random(randomseed); + Log.v(TAG, "Random seed: " + randomseed); + int video_duration = MediaNames.VIDEO_H263_AAC_DURATION; + int random_play_time = 0; + int random_seek_time = 0; + + mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); + try { + for (int i = 0; i < NUMBER_OF_STRESS_LOOPS; i++) { + MediaPlayer mp = new MediaPlayer(); + mp.setDataSource(MediaNames.VIDEO_H263_AMR); + mp.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder()); + mp.prepare(); + mp.start(); + // Random seek and play + for (int j = 0; j < generator.nextInt(10); j++) { + random_play_time = + generator.nextInt(video_duration / 2); + Log.v(TAG, "Play time = " + random_play_time); + Thread.sleep(random_play_time); + random_seek_time = + generator.nextInt(video_duration / 2); + Log.v(TAG, "Seek time = " + random_seek_time); + mp.seekTo(random_seek_time); + } + //wait until the movie finish and check the current position + //Make sure the wait time is long enough + long wait_until_playback_finish = video_duration - random_seek_time + PLAYBACK_END_TOLERANCE * 2; + Thread.sleep(wait_until_playback_finish); + Log.v(TAG, "CurrentPosition = " + mp.getCurrentPosition()); + if ( mp.isPlaying() || mp.getCurrentPosition() > (video_duration + PLAYBACK_END_TOLERANCE)){ + assertTrue("Current PlayTime greater than duration", false); + } + mp.release(); + } + + } catch (Exception e) { + Log.v(TAG, e.toString()); + } + } +} + diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java index dbf937c..69e93a1 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java @@ -18,6 +18,11 @@ package com.android.mediaframeworktest.stress; import com.android.mediaframeworktest.MediaFrameworkTest; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.Writer; + import android.hardware.Camera; import android.media.MediaPlayer; import android.media.MediaRecorder; @@ -47,6 +52,8 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me private static final long WAIT_TIME_PLAYBACK = 60000; // 6 second private static final String OUTPUT_FILE = "/sdcard/temp"; private static final String OUTPUT_FILE_EXT = ".3gp"; + private static final String MEDIA_STRESS_OUTPUT = + "/sdcard/mediaStressOutput.txt"; public MediaRecorderStressTest() { super("com.android.mediaframeworktest", MediaFrameworkTest.class); @@ -62,8 +69,14 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me public void testStressCamera() throws Exception { SurfaceHolder mSurfaceHolder; mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); + File stressOutFile = new File(MEDIA_STRESS_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(stressOutFile, true)); + output.write("Camera start preview stress:\n"); + output.write("Total number of loops:" + + NUMBER_OF_CAMERA_STRESS_LOOPS + "\n"); try { Log.v(TAG, "Start preview"); + output.write("No of loop: "); for (int i = 0; i< NUMBER_OF_CAMERA_STRESS_LOOPS; i++){ mCamera = Camera.open(); mCamera.setPreviewDisplay(mSurfaceHolder); @@ -71,10 +84,13 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me Thread.sleep(WAIT_TIME_CAMERA_TEST); mCamera.stopPreview(); mCamera.release(); + output.write(" ," + i); } } catch (Exception e) { Log.v(TAG, e.toString()); } + output.write("\n\n"); + output.close(); } //Test case for stressing the camera preview. @@ -83,7 +99,13 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me String filename; SurfaceHolder mSurfaceHolder; mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); - try { + File stressOutFile = new File(MEDIA_STRESS_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(stressOutFile, true)); + output.write("H263 video record- reset after prepare Stress test\n"); + output.write("Total number of loops:" + + NUMBER_OF_RECORDER_STRESS_LOOPS + "\n"); + try { + output.write("No of loop: "); Log.v(TAG, "Start preview"); for (int i = 0; i < NUMBER_OF_RECORDER_STRESS_LOOPS; i++){ Log.v(TAG, "counter = " + i); @@ -106,10 +128,13 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me Thread.sleep(WAIT_TIME_RECORDER_TEST); mRecorder.reset(); mRecorder.release(); + output.write(", " + i); } } catch (Exception e) { Log.v(TAG, e.toString()); } + output.write("\n\n"); + output.close(); } @@ -119,8 +144,14 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me String filename; SurfaceHolder mSurfaceHolder; mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); + File stressOutFile = new File(MEDIA_STRESS_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(stressOutFile, true)); + output.write("Camera and video recorder preview switching\n"); + output.write("Total number of loops:" + + NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER + "\n"); try { Log.v(TAG, "Start preview"); + output.write("No of loop: "); for (int i = 0; i < NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER; i++){ mCamera = Camera.open(); mCamera.setPreviewDisplay(mSurfaceHolder); @@ -147,11 +178,14 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me Log.v(TAG, "before release"); Thread.sleep(WAIT_TIME_CAMERA_TEST); mRecorder.release(); - Log.v(TAG, "release video recorder"); + Log.v(TAG, "release video recorder"); + output.write(", " + i); } } catch (Exception e) { Log.v(TAG, e.toString()); } + output.write("\n\n"); + output.close(); } //Stress test case for record a video and play right away. @@ -160,7 +194,13 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me String filename; SurfaceHolder mSurfaceHolder; mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); - try { + File stressOutFile = new File(MEDIA_STRESS_OUTPUT); + Writer output = new BufferedWriter(new FileWriter(stressOutFile, true)); + output.write("Video record and play back stress test:\n"); + output.write("Total number of loops:" + + NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS + "\n"); + try { + output.write("No of loop: "); for (int i = 0; i < NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS; i++){ filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT; Log.v(TAG, filename); @@ -189,10 +229,13 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me mp.start(); Thread.sleep(WAIT_TIME_PLAYBACK); mp.release(); + output.write(", " + i); } } catch (Exception e) { Log.v(TAG, e.toString()); } + output.write("\n\n"); + output.close(); } } |
