• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "rsFifoSocket.h"
18 #include "utils/Timers.h"
19 #include "utils/StopWatch.h"
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <ctype.h>
24 #include <unistd.h>
25 #include <sys/types.h>
26 #include <sys/socket.h>
27 
28 using namespace android;
29 using namespace android::renderscript;
30 
FifoSocket()31 FifoSocket::FifoSocket() {
32     sequence = 1;
33 }
34 
~FifoSocket()35 FifoSocket::~FifoSocket() {
36 
37 }
38 
init()39 bool FifoSocket::init() {
40     int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
41     return false;
42 }
43 
shutdown()44 void FifoSocket::shutdown() {
45 }
46 
writeAsync(const void * data,size_t bytes)47 void FifoSocket::writeAsync(const void *data, size_t bytes) {
48     if (bytes == 0) {
49         return;
50     }
51     //LOGE("writeAsync %p %i", data, bytes);
52     size_t ret = ::send(sv[0], data, bytes, 0);
53     //LOGE("writeAsync ret %i", ret);
54     rsAssert(ret == bytes);
55 }
56 
writeWaitReturn(void * retData,size_t retBytes)57 void FifoSocket::writeWaitReturn(void *retData, size_t retBytes) {
58     //LOGE("writeWaitReturn %p %i", retData, retBytes);
59     size_t ret = ::recv(sv[0], retData, retBytes, 0);
60     //LOGE("writeWaitReturn %i", ret);
61     rsAssert(ret == retBytes);
62 }
63 
read(void * data,size_t bytes)64 size_t FifoSocket::read(void *data, size_t bytes) {
65     //LOGE("read %p %i", data, bytes);
66     size_t ret = ::recv(sv[1], data, bytes, 0);
67     rsAssert(ret == bytes);
68     //LOGE("read ret %i", ret);
69     return ret;
70 }
71 
readReturn(const void * data,size_t bytes)72 void FifoSocket::readReturn(const void *data, size_t bytes) {
73     LOGE("readReturn %p %Zu", data, bytes);
74     size_t ret = ::send(sv[1], data, bytes, 0);
75     LOGE("readReturn %Zu", ret);
76     rsAssert(ret == bytes);
77 }
78 
79 
flush()80 void FifoSocket::flush() {
81 }
82 
83 
84