forked from pool/xine-lib
944f0a6698
Copy from multimedia:xine/xine-lib based on submit request 24887 from user lnussel OBS-URL: https://build.opensuse.org/request/show/24887 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/xine-lib?expand=0&rev=27
311 lines
8.5 KiB
Diff
311 lines
8.5 KiB
Diff
diff -ur xine-lib-1.1.16.3.orig/src/demuxers/demux_cdda.c xine-lib-1.1.16.3/src/demuxers/demux_cdda.c
|
|
--- xine-lib-1.1.16.3.orig/src/demuxers/demux_cdda.c 2008-06-15 01:15:00.000000000 +0200
|
|
+++ xine-lib-1.1.16.3/src/demuxers/demux_cdda.c 2009-05-07 19:43:04.000000000 +0200
|
|
@@ -60,6 +60,7 @@
|
|
input_plugin_t *input;
|
|
int status;
|
|
|
|
+ int send_newpts;
|
|
int seek_flag; /* this is set when a seek just occurred */
|
|
} demux_cdda_t;
|
|
|
|
@@ -91,9 +92,9 @@
|
|
buf->extra_info->input_time = buf->pts / 90;
|
|
buf->decoder_flags |= BUF_FLAG_FRAME_END;
|
|
|
|
- if (this->seek_flag) {
|
|
- _x_demux_control_newpts(this->stream, buf->pts, BUF_FLAG_SEEK);
|
|
- this->seek_flag = 0;
|
|
+ if (this->send_newpts) {
|
|
+ _x_demux_control_newpts(this->stream, buf->pts, this->seek_flag);
|
|
+ this->send_newpts = this->seek_flag = 0;
|
|
}
|
|
|
|
this->audio_fifo->put (this->audio_fifo, buf);
|
|
@@ -146,9 +147,14 @@
|
|
this->input->seek(this->input, start_pos & ~3, SEEK_SET);
|
|
else
|
|
this->input->seek(this->input, start_time * CD_BYTES_PER_SECOND, SEEK_SET);
|
|
- this->seek_flag = 1;
|
|
+
|
|
this->status = DEMUX_OK;
|
|
- _x_demux_flush_engine (this->stream);
|
|
+
|
|
+ this->send_newpts = 1;
|
|
+ if (playing) {
|
|
+ this->seek_flag = BUF_FLAG_SEEK;
|
|
+ _x_demux_flush_engine (this->stream);
|
|
+ }
|
|
|
|
return this->status;
|
|
}
|
|
diff -ur xine-lib-1.1.16.3.orig/src/input/input_cdda.c xine-lib-1.1.16.3/src/input/input_cdda.c
|
|
--- xine-lib-1.1.16.3.orig/src/input/input_cdda.c 2009-02-17 03:55:21.000000000 +0100
|
|
+++ xine-lib-1.1.16.3/src/input/input_cdda.c 2009-05-12 00:16:12.000000000 +0200
|
|
@@ -113,7 +113,7 @@
|
|
*************************************************************************/
|
|
|
|
#define MAX_TRACKS 99
|
|
-#define CACHED_FRAMES 500
|
|
+#define CACHED_FRAMES 100
|
|
|
|
typedef struct {
|
|
int start;
|
|
@@ -1433,6 +1433,73 @@
|
|
return err;
|
|
}
|
|
|
|
+static inline char *_cdda_append (/*const*/ char *first, const char *second)
|
|
+{
|
|
+ if (!first)
|
|
+ return strdup (second);
|
|
+
|
|
+ char *result = (char *) realloc (first, strlen (first) + strlen (second) + 1);
|
|
+ strcat (result, second);
|
|
+ return result;
|
|
+}
|
|
+
|
|
+static void _cdda_parse_cddb_info (cdda_input_plugin_t *this, char *buffer, char **dtitle)
|
|
+{
|
|
+ /* buffer should be no more than 2048 bytes... */
|
|
+ char buf[2048];
|
|
+ int track_no;
|
|
+
|
|
+ if (sscanf (buffer, "DTITLE=%s", &buf[0]) == 1) {
|
|
+ char *pt = strchr (buffer, '=');
|
|
+ if (pt) {
|
|
+ ++pt;
|
|
+
|
|
+ *dtitle = _cdda_append (*dtitle, pt);
|
|
+ pt = strdup (*dtitle);
|
|
+
|
|
+ char *title = strstr (pt, " / ");
|
|
+ if (title)
|
|
+ {
|
|
+ *title = 0;
|
|
+ title += 3;
|
|
+ free (this->cddb.disc_artist);
|
|
+ this->cddb.disc_artist = strdup (pt);
|
|
+ }
|
|
+ else
|
|
+ title = pt;
|
|
+
|
|
+ free (this->cddb.disc_title);
|
|
+ this->cddb.disc_title = strdup (title);
|
|
+
|
|
+ free (pt);
|
|
+ }
|
|
+ }
|
|
+ else if (sscanf (buffer, "DYEAR=%s", &buf[0]) == 1) {
|
|
+ char *pt = strchr (buffer, '=');
|
|
+ if (pt && strlen (pt) == 5)
|
|
+ this->cddb.disc_year = strdup (pt + 1);
|
|
+ }
|
|
+ else if(sscanf(buffer, "DGENRE=%s", &buf[0]) == 1) {
|
|
+ char *pt = strchr(buffer, '=');
|
|
+ if (pt)
|
|
+ this->cddb.disc_category = strdup (pt + 1);
|
|
+ }
|
|
+ else if (sscanf (buffer, "TTITLE%d=%s", &track_no, &buf[0]) == 2) {
|
|
+ char *pt = strchr(buffer, '=');
|
|
+ this->cddb.track[track_no].title = _cdda_append (this->cddb.track[track_no].title, pt + 1);
|
|
+ }
|
|
+ else if (!strncmp (buffer, "EXTD=", 5))
|
|
+ {
|
|
+ if (!this->cddb.disc_year)
|
|
+ {
|
|
+ int nyear;
|
|
+ char *y = strstr (buffer, "YEAR:");
|
|
+ if (y && sscanf (y + 5, "%4d", &nyear) == 1)
|
|
+ asprintf (&this->cddb.disc_year, "%d", nyear);
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
/*
|
|
* Try to load cached cddb infos
|
|
*/
|
|
@@ -1465,82 +1532,16 @@
|
|
return 0;
|
|
}
|
|
else {
|
|
- char buffer[256], *ln;
|
|
- char buf[256];
|
|
- int tnum;
|
|
+ char buffer[2048], *ln;
|
|
char *dtitle = NULL;
|
|
|
|
- while ((ln = fgets(buffer, 255, fd)) != NULL) {
|
|
-
|
|
- buffer[strlen(buffer) - 1] = '\0';
|
|
-
|
|
- if (sscanf(buffer, "DTITLE=%s", &buf[0]) == 1) {
|
|
- char *pt, *artist, *title;
|
|
-
|
|
- pt = strchr(buffer, '=');
|
|
- if (pt) {
|
|
- pt++;
|
|
-
|
|
- if (dtitle != NULL)
|
|
- {
|
|
- dtitle = (char *) realloc(dtitle, strlen(dtitle) + strlen(pt) + 1);
|
|
- strcat(dtitle, pt);
|
|
- pt = dtitle;
|
|
- }
|
|
- dtitle = strdup(pt);
|
|
-
|
|
- artist = pt;
|
|
- title = strstr(pt, " / ");
|
|
- if (title) {
|
|
- *title++ = '\0';
|
|
- title += 2;
|
|
- }
|
|
- else {
|
|
- title = artist;
|
|
- artist = NULL;
|
|
- }
|
|
+ while ((ln = fgets(buffer, sizeof (buffer) - 1, fd)) != NULL) {
|
|
|
|
- if (artist)
|
|
- this->cddb.disc_artist = strdup(artist);
|
|
+ int length = strlen (buffer);
|
|
+ if (length && buffer[length - 1] == '\n')
|
|
+ buffer[length - 1] = '\0';
|
|
|
|
- this->cddb.disc_title = strdup(title);
|
|
- }
|
|
- }
|
|
- else if (sscanf(buffer, "DYEAR=%s", &buf[0]) == 1) {
|
|
- char *pt;
|
|
-
|
|
- pt = strrchr(buffer, '=');
|
|
- pt++;
|
|
- if (pt != NULL && strlen(pt) == 4)
|
|
- this->cddb.disc_year = strdup(pt);
|
|
- }
|
|
- else if (sscanf(buffer, "TTITLE%d=%s", &tnum, &buf[0]) == 2) {
|
|
- char *pt;
|
|
-
|
|
- pt = strchr(buffer, '=');
|
|
- if (pt)
|
|
- pt++;
|
|
- if (this->cddb.track[tnum].title == NULL)
|
|
- this->cddb.track[tnum].title = strdup(pt);
|
|
- else
|
|
- {
|
|
- this->cddb.track[tnum].title
|
|
- = (char *) realloc(this->cddb.track[tnum].title, strlen(this->cddb.track[tnum].title) + strlen(pt) + 1);
|
|
- strcat(this->cddb.track[tnum].title, pt);
|
|
- }
|
|
- }
|
|
- else {
|
|
- if (!strncmp(buffer, "EXTD=", 5)) {
|
|
- char *y;
|
|
- int nyear;
|
|
-
|
|
- y = strstr(buffer, "YEAR:");
|
|
- if (y && this->cddb.disc_year == NULL) {
|
|
- if (sscanf(y+5, "%4d", &nyear) == 1)
|
|
- asprintf(&this->cddb.disc_year, "%d", nyear);
|
|
- }
|
|
- }
|
|
- }
|
|
+ _cdda_parse_cddb_info (this, buffer, &dtitle);
|
|
}
|
|
fclose(fd);
|
|
free(dtitle);
|
|
@@ -1803,82 +1804,13 @@
|
|
memset(&buffercache, 0, sizeof(buffercache));
|
|
|
|
while (strcmp(buffer, ".")) {
|
|
- char buf[2048];
|
|
- int tnum;
|
|
size_t bufsize = strlen(buffercache);
|
|
|
|
memset(&buffer, 0, sizeof(buffer));
|
|
_cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1);
|
|
snprintf(buffercache + bufsize, sizeof(buffercache) - bufsize, "%s\n", buffer);
|
|
|
|
- if (sscanf(buffer, "DTITLE=%s", &buf[0]) == 1) {
|
|
- char *pt, *artist, *title;
|
|
-
|
|
- pt = strrchr(buffer, '=');
|
|
- if (pt) {
|
|
- pt++;
|
|
-
|
|
- if (dtitle != NULL)
|
|
- {
|
|
- dtitle = (char *) realloc(dtitle, strlen(dtitle) + strlen(pt) + 1);
|
|
- strcat(dtitle, pt);
|
|
- pt = dtitle;
|
|
- }
|
|
- dtitle = strdup(pt);
|
|
-
|
|
- artist = pt;
|
|
- title = strstr(pt, " / ");
|
|
- if (title) {
|
|
- *title++ = '\0';
|
|
- title += 2;
|
|
- }
|
|
- else {
|
|
- title = artist;
|
|
- artist = NULL;
|
|
- }
|
|
-
|
|
- if (artist) {
|
|
- this->cddb.disc_artist = strdup(artist);
|
|
- }
|
|
- this->cddb.disc_title = strdup(title);
|
|
- }
|
|
- }
|
|
- else if(sscanf(buffer, "DYEAR=%s", &buf[0]) == 1) {
|
|
- char *pt;
|
|
-
|
|
- pt = strrchr(buffer, '=');
|
|
- pt++;
|
|
- if (pt != NULL && strlen(pt) == 4)
|
|
- this->cddb.disc_year = strdup(pt);
|
|
- }
|
|
- else if (sscanf(buffer, "TTITLE%d=%s", &tnum, &buf[0]) == 2) {
|
|
- char *pt;
|
|
-
|
|
- pt = strrchr(buffer, '=');
|
|
- if (pt) {
|
|
- pt++;
|
|
- if (this->cddb.track[tnum].title == NULL)
|
|
- this->cddb.track[tnum].title = strdup(pt);
|
|
- else
|
|
- {
|
|
- this->cddb.track[tnum].title
|
|
- = (char *) realloc(this->cddb.track[tnum].title, strlen(this->cddb.track[tnum].title) + strlen(pt) + 1);
|
|
- strcat(this->cddb.track[tnum].title, pt);
|
|
- }
|
|
- }
|
|
- }
|
|
- else {
|
|
- if (!strncmp(buffer, "EXTD=", 5)) {
|
|
- char *y;
|
|
- int nyear;
|
|
-
|
|
- y = strstr(buffer, "YEAR:");
|
|
- if (y && this->cddb.disc_year == NULL) {
|
|
- if (sscanf(y+5, "%4d", &nyear) == 1)
|
|
- asprintf(&this->cddb.disc_year, "%d", nyear);
|
|
- }
|
|
- }
|
|
- }
|
|
+ _cdda_parse_cddb_info (this, buffer, &dtitle);
|
|
}
|
|
free(dtitle);
|
|
|
|
@@ -2491,6 +2423,9 @@
|
|
}
|
|
lprintf("Track %d Title: %s\n", this->track+1, pt);
|
|
|
|
+ char tracknum[4];
|
|
+ snprintf(tracknum, 4, "%d", this->track+1);
|
|
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_TRACK_NUMBER, tracknum);
|
|
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_TITLE, pt);
|
|
}
|
|
|