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

  • SEARCH
  • Home
  • 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 8139569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:52:07+00:00 2026-06-06T11:52:07+00:00

I have developed a kernel module (Android) which provides me: PCM 16-bit 48000 Hz

  • 0

I have developed a kernel module (Android) which provides me:

PCM
16-bit
48000 Hz
2 channel

and I want to stream it to an Apple’s Airport Express (AEX) in java.

The AEX needs 44.1 kHz PCM so I have to resample the PCM-stream.

I have following possibilities, but which is the best?

1. Use the C-program “raop_play” (part of raop-play)

advantages: 
            high-performant due to native C
            already uses libsamplerate to resample wav, mp3, ogg, flac, aac, pls
            openssl as static library
            usable via command-line from my java-program via Runtime.exec()

disadvantages:
            I am relative new to C
            overloaded: I don't need wav, mp3.. only PCM
            many dependencies with GPL-libraries which I have to compile for Android
            only supports PCM already with 44.1 kHz, no resampling for PCM implemented yet 
            -> have to implement resampling for PCM

2. Resample & stream in java (with libresample JNI-bridge)

advantages: 
            I CAN java :)
            middle-performant due to resamling in C , but streaming in java
            just one dependency to LGPL-library
            no Runtime.exec() needed

disadvantages:
            needs [bouncycastle][3] for AES which is a bit larger than openssl
            less performant than solution #1 (but maybe fast enough)

3. Resample already in kernel module

advantages: 
            most performant
            no resampling at higher level

disadvantages:
            I am relative new to C
            Is it possible to use libsamplerate or libresample in kernel-space?!
  • 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-06T11:52:08+00:00Added an answer on June 6, 2026 at 11:52 am

    I’m a java-guy in heart, but this task (especially on a cpu constrained device, like a handheld) is crying for C. I would suggest simply using the libsamplerate. It has a simple API, and even if you’re new to C you’ll find plenty of examples by just googling around.

    of course the java based solution could and would work, it just doesn’t seem polite to the users to eat up their batteries just because your new to C 🙂

    EDIT:
    I might contradict myself a bit, but even though performance is a serious issue, I would avoid doing anything in kernel-space, unless I know the kernel and the hardware really well. In light of this I would go with a user-space program linked to libsamplerate. After a bit of googling around I’ve found this example (note that the output is the jack interface, obviously it has to be different for you)

    #include <jack/jack.h>
    #include <samplerate.h>
    
    int channels;
    float data_samplerate;
    
    
    /////////////////////////////////////////////////////
    /////////////////////////////////////////////////////
    void getDasData(float **dst,int num_frames){
    /* Provide sound data here, and only here. */
    }
    /////////////////////////////////////////////////////
    /////////////////////////////////////////////////////
    
    
    
    long getDasResampledData_callback(void *cb_data, float **data){
      static float ret[1024];
      static float ret3[1024];
      static float *ret2[2]={&ret[0],&ret[512]};
      getDasData(ret2,512);
      for(int i=0;i<512;i++){
        ret3[i*2]=ret2[0][i];
        ret3[i*2+1]=ret2[1][i];
      }
      *data=&ret3[0];
      return 512;
    }
    
    void getDasResampledData(float **dst,int num_frames){
      double ratio=samplerate/getSourceRate();
      float outsound[num_frames*2];
      long read=src_callback_read(dassrc_state,ratio,num_frames,outsound);
      //fprintf(stderr,"read: %d, num_frames: %d\n",read,num_frames);
      for(int i=0;i<read;i++){
          dst[0][i]=outsound[i*2];
          dst[1][i]=outsound[i*2+1];
      }
      if(read<num_frames){
        float *newdst[2]={dst[0]+read,dst[1]+read};
        getDasResampledData(newdst,num_frames-read);
      }
    }
    
    
    static int process (jack_nframes_t nframes, void *arg){
      int ch;
      sample_t *out[channels];
    
      for(ch=0;ch<channels;ch++){
        out[ch]=(sample_t*)jack_port_get_buffer(ports[ch],nframes);
      }
    
      if( (fabs(data_samplerate - jack_samplerate)) > 0.1)
        getDasResampledData(out,numSamples);
      else
        getDasData(outputChannelData,numSamples);
      return;
    
      audioCallback(NULL,0,out,channels,nframes);
    }
    
    int main(){
      dassrc_state=src_callback_new(getDasResampledData_callback,SRC_QUALITY,2,NULL,NULL);
      jack_set_process_callback(client, process,NULL);
    }
    

    from http://old.nabble.com/Example-of-using-libresample-with-jack-td8795847.html

    This example seems pretty straightforward, I hope you can use it.

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

Sidebar

Related Questions

I have a problem with use count of kernel module being developed.I'd like to
I have developed an iphone application which will be available in Apple Store in
I have developed a few Delphi Win32 (currently using D2007) applications, which revolve around
I have 6 months experience with Android, developing simple UI-based applications. Now I want
Have developed an MVC3 application which monitors when users access static content on the
I have developed a simple API to allow communication between my Android/iPhone apps and
I have developed a Cocos2d-X app with XCode which works perfectly when I launch
I have developped a HTTP web service which is queried by smartphone. I want
I have developed android application named VMS.I have to get messages from the webservice.The
I have developed web application which uses JasperReports for reporting purpose. In that I

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.