DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | List of all members
shaka::media::IoCache Class Reference

Declaration of class which implements a thread-safe circular buffer. More...

#include <io_cache.h>

Public Member Functions

 IoCache (uint64_t cache_size)
 
uint64_t Read (void *buffer, uint64_t size)
 
uint64_t Write (const void *buffer, uint64_t size)
 
void Clear ()
 Empties the cache.
 
void Close ()
 
bool closed ()
 
void Reopen ()
 Reopens the cache. Any data still in the cache will be lost.
 
uint64_t BytesCached ()
 
uint64_t BytesFree ()
 
void WaitUntilEmptyOrClosed ()
 Waits until the cache is empty or has been closed.
 

Detailed Description

Declaration of class which implements a thread-safe circular buffer.

Definition at line 20 of file io_cache.h.

Member Function Documentation

uint64_t shaka::media::IoCache::BytesCached ( )

Returns the number of bytes in the cache.

Returns
the number of bytes in the cache.

Definition at line 125 of file io_cache.cc.

uint64_t shaka::media::IoCache::BytesFree ( )

Returns the number of free bytes in the cache.

Returns
the number of free bytes in the cache.

Definition at line 130 of file io_cache.cc.

void shaka::media::IoCache::Close ( )

Close the cache. This will call any blocking calls to unblock, and the cache won't be usable until Reopened.

Definition at line 109 of file io_cache.cc.

bool shaka::media::IoCache::closed ( )
inline
Returns
true if the cache is closed, false otherwise.

Definition at line 50 of file io_cache.h.

uint64_t shaka::media::IoCache::Read ( void *  buffer,
uint64_t  size 
)

Read data from the cache. This function may block until there is data in the cache.

Parameters
bufferis a buffer into which to read the data from the cache.
sizeis the size of buffer.
Returns
the number of bytes read into buffer, or 0 if the call unblocked because the cache has been closed and is empty.

Definition at line 38 of file io_cache.cc.

uint64_t shaka::media::IoCache::Write ( const void *  buffer,
uint64_t  size 
)

Write data to the cache. This function may block until there is enough room in the cache.

Parameters
bufferis a buffer containing the data to be written to the cache.
sizeis the size of the data to be written to the cache.
Returns
the amount of data written to the buffer (which will equal data), or 0 if the call unblocked because the cache has been closed.

Definition at line 66 of file io_cache.cc.


The documentation for this class was generated from the following files: