Permalink
Browse files

Don't require extern usage of frame buffering value

This makes things a bit cleaner and easier to grasp.
1 parent 82e7cf8 commit 565b223bb09f2c4669b45098695c7e2a9b7249fc @toofishes toofishes committed Feb 24, 2012
Showing with 16 additions and 10 deletions.
  1. +7 −3 hairtunes.c
  2. +3 −2 hairtunes.h
  3. +6 −5 shairport.c
View
@@ -163,7 +163,8 @@ int init_decoder(void) {
}
int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, int pTimingPort,
- int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId)
+ int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId,
+ int bufStartFill)
{
if(pAeskey != NULL)
memcpy(aeskey, pAeskey, sizeof(aeskey));
@@ -183,6 +184,9 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, in
controlport = pCtrlPort;
timingport = pTimingPort;
dataport = pDataPort;
+ if(bufStartFill < 0)
+ bufStartFill = START_FILL;
+ buffer_start_fill = bufStartFill;
AES_set_decrypt_key(aeskey, 128, &aes);
@@ -309,7 +313,7 @@ int main(int argc, char **argv) {
if (hex2bin(aeskey, hexaeskey))
die("can't understand key");
return hairtunes_init(NULL, NULL, fmtpstr, controlport, timingport, dataport,
- NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, START_FILL);
}
#endif
@@ -654,7 +658,7 @@ short *buffer_get_frame(void) {
}
if (buf_fill >= BUFFER_FRAMES) { // overrunning! uh-oh. restart at a sane distance
fprintf(stderr, "\noverrun.\n");
- ab_read = ab_write - START_FILL;
+ ab_read = ab_write - buffer_start_fill;
}
read = ab_read;
ab_read++;
View
@@ -1,7 +1,8 @@
#ifndef _HAIRTUNES_H_
#define _HAIRTUNES_H_
-int hairtunes_init(char *pAeskey, char *pAesiv, char *pFmtpstr, int pCtrlPort, int pTimingPort,
- int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId);
+int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, int pTimingPort,
+ int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId,
+ int bufStartFill);
// default buffer size
// needs to be a power of 2 because of the way BUFIDX(seqno) works
View
@@ -40,7 +40,7 @@
// TEMP
int kCurrentLogLevel = LOG_INFO;
-extern int buffer_start_fill;
+int bufferStartFill = -1;
#ifdef _WIN32
#define DEVNULL "nul"
@@ -113,12 +113,12 @@ int main(int argc, char **argv)
}
else if(!strcmp(arg, "-b"))
{
- buffer_start_fill = atoi(*++argv);
+ bufferStartFill = atoi(*++argv);
argc--;
}
else if(!strncmp(arg, "--buffer=", 9))
{
- buffer_start_fill = atoi(arg + 9);
+ bufferStartFill = atoi(arg + 9);
}
else if(!strcmp(arg, "-k"))
{
@@ -161,7 +161,7 @@ int main(int argc, char **argv)
}
}
- if ( buffer_start_fill < 30 || buffer_start_fill > BUFFER_FRAMES ) {
+ if ( bufferStartFill < 30 || bufferStartFill > BUFFER_FRAMES ) {
fprintf(stderr, "buffer value must be > 30 and < %d\n", BUFFER_FRAMES);
return(0);
}
@@ -774,7 +774,8 @@ int parseMessage(struct connection *pConn, unsigned char *pIpBin, unsigned int p
}
cleanupBuffers(pConn);
hairtunes_init(tKeys->aeskey, tKeys->aesiv, tKeys->fmt, tControlport, tTimingport,
- tDataport, tRtp, tPipe, tAoDriver, tAoDeviceName, tAoDeviceId);
+ tDataport, tRtp, tPipe, tAoDriver, tAoDeviceName, tAoDeviceId,
+ bufferStartFill);
// Quit when finished.
slog(LOG_DEBUG, "Returned from hairtunes init....returning -1, should close out this whole side of the fork\n");

0 comments on commit 565b223

Please sign in to comment.