fix seek problems using dynamic art on mac platform

This commit is contained in:
Ron Pedde 2004-04-17 22:20:02 +00:00
parent b3e3f349c7
commit 44d29752c7
2 changed files with 11 additions and 9 deletions

View File

@ -78,7 +78,7 @@ int da_get_image_fd(char *filename) {
strcpy(path_end+1,config.artfilename);
fd = open(buffer,O_RDONLY);
if(fd != -1)
DPRINTF(ERR_INFO,"Found image file %s\n",buffer);
DPRINTF(ERR_INFO,"Found image file %s (fd %d)\n",buffer,fd);
return fd;
}
@ -126,14 +126,15 @@ int da_attach_image(int img_fd, int out_fd, int mp3_fd, int offset)
unsigned char buffer[4];
struct stat sb;
if(fstat(img_fd,&sb)) {
DPRINTF(ERR_INFO,"Cannot stat image file... %s\n",strerror(errno));
fstat(img_fd,&sb);
img_size=sb.st_size;
DPRINTF(ERR_INFO,"Image appears to be %ld bytes\n",img_size);
if(img_size < 1) {
r_close(img_fd);
return 0;
}
img_size=sb.st_size;
DPRINTF(ERR_INFO,"Image appears to be %ld bytes\n",img_size);
if (offset > (img_size + 24) ) {
lseek(mp3_fd,(offset - img_size - 24),SEEK_SET);
r_close(img_fd);

View File

@ -279,13 +279,14 @@ void daap_handler(WS_CONNINFO *pwsc) {
ws_emitheaders(pwsc);
config_set_status(pwsc,session_id,"Streaming file '%s'",pmp3->fname);
DPRINTF(ERR_LOG,"Session %d: Streaming file '%s' to %s\n",session_id,
pmp3->fname, pwsc->hostname);
DPRINTF(ERR_LOG,"Session %d: Streaming file '%s' to %s (offset %d)\n",
session_id,pmp3->fname, pwsc->hostname,offset);
if(!offset)
config.stats.songs_served++; /* FIXME: remove stat races */
if((config.artfilename) && (img_fd=da_get_image_fd(pmp3->path) != -1)) {
if((config.artfilename) && ((img_fd=da_get_image_fd(pmp3->path)) != -1) &&
(!offset)) {
DPRINTF(ERR_INFO,"Dynamically attaching artwork to %s (fd %d)\n",
pmp3->fname, img_fd);
da_attach_image(img_fd, pwsc->fd, file_fd, offset);