LCOV - code coverage report
Current view: directory - src/trusted/sel_universal - primitives.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 2 0 0.0 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #ifndef NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERASAL_PRIMITIVES_H_
       8                 : #define NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERASAL_PRIMITIVES_H_
       9                 : 
      10                 : #include <string>
      11                 : enum EVENT_TYPE {
      12                 :   EVENT_TYPE_INVALID,
      13                 :   EVENT_TYPE_OPEN_CALLBACK,
      14                 :   EVENT_TYPE_TERMINATION,
      15                 :   EVENT_TYPE_FLUSH_CALLBACK,
      16                 :   EVENT_TYPE_INIT_AUDIO,
      17                 :   EVENT_TYPE_TIMER_CALLBACK,
      18                 :   EVENT_TYPE_READ_CALLBACK,
      19                 :   EVENT_TYPE_INPUT
      20                 : };
      21                 : 
      22                 : // NOTE: the first element has to be the type field so we can
      23                 : //       distinguish it from other event structs given that they
      24                 : //       also start with a such a field.
      25                 : struct UserEvent {
      26                 :   EVENT_TYPE type;
      27                 :   int callback;   // this is often the callback handle on the nexe side
      28                 :   int result;     // this is often the result for the callback
      29                 :   void* pointer;  // this is often a marshalled pp_var
      30                 :   int size;       // size of the marshalled pp_var
      31                 : };
      32                 : 
      33                 : // User Event Helpers
      34                 : bool IsInputEvent(const UserEvent* event);
      35                 : bool IsInvalidEvent(const UserEvent* event);
      36                 : bool IsTerminationEvent(const UserEvent* event);
      37                 : 
      38                 : UserEvent* MakeUserEvent(EVENT_TYPE type,
      39                 :                          int callback,
      40                 :                          int result,
      41                 :                          void* pointer,
      42                 :                          int size);
      43                 : UserEvent* MakeInvalidEvent();
      44                 : UserEvent* MakeTerminationEvent();
      45                 : // for debugging
      46                 : std::string StringifyEvent(const UserEvent* event);
      47                 : std::string StringifyEventType(const UserEvent* event);
      48                 : 
      49                 : typedef void (*AUDIO_CALLBACK)(void* data, unsigned char* buffer, int length);
      50                 : 
      51               0 : class IMultimedia {
      52                 :  public:
      53               0 :   virtual ~IMultimedia() {}
      54                 : 
      55                 :   virtual int VideoBufferSize() = 0;
      56                 :   virtual int VideoWidth() = 0;
      57                 :   virtual int VideoHeight() = 0;
      58                 :   // Trigger a frame update in the multimedia system
      59                 :   virtual void VideoUpdate(const void* data) = 0;
      60                 :   // Inject a userevent into the event buffer.
      61                 :   // NOTE: the event will be copied
      62                 :   virtual void PushUserEvent(UserEvent* event) = 0;
      63                 : 
      64                 :   // schedule a event for future delivery
      65                 :   virtual void PushDelayedUserEvent(int delay, UserEvent* event) = 0;
      66                 :   // Get next event (non-blocking). If no event was available
      67                 :   // IsInvalidEvent(event) will be true afterwards.
      68                 :   virtual UserEvent* EventPoll() = 0;
      69                 :   // Get next event (blocking).
      70                 :   virtual UserEvent* EventGet() = 0;
      71                 :   // Get next event (blocking).
      72                 :   virtual void AudioInit16Bit(int frequency,
      73                 :                               int channels,
      74                 :                               int frame_count,
      75                 :                               AUDIO_CALLBACK cb,
      76                 :                               void* cb_data) = 0;
      77                 :   virtual void AudioStart() = 0;
      78                 :   virtual void AudioStop() = 0;
      79                 : };
      80                 : 
      81                 : /* Currently, there is only an SDL implementation */
      82                 : IMultimedia* MakeEmuPrimitives(int width, int heigth, const char* title);
      83                 : 
      84                 : #endif  /* NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERASAL_PRIMITIVES_H_ */

Generated by: LCOV version 1.7