diff --git a/softhddev.c b/softhddev.c index 13112af..531cb44 100644 --- a/softhddev.c +++ b/softhddev.c @@ -1716,21 +1716,23 @@ int Start(void) #ifdef DEBUG fprintf(stderr, "Start(void):\n"); #endif - AudioInit(); - av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE); - MyAudioDecoder = CodecAudioNewDecoder(); - AudioCodecID = AV_CODEC_ID_NONE; - AudioChannelID = -1; - - CodecInit(); - if (!MyVideoStream->Decoder) { - MyVideoStream->CodecID = AV_CODEC_ID_NONE; - } + if (!MyAudioDecoder) { + AudioInit(); + av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE); + MyAudioDecoder = CodecAudioNewDecoder(); + AudioCodecID = AV_CODEC_ID_NONE; + AudioChannelID = -1; - if ((MyVideoStream->Render = VideoNewRender(MyVideoStream))) { - VideoInit(MyVideoStream->Render); - MyVideoStream->Decoder = CodecVideoNewDecoder(MyVideoStream->Render); - VideoPacketInit(MyVideoStream); + CodecInit(); + if (!MyVideoStream->Decoder) { + MyVideoStream->CodecID = AV_CODEC_ID_NONE; + } + + if ((MyVideoStream->Render = VideoNewRender(MyVideoStream))) { + VideoInit(MyVideoStream->Render); + MyVideoStream->Decoder = CodecVideoNewDecoder(MyVideoStream->Render); + VideoPacketInit(MyVideoStream); + } } return 0; diff --git a/softhddevice-drm.cpp b/softhddevice-drm.cpp index 8c1db7f..94767af 100644 --- a/softhddevice-drm.cpp +++ b/softhddevice-drm.cpp @@ -94,6 +94,9 @@ void cSoftOsd::SetActive(bool on) cSoftOsd::cSoftOsd(int left, int top, uint level) :cOsd(left, top, level) { +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif #ifdef OSD_DEBUG /* FIXME: OsdWidth/OsdHeight not correct! */ @@ -111,6 +114,9 @@ cSoftOsd::cSoftOsd(int left, int top, uint level) */ cSoftOsd::~cSoftOsd(void) { +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif #ifdef OSD_DEBUG dsyslog("[softhddev] OSD %s: level %d\n", __FUNCTION__, OsdLevel); #endif @@ -363,6 +369,9 @@ void cSoftOsd::Flush(void) */ cOsd *cSoftOsdProvider::CreateOsd(int left, int top, uint level) { +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif #ifdef OSD_DEBUG dsyslog("[softhddev] OSD %s: %d, %d, %d\n", __FUNCTION__, left, top, level); #endif @@ -386,6 +395,9 @@ bool cSoftOsdProvider::ProvidesTrueColor(void) cSoftOsdProvider::cSoftOsdProvider(void) : cOsdProvider() { +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif #ifdef OSD_DEBUG dsyslog("[softhddev] OSD %s:\n", __FUNCTION__); #endif @@ -725,11 +737,16 @@ void cSoftHdDevice::MakePrimaryDevice(bool on) #ifdef DEBUG fprintf(stderr, "[softhddev]%s: %d\n", __FUNCTION__, on); #endif + if (!on) { + ::SoftHdDeviceExit(); + } else { + ::Start(); + } - cDevice::MakePrimaryDevice(on); - if (on) { - new cSoftOsdProvider(); - } + cDevice::MakePrimaryDevice(on); + if (on) { + new cSoftOsdProvider(); + } } @@ -1147,6 +1164,9 @@ bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[]) bool cPluginSoftHdDevice::Initialize(void) { //dsyslog("[softhddev]%s:\n", __FUNCTION__); +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif MyDevice = new cSoftHdDevice(); @@ -1158,19 +1178,22 @@ bool cPluginSoftHdDevice::Initialize(void) */ bool cPluginSoftHdDevice::Start(void) { - //dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif - if (!MyDevice->IsPrimaryDevice()) { - isyslog("[softhddev] softhddevice %d is not the primary device!", - MyDevice->DeviceNumber()); - if (ConfigMakePrimary) { - // Must be done in the main thread - dsyslog("[softhddev] makeing softhddevice %d the primary device!", - MyDevice->DeviceNumber()); - DoMakePrimary = MyDevice->DeviceNumber() + 1; + if (!MyDevice->IsPrimaryDevice()) { + isyslog("[softhddev] softhddevice %d is not the primary device!", + MyDevice->DeviceNumber()); + if (ConfigMakePrimary) { + // Must be done in the main thread + dsyslog("[softhddev] makeing softhddevice %d the primary device!", + MyDevice->DeviceNumber()); + DoMakePrimary = MyDevice->DeviceNumber() + 1; + } } - } - ::Start(); + ::Start(); return true; } @@ -1182,6 +1205,9 @@ bool cPluginSoftHdDevice::Start(void) void cPluginSoftHdDevice::Stop(void) { //dsyslog("[softhddev]%s:\n", __FUNCTION__); +#ifdef DEBUG + fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__); +#endif ::Stop(); } diff --git a/softhddevice-drm.h b/softhddevice-drm.h index dae3a33..c6e2e2b 100644 --- a/softhddevice-drm.h +++ b/softhddevice-drm.h @@ -166,6 +166,8 @@ class cSoftHdDevice:public cDevice cSoftHdDevice(void); virtual ~ cSoftHdDevice(void); + virtual cString DeviceName(void) const { return "softhddevice-drm"; } + virtual bool HasDecoder(void) const; virtual bool CanReplay(void) const; virtual bool SetPlayMode(ePlayMode); diff --git a/video_drm.c b/video_drm.c index 49c3d24..2394443 100644 --- a/video_drm.c +++ b/video_drm.c @@ -322,14 +322,13 @@ void ReadHWPlatform(VideoRender * render) size_t read_size; txt_buf = (char *) calloc(bufsize, sizeof(char)); - if (!txt_buf) - printf("ReadHWPlatform: No memory!\n"); - render->CodecMode = 0; read_size = ReadLineFromFile(txt_buf, bufsize, "/sys/firmware/devicetree/base/compatible"); - if (!read_size) + if (!read_size) { + free((void *)txt_buf); return; + } read_ptr = txt_buf; @@ -671,6 +670,11 @@ static int SetupFB(VideoRender * render, struct drm_buf *buf, } buf->plane[1] = buf->plane[0] + buf->offset[1]; buf->plane[2] = buf->plane[0] + buf->offset[2]; +#ifdef DRM_DEBUG + if (!render->buffers) + fprintf(stderr, "SetupFB: fb_id %d width %d height %d pix_fmt %4.4s\n", + buf->fb_id, buf->width, buf->height, (char *)&buf->pix_fmt); +#endif return 0; } @@ -1536,6 +1540,10 @@ void VideoRenderFrame(VideoRender * render, /// int64_t VideoGetClock(const VideoRender * render) { +#ifdef DEBUG + fprintf(stderr, "VideoGetClock: %s\n", + Timestamp2String(render->pts * 1000 * av_q2d(*render->timebase))); +#endif return render->pts; }