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

player.c File Reference


Detailed Description

Player.

 *
 * $Log$
 *
 * 

Definition in file player.c.

#include <cfg/os.h>
#include <cfg/clock.h>
#include <dev/board.h>
#include <sys/timer.h>
#include <sys/event.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "tlv320dac.h"
#include "receiver.h"
#include "mp3player.h"

Include dependency graph for player.c:

Go to the source code of this file.

Functions

PLAYERINFOPlayerCreate (PLAYERPLUGIN *plugin)
 Create a player instance.
static int PlayerPlugInControl (PLAYERINFO *pip, u_int sst, u_int xst)
 Set player to a specified state.
u_int PlayerStatus (PLAYERINFO *pip)
 Retrieve the current player status.
int PlayerStop (PLAYERINFO *pip)
 Stop player.
int PlayerStart (PLAYERINFO *pip, RECEIVERINFO *rip)
 Start playing a specified receiver.


Function Documentation

PLAYERINFO* PlayerCreate PLAYERPLUGIN plugin  ) 
 

Create a player instance.

Parameters:
plugin Pointer to a player plug-in.
Returns:
On success, the pointer to a PLAYERINFO structure is returned. A NULL pointer indicates an error.

Definition at line 66 of file player.c.

00068 {
00069     PLAYERINFO *pip;
00070 
00071     /* Allocate and initialize the player info structure. */
00072     if ((pip = malloc(sizeof(PLAYERINFO))) != NULL) {
00073         memset(pip, 0, sizeof(PLAYERINFO));
00074         /* Associate a new player plug-in instance. */
00075         if ((*plugin->pp_create) (pip)) {
00076             free(pip);
00077             pip = NULL;
00078         }
00079     }
00080     return pip;

static int PlayerPlugInControl PLAYERINFO pip,
u_int  sst,
u_int  xst
[static]
 

Set player to a specified state.

Parameters:
pip Pointer to a player info structure, obtained by a previous call to PlayerCreate().
sst Status to set, typically PSTAT_START or PSTAT_STOP.
xst Status to wait for, like PSTAT_IDLE or PSTAT_RUNNING.
Returns:
0 on success, -1 otherwise.

Definition at line 92 of file player.c.

00094 {
00095     int retries = 10;
00096 
00097     /* Loop until we got the status or give up on too many retires. */
00098     while (pip->pi_status != xst) {
00099         pip->pi_status = sst;
00100         NutEventPost(&pip->pi_cmdevt);
00101         if (NutEventWait(&pip->pi_stsevt, 500)) {
00102             if (retries-- <= 0) {
00103                 printf("No player control\n");
00104                 return -1;
00105             }
00106         }
00107     }
00108     return 0;

u_int PlayerStatus PLAYERINFO pip  ) 
 

Retrieve the current player status.

Parameters:
pip Pointer to a player info structure, obtained by a previous call to PlayerCreate().
Returns:
Player status.

Definition at line 118 of file player.c.

00120 {
00121     return pip->pi_status;

int PlayerStop PLAYERINFO pip  ) 
 

Stop player.

Parameters:
pip Player to stop. Pointer to a player info structure, obtained by a previous call to PlayerCreate().
Returns:
0 on success, -1 otherwise.

Definition at line 131 of file player.c.

Referenced by CgiControl().

00133 {
00134     printf("[PSTOP]");
00135     return PlayerPlugInControl(pip, PSTAT_STOP, PSTAT_IDLE);

int PlayerStart PLAYERINFO pip,
RECEIVERINFO rip
 

Start playing a specified receiver.

Parameters:
pip Player to start. Pointer to a player info structure, obtained by a previous call to PlayerCreate().
rip Receiver to play.
Returns:
0 on success, -1 otherwise.

Definition at line 146 of file player.c.

00148 {
00149     if (PlayerStop(pip)) {
00150         return -1;
00151     }
00152     printf("[PSTART]");
00153     pip->pi_rcvr = rip;
00154 
00155     return PlayerPlugInControl(pip, PSTAT_START, PSTAT_RUNNING);


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