From be009a3d9897e5f3a66f3eeeb6762552a1f858a8 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 7 Sep 2012 15:05:53 -0700 Subject: Make wfd code work with both old and new dongles. Change-Id: Idc750dc334c47a171791587dd7e7281d565ff566 --- .../wifi-display/ANetworkSession.cpp | 8 +++-- .../wifi-display/source/PlaybackSession.cpp | 42 +++++++++++----------- 2 files changed, 26 insertions(+), 24 deletions(-) (limited to 'media') diff --git a/media/libstagefright/wifi-display/ANetworkSession.cpp b/media/libstagefright/wifi-display/ANetworkSession.cpp index 4ddd778..1c4f535 100644 --- a/media/libstagefright/wifi-display/ANetworkSession.cpp +++ b/media/libstagefright/wifi-display/ANetworkSession.cpp @@ -331,11 +331,15 @@ status_t ANetworkSession::Session::readMore() { notify->post(); #if 1 - // XXX The dongle sends the wrong content length header on a + // XXX The (old) dongle sends the wrong content length header on a // SET_PARAMETER request that signals a "wfd_idr_request". // (17 instead of 19). const char *content = msg->getContent(); - if (content && !memcmp(content, "wfd_idr_request\r\n", 17)) { + if (content + && !memcmp(content, "wfd_idr_request\r\n", 17) + && length >= 19 + && mInBuffer.c_str()[length] == '\r' + && mInBuffer.c_str()[length + 1] == '\n') { length += 2; } #endif diff --git a/media/libstagefright/wifi-display/source/PlaybackSession.cpp b/media/libstagefright/wifi-display/source/PlaybackSession.cpp index 6c01c7b..5665093 100644 --- a/media/libstagefright/wifi-display/source/PlaybackSession.cpp +++ b/media/libstagefright/wifi-display/source/PlaybackSession.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include @@ -598,10 +597,6 @@ status_t WifiDisplaySource::PlaybackSession::setupPacketizer() { mCodecLooper = new ALooper; mCodecLooper->start(); - DisplayInfo info; - SurfaceComposerClient::getDisplayInfo(0, &info); - - // sp source = new SurfaceMediaSource(info.w, info.h); sp source = new SurfaceMediaSource(width(), height()); #if 0 @@ -642,7 +637,8 @@ status_t WifiDisplaySource::PlaybackSession::setupPacketizer() { CHECK(service != NULL); // Add one reference to account for the serializer. - err = source->setMaxAcquiredBufferCount(numInputBuffers + 1); + // Add another one for unknown reasons. + err = source->setMaxAcquiredBufferCount(numInputBuffers + 2); CHECK_EQ(err, (status_t)OK); mBufferQueue = source->getBufferQueue(); @@ -650,7 +646,6 @@ status_t WifiDisplaySource::PlaybackSession::setupPacketizer() { if (mLegacyMode) { service->connectDisplay(mBufferQueue); } -#endif #if 0 sp audioSource = new AudioSource( @@ -658,24 +653,27 @@ status_t WifiDisplaySource::PlaybackSession::setupPacketizer() { 48000 /* sampleRate */, 2 /* channelCount */); // XXX AUDIO_CHANNEL_IN_STEREO? - CHECK_EQ((status_t)OK, audioSource->initCheck()); - - audioSource->setUseLooperTime(true); + if (audioSource->initCheck() == OK) { + audioSource->setUseLooperTime(true); - index = mSerializer->addSource(audioSource); - CHECK_GE(index, 0); + index = mSerializer->addSource(audioSource); + CHECK_GE(index, 0); - sp audioFormat; - err = convertMetaDataToMessage(audioSource->getFormat(), &audioFormat); - CHECK_EQ(err, (status_t)OK); + sp audioFormat; + err = convertMetaDataToMessage(audioSource->getFormat(), &audioFormat); + CHECK_EQ(err, (status_t)OK); - sp audioNotify = new AMessage(kWhatConverterNotify, id()); - audioNotify->setSize("trackIndex", index); + sp audioNotify = new AMessage(kWhatConverterNotify, id()); + audioNotify->setSize("trackIndex", index); - converter = new Converter(audioNotify, mCodecLooper, audioFormat); - looper()->registerHandler(converter); + converter = new Converter(audioNotify, mCodecLooper, audioFormat); + looper()->registerHandler(converter); - mTracks.add(index, new Track(converter)); + mTracks.add(index, new Track(converter)); + } else { + ALOGW("Unable to instantiate audio source"); + } +#endif #endif return OK; @@ -686,11 +684,11 @@ sp WifiDisplaySource::PlaybackSession::getSurfaceTexture() { } int32_t WifiDisplaySource::PlaybackSession::width() const { - return 720; + return mLegacyMode ? 720 : 1280; } int32_t WifiDisplaySource::PlaybackSession::height() const { - return 1280; + return mLegacyMode ? 1280 : 720; } void WifiDisplaySource::PlaybackSession::scheduleSendSR() { -- cgit v1.1