Disconnect the mediaplayer when reset

When the mediaplayer is reset the strong pointer to the
media service client is destroyed and the client should
deconstruct. However this could take some time and if a new
client is connected before the old client is disconnected
there could be problems. By assuring that the client disconnects
these problems can be avoided.

Change-Id: I5d2cf6d22860aa616b14397b1f523ddc35197b83
Audio streaming error when playing a stream that contains "end of file".

Although EOS is being posted upon receipt of BYE message from RTSP
server, still it didn't reach the media framework and application.
This happens because the Nuplayer::Renderer::onDrainAudioQueue() funtion
returns false after mAudioSink->getPosition() call , and the EOS message
present in mAudioQueue was lost.The mAudioSink->getPosition() returns
NO_INIT as mAudioSink->open() is not yet called,
hence no audio track exists in MediaPlayerService::AudioOutput.

Change-Id: I905e8f3af87dc778952eeef3904c4e2a6a75ca7a
Signed-off-by: Arulselvan M <arulselvan.m@intel.com>
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Support MPEG4 codec in Matroska files

For MPEG4 the matroska parser must handle files with and without
configinfo in the codec private data.

Change-Id: I7025772c87ee24bc074bd3837f6877552245e389
Support AAC audio (WaveFormat = 0xFF) in AVI container.

Present AVIExtractor doesn't support AAC audio. So some AVI clip with AAC,
AAC-HEv1, AAC-HEv2 audio, can't be played from gallery.
With this fix, added support for AAC audio (WaveFormat = 0xFF) in AVI container.
Also added a condition to check the sampling rates which are supported and return
error if unsupported sampling rate is encountered, to avoid tombstone crash.

Change-Id: Ic8f081ed254ce8c0b3c0cbd1c3811b89b18c6e8e
Signed-off-by: gbhakteX <gurudattax.bhakte@intel.com>
Signed-off-by: Mazhar <mazharx.sameullah@intel.com>
Support MP2 contents in AVI container.

In present code only "Wave Format = 0x55 (MPEG Layer 3)" is supported in AVI container.
With this fix, adding support for "Wave Format = 0x50 (MPEG)".
As per "RFC 2361 - WAVE and AVI Codec Registries":
A.45 MPEG
WAVE form Registration Number (hex): 0x0050
Codec ID in the IANA Namespace:      audio/vnd.wave;codec=50
WAVE form wFormatTag ID:             WAVE_FORMAT_MPEG

Change-Id: I7cc9d3c8bd8da7a079ac8d50a6d61ccbdedb6f82
Signed-off-by: gbhakteX <gurudattax.bhakte@intel.com>
AACExtractor: Added support for APE tag

To support aac audio with APE tag we need parse
this tag. Otherwise AACExtractor stops reading of
audio file.

DR: OMAPS00267689

Change-Id: Ic697b90dbc9f2b93aeb227411359c36c113cb71e
Signed-off-by: Daniel Levin <dendy@ti.com>
libstagefright: Adds some parsing capability

o Adds AC3, EAC3 and DTS mime types
o Adds AC3/EAC3 support in MP4 parser
o Adds MPEG4 video, MPEG Audio, AC3, DTS, EAC3 support
in mkv extractor.

Change-Id: I9895c0e40e5ad38976004a9569200f1340d525de
Audio stops after seeking AVI clip with MP3 audio (special contents without proper key samples)

During seek in AVI, nearest Sync sample was searched both for
audio and video. Sync samples are useful only in case of
video. We can ignore Sync field for non-video tracks.

Change-Id: Ibaeda8f14afb83905e19087625a7d72fb1b3c8d6
Signed-off-by: Arulselvan M <arulselvan.m@intel.com>
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Remove potential cause of underrun.

1. This part of ProcessAudioBuffer function can make underrun issue.
   Because AudioTrackThread::threadLoop's default case is 'pauseInternal'.

2. Without removed part : If AudioTrack obtain small buffer, then it can request small decoded data to player service without waiting.

3. We already have 'waiting codes' in 'AudioTrackshared.cpp ClientProxy::obtainBuffer', it using '__futex_syscall'.
   If we got 'full shared buffer', then 'ClientProxy::obtainBuffer' waits 'ServerProxy::releaseBuffer'.
   It means, there are duplicated 'waiting codes' for ProcessAudioBuffer.

So I removed this part for preventing underrun issue.

Change-Id: Idcca686054d92a4d123873b78b3b9c2e87d3bdca
Signed-off-by: Jinhyuk Seong <jin.seong@lge.com>
Support MPEG4 and H263 FourCC types in Matroska files

Handles MPEG4 and H263 content with FourCC header in Matroska files
based on how these are handled in the AVI parser.

Also adding placehoders for DivX.

Change-Id: I38b2c2fd429b6e4810a7b118bf60823d502320ae
Solved problem with hanging decode call

Improved error handling in Mediaplayer service,
stops decode from hanging when player->start()
fails.

Change-Id: Ia160ff6eb9aeef0971c004e8baa90750e5636479
Correct the time returned by AudioPlayer::getMediaTime

The change 80a68deec52c9a1b47215ed68526206ec88197f8 was added to
eliminate returning negative media positions.

In the change all negative values of realTimeOffset were discarded.
The value realTimeOffset accounts for the latency and the
number of samples played since last feeding the AudioTrack and is
generally negative. By discarding this value for negative values the
time returned does not account for latency or the number of samples
played.

Change-Id: I470450934228732e34539c227365a225be74ccc8
Fix for getPosition after seek

When starting playback with a seek pending
(calling seek before start) there is a brief period
when the audioplayer returns an incorrect position (zero)

This is caused by that mSeeking is set to false
before the position in the audioplayer actually is updated.

Change-Id: Iaec355c8fdfe589d9b826d20c2531034f2b4e6fb
HLS: getDuration should return -1 for live streams

According to the MediaPlayer API documentation -1 should
be returned if the duration is not available. But for HLS 0
is returned. Change this.

Change-Id: Ib7704a94ac8dc104ceed4da4491f0d03cb8f4560
libstagefright: Handle unsupported codec metaData

Modification done in StagefrightMetadataRetriver
to handle NULL return for meta data if codec is
unsupported by extractor.

Change-Id: I905cec5ee91b098d99e1935437b562d2d9206381
Track volume should be maintained even if track is restored.

If track is dead when it set it`s volume is zero, track
sound should be mute even if it is restored. But now, we can hear track sound when it dead.

Change-Id: I79f34c6c7d6f535baba813fd3b8ba8e55cac8ad7
The progress bar of next song is not properly started in offload use case

The gapless data was not passed to HAL, which in turn to DRV/FW.
During start of every song gapless information is passed to
DSP to indicate the reset of hardware pointer. This pointer
is used in getting the render position. If some files does
not have gapless header, this value is not passed to DSP.
This causes wrong updation of render position for the next song
in the loop mode. This change will update the necessary information
to DSP appropriately.

Change-Id: I3dc71f6fb38e7067610813503ff60340e7dcb815
Signed-off-by: samaga Prasanna Krishna <samaga.krishna@intel.com>
Signed-off-by: Mazhar <mazharx.sameullah@intel.com>
libstagefright: ACodec: Add missing message handling

Add kWhatSetParameters as a valid received message in state
OutputPortSettingsChangedState.
Without this fix, the mediaserver can end up in an endless loop
consuming significant extra cpu power.

Change-Id: I9719f1698bf411914eb753d3c349a15b9fbf9df6
Signed-off-by: Per Persson <per.persson@intel.com>
Signed-off-by: Persson, Mikael <mikael.persson@intel.com>
Signed-off-by: Fagerstedt, Axel <axel.fagerstedt@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
audio: Fix PCM offload for NuPlayer

 * PCM offload is wonderfully broken on NuPlayer in the current CAF
   codebase.  Force the format to an offload format to get it
   working again.

Change-Id: I2ebfa4afc2e0a2bd7e7b6df4595449a2705f1eab
libstagefright: matroska: add missing include dir and header

Change-Id: Ied9c32307e207d171182b83f65368b34c7204651