On 2009/02/18 14:28, Jochen Keil <jochen.k...@gmail.com> wrote:
> After "playing" (or fooling) around with mpds code i came to these
> results and questions:
> 
> I was able to add "sub-songs" into a virtual directory for each embedded
> track by modifying update.c.

Cool :-)

> Problem #1: The decoder makes use of the input_plugin->read method to
> get the "real" filename which in my case is a virtual file in a virtual
> directory which obviously doesn't work.
> Unfortunately i couldn't figure out how to solve this in a gentle way (i
> was thinking about the tag_dup method but i guess that would be rather
> ugly).

We're entering a realm where the current MPD core API doesn't
suffice.  We have to extend it, don't be afraid to do so.  An ugly
design which is functional is better than none at all, and once we
have your code in, we can still clean up the API.

I suggest you start looking at Viliam's archive code, especially his
archive_lookup() function, which is a nice hack to solve problems
similar to yours.

> Problem #2: I need to seek within the flac file to a certain offset to
> decode the "next" track. I have to admit that even after studying the
> code for a while now i still lack the understanding of how i could do this.

How seeking works differs from your point of view:

- if you're the main thread, call playerSeek() (which invokes the
  player thread)

- if you're the player thread, call dc_seek() (which invokes the
  decoder plugin)

- the decoder plugin receives a SEEK command (decoder_get_command() ==
  DECODE_COMMAND_SEEK); the rest is specific to the decoder plugin

So what you're about to do depends on where your CUE code will run.

If you're doing FLAC cuesheets only, then you have to write the code
in flac_plugin.c; I think you have to implement the file_decode()
method, and expect a path in the form "foo/bar.flac/subsongnumber".
In this method, you open the FLAC file and call flac_seek_absolute()
to seek to the correct sub song.

> Another way would be to list the single tracks without the virtual
> directory but instead with different tag structs.

I don't understand...

> This initially worked, i've been able to add several tracks but then i
> had to realize that instead of having different tags they all had the
> same tag struct. I guess this is due to songvec sorting by path or so
> which leads to every file getting updated with the same tag struct.

For the sorting algorithm, see songvec_cmp() in songvec.c.  To get the
correct sorting order, assign an incrementing TAG_ITEM_TRACK number to
each virtual sub-song.

> At the moment i'm even thinking if one shouldn't rewrite the whole
> flac plugin (which would be something i am not up to at the moment i
> think..)

If you think this is worthwhile, you can start by implementing a new
plugin, let's say "cueflac".  Make it refuses to decode FLAC files
without cuesheet, so if we insert it before the old "flac" plugin in
the plugin list, MPD will handle cue-less files with the old plugin,
and files with CUE will be handled by your code.

Max


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to