changeset 31445:872a1ef8b43b

cosmetics: Reorder functions to avoid forward declarations.
author diego
date Mon, 21 Jun 2010 10:40:30 +0000
parents d8fcf2a01af2
children a9475c68aa47
files stream/stream_cdda.c
diffstat 1 files changed, 106 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_cdda.c	Mon Jun 21 10:33:00 2010 +0000
+++ b/stream/stream_cdda.c	Mon Jun 21 10:40:30 2010 +0000
@@ -124,9 +124,112 @@
   {NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
-static int seek(stream_t* s,off_t pos);
-static int fill_buffer(stream_t* s, char* buffer, int max_len);
-static void close_cdda(stream_t* s);
+#ifndef CONFIG_LIBCDIO
+static void cdparanoia_callback(long inpos, int function) {
+#else
+static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) {
+#endif
+}
+
+static int fill_buffer(stream_t* s, char* buffer, int max_len) {
+  cdda_priv* p = (cdda_priv*)s->priv;
+  cd_track_t *cd_track;
+  int16_t * buf;
+  int i;
+
+  if((p->sector < p->start_sector) || (p->sector > p->end_sector)) {
+    s->eof = 1;
+    return 0;
+  }
+
+  buf = paranoia_read(p->cdp,cdparanoia_callback);
+  if (!buf)
+    return 0;
+
+#if HAVE_BIGENDIAN
+  for(i=0;i<CD_FRAMESIZE_RAW/2;i++)
+          buf[i]=le2me_16(buf[i]);
+#endif
+
+  p->sector++;
+  memcpy(buffer,buf,CD_FRAMESIZE_RAW);
+
+  for(i=0;i<p->cd->tracks;i++){
+	  if(p->cd->disc_toc[i].dwStartSector==p->sector-1) {
+		  cd_track = cd_info_get_track(p->cd_info, i+1);
+//printf("Track %d, sector=%d\n", i, p->sector-1);
+		  if( cd_track!=NULL ) {
+			mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
+			mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb);
+		  }
+		  break;
+	  }
+  }
+
+
+  return CD_FRAMESIZE_RAW;
+}
+
+static int seek(stream_t* s,off_t newpos) {
+  cdda_priv* p = (cdda_priv*)s->priv;
+  cd_track_t *cd_track;
+  int sec;
+  int current_track=0, seeked_track=0;
+  int seek_to_track = 0;
+  int i;
+
+  s->pos = newpos;
+  sec = s->pos/CD_FRAMESIZE_RAW;
+  if (s->pos < 0 || sec > p->end_sector) {
+    s->eof = 1;
+    return 0;
+  }
+
+//printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW);
+//printf("sector: %d  new: %d\n", p->sector, sec );
+
+  for(i=0;i<p->cd->tracks;i++){
+//        printf("trk #%d: %d .. %d\n",i,p->cd->disc_toc[i].dwStartSector,p->cd->disc_toc[i+1].dwStartSector);
+	if( p->sector>=p->cd->disc_toc[i].dwStartSector && p->sector<p->cd->disc_toc[i+1].dwStartSector ) {
+		current_track = i;
+	}
+	if( sec>=p->cd->disc_toc[i].dwStartSector && sec<p->cd->disc_toc[i+1].dwStartSector ) {
+		seeked_track = i;
+		seek_to_track = sec == p->cd->disc_toc[i].dwStartSector;
+	}
+  }
+//printf("current: %d, seeked: %d\n", current_track, seeked_track);
+	if (current_track != seeked_track && !seek_to_track) {
+//printf("Track %d, sector=%d\n", seeked_track, sec);
+		  cd_track = cd_info_get_track(p->cd_info, seeked_track+1);
+		  if( cd_track!=NULL ) {
+			  mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
+			  mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb);
+		  }
+
+	}
+#if 0
+  if(sec < p->start_sector)
+    sec = p->start_sector;
+  else if(sec > p->end_sector)
+    sec = p->end_sector;
+#endif
+
+  p->sector = sec;
+//  s->pos = sec*CD_FRAMESIZE_RAW;
+
+//printf("seek: %d, sec: %d\n", (int)s->pos, sec);
+  paranoia_seek(p->cdp,sec,SEEK_SET);
+  return 1;
+}
+
+static void close_cdda(stream_t* s) {
+  cdda_priv* p = (cdda_priv*)s->priv;
+  paranoia_free(p->cdp);
+  cdda_close(p->cd);
+  cd_info_free(p->cd_info);
+  free(p);
+}
 
 static int get_track_by_sector(cdda_priv *p, unsigned int sector) {
   int i;
@@ -356,113 +459,6 @@
   return STREAM_OK;
 }
 
-#ifndef CONFIG_LIBCDIO
-static void cdparanoia_callback(long inpos, int function) {
-#else
-static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) {
-#endif
-}
-
-static int fill_buffer(stream_t* s, char* buffer, int max_len) {
-  cdda_priv* p = (cdda_priv*)s->priv;
-  cd_track_t *cd_track;
-  int16_t * buf;
-  int i;
-
-  if((p->sector < p->start_sector) || (p->sector > p->end_sector)) {
-    s->eof = 1;
-    return 0;
-  }
-
-  buf = paranoia_read(p->cdp,cdparanoia_callback);
-  if (!buf)
-    return 0;
-
-#if HAVE_BIGENDIAN
-  for(i=0;i<CD_FRAMESIZE_RAW/2;i++)
-          buf[i]=le2me_16(buf[i]);
-#endif
-
-  p->sector++;
-  memcpy(buffer,buf,CD_FRAMESIZE_RAW);
-
-  for(i=0;i<p->cd->tracks;i++){
-	  if(p->cd->disc_toc[i].dwStartSector==p->sector-1) {
-		  cd_track = cd_info_get_track(p->cd_info, i+1);
-//printf("Track %d, sector=%d\n", i, p->sector-1);
-		  if( cd_track!=NULL ) {
-			mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
-			mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb);
-		  }
-		  break;
-	  }
-  }
-
-
-  return CD_FRAMESIZE_RAW;
-}
-
-static int seek(stream_t* s,off_t newpos) {
-  cdda_priv* p = (cdda_priv*)s->priv;
-  cd_track_t *cd_track;
-  int sec;
-  int current_track=0, seeked_track=0;
-  int seek_to_track = 0;
-  int i;
-
-  s->pos = newpos;
-  sec = s->pos/CD_FRAMESIZE_RAW;
-  if (s->pos < 0 || sec > p->end_sector) {
-    s->eof = 1;
-    return 0;
-  }
-
-//printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW);
-//printf("sector: %d  new: %d\n", p->sector, sec );
-
-  for(i=0;i<p->cd->tracks;i++){
-//        printf("trk #%d: %d .. %d\n",i,p->cd->disc_toc[i].dwStartSector,p->cd->disc_toc[i+1].dwStartSector);
-	if( p->sector>=p->cd->disc_toc[i].dwStartSector && p->sector<p->cd->disc_toc[i+1].dwStartSector ) {
-		current_track = i;
-	}
-	if( sec>=p->cd->disc_toc[i].dwStartSector && sec<p->cd->disc_toc[i+1].dwStartSector ) {
-		seeked_track = i;
-		seek_to_track = sec == p->cd->disc_toc[i].dwStartSector;
-	}
-  }
-//printf("current: %d, seeked: %d\n", current_track, seeked_track);
-	if (current_track != seeked_track && !seek_to_track) {
-//printf("Track %d, sector=%d\n", seeked_track, sec);
-		  cd_track = cd_info_get_track(p->cd_info, seeked_track+1);
-		  if( cd_track!=NULL ) {
-			  mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
-			  mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb);
-		  }
-
-	}
-#if 0
-  if(sec < p->start_sector)
-    sec = p->start_sector;
-  else if(sec > p->end_sector)
-    sec = p->end_sector;
-#endif
-
-  p->sector = sec;
-//  s->pos = sec*CD_FRAMESIZE_RAW;
-
-//printf("seek: %d, sec: %d\n", (int)s->pos, sec);
-  paranoia_seek(p->cdp,sec,SEEK_SET);
-  return 1;
-}
-
-static void close_cdda(stream_t* s) {
-  cdda_priv* p = (cdda_priv*)s->priv;
-  paranoia_free(p->cdp);
-  cdda_close(p->cd);
-  cd_info_free(p->cd_info);
-  free(p);
-}
-
 const stream_info_t stream_info_cdda = {
   "CDDA",
   "cdda",