http://github.com/ipkn/crow
Crow 프로젝트에서 사용한 C++11 기법들을 실제 구현에 대한 설명을 포함하여 자세히 설명한 발표자료입니다.
C++11 features used in Crow
video:
http://youtu.be/MixS9c3mE6U
https://vimeo.com/119627253
이 자료는 이영록강사님이 2011년 iOS 개발자 포럼에서 발표한 내용을 약간 개선하고 정리한 자료입니다.
iOS의 메모리관리 기법은 retain count라고 하는 독특하면서도 효율적인 방법을 사용하며 최근에 발표된 Xcode에서는 Automatic Reference Counting(ARC) 기법을 통해 release를 사용하에 객체를 소거하는 불편함을 많이 개선하였습니다.
본 자료에서는 이러한 점에 대한 비교적 상세한 설명을 담고 있습니다.
1. The document describes the initialization process of SurfaceFlingerService in Android.
2. SurfaceFlinger is instantiated which creates the main SurfaceFlinger instance. This triggers the initialization of various core Android services.
3. The main display is initialized by creating a DisplayHardware instance and a graphic plane for the display. Shared memory is allocated to share display information.
http://github.com/ipkn/crow
Crow 프로젝트에서 사용한 C++11 기법들을 실제 구현에 대한 설명을 포함하여 자세히 설명한 발표자료입니다.
C++11 features used in Crow
video:
http://youtu.be/MixS9c3mE6U
https://vimeo.com/119627253
이 자료는 이영록강사님이 2011년 iOS 개발자 포럼에서 발표한 내용을 약간 개선하고 정리한 자료입니다.
iOS의 메모리관리 기법은 retain count라고 하는 독특하면서도 효율적인 방법을 사용하며 최근에 발표된 Xcode에서는 Automatic Reference Counting(ARC) 기법을 통해 release를 사용하에 객체를 소거하는 불편함을 많이 개선하였습니다.
본 자료에서는 이러한 점에 대한 비교적 상세한 설명을 담고 있습니다.
1. The document describes the initialization process of SurfaceFlingerService in Android.
2. SurfaceFlinger is instantiated which creates the main SurfaceFlinger instance. This triggers the initialization of various core Android services.
3. The main display is initialized by creating a DisplayHardware instance and a graphic plane for the display. Shared memory is allocated to share display information.
The document discusses the Android audio system initialization process and the creation of playback and recording threads. The audio HAL library is loaded based on the device properties, and the AudioFlinger service initializes and manages the audio streams. It creates a MixerThread for playback using the audio HAL output, and a RecordThread is generated for audio input using the HAL functions.
Camera camcorder framework overview(ginger bread)fefe7270
1. The document discusses the camera and camcorder frameworks in Android (Gingerbread).
2. The camera framework uses a Binder client-server model with the Camera service as the server and Camera app as the client. The service communicates with the camera HAL through JNI.
3. The camcorder framework similarly uses a Binder model to connect the media recorder app with the media player service. The service records video via the Stagefright recorder and communicates with the camera through its client.
1. The document describes the overall structure and process of setting up and starting a camera recording using the StagefrightRecorder and CameraSource classes in Android.
2. It establishes connections between the CameraSource, CameraService, CameraRecordingProxy and Camera classes to initialize the camera and get camera frames.
3. Upon start, it begins recording by starting tracks in the MPEG4Writer, which signals the CameraSource to start the actual camera recording via the CameraRecordingProxy.
This document summarizes Android audio APIs and OpenSL ES, an open sound library for embedded systems like Android. It discusses APIs like MediaPlayer, SoundPool, AudioTrack/AudioRecord and their limitations. OpenSL ES provides low-level audio control and is device independent but Android's implementation supports only a subset of OpenSL features. It provides code examples for creating an OpenSL engine and implementing audio playback and recording in a loopback sample application using OpenSL objects like AudioPlayer and AudioRecorder across two threads.
1. The document discusses Android's AudioPolicyService which manages audio routing and device connections.
2. It describes the initialization process where AudioPolicyService is started and an AudioPolicyManager is created.
3. The AudioPolicyManager handles requests from AudioPolicyService like setting output devices and parameters which are passed to AudioFlinger for processing.
The document discusses the Android audio system architecture. It is comprised of an Audio Framework layer that includes AudioTrack, AudioRecord and AudioPolicy classes that handle routing audio between apps and the hardware. Below this is the Audio HAL interface that provides read/write functions to the underlying Linux audio driver and hardware. The Audio Flinger manages multiple threads to non-blocking read and write audio data to attached hardware devices. This layered design provides flexibility and handles the real-time audio needs across different Android devices and usage scenarios.
The document discusses Android's audio system and the AudioHardware class. It describes how AudioHardware initializes and manages audio devices, streams, and drivers. Key methods like setVoiceVolume and setVolume are analyzed in detail from the framework level down to the hardware abstraction layer. The initialization and roles of classes like AudioStreamOut and AudioStreamIn are also explained.
3. 1.그래픽 버퍼 공유 메모리 생성
서피스 플링거 서비스와 서비스 클라이언트간의 data 공유를 위해 그래픽 버퍼 공유 메모리 생성
Client SurfaceFlinger
생성 버퍼등록 Android
kernel
그래픽 버퍼 공유
메모리
Ex)CameraService에서 preview data를 surfaceflinger와 공유하기 위한 그래픽 버퍼 공유 메모리 생성
CameraService.cpp
status_t CameraService::Client::startPreviewMode()
{
result = mHardware->startPreview();
}
3
4. 1.그래픽 버퍼 공유 메모리 생성
QualcommCameraHardware.cpp
status_t QualcommCameraHardware::startPreview()
{
return startPreviewInternal();
}
status_t QualcommCameraHardware::startPreviewInternal()
{
mPreviewInitialized = initPreview();
}
bool QualcommCameraHardware::initPreview()
{
mPreviewHeap = new PmemPool(pmem_region, MemoryHeapBase::READ_ONLY |
MemoryHeapBase::NO_CACHING,
MSM_PMEM_PREVIEW,
mPreviewFrameSize,
kPreviewBufferCountActual,
mPreviewFrameSize,
CbCrOffset, 0, "preview");
QualcommCameraHardware::PmemPool::PmemPool(..)
{
sp<MemoryHeapBase> masterHeap =new MemoryHeapBase(pmem_pool, mAlignedSize,flags);
MemoryHeapBase class를 이용하여, "/dev/pmem_adsp“ 영역(pmem_pool)에 mAlignedSize 만큼의 공유 메모리 생성
(kernel virtual address)
4
5. 1.그래픽 버퍼 공유 메모리 생성
sp<MemoryHeapPmem> pmemHeap = new MemoryHeapPmem(masterHeap, flags);
생성된 공유 메모리의 영역을 physical 메모리의 연속된 영역으로 잡음
mHeap = pmemHeap;
register_buf(mBufferSize,
mFrameSize, mCbCrOffset, myOffset,
mHeap->getHeapID(),
mAlignedBufferSize * cnt,
(uint8_t *)mHeap->base() + mAlignedBufferSize * cnt,
pmem_type,
active);
생성된 공유 메모리를 camera drive에 등록.
completeInitialization(); 생성된 MemoryHeapBase 영역을 4개의 mBuffers로 나눔
CameraService Android
Virtual address
생성 Mapping된 address return
Kernel
mBuffers[0] Virtual address
mBuffers[3]
Physical memory 0x4000 write
Camera driver
0x1000
5
6. 2. 그래픽 버퍼 공유 메모리 등록 요청
생성된 그래픽 버퍼 공유 메모리를 SurfaceFlinger에게 등록 요청 한다.
status_t CameraService::Client::registerPreviewBuffers() {
ISurface::BufferHeap buffers(w, h, w, h,
mPixelFormat,
mOrientation,
0,
mHardware->getPreviewHeap());생성된 그래픽 버퍼 공유 메모리의 프락시
생성된 그래픽 버퍼 공유 메모리의 넓이,높이,format, 서비스 프락시를 가진 buffers class를 생성한다.
status_t result = mSurface->registerBuffers(buffers);
mSurface는 layerbuffer의 서피스 핸들인 SurfaceLayerBuffer를 가리킨다.
}
Layerbuffer.cpp
status_t LayerBuffer::SurfaceLayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers)
{
sp<LayerBuffer> owner(getOwner());
if (owner != 0)
return owner->registerBuffers(buffers);
return NO_INIT;
}
status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers)
{
sp<BufferSource> source = new BufferSource(*this, buffers);
mSource = source;
}
6
7. 2. 그래픽 버퍼 공유 메모리 등록 요청
LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,const ISurface::BufferHeap& buffers)
{
mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride;
mBufferHeap = buffers;
buffers에는 공유 메모리에 접근할 수 있는 프락시가 저장 되어 있다,
즉, Buffersource의 mBufferHeap 변수가 공유 메모리를 가리키게 된다.
}
void LayerBuffer::onDraw(const Region& clip) const
{
sp<Source> source(getSource());
Layerbuffer if (LIKELY(source != 0)) {
source->onDraw(clip);
onDraw() } else {
clearWithOpenGL(clip);
Source }
}
onDraw()
void LayerBuffer::Source::onDraw(const Region& clip) const {
}
void LayerBuffer::BufferSource::onDraw(const Region& clip)
const
{
BufferSource OverlaySource
mLayer.drawWithOpenGL(tempClip, mTexture);
onDraw() onDraw() }
void LayerBuffer::OverlaySource::onDraw(const Region& clip)
const
{
mLayer.clearWithOpenGL(clip, 0, 0, 0, 0);
layer를 검은색으로 덮음
}
7
8. 2. 그래픽 버퍼 공유 메모리 등록 요청
SurfaceFlinger
CameraService
Layerbuffer
BufferHeap 등록
mSource BufferSource
mBufferHeap
Android
Virtual address
Kernel
Virtual address mBuffers[0]
mBuffers[3]
Physical memory 0x4000 write
Camera driver
0x1000
8
9. 2. 그래픽 버퍼 공유 메모리 등록 요청-Overlay 경우
Camera process
SurfaceFlinger
mSurface->createOverlay
1.CameraService 에서 setOverlay()호출 Layerbuffer
mSource
3. Overlay 변수 저장
4. Preview thread에서 OverlaySource
mOverlay->setFd(mPreviewHeap->mHeap- Overlay
>getHeapID());
5. mOverlay->queueBuffer
((void *)offset_addr);
2.Overlay device open
Overlay device
queueBuffer
mBuffers[0]
mBuffers[3] 4번 이후
Overlay는
그래픽 버퍼 공유 메모리를 가리킴
9