Printable Version of Topic

Click here to view this topic in its original format

AMIP Community _ SDK Support _ getplaylist fails with iTunes v9

Posted by: jdh Feb 20 2010, 01:50 AM

Hi,

I'm using AMIP SDK v1.4, but am unable to get a playlist when using iTunes v9. Even the supplied getplaylist example fails in:

int code = ac_get_pl();
LeaveCriticalSection(&cs_list);
if (code != AC_ERR_NOERROR) {
printf("Failed to get playlist: %d\n", code);

It reports: Failed to get playlist: 3

When using WinAmp or foobar2000 then getplaylist works just fine!

Just wondering if I'm doing something wrong or if it simply does not work with iTunes v9.

Thanks, Jdh

Posted by: Serge Mar 10 2010, 02:49 PM

In case your playlist is large, it can timeout. Try increasing the timeouts.

Posted by: jdh Mar 21 2010, 09:11 PM

QUOTE(Serge @ Mar 10 2010, 10:49 AM) *

In case your playlist is large, it can timeout. Try increasing the timeouts.


Thanks Serge,

Yes the playlist is indeed lager, about 3700 songs. But even increasing the timeout to 1800000, i.e. 30 minutes, gives the same error 3, aka AC_ERR_CONNECTIONFAILED. I've changed the timeout on both ac_init_client and ac_init_client!

I just have not found a way to make getplaylist work (on larger playlists) sad.gif

Jdh

Posted by: Serge Mar 22 2010, 08:21 AM

Does it work on small playlists?

Posted by: jdh Mar 23 2010, 12:14 AM

QUOTE(Serge @ Mar 22 2010, 04:21 AM) *

Does it work on small playlists?

Yes, smaller playlists do work! So I did some testing:Btw: Tried this using iTunes and foobar2000, same results for both.

Also, I would have expected that if this is a timeout issue that with the increase of the timeout the getplaylist program would wait longer before returning the error 3. However I see no noticable wait delay when using a 1800000 second timeout and using 3700+ songs or when using only 115 songs and a 5000 timeout.

Thanks for taking the time and responding Serge!

Posted by: Serge Mar 23 2010, 08:49 AM

QUOTE(jdh @ Mar 23 2010, 03:14 AM) *

Yes, smaller playlists do work! So I did some testing:
  • A playlist of 114 songs works - both using the 5000 or 1800000 timeout value.
  • A playlist of 115 songs fails - both using the 5000 and 1800000 timeout value!
Btw: Tried this using iTunes and foobar2000, same results for both.

Also, I would have expected that if this is a timeout issue that with the increase of the timeout the getplaylist program would wait longer before returning the error 3. However I see no noticable wait delay when using a 1800000 second timeout and using 3700+ songs or when using only 115 songs and a 5000 timeout.

Thanks for taking the time and responding Serge!


I guess you are setting timeouts in the wrong place, you should set the bigger timeout in the following function:
CODE

  // Adds listener to AMIP, AMIP will notify host:port about the events specified by flags
  // until listener is removed or fail_count limit is reached. If notification fails
  // fail_count times, AMIP automatically removes listener for the specified host:port.
  // AMIP keeps listeners even between restarts (in plugin.ini file)
  int WINAPI ac_add_event_listener(const char *host, int port, int timeout, UINT flags, UINT fail_count=1);

Posted by: jdh Mar 23 2010, 03:44 PM

QUOTE(Serge @ Mar 23 2010, 04:49 AM) *

I guess you are setting timeouts in the wrong place, you should set the bigger timeout in the following function:
.....


Tried the following:

getplaylist.cpp:
CODE

  // Init client
  if (!ac_init_client(AMIP_HOST, AMIP_PORT, 5000, 5, 1)) {
    printf("Client cannot be initialized\n");
    exit(1);
  }

  // Add event listener to be notified on playlist change and ready events
  if (AC_ERR_NOERROR
      != ac_add_event_listener(SERVER_HOST, SERVER_PORT, 1800000, AC_EVT_PLCHANGE | AC_EVT_PLREADY)) {
    printf("Failed to add listener, check that AMIP is running and Remote/API Server is enabled on specified port\n");
    ac_uninit();
    exit(1);
  }


Using foobar2000 and 115 songs in the playlist, below is the output when running getplaylist:
CODE

$ make clean
rm -f *.o *.exe ./Release/*.*
rmdir Release
$ make prepare
mkdir -p Release
cp ../Release/ac.lib ac.lib
cp ../Release/ac.dll ./Release/ac.dll
tools/reimp.exe ac.lib
rm -f ac.lib ac.def
mv libac.a ./Release/libac.a
$ make getplaylist
g++ -I"../" -mno-cygwin -fpermissive -fexpensive-optimizations -O3 -Os -fno-exce
ptions -Wno-error -w   -c -o getplaylist.o getplaylist.cpp
g++.exe -I"../" -mno-cygwin -fpermissive -fexpensive-optimizations -O3 -Os -fno-
exceptions -Wno-error -w -L./Release -s -Wl -mno-cygwin getplaylist.o -lac -o ./
Release/getplaylist.exe
$ cd release
$ date;time getplaylist;date
Tue Mar 23 11:36:11 EDT 2010
Playlist cache is already in sync!
Failed to get playlist: 3

real    0m0.516s
user    0m0.015s
sys     0m0.015s
Tue Mar 23 11:36:11 EDT 2010
$


As you can see getplaylist did not wait for the timeout value. I have no idea what else to try.

Thanks, Jdh

Posted by: Serge Mar 23 2010, 04:20 PM

Nevermind, I can reproduce this issue, will investigate later.

Posted by: Serge Mar 23 2010, 06:35 PM

I've released SDK 1.5 with a fix. Thanks for the report.

Posted by: jdh Mar 23 2010, 09:54 PM

I realy appreciate this quick SDK fix! Going to download the new SDK now..

Thanks so much Serge!

Jdh

Powered by Invision Power Board
© Invision Power Services