Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

receiver.c File Reference


Detailed Description

Receiver.

 *
 * $Log$
 *
 * 

Definition in file receiver.c.

#include <cfg/os.h>
#include <cfg/clock.h>
#include <dev/board.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <sys/version.h>
#include <sys/confnet.h>
#include <sys/atom.h>
#include <sys/heap.h>
#include <sys/thread.h>
#include <sys/timer.h>
#include <sys/event.h>
#include <sys/socket.h>
#include <hxmp3/mp3dec.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <net/route.h>
#include <pro/dhcp.h>
#include "tlv320dac.h"
#include "config.h"
#include "receiver.h"
#include "shoutcast.h"

Include dependency graph for receiver.c:

Go to the source code of this file.

Functions

RECEIVERINFOReceiverCreate (RECEIVERPLUGIN *plugin)
 Create stream receiver instance with the specified plug-in.
static int ReceiverPlugInControl (RECEIVERINFO *rip, u_int sst, u_int xst)
 Change receiver plug-in status.
u_int ReceiverStatus (RECEIVERINFO *rip)
 Retrieve the current receiver status.
int ReceiverStop (RECEIVERINFO *rip)
 Stop receiver.
int ReceiverStart (RECEIVERINFO *rip, STATIONINFO *sip)
 Start receiving a specified station.


Function Documentation

RECEIVERINFO* ReceiverCreate RECEIVERPLUGIN plugin  ) 
 

Create stream receiver instance with the specified plug-in.

Parameters:
plugin Pointer to a receiver plug-in.
Returns:
Pointer to the receiver info structure or NULL, if the creation failed.

Definition at line 82 of file receiver.c.

00084 {
00085     RECEIVERINFO *rip;
00086 
00087     /* Allocate and initialize the receiver info structure. */
00088     if ((rip = malloc(sizeof(RECEIVERINFO))) != NULL) {
00089         memset(rip, 0, sizeof(RECEIVERINFO));
00090         rip->ri_rpp = plugin;
00091         /* Associate a new player plug-in instance. */
00092         if ((*plugin->rp_create) (rip)) {
00093             free(rip);
00094             rip = NULL;
00095         }
00096     }
00097     return rip;

static int ReceiverPlugInControl RECEIVERINFO rip,
u_int  sst,
u_int  xst
[static]
 

Change receiver plug-in status.

Parameters:
rip Points to the receiver information structure.
sst Command status to set, either RSTAT_STOP or RSTAT_START.
xst Expected final status, RSTAT_IDLE or RSTAT_RUNNING.
Returns:
0 on success, -1 otherwise.

Definition at line 108 of file receiver.c.

00110 {
00111     int retries = 40;
00112 
00113     while (rip->ri_status != xst) {
00114         rip->ri_status = sst;
00115         NutEventPost(&rip->ri_cmdevt);
00116         if (retries-- <= 0) {
00117             printf("No receiver control\n");
00118             return -1;
00119         }
00120         NutEventWait(&rip->ri_stsevt, 500);
00121     }
00122     return 0;

u_int ReceiverStatus RECEIVERINFO rip  ) 
 

Retrieve the current receiver status.

Parameters:
rip Pointer to the receiver information structure.
Returns:
Receiver status.

Definition at line 131 of file receiver.c.

00133 {
00134     return rip->ri_status;

int ReceiverStop RECEIVERINFO rip  ) 
 

Stop receiver.

Parameters:
rip Receiver to stop.
Returns:
0 on success, -1 otherwise.

Definition at line 143 of file receiver.c.

Referenced by CgiControl().

00145 {
00146     printf("[RSTOP]");
00147     return ReceiverPlugInControl(rip, RSTAT_STOP, RSTAT_IDLE);

int ReceiverStart RECEIVERINFO rip,
STATIONINFO sip
 

Start receiving a specified station.

Parameters:
rip Receiver to start.
sip Station to receive.
Returns:
0 on success, -1 otherwise.

Definition at line 157 of file receiver.c.

00159 {
00160     /* Make sure that the receiver is not running. */
00161     if (ReceiverStop(rip)) {
00162         return -1;
00163     }
00164     printf("[RSTART]");
00165     rip->ri_sip = sip;
00166     rip->ri_wpos = 0;
00167     rip->ri_rpos = 0;
00168     rip->ri_avail = 0;
00169 
00170     if ((*rip->ri_rpp->rp_setup)(rip)) {
00171         return -1;
00172     }
00173     return ReceiverPlugInControl(rip, RSTAT_START, RSTAT_RUNNING);


Generated on Fri Feb 23 17:28:56 2007 for SAM Internet Radio by  doxygen 1.4.4