libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libcdio-devel] CD-Text order of operation bug


From: R. Bernstein
Subject: [Libcdio-devel] CD-Text order of operation bug
Date: Sun, 15 May 2005 11:51:40 -0400

Christian A. Moser reports this problem with CD-Text retrieval (tested
on both libcdio 0.72 and 0.74). I think I've noticed it too and
probalby others have as well, but he may have narrowed the problem
down more into (I think) an order of operation bug. If there is as he
suggests and uninitalized problem I suppose a memory-leak detector
like valgrind on GNU/Linux will find. I'll look into this when I get a
chance but I want to alert/forward it in case someone else would like
to find/fix.


Christian A. Moser informs:
> Hi
>
> While working on my plugin for the vdr (video disc recorder), i've
> stumbled over a weird behavior of libcdio regarding to the cdtext
> routines.
>
> My plugin reads all information (number of tracks, cdtext, sectors,
> etc) about the disc via your library. This functions properly
> without any problems. But due some reorganization in my plugin, i've
> found the following:
>
> When i read the cdtext information from the cd, beginning from 0  
> (to get the disc information) to the last track, it is important _when_ i will
> call cdio_get_last_track_num().
>

> * When i call cdio_get_last_track_num() before i get the first
> cdtext (i always begin with track #0) information, i get all cdtext
> information properly.  * But when i first get cdtext information
> about track #0 and _then_ call cdio_get_last_track_num(), all
> following cdio_get_cdtext() calls return wrong data.
>
> then it looks like this:
>
> - call to cdio_get_cdtext() with track #0 returns correct info...
> * call to cdio_get_last_track_num()
> - call to cdio_... with track #1 returns NULL
> - call to cdio_... with track #2 returns the info about track no 1 !
> - call to cdio_... with track #3 returns the info about track no 2 !
> - ...
>
> to give your more information and make my problem a little bit
> clearer, i've appended a small program to reproduce the effect. just
> comment in / out the right or wrong part.  it seems to me that some
> data isn't correctly initialized, when i dont call
> cdio_get_last_track_num() before accessing the cdtext info. is this
> a bug or just a dumb error of myself?
>
> BR
> Christian Moser
>
> p.s.: nevertheless, thanks for the good library
>

--Apple-Mail-2-420207455
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
        x-unix-mode=0666;
        name="cdtext.c"
Content-Disposition: attachment;
        filename=cdtext.c

#include <cdio/cdio.h>
#include <cdio/cdtext.h>

int main(int argc, char *argv[]) {
  char dev[] = "/dev/cdrom";
  int i = 0, max = 0;
  CdIo_t *p_cdIo = NULL;
  cdtext_t *p_cdText = NULL;
  
  p_cdIo = cdio_open(dev, DRIVER_LINUX);

  if (NULL == p_cdIo)
    return 1;

  max = 14;
// correnct !!!  max = cdio_get_last_track_num(p_cdIo);

  for (i = 0; i <= max; i++) {
    p_cdText = cdio_get_cdtext(p_cdIo, i);

    if (NULL == p_cdText)
      printf("ERROR: %d - NULL == p_cdText\n", i);

    if (NULL != p_cdText)
      if (NULL != p_cdText->field[CDTEXT_TITLE])
        printf("%d CDTEXT_TITLE=%s\n", i, cdtext_get(CDTEXT_TITLE, p_cdText));
      else
        printf("%d ERROR: NO cd-text\n", i);

    cdtext_destroy(p_cdText);
    p_cdText = NULL;

// wrong !!!   if (0 == i)
// wrong !!!     max = cdio_get_last_track_num(p_cdIo);
  }

  cdio_destroy(p_cdIo);

  return 0;
}

--Apple-Mail-2-420207455
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
        charset=US-ASCII;
        format=flowed

>


--Apple-Mail-2-420207455--




reply via email to

[Prev in Thread] Current Thread [Next in Thread]