f998922f30
First, clear an issue which was causing an assert to fire. Basically, once a decoder pump had entered the error state and was shutdown, it was not clearing its status, and when a substream attempt to recycle the pump, startup was failing an assert (no thread had been created, meaning that the system was not initialized, yet status indicated an error). This was a small one-liner in aah_decoder_pump.cpp. Second, try to become a little nuanced about how we handle errors in the decoder pump. A comment in the code pretty much says it all, but the summary is that we don't want to completely abort playback because a single chunk of ES failed to decode, but if nothing is decoding and we are making no progress at all, we probably need to put the MediaPlayer instance into the fatal Error state and signal the app level so that further action can be taken (automatic recovery attempts followed by bug reports and signalling the user if those fail). This is to address the fallout of http://b/issue?id=5498460, where something at the OMX decoder level becomes unhappy about not being able to obtain an output buffer which eventually unwinds to this assert which results in a dead mediaserver. After this change, the mediaserver will no longer crash, and may even recover (depending on whether or not the OMX unhappiness is transient or not), but the primary issue (unhappy OMX) is probably still around. It is quite difficult to reproduce, I will probably need to open a different bug to track that issue. Change-Id: I5b65b818378a5ae9c915e91b7db7129f0bda6837 Signed-off-by: John Grossman <johngro@google.com>
106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
/*
|
|
* Copyright (C) 2011 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.
|
|
*/
|
|
|
|
#ifndef __DECODER_PUMP_H__
|
|
#define __DECODER_PUMP_H__
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <media/stagefright/MediaSource.h>
|
|
#include <utils/LinearTransform.h>
|
|
#include <utils/List.h>
|
|
#include <utils/threads.h>
|
|
|
|
namespace android {
|
|
|
|
class MetaData;
|
|
class OMXClient;
|
|
class TimedAudioTrack;
|
|
|
|
class AAH_DecoderPump : public MediaSource {
|
|
public:
|
|
explicit AAH_DecoderPump(OMXClient& omx);
|
|
status_t initCheck();
|
|
|
|
status_t queueForDecode(MediaBuffer* buf);
|
|
|
|
status_t init(sp<MetaData> params);
|
|
status_t shutdown();
|
|
|
|
void setRenderTSTransform(const LinearTransform& trans);
|
|
void setRenderVolume(uint8_t volume);
|
|
bool isAboutToUnderflow(int64_t threshold);
|
|
bool getStatus() const { return thread_status_; }
|
|
|
|
// MediaSource methods
|
|
virtual status_t start(MetaData *params) { return OK; }
|
|
virtual sp<MetaData> getFormat() { return format_; }
|
|
virtual status_t stop() { return OK; }
|
|
virtual status_t read(MediaBuffer **buffer,
|
|
const ReadOptions *options);
|
|
|
|
protected:
|
|
virtual ~AAH_DecoderPump();
|
|
|
|
private:
|
|
class ThreadWrapper : public Thread {
|
|
public:
|
|
friend class AAH_DecoderPump;
|
|
explicit ThreadWrapper(AAH_DecoderPump* owner);
|
|
|
|
private:
|
|
virtual bool threadLoop();
|
|
AAH_DecoderPump* owner_;
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(ThreadWrapper);
|
|
};
|
|
|
|
void* workThread();
|
|
virtual status_t shutdown_l();
|
|
void queueToRenderer(MediaBuffer* decoded_sample);
|
|
void stopAndCleanupRenderer();
|
|
|
|
sp<MetaData> format_;
|
|
int32_t format_channels_;
|
|
int32_t format_sample_rate_;
|
|
|
|
sp<MediaSource> decoder_;
|
|
OMXClient& omx_;
|
|
Mutex init_lock_;
|
|
|
|
sp<ThreadWrapper> thread_;
|
|
Condition thread_cond_;
|
|
Mutex thread_lock_;
|
|
status_t thread_status_;
|
|
|
|
Mutex render_lock_;
|
|
TimedAudioTrack* renderer_;
|
|
bool last_queued_pts_valid_;
|
|
int64_t last_queued_pts_;
|
|
bool last_ts_transform_valid_;
|
|
LinearTransform last_ts_transform_;
|
|
uint8_t last_volume_;
|
|
|
|
// protected by the thread_lock_
|
|
typedef List<MediaBuffer*> MBQueue;
|
|
MBQueue in_queue_;
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(AAH_DecoderPump);
|
|
};
|
|
|
|
} // namespace android
|
|
#endif // __DECODER_PUMP_H__
|