2012-08-14 103 views
0

你好傢伙另一個C++編程問題。當我剛開始學習C++時,再次輕鬆一點。我得到在編譯時,顯示一個錯誤:針對android編譯的問題...'在此範圍內沒有聲明'錯誤

frameworks/native/libs/gui/SurfaceTextureClient.cpp: In member function 'virtual int >android::SurfaceTextureClient::setUsage(uint32_t)': frameworks/native/libs/gui/SurfaceTextureClient.cpp:498:20: error: >'GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY' was not declared in this scope frameworks/native/libs/gui/SurfaceTextureClient.cpp:503:23: error: >'GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK' was not declared in this scope frameworks/native/libs/gui/SurfaceTextureClient.cpp:505:30: error: >'GRALLOC_USAGE_PRIVATE_EXTERNAL_CC' was not declared in this scope

這裏是「SurfaceTextureClient.cpp」文件:

17 #define LOG_TAG "SurfaceTextureClient" 
18 #define ATRACE_TAG ATRACE_TAG_GRAPHICS 
19 //#define LOG_NDEBUG 0 
20 
21 #include <android/native_window.h> 
22 
23 #include <utils/Log.h> 
24 #include <utils/Trace.h> 
25 
26 #include <gui/ISurfaceComposer.h> 
27 #include <gui/SurfaceComposerClient.h> 
28 #include <gui/SurfaceTexture.h> 
29 #include <gui/SurfaceTextureClient.h> 
30 
31 #include <private/gui/ComposerService.h> 
32 #ifdef QCOMHW 
33 #include <gralloc_priv.h> 
34 #endif 
35 
36 namespace android { 
37 
38 SurfaceTextureClient::SurfaceTextureClient(
39   const sp<ISurfaceTexture>& surfaceTexture) 
40 { 
41  SurfaceTextureClient::init(); 
42  SurfaceTextureClient::setISurfaceTexture(surfaceTexture); 
43 } 
44 
45 // see SurfaceTextureClient.h 
46 SurfaceTextureClient::SurfaceTextureClient(const 
47   sp<SurfaceTexture>& surfaceTexture) 
48 { 
49  SurfaceTextureClient::init(); 
50  SurfaceTextureClient::setISurfaceTexture(surfaceTexture->getBufferQueue()); 
51 } 
52 
53 SurfaceTextureClient::SurfaceTextureClient() { 
54  SurfaceTextureClient::init(); 
55 } 
56 
57 SurfaceTextureClient::~SurfaceTextureClient() { 
58  if (mConnectedToCpu) { 
59   SurfaceTextureClient::disconnect(NATIVE_WINDOW_API_CPU); 
60 
61 } 

494 int SurfaceTextureClient::setUsage(uint32_t reqUsage) 
493 { 
494  ALOGV("SurfaceTextureClient::setUsage"); 
495  Mutex::Autolock lock(mMutex); 
496 
497 #ifdef QCOMHW 
498  if (reqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) { 
499   //Set explicitly, since reqUsage may have other values. 
500   mReqExtUsage = GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY; 
501   //This flag is never independent. Always an add-on to 
502   //GRALLOC_USAGE_EXTERNAL_ONLY 
503   if(reqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) { 
504    mReqExtUsage |= GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK; 
505   } else if(reqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) { 
506    mReqExtUsage |= GRALLOC_USAGE_PRIVATE_EXTERNAL_CC; 
507   } 
508  } 
509 #endif 

如果需要更多的信息讓我知道。修復了此編譯的以前的錯誤。不知道在這裏用這個做什麼。

+0

「GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY」聲明在哪裏? – 2012-08-14 05:28:42

+0

這裏是鏈接到以前的職位與gralloc ...頭文件: – dru 2012-08-14 05:34:39

+0

http://stackoverflow.com/questions/11923550/error-compiling-with-gralloc-priv-h-file – dru 2012-08-14 05:35:29

回答

0

那麼我發現問題的解決方案,我認爲哈哈。源文件夾中的另一個gralloc_priv.h文件位於不同的目錄下,並且複製到該頭文件的聲明中,以供無範圍的成員使用,並且很好。如果有人遇到這個問題,請告訴我,我會告訴你我在哪裏找到這些文件。

+0

如果你發現自己的問題的答案,編輯問題並添加你的答案。 – RiggsFolly 2014-04-27 15:06:18

+2

@RiggsFolly其實,這就是這個網站上不需要的東西。但我們希望得到完整的答案,而不是「我想我解決了它,問你是否想要細節」。 – stefan 2014-04-27 15:18:23

+0

@stefan道歉,檢查了禮節。我認爲這是一個不可以,你應該添加自己的答案作爲你的問題的一部分。我不會再犯這個錯誤。謝謝。 – RiggsFolly 2014-04-27 15:27:11

相關問題