Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9214211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:55:37+00:00 2026-06-18T01:55:37+00:00

Currently we’re implementing Libspotify in a win 7 64 bit system. Everything seems to

  • 0

Currently we’re implementing Libspotify in a win 7 64 bit system. Everything seems to work fine except the playback. We get data from the callback , but even using audicity on the saved audio, is filled with abnormalities. So to research further we took the win32 sample (spshell ) and modified it to save the music data to file. Same problem, definitely music with these ticks in it. I’m sure there’s something simple I’m missing here, but I’m at a loss as to what could be the problem. Any help would be great since as it stands our project is at a stand still until we can resolve this.

The audio saved can be viewed here
http://uploader.crestron.com/download.php?file=8001d80992480280dba365752aeaca81

Below are the code changes I made to save the file ( for testing only )

static FILE *pFile;
int numBytesToWrite=0;
CRITICAL_SECTION m_cs;

int SP_CALLCONV music_delivery(sp_session *s, const sp_audioformat *fmt, const void *frames, int num_frames)
{
    if ( num_frames == 0 )
        return;
    EnterCriticalSection(&m_cs);
    numBytesToWrite = ( num_frames ) * fmt->channels * sizeof(short);
    if (numBytesToWrite > 0 )
        fwrite(frames, sizeof(short), numBytesToWrite, pFile);
    LeaveCriticalSection(&m_cs);
    return num_frames;
}
static void playtrack_test(void)
{


    sp_error err;
    InitializeCriticalSection(&m_cs);
    pFile = fopen ("C:\\zzzspotify.pcm","wb");
    test_start(&playtrack);
    if((err = sp_session_player_load(g_session, stream_track)) != SP_ERROR_OK) {
        test_report(&playtrack, "Unable to load track: %s",  sp_error_message(err));
        return;
    }

    info_report("Streaming '%s' by '%s' this will take a while", sp_track_name(stream_track),
            sp_artist_name(sp_track_artist(stream_track, 0)));
    sp_session_player_play(g_session, 1);
}

void SP_CALLCONV play_token_lost(sp_session *s)
{
    fclose(pFile);
    DeleteCriticalSection(&m_cs);
    stream_track_end = 2;
    notify_main_thread(g_session);
    info_report("Playtoken lost");
}
static int check_streaming_done(void)
{
    if(stream_track_end == 2)
        test_report(&playtrack, "Playtoken lost");
    else if(stream_track_end == 1)
        test_ok(&playtrack);
    else
        return 0;
    fclose(pFile);
    stream_track_end = 0;
    return 1;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:55:37+00:00Added an answer on June 18, 2026 at 1:55 am

    It looks like this is the problem:

    fwrite(frames, sizeof(short), numBytesToWrite, pFile);

    The fwrite documentation states that the second argument is the “size in bytes of each element to be written”, and the third is this “number of elements, each one with a size of size bytes”.

    The way you’re calling frwritewill tell it to write numBytesToWrite * sizeof(short) bytes, which will run right off the end of the given buffer. I’m actually surprised it doesn’t crash!

    I’d suggest changing your fwrite call to something like:

    fwrite(frames, sizeof(char), numBytesToWrite, pFile);

    or:

    int numSamplesToWrite = num_frames * fmt->channels;
    fwrite(frames, sizeof(short), numSamplesToWrite, pFile);
    

    Edit:

    After looking at your audio in detail, I’m more convinced that this is the case. The song seems to be playing at half speed (i.e., 2x as much data is being written) and the artefacts seem to look like buffer overrun into random memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently everything is working golden except for the fact that a user could manually
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently, I'm working on to get a list of all running applications. I've been
Currently, I've been involved in an warehouse based intelligent transaction analysis banking system featuring
Currently, I am implementing a table with items(slot_allocations) in it. The items are based
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Currently I’m trying to get the hang of a block copy with my current
Currently unable to get my rss feed to validate through W3C RSS Validator .
currently I am trying to make it so that I can get access to
Currently where I work we have the following set-up (for ASP.NET web-development) using Git

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.